Skip to content

Commit

Permalink
DSSL: Added the "gui" module for GUI related utility functions
Browse files Browse the repository at this point in the history
"DSSL" means Doomsday Script Standard Library.
  • Loading branch information
skyjake committed May 12, 2013
1 parent 9659f9d commit 0b9d5b0
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions doomsday/client/client.pro
Expand Up @@ -655,6 +655,7 @@ data.files = $$OUT_PWD/../doomsday.pk3

mod.files = \
$$DENG_MODULES_DIR/Config.de \
$$DENG_MODULES_DIR/gui.de \
$$DENG_MODULES_DIR/recutil.de

# These fonts may be needed during the initial startup busy mode.
Expand Down
1 change: 1 addition & 0 deletions doomsday/libdeng2/libdeng2.pro
Expand Up @@ -150,6 +150,7 @@ SOURCES += \

OTHER_FILES += \
modules/Config.de \
modules/gui.de \
modules/recutil.de

# Installation ---------------------------------------------------------------
Expand Down
36 changes: 36 additions & 0 deletions doomsday/libdeng2/modules/gui.de
@@ -0,0 +1,36 @@
# The Doomsday Engine Project -- libdeng2
#
# Copyright (c) 2013 Jaakko Keränen <jaakko.keranen@iki.fi>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.

#----------------------------------------------------------------------------
# Graphical user interface

def scale(value, factor)
# Scales a value by 'factor'. If 'value' is a text string, the
# suffixes "pt" and "px" (point, pixel) are retained in the result.
# - src: Value to scale. Number or Text, may have "pt" or "px"
# as suffix.
# - factor: Scale factor (Number).

unit = ''
p = Text(value)
amount = p
if p[-2:] == 'pt' or p[-2:] == 'px'
unit = p[-2:]
amount = p[:-2]
end
return Text(floor(Number(amount) * factor)) + unit
end

0 comments on commit 0b9d5b0

Please sign in to comment.