summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS29
-rw-r--r--Xcode/mana.xcodeproj/project.pbxproj6
-rw-r--r--data/fonts/CMakeLists.txt4
-rw-r--r--data/fonts/DejaVuSerifCondensed-Bold.ttfbin0 -> 316440 bytes
-rw-r--r--data/fonts/DejaVuSerifCondensed.ttfbin0 -> 330012 bytes
-rw-r--r--data/fonts/dejavusans-bold.ttfbin672300 -> 0 bytes
-rw-r--r--data/fonts/dejavusans.ttfbin720012 -> 0 bytes
-rw-r--r--data/graphics/gui/CMakeLists.txt3
-rw-r--r--data/graphics/gui/button.pngbin374 -> 464 bytes
-rw-r--r--data/graphics/gui/button_disabled.pngbin313 -> 342 bytes
-rw-r--r--data/graphics/gui/buttonhi.pngbin374 -> 474 bytes
-rw-r--r--data/graphics/gui/buttonpress.pngbin377 -> 424 bytes
-rw-r--r--data/graphics/gui/checkbox.pngbin802 -> 694 bytes
-rw-r--r--data/graphics/gui/close_button.pngbin650 -> 317 bytes
-rw-r--r--data/graphics/gui/colors.xml1
-rw-r--r--data/graphics/gui/hscroll_left_default.pngbin358 -> 257 bytes
-rw-r--r--data/graphics/gui/hscroll_left_highlight.pngbin364 -> 257 bytes
-rw-r--r--data/graphics/gui/hscroll_left_pressed.pngbin349 -> 261 bytes
-rw-r--r--data/graphics/gui/hscroll_right_default.pngbin340 -> 242 bytes
-rw-r--r--data/graphics/gui/hscroll_right_highlight.pngbin359 -> 241 bytes
-rw-r--r--data/graphics/gui/hscroll_right_pressed.pngbin350 -> 264 bytes
-rw-r--r--data/graphics/gui/lpc_window.pngbin0 -> 12568 bytes
-rw-r--r--data/graphics/gui/npcdialog.pngbin0 -> 649 bytes
-rw-r--r--data/graphics/gui/npcdialog.xml18
-rw-r--r--data/graphics/gui/scrololol.pngbin0 -> 26172 bytes
-rw-r--r--data/graphics/gui/slider.pngbin485 -> 324 bytes
-rw-r--r--data/graphics/gui/slider_hilight.pngbin444 -> 327 bytes
-rw-r--r--data/graphics/gui/tab.pngbin329 -> 270 bytes
-rw-r--r--data/graphics/gui/tab_hilight.pngbin316 -> 294 bytes
-rw-r--r--data/graphics/gui/tabselected.pngbin313 -> 268 bytes
-rw-r--r--data/graphics/gui/vscroll_down_default.pngbin367 -> 247 bytes
-rw-r--r--data/graphics/gui/vscroll_down_highlight.pngbin382 -> 247 bytes
-rw-r--r--data/graphics/gui/vscroll_down_pressed.pngbin376 -> 248 bytes
-rw-r--r--data/graphics/gui/vscroll_grey.pngbin338 -> 297 bytes
-rw-r--r--data/graphics/gui/vscroll_highlight.pngbin338 -> 252 bytes
-rw-r--r--data/graphics/gui/vscroll_up_default.pngbin377 -> 253 bytes
-rw-r--r--data/graphics/gui/vscroll_up_highlight.pngbin376 -> 253 bytes
-rw-r--r--data/graphics/gui/vscroll_up_pressed.pngbin364 -> 250 bytes
-rw-r--r--data/graphics/gui/window.xml20
-rw-r--r--docs/lpc2012.mana18
-rw-r--r--mana.cbp2
-rw-r--r--mana.files2
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/client.cpp8
-rw-r--r--src/defaults.cpp5
-rw-r--r--src/game.cpp7
-rw-r--r--src/graphics.cpp79
-rw-r--r--src/graphics.h21
-rw-r--r--src/gui/beingpopup.cpp9
-rw-r--r--src/gui/charcreatedialog.cpp13
-rw-r--r--src/gui/charselectdialog.cpp6
-rw-r--r--src/gui/debugwindow.cpp4
-rw-r--r--src/gui/equipmentwindow.cpp12
-rw-r--r--src/gui/gui.cpp12
-rw-r--r--src/gui/itempopup.cpp20
-rw-r--r--src/gui/npcdialog.cpp291
-rw-r--r--src/gui/npcdialog.h77
-rw-r--r--src/gui/sdlinput.cpp15
-rw-r--r--src/gui/setup.cpp2
-rw-r--r--src/gui/setup_audio.cpp7
-rw-r--r--src/gui/setup_colors.cpp7
-rw-r--r--src/gui/setup_interface.cpp20
-rw-r--r--src/gui/setup_interface.h2
-rw-r--r--src/gui/setup_joystick.cpp14
-rw-r--r--src/gui/setup_keyboard.cpp7
-rw-r--r--src/gui/setup_players.cpp10
-rw-r--r--src/gui/setup_video.cpp131
-rw-r--r--src/gui/setup_video.h16
-rw-r--r--src/gui/skilldialog.cpp19
-rw-r--r--src/gui/skilldialog.h2
-rw-r--r--src/gui/socialwindow.cpp1
-rw-r--r--src/gui/specialswindow.cpp1
-rw-r--r--src/gui/statuswindow.cpp11
-rw-r--r--src/gui/textpopup.cpp11
-rw-r--r--src/gui/viewport.cpp7
-rw-r--r--src/gui/widgets/container.cpp25
-rw-r--r--src/gui/widgets/container.h24
-rw-r--r--src/gui/widgets/layouthelper.cpp5
-rw-r--r--src/gui/widgets/layouthelper.h4
-rw-r--r--src/gui/widgets/popup.cpp10
-rw-r--r--src/gui/widgets/resizegrip.cpp12
-rw-r--r--src/gui/widgets/setuptab.cpp1
-rw-r--r--src/gui/widgets/vertcontainer.h2
-rw-r--r--src/gui/widgets/window.cpp6
-rw-r--r--src/gui/windowmenu.cpp3
-rw-r--r--src/keyboardconfig.cpp1
-rw-r--r--src/keyboardconfig.h1
-rw-r--r--src/map.cpp12
-rw-r--r--src/map.h5
-rw-r--r--src/net/manaserv/charhandler.cpp5
-rw-r--r--src/openglgraphics.cpp118
-rw-r--r--src/openglgraphics.h24
-rw-r--r--src/resources/image.cpp174
-rw-r--r--src/resources/image.h21
-rw-r--r--src/resources/imageloader.cpp98
-rw-r--r--src/resources/imageloader.h69
-rw-r--r--src/resources/theme.cpp1
-rw-r--r--src/resources/theme.h1
98 files changed, 608 insertions, 966 deletions
diff --git a/AUTHORS b/AUTHORS
index 1a3761e2..6969fdd4 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -82,3 +82,32 @@ Zuzanna K. Filutowska <platyna users.sourceforge.net>
== Sound files ==
data/sfx/system/newmessage.ogg (Psi-IM, GPL)
+
+== Client theming for the Liberated Pixel Cup ==
+
+daneeklu (opengameart.org) (CC BY-SA 3.0, GPLv3):
+ data/graphics/gui/buttong.png
+ data/graphics/gui/button_disabled.png
+ data/graphics/gui/buttonhi.png
+ data/graphics/gui/buttonpress.png
+ data/graphics/gui/checkbox.png
+ data/graphics/gui/close_button.png
+ data/graphics/gui/hscroll_left_default.png
+ data/graphics/gui/hscroll_left_highlight.png
+ data/graphics/gui/hscroll_left_pressed.png
+ data/graphics/gui/hscroll_right_default.png
+ data/graphics/gui/hscroll_right_highlight.png
+ data/graphics/gui/hscroll_right_pressed.png
+ data/graphics/gui/slider.png
+ data/graphics/gui/slider_highlight.png
+ data/graphics/gui/tab.png
+ data/graphics/gui/tab_highlight.png
+ data/graphics/gui/tabselected.png
+ data/graphics/gui/vscoll_down_default.png
+ data/graphics/gui/vscroll_down_highlight.png
+ data/graphics/gui/vscroll_down_pressed.png
+ data/graphics/gui/vscroll_grey.png
+ data/graphics/gui/vscroll_highlight.png
+ data/graphics/gui/vscroll_up_default.png
+ data/graphics/gui/vscroll_up_highlight.png
+ data/graphics/gui/vscroll_up_pressed.png
diff --git a/Xcode/mana.xcodeproj/project.pbxproj b/Xcode/mana.xcodeproj/project.pbxproj
index 17563c6e..ec296b60 100644
--- a/Xcode/mana.xcodeproj/project.pbxproj
+++ b/Xcode/mana.xcodeproj/project.pbxproj
@@ -225,7 +225,6 @@
FC047CAF151E500C00C5E9E7 /* emotedb.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FC047C82151E500C00C5E9E7 /* emotedb.cpp */; };
FC047CB0151E500C00C5E9E7 /* hairdb.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FC047C84151E500C00C5E9E7 /* hairdb.cpp */; };
FC047CB1151E500C00C5E9E7 /* image.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FC047C86151E500C00C5E9E7 /* image.cpp */; };
- FC047CB2151E500C00C5E9E7 /* imageloader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FC047C88151E500C00C5E9E7 /* imageloader.cpp */; };
FC047CB3151E500C00C5E9E7 /* imageset.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FC047C8A151E500C00C5E9E7 /* imageset.cpp */; };
FC047CB4151E500C00C5E9E7 /* imagewriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FC047C8C151E500C00C5E9E7 /* imagewriter.cpp */; };
FC047CB5151E500C00C5E9E7 /* itemdb.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FC047C8E151E500C00C5E9E7 /* itemdb.cpp */; };
@@ -767,8 +766,6 @@
FC047C85151E500C00C5E9E7 /* hairdb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hairdb.h; sourceTree = "<group>"; };
FC047C86151E500C00C5E9E7 /* image.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = image.cpp; sourceTree = "<group>"; };
FC047C87151E500C00C5E9E7 /* image.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = image.h; sourceTree = "<group>"; };
- FC047C88151E500C00C5E9E7 /* imageloader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = imageloader.cpp; sourceTree = "<group>"; };
- FC047C89151E500C00C5E9E7 /* imageloader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = imageloader.h; sourceTree = "<group>"; };
FC047C8A151E500C00C5E9E7 /* imageset.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = imageset.cpp; sourceTree = "<group>"; };
FC047C8B151E500C00C5E9E7 /* imageset.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = imageset.h; sourceTree = "<group>"; };
FC047C8C151E500C00C5E9E7 /* imagewriter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = imagewriter.cpp; sourceTree = "<group>"; };
@@ -1479,8 +1476,6 @@
FC047C85151E500C00C5E9E7 /* hairdb.h */,
FC047C86151E500C00C5E9E7 /* image.cpp */,
FC047C87151E500C00C5E9E7 /* image.h */,
- FC047C88151E500C00C5E9E7 /* imageloader.cpp */,
- FC047C89151E500C00C5E9E7 /* imageloader.h */,
FC047C8A151E500C00C5E9E7 /* imageset.cpp */,
FC047C8B151E500C00C5E9E7 /* imageset.h */,
FC047C8C151E500C00C5E9E7 /* imagewriter.cpp */,
@@ -1879,7 +1874,6 @@
FC047CAF151E500C00C5E9E7 /* emotedb.cpp in Sources */,
FC047CB0151E500C00C5E9E7 /* hairdb.cpp in Sources */,
FC047CB1151E500C00C5E9E7 /* image.cpp in Sources */,
- FC047CB2151E500C00C5E9E7 /* imageloader.cpp in Sources */,
FC047CB3151E500C00C5E9E7 /* imageset.cpp in Sources */,
FC047CB4151E500C00C5E9E7 /* imagewriter.cpp in Sources */,
FC047CB5151E500C00C5E9E7 /* itemdb.cpp in Sources */,
diff --git a/data/fonts/CMakeLists.txt b/data/fonts/CMakeLists.txt
index f5812e5d..61ea9805 100644
--- a/data/fonts/CMakeLists.txt
+++ b/data/fonts/CMakeLists.txt
@@ -1,6 +1,6 @@
SET (FILES
- dejavusans.ttf
- dejavusans-bold.ttf
+ DejaVuSerifCondensed.ttf
+ DejaVuSerifCondensed-Bold.ttf
dejavusans-mono.ttf
)
diff --git a/data/fonts/DejaVuSerifCondensed-Bold.ttf b/data/fonts/DejaVuSerifCondensed-Bold.ttf
new file mode 100644
index 00000000..55adca41
--- /dev/null
+++ b/data/fonts/DejaVuSerifCondensed-Bold.ttf
Binary files differ
diff --git a/data/fonts/DejaVuSerifCondensed.ttf b/data/fonts/DejaVuSerifCondensed.ttf
new file mode 100644
index 00000000..83120cd9
--- /dev/null
+++ b/data/fonts/DejaVuSerifCondensed.ttf
Binary files differ
diff --git a/data/fonts/dejavusans-bold.ttf b/data/fonts/dejavusans-bold.ttf
deleted file mode 100644
index 0f4d5e9d..00000000
--- a/data/fonts/dejavusans-bold.ttf
+++ /dev/null
Binary files differ
diff --git a/data/fonts/dejavusans.ttf b/data/fonts/dejavusans.ttf
deleted file mode 100644
index 27cff476..00000000
--- a/data/fonts/dejavusans.ttf
+++ /dev/null
Binary files differ
diff --git a/data/graphics/gui/CMakeLists.txt b/data/graphics/gui/CMakeLists.txt
index cc257eee..51782750 100644
--- a/data/graphics/gui/CMakeLists.txt
+++ b/data/graphics/gui/CMakeLists.txt
@@ -29,6 +29,8 @@ SET (FILES
hscroll_right_pressed.png
item_shortcut_bgr.png
mouse.png
+ npcdialog.png
+ npcdialog.xml
progress-indicator.png
radioin.png
radioin_highlight.png
@@ -55,6 +57,7 @@ SET (FILES
vscroll_up_highlight.png
vscroll_up_pressed.png
window.png
+ lpc_window.png
window.xml
)
diff --git a/data/graphics/gui/button.png b/data/graphics/gui/button.png
index 9ebbea63..d23d5fc2 100644
--- a/data/graphics/gui/button.png
+++ b/data/graphics/gui/button.png
Binary files differ
diff --git a/data/graphics/gui/button_disabled.png b/data/graphics/gui/button_disabled.png
index 0ce3aa6f..f0646193 100644
--- a/data/graphics/gui/button_disabled.png
+++ b/data/graphics/gui/button_disabled.png
Binary files differ
diff --git a/data/graphics/gui/buttonhi.png b/data/graphics/gui/buttonhi.png
index c4772634..63a71fd8 100644
--- a/data/graphics/gui/buttonhi.png
+++ b/data/graphics/gui/buttonhi.png
Binary files differ
diff --git a/data/graphics/gui/buttonpress.png b/data/graphics/gui/buttonpress.png
index e9cd1765..05e7020d 100644
--- a/data/graphics/gui/buttonpress.png
+++ b/data/graphics/gui/buttonpress.png
Binary files differ
diff --git a/data/graphics/gui/checkbox.png b/data/graphics/gui/checkbox.png
index 29b64100..67af8c99 100644
--- a/data/graphics/gui/checkbox.png
+++ b/data/graphics/gui/checkbox.png
Binary files differ
diff --git a/data/graphics/gui/close_button.png b/data/graphics/gui/close_button.png
index f87cc2a9..b3ce4ef4 100644
--- a/data/graphics/gui/close_button.png
+++ b/data/graphics/gui/close_button.png
Binary files differ
diff --git a/data/graphics/gui/colors.xml b/data/graphics/gui/colors.xml
index 4a35d081..4d3e6e62 100644
--- a/data/graphics/gui/colors.xml
+++ b/data/graphics/gui/colors.xml
@@ -1,5 +1,6 @@
<colors>
<color id="TEXT" color="#000000" />
+ <color id="NPC_DIALOG_TEXT" color="#ffffff" />
<color id="SHADOW" color="#000000" />
<color id="OUTLINE" color="#000000" />
<color id="PROGRESS_BAR" color="#ffffff" />
diff --git a/data/graphics/gui/hscroll_left_default.png b/data/graphics/gui/hscroll_left_default.png
index 2f763d30..1d792525 100644
--- a/data/graphics/gui/hscroll_left_default.png
+++ b/data/graphics/gui/hscroll_left_default.png
Binary files differ
diff --git a/data/graphics/gui/hscroll_left_highlight.png b/data/graphics/gui/hscroll_left_highlight.png
index 6be5ae25..1bf98865 100644
--- a/data/graphics/gui/hscroll_left_highlight.png
+++ b/data/graphics/gui/hscroll_left_highlight.png
Binary files differ
diff --git a/data/graphics/gui/hscroll_left_pressed.png b/data/graphics/gui/hscroll_left_pressed.png
index b8ebcb46..d5142d80 100644
--- a/data/graphics/gui/hscroll_left_pressed.png
+++ b/data/graphics/gui/hscroll_left_pressed.png
Binary files differ
diff --git a/data/graphics/gui/hscroll_right_default.png b/data/graphics/gui/hscroll_right_default.png
index 33fdddd0..93418c56 100644
--- a/data/graphics/gui/hscroll_right_default.png
+++ b/data/graphics/gui/hscroll_right_default.png
Binary files differ
diff --git a/data/graphics/gui/hscroll_right_highlight.png b/data/graphics/gui/hscroll_right_highlight.png
index e9e633ea..1c7d0529 100644
--- a/data/graphics/gui/hscroll_right_highlight.png
+++ b/data/graphics/gui/hscroll_right_highlight.png
Binary files differ
diff --git a/data/graphics/gui/hscroll_right_pressed.png b/data/graphics/gui/hscroll_right_pressed.png
index 53972f2b..55490a47 100644
--- a/data/graphics/gui/hscroll_right_pressed.png
+++ b/data/graphics/gui/hscroll_right_pressed.png
Binary files differ
diff --git a/data/graphics/gui/lpc_window.png b/data/graphics/gui/lpc_window.png
new file mode 100644
index 00000000..ddcef395
--- /dev/null
+++ b/data/graphics/gui/lpc_window.png
Binary files differ
diff --git a/data/graphics/gui/npcdialog.png b/data/graphics/gui/npcdialog.png
new file mode 100644
index 00000000..61f0c5ce
--- /dev/null
+++ b/data/graphics/gui/npcdialog.png
Binary files differ
diff --git a/data/graphics/gui/npcdialog.xml b/data/graphics/gui/npcdialog.xml
new file mode 100644
index 00000000..40f1fcc6
--- /dev/null
+++ b/data/graphics/gui/npcdialog.xml
@@ -0,0 +1,18 @@
+<skinset name="SpeechBubble" image="npcdialog.png">
+ <widget type="Window">
+ <!-- Top Row -->
+ <part type="top-left-corner" xpos="0" ypos="0" width="16" height="13" />
+ <part type="top-edge" xpos="16" ypos="0" width="15" height="13" />
+ <part type="top-right-corner" xpos="31" ypos="0" width="16" height="13" />
+
+ <!-- Middle Row -->
+ <part type="left-edge" xpos="0" ypos="13" width="16" height="14" />
+ <part type="bg-quad" xpos="16" ypos="13" width="15" height="14" />
+ <part type="right-edge" xpos="31" ypos="13" width="16" height="14" />
+
+ <!-- Bottom Row -->
+ <part type="bottom-left-corner" xpos="0" ypos="27" width="16" height="15" />
+ <part type="bottom-edge" xpos="16" ypos="27" width="15" height="15" />
+ <part type="bottom-right-corner" xpos="31" ypos="27" width="16" height="15" />
+ </widget>
+</skinset>
diff --git a/data/graphics/gui/scrololol.png b/data/graphics/gui/scrololol.png
new file mode 100644
index 00000000..e0bd67d3
--- /dev/null
+++ b/data/graphics/gui/scrololol.png
Binary files differ
diff --git a/data/graphics/gui/slider.png b/data/graphics/gui/slider.png
index 465ad0e8..dc5ef556 100644
--- a/data/graphics/gui/slider.png
+++ b/data/graphics/gui/slider.png
Binary files differ
diff --git a/data/graphics/gui/slider_hilight.png b/data/graphics/gui/slider_hilight.png
index 37c780cd..11727ea2 100644
--- a/data/graphics/gui/slider_hilight.png
+++ b/data/graphics/gui/slider_hilight.png
Binary files differ
diff --git a/data/graphics/gui/tab.png b/data/graphics/gui/tab.png
index 91eadf08..098fe0b3 100644
--- a/data/graphics/gui/tab.png
+++ b/data/graphics/gui/tab.png
Binary files differ
diff --git a/data/graphics/gui/tab_hilight.png b/data/graphics/gui/tab_hilight.png
index f6b39942..69b95c19 100644
--- a/data/graphics/gui/tab_hilight.png
+++ b/data/graphics/gui/tab_hilight.png
Binary files differ
diff --git a/data/graphics/gui/tabselected.png b/data/graphics/gui/tabselected.png
index e2983060..1a727e4f 100644
--- a/data/graphics/gui/tabselected.png
+++ b/data/graphics/gui/tabselected.png
Binary files differ
diff --git a/data/graphics/gui/vscroll_down_default.png b/data/graphics/gui/vscroll_down_default.png
index c4292489..0780e9fa 100644
--- a/data/graphics/gui/vscroll_down_default.png
+++ b/data/graphics/gui/vscroll_down_default.png
Binary files differ
diff --git a/data/graphics/gui/vscroll_down_highlight.png b/data/graphics/gui/vscroll_down_highlight.png
index ac88f7c7..f01caad2 100644
--- a/data/graphics/gui/vscroll_down_highlight.png
+++ b/data/graphics/gui/vscroll_down_highlight.png
Binary files differ
diff --git a/data/graphics/gui/vscroll_down_pressed.png b/data/graphics/gui/vscroll_down_pressed.png
index 9dcc89f6..d5525ca1 100644
--- a/data/graphics/gui/vscroll_down_pressed.png
+++ b/data/graphics/gui/vscroll_down_pressed.png
Binary files differ
diff --git a/data/graphics/gui/vscroll_grey.png b/data/graphics/gui/vscroll_grey.png
index f99da467..46132a6c 100644
--- a/data/graphics/gui/vscroll_grey.png
+++ b/data/graphics/gui/vscroll_grey.png
Binary files differ
diff --git a/data/graphics/gui/vscroll_highlight.png b/data/graphics/gui/vscroll_highlight.png
index 2e0fcbfc..d00744e1 100644
--- a/data/graphics/gui/vscroll_highlight.png
+++ b/data/graphics/gui/vscroll_highlight.png
Binary files differ
diff --git a/data/graphics/gui/vscroll_up_default.png b/data/graphics/gui/vscroll_up_default.png
index 1cecc351..c71cc6de 100644
--- a/data/graphics/gui/vscroll_up_default.png
+++ b/data/graphics/gui/vscroll_up_default.png
Binary files differ
diff --git a/data/graphics/gui/vscroll_up_highlight.png b/data/graphics/gui/vscroll_up_highlight.png
index 7b5009f3..85a80b6a 100644
--- a/data/graphics/gui/vscroll_up_highlight.png
+++ b/data/graphics/gui/vscroll_up_highlight.png
Binary files differ
diff --git a/data/graphics/gui/vscroll_up_pressed.png b/data/graphics/gui/vscroll_up_pressed.png
index 2320ec42..4518e100 100644
--- a/data/graphics/gui/vscroll_up_pressed.png
+++ b/data/graphics/gui/vscroll_up_pressed.png
Binary files differ
diff --git a/data/graphics/gui/window.xml b/data/graphics/gui/window.xml
index f27dbc7f..3310cd89 100644
--- a/data/graphics/gui/window.xml
+++ b/data/graphics/gui/window.xml
@@ -1,18 +1,18 @@
-<skinset name="Default" image="window.png">
+<skinset name="Default" image="lpc_window.png">
<widget type="Window">
<!-- Top Row -->
- <part type="top-left-corner" xpos="0" ypos="0" width="4" height="4" />
- <part type="top-edge" xpos="4" ypos="0" width="32" height="4" />
- <part type="top-right-corner" xpos="36" ypos="0" width="4" height="4" />
+ <part type="top-left-corner" xpos="0" ypos="0" width="32" height="13" />
+ <part type="top-edge" xpos="32" ypos="0" width="33" height="13" />
+ <part type="top-right-corner" xpos="65" ypos="0" width="32" height="13" />
<!-- Middle Row -->
- <part type="left-edge" xpos="0" ypos="4" width="4" height="216" />
- <part type="bg-quad" xpos="4" ypos="4" width="32" height="216" />
- <part type="right-edge" xpos="36" ypos="4" width="4" height="216" />
+ <part type="left-edge" xpos="0" ypos="13" width="32" height="7" />
+ <part type="bg-quad" xpos="32" ypos="13" width="33" height="7" />
+ <part type="right-edge" xpos="65" ypos="13" width="32" height="7" />
<!-- Bottom Row -->
- <part type="bottom-left-corner" xpos="0" ypos="220" width="4" height="4" />
- <part type="bottom-edge" xpos="4" ypos="220" width="32" height="4" />
- <part type="bottom-right-corner" xpos="36" ypos="220" width="4" height="4" />
+ <part type="bottom-left-corner" xpos="0" ypos="20" width="32" height="12" />
+ <part type="bottom-edge" xpos="32" ypos="20" width="33" height="12" />
+ <part type="bottom-right-corner" xpos="65" ypos="20" width="32" height="12" />
</widget>
</skinset>
diff --git a/docs/lpc2012.mana b/docs/lpc2012.mana
new file mode 100644
index 00000000..6a9aaa65
--- /dev/null
+++ b/docs/lpc2012.mana
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+
+<!--
+Example branding file
+
+With a branding file you can customize the appearance and various
+other default settings. To use a branding file just pass its
+filename / path as a command line parameter
+-->
+
+<configuration>
+ <option name="appName" value="Mana"/>
+ <option name="appShort" value="mana"/>
+ <option name="appIcon" value="icons/mana.png"/>
+ <option name="defaultServer" value="localhost"/>
+ <option name="defaultPort" value="9601"/>
+ <option name="defaultServerType" value="manaserv"/>
+</configuration>
diff --git a/mana.cbp b/mana.cbp
index a1d92c44..e1311c9b 100644
--- a/mana.cbp
+++ b/mana.cbp
@@ -532,8 +532,6 @@
<Unit filename="src\resources\hairdb.h" />
<Unit filename="src\resources\image.cpp" />
<Unit filename="src\resources\image.h" />
- <Unit filename="src\resources\imageloader.cpp" />
- <Unit filename="src\resources\imageloader.h" />
<Unit filename="src\resources\imageset.cpp" />
<Unit filename="src\resources\imageset.h" />
<Unit filename="src\resources\imagewriter.cpp" />
diff --git a/mana.files b/mana.files
index b2d0578c..be668387 100644
--- a/mana.files
+++ b/mana.files
@@ -478,8 +478,6 @@ src/resources/hairdb.cpp
src/resources/hairdb.h
src/resources/image.cpp
src/resources/image.h
-src/resources/imageloader.cpp
-src/resources/imageloader.h
src/resources/imageset.cpp
src/resources/imageset.h
src/resources/imagewriter.cpp
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9501b617..b9aa6bb7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -375,8 +375,6 @@ SET(SRCS
resources/hairdb.h
resources/image.cpp
resources/image.h
- resources/imageloader.cpp
- resources/imageloader.h
resources/imageset.h
resources/imageset.cpp
resources/imagewriter.cpp
diff --git a/src/client.cpp b/src/client.cpp
index 28affce6..fec41f5e 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -1397,10 +1397,7 @@ void Client::handleVideoResize(int width, int height)
// Keep a minimum size. This isn't adhered to by the actual window, but
// it keeps some window positions from getting messed up.
width = std::max(640, width);
- height = std::max(480, height);
-
- if (graphics->getWidth() == width && graphics->getHeight() == height)
- return;
+ height = std::max(360, height);
if (graphics->changeVideoMode(width,
height,
@@ -1408,7 +1405,8 @@ void Client::handleVideoResize(int width, int height)
false,
graphics->getHWAccel()))
{
- videoResized(width, height);
+ videoResized(graphics->getWidth(),
+ graphics->getHeight());
// Since everything appears to have worked out, remember to store the
// new size in the configuration.
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 0dc8e3ed..facff7d8 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -101,7 +101,6 @@ DefaultsData* getConfigDefaults()
AddDEF(configData, "downTolerance", 100);
AddDEF(configData, "leftTolerance", 100);
AddDEF(configData, "rightTolerance", 100);
- AddDEF(configData, "logNpcInGui", true);
AddDEF(configData, "download-music", false);
AddDEF(configData, "guialpha", 0.8f);
AddDEF(configData, "ChatLogLength", 0);
@@ -142,8 +141,8 @@ DefaultsData* getBrandingDefaults()
AddDEF(brandingData, "onlineServerList", "");
AddDEF(brandingData, "guiThemePath", "");
AddDEF(brandingData, "theme", "");
- AddDEF(brandingData, "font", "fonts/dejavusans.ttf");
- AddDEF(brandingData, "boldFont", "fonts/dejavusans-bold.ttf");
+ AddDEF(brandingData, "font", "fonts/DejaVuSerifCondensed.ttf");
+ AddDEF(brandingData, "boldFont", "fonts/DejaVuSerifCondensed-Bold.ttf");
AddDEF(brandingData, "monoFont", "fonts/dejavusans-mono.ttf");
return brandingData;
diff --git a/src/game.cpp b/src/game.cpp
index 222e56df..aa4be543 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -107,7 +107,6 @@ TradeWindow *tradeWindow;
HelpWindow *helpWindow;
DebugWindow *debugWindow;
ShortcutWindow *itemShortcutWindow;
-ShortcutWindow *emoteShortcutWindow;
OutfitWindow *outfitWindow;
SpecialsWindow *specialsWindow;
SocialWindow *socialWindow;
@@ -161,8 +160,6 @@ static void createGuiWindows()
debugWindow = new DebugWindow;
itemShortcutWindow = new ShortcutWindow("ItemShortcut",
new ItemShortcutContainer);
- emoteShortcutWindow = new ShortcutWindow("EmoteShortcut",
- new EmoteShortcutContainer);
outfitWindow = new OutfitWindow();
specialsWindow = new SpecialsWindow();
socialWindow = new SocialWindow();
@@ -195,7 +192,6 @@ static void destroyGuiWindows()
del_0(helpWindow)
del_0(debugWindow)
del_0(itemShortcutWindow)
- del_0(emoteShortcutWindow)
del_0(outfitWindow)
del_0(specialsWindow)
del_0(socialWindow)
@@ -685,9 +681,6 @@ void Game::handleInput()
case KeyboardConfig::KEY_WINDOW_SOCIAL:
requestedWindow = socialWindow;
break;
- case KeyboardConfig::KEY_WINDOW_EMOTE_SHORTCUT:
- requestedWindow = emoteShortcutWindow;
- break;
case KeyboardConfig::KEY_WINDOW_OUTFIT:
requestedWindow = outfitWindow;
break;
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 7b56d974..61cc78ba 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -25,20 +25,23 @@
#include "log.h"
#include "resources/image.h"
-#include "resources/imageloader.h"
#include "utils/gettext.h"
#include <SDL_gfxBlitFunc.h>
+#include <SDL/SDL_rotozoom.h>
Graphics::Graphics():
mWidth(0),
mHeight(0),
+ mScale(1),
mBpp(0),
mFullscreen(false),
mHWAccel(false),
- mBlitMode(BLIT_NORMAL)
+ mBlitMode(BLIT_NORMAL),
+ mScreenSurface(0)
{
+ mTarget = 0;
}
Graphics::~Graphics()
@@ -65,13 +68,24 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
else
displayFlags |= SDL_SWSURFACE;
- setTarget(SDL_SetVideoMode(w, h, bpp, displayFlags));
+ SDL_FreeSurface(mTarget);
+ mTarget = 0;
+
+ // Calculate scaling factor
+ mScale = std::max(w / 640, h / 360);
+
+ mScreenSurface = SDL_SetVideoMode(w, h, bpp, displayFlags);
+ const SDL_PixelFormat& fmt = *(mScreenSurface->format);
+ setTarget(SDL_CreateRGBSurface(SDL_SWSURFACE,
+ w / mScale, h / mScale,
+ fmt.BitsPerPixel,
+ fmt.Rmask, fmt.Gmask, fmt.Bmask, 0));
if (!mTarget)
return false;
- mWidth = w;
- mHeight = h;
+ mWidth = mTarget->w;
+ mHeight = mTarget->h;
mBpp = bpp;
mFullscreen = fs;
mHWAccel = hwaccel;
@@ -111,8 +125,8 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
bool Graphics::changeVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
{
// Just return success if we're already in this mode
- if (mWidth == w &&
- mHeight == h &&
+ if (mScreenSurface && mScreenSurface->w == w &&
+ mScreenSurface->h == h &&
mBpp == bpp &&
mFullscreen == fs &&
mHWAccel == hwaccel)
@@ -122,12 +136,14 @@ bool Graphics::changeVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
bool success = setVideoMode(w, h, bpp, fs, hwaccel);
- // If it didn't work, try to restore the previous mode. If that doesn't
+ // If it didn't work, try to restore fallback resolution. If that doesn't
// work either, we're in big trouble and bail out.
- if (!success) {
- if (!setVideoMode(mWidth, mHeight, mBpp, mFullscreen, mHWAccel)) {
+ if (!success)
+ {
+ if (!setVideoMode(640, 360, mBpp, mFullscreen, mHWAccel))
+ {
logger->error(_("Failed to change video mode and couldn't "
- "switch back to the previous mode!"));
+ "switch back to the fallback mode!"));
}
}
@@ -136,16 +152,6 @@ bool Graphics::changeVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
return success;
}
-int Graphics::getWidth() const
-{
- return mWidth;
-}
-
-int Graphics::getHeight() const
-{
- return mHeight;
-}
-
bool Graphics::drawImage(Image *image, int x, int y)
{
if (image)
@@ -219,15 +225,6 @@ bool Graphics::drawImage(Image *image, int srcX, int srcY, int dstX, int dstY,
return !(SDL_gfxBlitRGBA(image->mSDLSurface, &srcRect, mTarget, &dstRect) < 0);
}
-void Graphics::drawImage(gcn::Image const *image, int srcX, int srcY,
- int dstX, int dstY, int width, int height)
-{
- ProxyImage const *srcImage =
- dynamic_cast< ProxyImage const * >(image);
- assert(srcImage);
- drawImage(srcImage->getImage(), srcX, srcY, dstX, dstY, width, height, true);
-}
-
void Graphics::drawImagePattern(Image *image, int x, int y, int w, int h)
{
// Check that preconditions for blitting are met.
@@ -371,7 +368,27 @@ void Graphics::drawImageRect(int x, int y, int w, int h,
void Graphics::updateScreen()
{
- SDL_Flip(mTarget);
+ // Center viewport
+ SDL_Rect dstRect;
+ dstRect.x = (mScreenSurface->w-getWidth() * mScale) / 2;
+ dstRect.y = (mScreenSurface->h-getHeight() * mScale) / 2;
+
+ // Zoom in if necessary
+ if (mScale > 1)
+ {
+ SDL_Surface *tmp = zoomSurface(mTarget, mScale, mScale, 0);
+
+ // Copy temporary surface to screen
+ SDL_BlitSurface(tmp, NULL, mScreenSurface, &dstRect);
+ SDL_FreeSurface(tmp);
+ }
+ else
+ {
+ // Copy mTarget directly to screen
+ SDL_BlitSurface(mTarget, NULL, mScreenSurface, &dstRect);
+ }
+
+ SDL_Flip(mScreenSurface);
}
SDL_Surface *Graphics::getScreenshot()
diff --git a/src/graphics.h b/src/graphics.h
index 6a17aab4..4c1b2561 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -102,12 +102,6 @@ class Graphics : public gcn::SDLGraphics
bool drawImage(Image *image, int x, int y);
/**
- * Overrides with our own drawing method.
- */
- void drawImage(gcn::Image const *image, int srcX, int srcY,
- int dstX, int dstY, int width, int height);
-
- /**
* Draws a resclaled version of the image
*/
bool drawRescaledImage(Image *image, int srcX, int srcY,
@@ -195,14 +189,19 @@ class Graphics : public gcn::SDLGraphics
virtual void updateScreen();
/**
- * Returns the width of the screen.
+ * Returns the width of the drawable surface.
+ */
+ int getWidth() const { return mWidth; }
+
+ /**
+ * Returns the height of the drawable surface.
*/
- int getWidth() const;
+ int getHeight() const { return mHeight; }
/**
- * Returns the height of the screen.
+ * Returns the current scale ratio of the screen.
*/
- int getHeight() const;
+ int getScale() const { return mScale; }
/**
* Returns the amount of bits per pixel that was requested (not the
@@ -231,10 +230,12 @@ class Graphics : public gcn::SDLGraphics
protected:
int mWidth;
int mHeight;
+ int mScale;
int mBpp;
bool mFullscreen;
bool mHWAccel;
BlitMode mBlitMode;
+ SDL_Surface *mScreenSurface;
};
extern Graphics *graphics;
diff --git a/src/gui/beingpopup.cpp b/src/gui/beingpopup.cpp
index 56faed39..381bf011 100644
--- a/src/gui/beingpopup.cpp
+++ b/src/gui/beingpopup.cpp
@@ -41,13 +41,12 @@ BeingPopup::BeingPopup():
// Being Name
mBeingName = new Label("A");
mBeingName->setFont(boldFont);
- mBeingName->setPosition(getPadding(), getPadding());
- const int fontHeight = mBeingName->getHeight() + getPadding();
+ const int fontHeight = mBeingName->getHeight() + 3;
// Being's party
mBeingParty = new Label("A");
- mBeingParty->setPosition(getPadding(), fontHeight);
+ mBeingParty->setPosition(0, fontHeight);
add(mBeingName);
add(mBeingParty);
@@ -80,12 +79,12 @@ void BeingPopup::show(int x, int y, Being *b)
if (minWidth < mBeingParty->getWidth())
minWidth = mBeingParty->getWidth();
- setContentSize(minWidth + 10, (height * 2) + 10);
+ setContentSize(minWidth, height * 2);
}
else
{
mBeingParty->setCaption("");
- setContentSize(minWidth + 10, height + 10);
+ setContentSize(minWidth, height);
}
position(x, y);
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp
index 8fee148b..931735f8 100644
--- a/src/gui/charcreatedialog.cpp
+++ b/src/gui/charcreatedialog.cpp
@@ -101,11 +101,8 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
mNameField->setActionEventId("create");
mNameField->addActionListener(this);
- mAttributesLeft = new Label(
- strprintf(_("Please distribute %d points"), 99));
-
int w = 200;
- int h = 330;
+ int h = 160;
setContentSize(w, h);
mPlayerBox->setDimension(gcn::Rectangle(80, 30, 110, 85));
mNameLabel->setPosition(5, 5);
@@ -117,7 +114,6 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
mPrevHairStyleButton->setPosition(90, 64);
mNextHairStyleButton->setPosition(165, 64);
mHairStyleLabel->setPosition(5, 70);
- mAttributesLeft->setPosition(15, 280);
updateSliders();
mCancelButton->setPosition(
w - 5 - mCancelButton->getWidth(),
@@ -138,7 +134,6 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
add(mNextHairStyleButton);
add(mPrevHairStyleButton);
add(mHairStyleLabel);
- add(mAttributesLeft);
add(mCreateButton);
add(mCancelButton);
@@ -148,6 +143,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
center();
setVisible(true);
mNameField->requestFocus();
+ setFixedGender(true, GENDER_MALE);
}
CharCreateDialog::~CharCreateDialog()
@@ -239,6 +235,9 @@ std::string CharCreateDialog::getName() const
void CharCreateDialog::updateSliders()
{
+ if (Net::getNetworkType() == ServerInfo::MANASERV)
+ return;
+
for (unsigned i = 0; i < mAttributeSlider.size(); i++)
{
// Update captions
@@ -359,6 +358,8 @@ void CharCreateDialog::setFixedGender(bool fixed, Gender gender)
if (fixed)
{
mMale->setEnabled(false);
+ mMale->setVisible(false);
+ mFemale->setVisible(false);
mFemale->setEnabled(false);
}
}
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index 1850eb9d..dff648ec 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -39,7 +39,6 @@
#include "gui/widgets/container.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layout.h"
-#include "gui/widgets/layouthelper.h"
#include "gui/widgets/playerbox.h"
#include "gui/widgets/textfield.h"
@@ -358,9 +357,6 @@ CharacterDisplay::CharacterDisplay(CharSelectDialog *charSelectDialog):
mDelete = new Button(_("Delete"), "delete", charSelectDialog);
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
place(0, 0, mPlayerBox, 3, 5);
place(0, 5, mName, 3);
place(0, 6, mLevel, 3);
@@ -370,7 +366,7 @@ CharacterDisplay::CharacterDisplay(CharSelectDialog *charSelectDialog):
update();
- h.reflowLayout(80, 112 + mName->getHeight() + mLevel->getHeight() +
+ setSize(80, 112 + mName->getHeight() + mLevel->getHeight() +
mMoney->getHeight() + mButton->getHeight() + mDelete->getHeight());
}
diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp
index d2fd4a29..1eedd638 100644
--- a/src/gui/debugwindow.cpp
+++ b/src/gui/debugwindow.cpp
@@ -66,7 +66,7 @@ public:
mTileMouseLabel = new Label("");
mParticleCountLabel = new Label("");
- LayoutHelper h = (this);
+ LayoutHelper h(this);
ContainerPlacer place = h.getPlacer(0, 0);
place(0, 0, mFPSLabel, 1);
@@ -144,7 +144,7 @@ public:
mSpecial2 = new RadioButton(_("Special 2"), "mapdebug");
mSpecial3 = new RadioButton(_("Special 3"), "mapdebug");
- LayoutHelper h = (this);
+ LayoutHelper h(this);
ContainerPlacer place = h.getPlacer(0, 0);
place(0, 0, showLabel, 1);
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 85a4c766..bd385e40 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -25,15 +25,12 @@
#include "graphics.h"
#include "inventory.h"
#include "item.h"
-#include "localplayer.h"
#include "gui/equipmentwindow.h"
#include "gui/itempopup.h"
#include "gui/setup.h"
#include "gui/viewport.h"
-#include "gui/widgets/playerbox.h"
-
#include "net/inventoryhandler.h"
#include "net/net.h"
@@ -60,11 +57,6 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment):
mItemPopup = new ItemPopup;
setupWindow->registerWindowForReset(this);
- // Control that shows the Player
- PlayerBox *playerBox = new PlayerBox;
- playerBox->setDimension(gcn::Rectangle(50, 80, 74, 123));
- playerBox->setPlayer(local_player);
-
setWindowName("Equipment");
setCloseButton(true);
setSaveVisible(true);
@@ -77,7 +69,6 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment):
area.height - mUnequip->getHeight() - 5);
mUnequip->setEnabled(false);
- add(playerBox);
add(mUnequip);
}
@@ -254,6 +245,9 @@ void EquipmentWindow::mouseMoved(gcn::MouseEvent &event)
int mouseX, mouseY;
SDL_GetMouseState(&mouseX, &mouseY);
+ mouseX /= graphics->getScale();
+ mouseY /= graphics->getScale();
+
// Show ItemTooltip
std::string slotName = getSlotName(x, y);
if (!slotName.empty())
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 78fc42fb..2e1d006e 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -37,7 +37,6 @@
#include "resources/image.h"
#include "resources/imageset.h"
-#include "resources/imageloader.h"
#include "resources/resourcemanager.h"
#include "resources/theme.h"
@@ -88,10 +87,6 @@ Gui::Gui(Graphics *graphics):
// Set graphics
setGraphics(graphics);
- // Set image loader
- static ImageLoader imageLoader;
- gcn::Image::setImageLoader(&imageLoader);
-
// Set input
guiInput = new SDLInput;
setInput(guiInput);
@@ -112,7 +107,7 @@ Gui::Gui(Graphics *graphics):
// Set global font
const int fontSize = config.getValue("fontSize", 11);
- std::string fontFile = branding.getValue("font", "fonts/dejavusans.ttf");
+ std::string fontFile = branding.getValue("font", "fonts/DejaVuSerifCondensed.ttf");
std::string path = resman->getPath(fontFile);
try
@@ -127,7 +122,7 @@ Gui::Gui(Graphics *graphics):
}
// Set bold font
- fontFile = branding.getValue("boldFont", "fonts/dejavusans-bold.ttf");
+ fontFile = branding.getValue("boldFont", "fonts/DejaVuSerifCondensed-Bold.ttf");
path = resman->getPath(fontFile);
try
{
@@ -205,6 +200,9 @@ void Gui::draw()
int mouseX, mouseY;
Uint8 button = SDL_GetMouseState(&mouseX, &mouseY);
+ mouseX /= graphics->getScale();
+ mouseY /= graphics->getScale();
+
if ((Client::hasMouseFocus() || button & SDL_BUTTON(1))
&& mCustomCursor
&& mMouseCursorAlpha > 0.0f)
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index c09a0504..193fec23 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -88,7 +88,6 @@ ItemPopup::ItemPopup():
// Item Name
mItemName = new Label;
mItemName->setFont(boldFont);
- mItemName->setPosition(getPadding(), getPadding());
// Item Description
mItemDesc = new TextBox;
@@ -143,12 +142,12 @@ void ItemPopup::setNoItem()
mItemName->adjustSize();
mItemName->setForegroundColor(Theme::getThemeColor(Theme::GENERIC));
- mItemName->setPosition(getPadding(), getPadding());
+ mItemName->setPosition(0, 0);
mItemDesc->setText(std::string());
mItemEffect->setText(std::string());
- setContentSize(mItemName->getWidth() + 2 * getPadding(), 0);
+ setContentSize(mItemName->getWidth(), mItemName->getHeight());
}
void ItemPopup::setItem(const ItemInfo &item, bool showImage)
@@ -171,12 +170,7 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage)
mIcon->setImage(image);
if (image)
- {
- int x = getPadding();
- int y = getPadding();
- mIcon->setPosition(x, y);
space = mIcon->getWidth();
- }
}
else
{
@@ -192,7 +186,7 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage)
mItemName->setCaption(caption);
mItemName->adjustSize();
mItemName->setForegroundColor(getColorFromItemType(mItemType));
- mItemName->setPosition(getPadding() + space, getPadding());
+ mItemName->setPosition(space, 0);
mItemDesc->setTextWrapped(item.getDescription(), ITEMPOPUP_WRAP_WIDTH);
{
@@ -235,7 +229,7 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage)
setContentSize(minWidth, nameHeight +
(numRowsDesc + numRowsWeight + 1) * fontHeight);
- mItemWeight->setPosition(getPadding(),
+ mItemWeight->setPosition(0,
nameHeight + (numRowsDesc + 1) * fontHeight);
}
else
@@ -243,12 +237,12 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage)
setContentSize(minWidth, nameHeight + (numRowsDesc + numRowsEffect +
numRowsWeight + 1) * fontHeight);
- mItemWeight->setPosition(getPadding(), nameHeight + (numRowsDesc +
+ mItemWeight->setPosition(0, nameHeight + (numRowsDesc +
numRowsEffect + 1) * fontHeight);
}
- mItemDesc->setPosition(getPadding(), nameHeight);
- mItemEffect->setPosition(getPadding(), nameHeight +
+ mItemDesc->setPosition(0, nameHeight);
+ mItemEffect->setPosition(0, nameHeight +
(numRowsDesc + 1) * fontHeight);
}
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp
index 74d8a4aa..16d8d5bd 100644
--- a/src/gui/npcdialog.cpp
+++ b/src/gui/npcdialog.cpp
@@ -41,16 +41,13 @@
#include "net/net.h"
#include "net/npchandler.h"
+#include "resources/theme.h"
+
#include "utils/gettext.h"
#include "utils/stringutils.h"
#include <guichan/font.hpp>
-#define CAPTION_WAITING _("Waiting for server")
-#define CAPTION_NEXT _("Next")
-#define CAPTION_CLOSE _("Close")
-#define CAPTION_SUBMIT _("Submit")
-
typedef std::map<int, NpcDialog*> NpcDialogs;
class NpcEventListener : public EventListener
@@ -71,37 +68,36 @@ static NpcEventListener *npcListener = NULL;
NpcDialog::DialogList NpcDialog::instances;
NpcDialog::NpcDialog(int npcId)
- : Window(_("NPC")),
+ : Window("", false, NULL, "npcdialog.xml"),
mNpcId(npcId),
- mLogInteraction(config.getBoolValue("logNpcInGui")),
mDefaultInt(0),
+ mText(""),
+ mTextPlayTime(tick_time),
+ mClearTextOnNextPlay(true),
mInputState(NPC_INPUT_NONE),
mActionState(NPC_ACTION_WAIT)
{
// Basic Window Setup
setWindowName("NpcText");
- setResizable(true);
+ setResizable(false);
setCloseButton(false);
+ setMovable(false);
setFocusable(true);
- setMinWidth(200);
- setMinHeight(150);
-
- setDefaultSize(260, 200, ImageRect::CENTER);
-
// Setup output text box
mTextBox = new TextBox;
mTextBox->setEditable(false);
mTextBox->setOpaque(false);
- mScrollArea = new ScrollArea(mTextBox);
- mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- mScrollArea->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS);
+ mTextBox->setTextColor(&(Theme::instance()->getColor(Theme::ThemePalette::NPC_DIALOG_TEXT)));
+
+ // Place the window
+ setContentSize(getParent()->getWidth() / 2, 175);
+ setLocationRelativeTo(ImageRect::LOWER_CENTER, 0, -50);
// Setup listbox
mItemList = new ListBox(this);
mItemList->setWrappingEnabled(true);
- setContentSize(260, 175);
mListScrollArea = new ScrollArea(mItemList);
mListScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
@@ -116,35 +112,17 @@ NpcDialog::NpcDialog(int npcId)
mIntField = new IntTextField;
mIntField->setVisible(true);
- mClearButton = new Button(_("Clear log"), "clear", this);
-
- // Setup button
- mNextButton = new Button("", "ok", this);
-
- //Setup more and less buttons (int input)
- mPlusButton = new Button(_("+"), "inc", this);
- mMinusButton = new Button(_("-"), "dec", this);
-
- int width = std::max(mNextButton->getFont()->getWidth(CAPTION_WAITING),
- mNextButton->getFont()->getWidth(CAPTION_NEXT));
- width = std::max(width, mNextButton->getFont()->getWidth(CAPTION_CLOSE));
- width = std::max(width, mNextButton->getFont()->getWidth(CAPTION_SUBMIT));
-
- mNextButton->setWidth(8 + width);
-
- mResetButton = new Button(_("Reset"), "reset", this);
+ mSubmitButton = new Button(_("Submit"), "submit", this);
// Place widgets
buildLayout();
- center();
- loadWindowState();
-
instances.push_back(this);
setVisible(true);
requestFocus();
- listen(Event::ConfigChannel);
+ this->addKeyListener(this);
+
PlayerInfo::setNPCInteractionCount(PlayerInfo::getNPCInteractionCount()
+ 1);
}
@@ -152,130 +130,127 @@ NpcDialog::NpcDialog(int npcId)
NpcDialog::~NpcDialog()
{
// These might not actually be in the layout, so lets be safe
- delete mScrollArea;
+ delete mTextBox;
delete mItemList;
delete mTextField;
delete mIntField;
- delete mResetButton;
- delete mPlusButton;
- delete mMinusButton;
- delete mNextButton;
+ delete mSubmitButton;
instances.remove(this);
+ this->removeKeyListener(this);
+
PlayerInfo::setNPCInteractionCount(PlayerInfo::getNPCInteractionCount()
- 1);
npcListener->removeDialog(mNpcId);
}
-void NpcDialog::setText(const std::string &text)
+void NpcDialog::logic()
{
- mText = text;
- mTextBox->setTextWrapped(mText, mScrollArea->getWidth() - 15);
+
+ if (get_elapsed_time(mTextPlayTime) > 10)
+ {
+ mTextPlayTime = tick_time;
+
+ ushort currentLength = mTextBox->getText().length();
+ if (currentLength < mText.length())
+ {
+ setText(mText.substr(0, currentLength + 1));
+ }
+ }
+ Window::logic();
}
-void NpcDialog::addText(const std::string &text, bool save)
+void NpcDialog::playText(const std::string &text)
{
- if (save || mLogInteraction)
+ if (mClearTextOnNextPlay)
{
- mNewText += text + "\n";
- setText(mText + text + "\n");
+ mClearTextOnNextPlay = false;
+ mText = "";
+ setText("");
+
}
- mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll());
- mActionState = NPC_ACTION_WAIT;
- buildLayout();
+ mText += text + "\n";
+}
+
+void NpcDialog::setText(const std::string &text)
+{
+ mTextBox->setTextWrapped(text, getWidth() - 15);
}
-void NpcDialog::showNextButton()
+void NpcDialog::setStateNext()
{
mActionState = NPC_ACTION_NEXT;
buildLayout();
}
-void NpcDialog::showCloseButton()
+void NpcDialog::setStateClose()
{
mActionState = NPC_ACTION_CLOSE;
buildLayout();
}
-void NpcDialog::action(const gcn::ActionEvent &event)
+void NpcDialog::keyPressed(gcn::KeyEvent &keyEvent)
{
- if (event.getId() == "ok")
+ if (!keyEvent.isConsumed())
{
- if (mActionState == NPC_ACTION_NEXT)
+ if (keyEvent.getKey() == gcn::Key::SPACE)
{
- nextDialog();
- addText(std::string(), false);
+ keyEvent.consume();
+ proceed();
}
- else if (mActionState == NPC_ACTION_CLOSE)
- {
- close();
- }
- else if (mActionState == NPC_ACTION_INPUT)
- {
- std::string printText = ""; // Text that will get printed in the textbox
-
- if (mInputState == NPC_INPUT_LIST)
- {
- int selectedIndex = mItemList->getSelected();
-
- if (selectedIndex >= (int) mItems.size() || selectedIndex < 0)
- return;
+ }
+}
- printText = mItems[selectedIndex];
+void NpcDialog::action(const gcn::ActionEvent &event)
+{
+ if (event.getId() == "submit")
+ {
+ proceed();
+ }
+}
- Net::getNpcHandler()->menuSelect(mNpcId, selectedIndex + 1);
- }
- else if (mInputState == NPC_INPUT_STRING)
- {
- printText = mTextField->getText();
+void NpcDialog::proceed()
+{
+ // If the message isn't done typing out, finish it
+ if (mTextBox->getText().length() < mText.length())
+ {
+ setText(mText);
+ return;
+ }
- Net::getNpcHandler()->stringInput(mNpcId, printText);
- }
- else if (mInputState == NPC_INPUT_INTEGER)
- {
- printText = strprintf("%d", mIntField->getValue());
+ if (mActionState == NPC_ACTION_NEXT)
+ {
+ mClearTextOnNextPlay = true;
+ Net::getNpcHandler()->nextDialog(mNpcId);
+ }
+ else if (mActionState == NPC_ACTION_CLOSE)
+ {
+ close();
+ }
+ else if (mActionState == NPC_ACTION_INPUT)
+ {
+ if (mInputState == NPC_INPUT_LIST)
+ {
+ int selectedIndex = mItemList->getSelected();
- Net::getNpcHandler()->integerInput(mNpcId, mIntField->getValue());
- }
- // addText will auto remove the input layout
- addText(strprintf("\n> \"%s\"\n", printText.c_str()), false);
+ if (selectedIndex >= (int) mItems.size() || selectedIndex < 0)
+ return;
- mNewText.clear();
+ Net::getNpcHandler()->menuSelect(mNpcId, selectedIndex + 1);
}
-
- if (!mLogInteraction)
- setText("");
- }
- else if (event.getId() == "reset")
- {
- if (mInputState == NPC_INPUT_STRING)
+ else if (mInputState == NPC_INPUT_STRING)
{
- mTextField->setText(mDefaultString);
+ Net::getNpcHandler()->stringInput(mNpcId, mTextField->getText());
}
else if (mInputState == NPC_INPUT_INTEGER)
{
- mIntField->setValue(mDefaultInt);
+ Net::getNpcHandler()->integerInput(mNpcId, mIntField->getValue());
}
+ mClearTextOnNextPlay = true;
}
- else if (event.getId() == "inc")
- {
- mIntField->setValue(mIntField->getValue() + 1);
- }
- else if (event.getId() == "dec")
- {
- mIntField->setValue(mIntField->getValue() - 1);
- }
- else if (event.getId() == "clear")
- {
- setText(mNewText);
- }
-}
-void NpcDialog::nextDialog()
-{
- Net::getNpcHandler()->nextDialog(mNpcId);
}
void NpcDialog::close()
@@ -284,6 +259,7 @@ void NpcDialog::close()
Window::close();
}
+
int NpcDialog::getNumberOfElements()
{
return mItems.size();
@@ -376,13 +352,6 @@ void NpcDialog::move(int amount)
}
}
-void NpcDialog::widgetResized(const gcn::Event &event)
-{
- Window::widgetResized(event);
-
- setText(mText);
-}
-
void NpcDialog::setVisible(bool visible)
{
Window::setVisible(visible);
@@ -393,31 +362,18 @@ void NpcDialog::setVisible(bool visible)
}
}
-void NpcDialog::event(Event::Channel channel, const Event &event)
-{
- if (channel != Event::ConfigChannel)
- return;
-
- if (event.getType() == Event::ConfigOptionChanged &&
- event.getString("option") == "logNpcInGui")
- {
- mLogInteraction = config.getBoolValue("logNpcInGui");
- }
-}
-
-void NpcDialog::mouseClicked(gcn::MouseEvent &mouseEvent)
+void NpcDialog::mousePressed(gcn::MouseEvent &mouseEvent)
{
if (mouseEvent.getSource() == mItemList &&
isDoubleClick(mItemList->getSelected()))
{
- action(gcn::ActionEvent(mNextButton, mNextButton->getActionEventId()));
+ proceed();
}
- if (mouseEvent.getSource() == mTextBox && isDoubleClick((int)(long)mTextBox))
+ if (mActionState == NPC_ACTION_NEXT || mActionState == NPC_ACTION_CLOSE)
{
- if (mActionState == NPC_ACTION_NEXT || mActionState == NPC_ACTION_CLOSE)
- action(gcn::ActionEvent(mNextButton,
- mNextButton->getActionEventId()));
+ proceed();
}
+ Window::mousePressed(mouseEvent);
}
NpcDialog *NpcDialog::getActive()
@@ -466,67 +422,35 @@ void NpcDialog::buildLayout()
if (mActionState != NPC_ACTION_INPUT)
{
- if (mActionState == NPC_ACTION_WAIT)
- {
- mNextButton->setCaption(CAPTION_WAITING);
- }
- else if (mActionState == NPC_ACTION_NEXT)
- {
- mNextButton->setCaption(CAPTION_NEXT);
- }
- else if (mActionState == NPC_ACTION_CLOSE)
- {
- mNextButton->setCaption(CAPTION_CLOSE);
- }
- place(0, 0, mScrollArea, 5, 3);
- place(3, 3, mClearButton);
- place(4, 3, mNextButton);
+ place(0, 0, mTextBox, 5, 3);
}
else if (mInputState != NPC_INPUT_NONE)
{
- if (!mLogInteraction)
- setText(mNewText);
-
- mNextButton->setCaption(CAPTION_SUBMIT);
if (mInputState == NPC_INPUT_LIST)
{
- place(0, 0, mScrollArea, 6, 3);
+ place(0, 0, mTextBox, 6, 3);
place(0, 3, mListScrollArea, 6, 3);
- place(2, 6, mClearButton, 2);
- place(4, 6, mNextButton, 2);
mItemList->setSelected(-1);
}
else if (mInputState == NPC_INPUT_STRING)
{
- place(0, 0, mScrollArea, 6, 3);
- place(0, 3, mTextField, 6);
- place(0, 4, mResetButton, 2);
- place(2, 4, mClearButton, 2);
- place(4, 4, mNextButton, 2);
+ place(0, 0, mTextBox, 6, 3);
+ place(1, 3, mTextField, 3);
+ place(4, 3, mSubmitButton, 1);
}
else if (mInputState == NPC_INPUT_INTEGER)
{
- place(0, 0, mScrollArea, 6, 3);
- place(0, 3, mMinusButton, 1);
- place(1, 3, mIntField, 4);
- place(5, 3, mPlusButton, 1);
- place(0, 4, mResetButton, 2);
- place(2, 4, mClearButton, 2);
- place(4, 4, mNextButton, 2);
+ place(0, 0, mTextBox, 6, 3);
+ place(1, 3, mIntField, 3);
+ place(4, 3, mSubmitButton, 1);
}
}
Layout &layout = getLayout();
layout.setRowHeight(0, Layout::AUTO_SET);
- bool waitState = isWaitingForTheServer();
- mNextButton->setEnabled(!waitState);
- setCloseButton(waitState);
-
redraw();
-
- mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll());
}
void NpcEventListener::event(Event::Channel channel,
@@ -538,8 +462,7 @@ void NpcEventListener::event(Event::Channel channel,
if (event.getType() == Event::Message)
{
NpcDialog *dialog = getDialog(event.getInt("id"));
-
- dialog->addText(event.getString("text"));
+ dialog->playText(event.getString("text"));
}
else if (event.getType() == Event::Menu)
{
@@ -587,7 +510,7 @@ void NpcEventListener::event(Event::Channel channel,
return;
}
- dialog->showNextButton();
+ dialog->setStateNext();
}
else if (event.getType() == Event::Close)
{
@@ -601,7 +524,7 @@ void NpcEventListener::event(Event::Channel channel,
return;
}
- dialog->showCloseButton();
+ dialog->setStateClose();
}
else if (event.getType() == Event::CloseAll)
{
diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h
index 9c6839b0..5f2b61be 100644
--- a/src/gui/npcdialog.h
+++ b/src/gui/npcdialog.h
@@ -27,8 +27,10 @@
#include "gui/widgets/window.h"
#include <guichan/actionlistener.hpp>
+#include <guichan/keylistener.hpp>
#include <guichan/listmodel.hpp>
+
#include <list>
#include <string>
#include <vector>
@@ -47,7 +49,7 @@ class Button;
class NpcDialog : public Window,
public gcn::ActionListener,
public gcn::ListModel,
- public EventListener
+ public gcn::KeyListener
{
public:
NpcDialog(int npcId);
@@ -59,36 +61,46 @@ class NpcDialog : public Window,
*/
void action(const gcn::ActionEvent &event);
+ void keyPressed(gcn::KeyEvent &keyEvent);
+
/**
- * Sets the text shows in the dialog.
- *
- * @param string The new text.
- */
- void setText(const std::string &string);
+ * Moves the dialog forward
+ */
+ void proceed();
/**
- * Adds the text to the text shows in the dialog. Also adds a newline
- * to the end.
+ * Update the text being written to the screen
*
- * @param string The text to add.
+ * @overload Window::logic
*/
- void addText(const std::string &string, bool save = true);
+ void logic();
/**
- * When called, the widget will show a "Next" button.
+ * Has the dialog window animate playing the text
+ *
+ * @param string The text that will be played
*/
- void showNextButton();
+ void playText(const std::string &string);
+
+ /**
+ * Sets the text shows in the dialog.
+ *
+ * @param string The new text.
+ */
+ void setText(const std::string &string);
/**
- * When called, the widget will show a "Close" button and will close
- * the dialog when clicked.
+ * When called the window's next interaction
+ * with the player will be to request the next
+ * stage in the interaction.
*/
- void showCloseButton();
+ void setStateNext();
/**
- * Notifies the server that client has performed a next action.
+ * When called the window's next interaction
+ * with the player will be to close the window.
*/
- void nextDialog();
+ void setStateClose();
/**
* Notifies the server that the client has performed a close action.
@@ -139,18 +151,9 @@ class NpcDialog : public Window,
void move(int amount);
- /**
- * Called when resizing the window.
- *
- * @param event The calling event
- */
- void widgetResized(const gcn::Event &event);
-
void setVisible(bool visible);
- void event(Event::Channel channel, const Event &event);
-
- void mouseClicked(gcn::MouseEvent &mouseEvent);
+ void mousePressed(gcn::MouseEvent &mouseEvent);
/**
* Returns the first active instance. Useful for pushing user
@@ -175,16 +178,19 @@ class NpcDialog : public Window,
void buildLayout();
int mNpcId;
- bool mLogInteraction;
int mDefaultInt;
std::string mDefaultString;
// Used for the main input area
- gcn::ScrollArea *mScrollArea;
TextBox *mTextBox;
+ // Target string to be displayed into mTextBox
std::string mText;
- std::string mNewText;
+ // Timer for when to add a new character
+ int mTextPlayTime;
+ // When set, if playText() is called again
+ // It will clear the existing values
+ bool mClearTextOnNextPlay;
// Used for choice input
ListBox *mItemList;
@@ -194,16 +200,7 @@ class NpcDialog : public Window,
// Used for string and integer input
TextField *mTextField;
IntTextField *mIntField;
- Button *mPlusButton;
- Button *mMinusButton;
-
- Button *mClearButton;
-
- // Used for the button
- Button *mNextButton;
-
- // Will reset the text and integer input to the provided default
- Button *mResetButton;
+ Button *mSubmitButton;
enum NpcInputState
{
diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp
index 4ccb7580..46636d52 100644
--- a/src/gui/sdlinput.cpp
+++ b/src/gui/sdlinput.cpp
@@ -60,6 +60,8 @@
#include <guichan/exception.hpp>
+#include "graphics.h"
+
SDLInput::SDLInput()
{
mMouseInWindow = true;
@@ -73,14 +75,12 @@ bool SDLInput::isKeyQueueEmpty()
gcn::KeyInput SDLInput::dequeueKeyInput()
{
- gcn::KeyInput keyInput;
-
if (mKeyInputQueue.empty())
{
throw GCN_EXCEPTION("The queue is empty.");
}
- keyInput = mKeyInputQueue.front();
+ gcn::KeyInput keyInput = mKeyInputQueue.front();
mKeyInputQueue.pop();
return keyInput;
@@ -93,16 +93,19 @@ bool SDLInput::isMouseQueueEmpty()
gcn::MouseInput SDLInput::dequeueMouseInput()
{
- gcn::MouseInput mouseInput;
-
if (mMouseInputQueue.empty())
{
throw GCN_EXCEPTION("The queue is empty.");
}
- mouseInput = mMouseInputQueue.front();
+ gcn::MouseInput mouseInput = mMouseInputQueue.front();
mMouseInputQueue.pop();
+ // Scale the mouse input by the graphics scale ratio
+ int scale = graphics->getScale();
+ mouseInput.setX(mouseInput.getX() / scale);
+ mouseInput.setY(mouseInput.getY() / scale);
+
return mouseInput;
}
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index f378572b..c468490c 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -45,7 +45,7 @@ Setup::Setup():
{
setCloseButton(true);
int width = 395;
- int height = 360;
+ int height = 300;
setContentSize(width, height);
static const char *buttonNames[] = {
diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp
index 69ee3dc3..56815e32 100644
--- a/src/gui/setup_audio.cpp
+++ b/src/gui/setup_audio.cpp
@@ -29,7 +29,6 @@
#include "gui/widgets/checkbox.h"
#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
#include "gui/widgets/slider.h"
#include "utils/gettext.h"
@@ -47,7 +46,6 @@ Setup_Audio::Setup_Audio():
mMusicSlider(new Slider(0, sound.getMaxVolume()))
{
setName(_("Audio"));
- setDimension(gcn::Rectangle(0, 0, 250, 200));
gcn::Label *sfxLabel = new Label(_("Sfx volume"));
gcn::Label *notificationsLabel = new Label(_("Notifications volume"));
@@ -72,9 +70,6 @@ Setup_Audio::Setup_Audio():
mMusicSlider->setWidth(90);
// Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
place(0, 0, mSoundCheckBox);
place(0, 1, mSfxSlider);
place(1, 1, sfxLabel);
@@ -83,8 +78,6 @@ Setup_Audio::Setup_Audio():
place(0, 3, mMusicSlider);
place(1, 3, musicLabel);
place(0, 4, mDownloadMusicCheckBox);
-
- setDimension(gcn::Rectangle(0, 0, 370, 280));
}
void Setup_Audio::apply()
diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp
index 95b2000d..cf234eb3 100644
--- a/src/gui/setup_colors.cpp
+++ b/src/gui/setup_colors.cpp
@@ -28,7 +28,7 @@
#include "gui/widgets/browserbox.h"
#include "gui/widgets/itemlinkhandler.h"
#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/layout.h"
#include "gui/widgets/listbox.h"
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/slider.h"
@@ -155,9 +155,6 @@ Setup_Colors::Setup_Colors() :
setOpaque(false);
// Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
place(0, 0, mScroll, 6, 6).setPadding(2);
place(0, 6, mPreviewBox, 6).setPadding(2);
place(0, 7, mGradTypeLabel, 3);
@@ -177,8 +174,6 @@ Setup_Colors::Setup_Colors() :
place(5, 11, mGradDelayText).setPadding(1);
mGradTypeText->setCaption("");
-
- setDimension(gcn::Rectangle(0, 0, 370, 280));
}
Setup_Colors::~Setup_Colors()
diff --git a/src/gui/setup_interface.cpp b/src/gui/setup_interface.cpp
index 67d8d476..90cfba48 100644
--- a/src/gui/setup_interface.cpp
+++ b/src/gui/setup_interface.cpp
@@ -33,7 +33,7 @@
#include "gui/widgets/checkbox.h"
#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/layout.h"
#include "gui/widgets/listbox.h"
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/slider.h"
@@ -97,7 +97,6 @@ Setup_Interface::Setup_Interface():
mShowMonsterDamageEnabled(config.getBoolValue("showMonstersTakedDamage")),
mVisibleNamesEnabled(config.getBoolValue("visiblenames")),
mNameEnabled(config.getBoolValue("showownname")),
- mNPCLogEnabled(config.getBoolValue("logNpcInGui")),
mPickupChatEnabled(config.getBoolValue("showpickupchat")),
mPickupParticleEnabled(config.getBoolValue("showpickupparticle")),
mOpacity(config.getFloatValue("guialpha")),
@@ -105,7 +104,6 @@ Setup_Interface::Setup_Interface():
mVisibleNamesCheckBox(new CheckBox(_("Visible names"),
mVisibleNamesEnabled)),
mNameCheckBox(new CheckBox(_("Show own name"), mNameEnabled)),
- mNPCLogCheckBox(new CheckBox(_("Log NPC dialogue"), mNPCLogEnabled)),
mPickupNotifyLabel(new Label(_("Show pickup notification:"))),
// TRANSLATORS: Refers to "Show pickup notification"
mPickupChatCheckBox(new CheckBox(_("in chat"), mPickupChatEnabled)),
@@ -143,7 +141,6 @@ Setup_Interface::Setup_Interface():
mPickupChatCheckBox->setActionEventId("pickupchat");
mPickupParticleCheckBox->setActionEventId("pickupparticle");
mNameCheckBox->setActionEventId("showownname");
- mNPCLogCheckBox->setActionEventId("lognpc");
mAlphaSlider->setActionEventId("guialpha");
mSpeechSlider->setActionEventId("speech");
@@ -153,7 +150,6 @@ Setup_Interface::Setup_Interface():
mPickupChatCheckBox->addActionListener(this);
mPickupParticleCheckBox->addActionListener(this);
mNameCheckBox->addActionListener(this);
- mNPCLogCheckBox->addActionListener(this);
mAlphaSlider->addActionListener(this);
mSpeechSlider->addActionListener(this);
@@ -164,14 +160,10 @@ Setup_Interface::Setup_Interface():
mFontSizeDropDown->adjustHeight();
// Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
place(0, 0, mVisibleNamesCheckBox, 3);
place(3, 0, mNameCheckBox, 3);
place(0, 1, mShowMonsterDamageCheckBox, 3);
- place(3, 1, mNPCLogCheckBox, 3);
place(0, 2, space, 1, 1);
@@ -193,8 +185,6 @@ Setup_Interface::Setup_Interface():
place(0, 9, mSpeechSlider, 2);
place(2, 9, speechLabel, 2);
place(4, 9, mSpeechLabel, 2).setPadding(2);
-
- setDimension(gcn::Rectangle(0, 0, 370, 300));
}
Setup_Interface::~Setup_Interface()
@@ -209,7 +199,6 @@ void Setup_Interface::apply()
mShowMonsterDamageEnabled = config.getBoolValue("showMonstersTakedDamage");
mVisibleNamesEnabled = config.getBoolValue("visiblenames");
mNameEnabled = config.getBoolValue("showownname");
- mNPCLogEnabled = config.getBoolValue("logNpcInGui");
mSpeechMode = static_cast<Being::Speech>(config.getIntValue("speech"));
mOpacity = config.getFloatValue("guialpha");
mPickupChatEnabled = config.getBoolValue("showpickupchat");
@@ -222,7 +211,6 @@ void Setup_Interface::cancel()
mVisibleNamesCheckBox->setSelected(mVisibleNamesEnabled);
mSpeechSlider->setValue(mSpeechMode);
mNameCheckBox->setSelected(mNameEnabled);
- mNPCLogCheckBox->setSelected(mNPCLogEnabled);
mAlphaSlider->setValue(mOpacity);
//mAlphaSlider->setEnabled(!mSDLTransparencyDisabled);
@@ -232,7 +220,6 @@ void Setup_Interface::cancel()
config.setValue("showownname", mNameEnabled);
if (local_player)
local_player->setCheckNameSetting(true);
- config.setValue("logNpcInGui", mNPCLogEnabled);
config.setValue("guialpha", mOpacity);
config.setValue("showpickupchat", mPickupChatEnabled);
config.setValue("showpickupparticle", mPickupParticleEnabled);
@@ -278,10 +265,5 @@ void Setup_Interface::action(const gcn::ActionEvent &event)
local_player->setCheckNameSetting(true);
config.setValue("showownname", mNameCheckBox->isSelected());
}
- else if (id == "lognpc")
- {
- config.setValue("logNpcInGui", mNPCLogCheckBox->isSelected());
- }
-
}
diff --git a/src/gui/setup_interface.h b/src/gui/setup_interface.h
index 2b1de5b7..d3ddefdb 100644
--- a/src/gui/setup_interface.h
+++ b/src/gui/setup_interface.h
@@ -48,7 +48,6 @@ class Setup_Interface : public SetupTab, public gcn::ActionListener,
bool mShowMonsterDamageEnabled;
bool mVisibleNamesEnabled;
bool mNameEnabled;
- bool mNPCLogEnabled;
bool mPickupChatEnabled;
bool mPickupParticleEnabled;
double mOpacity;
@@ -63,7 +62,6 @@ class Setup_Interface : public SetupTab, public gcn::ActionListener,
gcn::CheckBox *mShowMonsterDamageCheckBox;
gcn::CheckBox *mVisibleNamesCheckBox;
gcn::CheckBox *mNameCheckBox;
- gcn::CheckBox *mNPCLogCheckBox;
gcn::Label *mPickupNotifyLabel;
gcn::CheckBox *mPickupChatCheckBox;
diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp
index b3bdc226..1109f06e 100644
--- a/src/gui/setup_joystick.cpp
+++ b/src/gui/setup_joystick.cpp
@@ -27,7 +27,6 @@
#include "gui/widgets/button.h"
#include "gui/widgets/checkbox.h"
#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
#include "utils/gettext.h"
@@ -46,16 +45,9 @@ Setup_Joystick::Setup_Joystick():
mJoystickCheckBox->addActionListener(this);
// Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
- place(0, 0, mJoystickCheckBox);
- place(0, 1, mCalibrateLabel);
- place.getCell().matchColWidth(0, 0);
- place = h.getPlacer(0, 1);
- place(0, 0, mCalibrateButton);
-
- setDimension(gcn::Rectangle(0, 0, 370, 75));
+ place(0, 0, mJoystickCheckBox, 2);
+ place(0, 1, mCalibrateLabel, 2);
+ place(0, 2, mCalibrateButton);
}
void Setup_Joystick::action(const gcn::ActionEvent &event)
diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp
index a108ae6a..5e29519b 100644
--- a/src/gui/setup_keyboard.cpp
+++ b/src/gui/setup_keyboard.cpp
@@ -29,7 +29,7 @@
#include "gui/okdialog.h"
#include "gui/widgets/button.h"
-#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/layout.h"
#include "gui/widgets/listbox.h"
#include "gui/widgets/scrollarea.h"
@@ -98,15 +98,10 @@ Setup_Keyboard::Setup_Keyboard():
mMakeDefaultButton->addActionListener(this);
// Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
place(0, 0, scrollArea, 4, 6).setPadding(2);
place(0, 6, mMakeDefaultButton);
place(2, 6, mAssignKeyButton);
place(3, 6, mUnassignKeyButton);
-
- setDimension(gcn::Rectangle(0, 0, 370, 280));
}
Setup_Keyboard::~Setup_Keyboard()
diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp
index c9776fe3..ad50baad 100644
--- a/src/gui/setup_players.cpp
+++ b/src/gui/setup_players.cpp
@@ -31,7 +31,7 @@
#include "gui/widgets/checkbox.h"
#include "gui/widgets/dropdown.h"
#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/layout.h"
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/table.h"
@@ -99,8 +99,7 @@ public:
{
freeWidgets();
delete mListModel;
- if (mPlayers)
- delete mPlayers;
+ delete mPlayers;
}
virtual int getRows() const
@@ -287,9 +286,6 @@ Setup_Players::Setup_Players():
reset();
// Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
place(0, 0, mPlayerTitleTable, 4);
place(0, 1, mPlayerScrollArea, 4, 4).setPadding(2);
place(0, 5, mDeleteButton);
@@ -302,8 +298,6 @@ Setup_Players::Setup_Players():
place(0, 10, mWhisperTabCheckBox, 4).setPadding(4);
player_relations.addListener(this);
-
- setDimension(gcn::Rectangle(0, 0, 370, 280));
}
Setup_Players::~Setup_Players()
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 3c92aa31..05bc6c44 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -28,13 +28,12 @@
#include "localplayer.h"
#include "log.h"
#include "main.h"
-#include "particle.h"
#include "gui/okdialog.h"
#include "gui/widgets/checkbox.h"
#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/layout.h"
#include "gui/widgets/listbox.h"
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/slider.h"
@@ -106,7 +105,7 @@ ModeListModel::ModeListModel()
const int height = modes[i]->h;
// Skip the unreasonably small modes
- if (width < 640 || height < 480)
+ if (width < 640 || height < 360)
continue;
mVideoModes.push_back(toString(width) + "x" + toString(height));
@@ -123,40 +122,10 @@ int ModeListModel::getIndexOf(const std::string &widthXHeightMode)
return -1;
}
-const char *Setup_Video::overlayDetailToString(int detail)
-{
- if (detail == -1)
- detail = config.getIntValue("OverlayDetail");
-
- switch (detail)
- {
- case 0: return _("off");
- case 1: return _("low");
- case 2: return _("high");
- }
- return "";
-}
-
-const char *Setup_Video::particleDetailToString(int detail)
-{
- if (detail == -1)
- detail = 3 - config.getIntValue("particleEmitterSkip");
-
- switch (detail)
- {
- case 0: return _("low");
- case 1: return _("medium");
- case 2: return _("high");
- case 3: return _("max");
- }
- return "";
-}
-
Setup_Video::Setup_Video():
mFullScreenEnabled(config.getBoolValue("screen")),
mOpenGLEnabled(config.getBoolValue("opengl")),
mCustomCursorEnabled(config.getBoolValue("customcursor")),
- mParticleEffectsEnabled(config.getBoolValue("particleeffects")),
mFps(config.getIntValue("fpslimit")),
mSDLTransparencyDisabled(config.getBoolValue("disableTransparency")),
mModeListModel(new ModeListModel),
@@ -165,17 +134,9 @@ Setup_Video::Setup_Video():
mOpenGLCheckBox(new CheckBox(_("OpenGL"), mOpenGLEnabled)),
mCustomCursorCheckBox(new CheckBox(_("Custom cursor"),
mCustomCursorEnabled)),
- mParticleEffectsCheckBox(new CheckBox(_("Particle effects"),
- mParticleEffectsEnabled)),
mFpsCheckBox(new CheckBox(_("FPS limit:"))),
mFpsSlider(new Slider(10, 120)),
mFpsLabel(new Label),
- mOverlayDetail(config.getIntValue("OverlayDetail")),
- mOverlayDetailSlider(new Slider(0, 2)),
- mOverlayDetailField(new Label),
- mParticleDetail(3 - config.getIntValue("particleEmitterSkip")),
- mParticleDetailSlider(new Slider(0, 3)),
- mParticleDetailField(new Label),
mDisableSDLTransparencyCheckBox(
new CheckBox(_("Disable transparency (Low CPU mode)"),
mSDLTransparencyDisabled))
@@ -188,9 +149,6 @@ Setup_Video::Setup_Video():
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
scrollArea->setSize(100, 200);
- overlayDetailLabel = new Label(_("Ambient FX:"));
- particleDetailLabel = new Label(_("Particle detail:"));
-
mModeList->setEnabled(true);
#ifndef USE_OPENGL
@@ -203,9 +161,6 @@ Setup_Video::Setup_Video():
mFpsSlider->setEnabled(mFps > 0);
mFpsCheckBox->setSelected(mFps > 0);
- overlayDetailLabel->setAlignment(Graphics::RIGHT);
- particleDetailLabel->setAlignment(Graphics::RIGHT);
-
// If the openGL Mode is enabled, disabling the transaprency
// is irrelevant.
mDisableSDLTransparencyCheckBox->setEnabled(!mOpenGLEnabled);
@@ -218,68 +173,30 @@ Setup_Video::Setup_Video():
// Set actions
mModeList->setActionEventId("videomode");
mCustomCursorCheckBox->setActionEventId("customcursor");
- mParticleEffectsCheckBox->setActionEventId("particleeffects");
mDisableSDLTransparencyCheckBox->setActionEventId("disableTransparency");
mFpsCheckBox->setActionEventId("fpslimitcheckbox");
mFpsSlider->setActionEventId("fpslimitslider");
- mOverlayDetailSlider->setActionEventId("overlaydetailslider");
- mOverlayDetailField->setActionEventId("overlaydetailfield");
mOpenGLCheckBox->setActionEventId("opengl");
- mParticleDetailSlider->setActionEventId("particledetailslider");
- mParticleDetailField->setActionEventId("particledetailfield");
// Set listeners
mModeList->addActionListener(this);
mCustomCursorCheckBox->addActionListener(this);
mOpenGLCheckBox->addActionListener(this);
- mParticleEffectsCheckBox->addActionListener(this);
mDisableSDLTransparencyCheckBox->addActionListener(this);
mFpsCheckBox->addActionListener(this);
mFpsSlider->addActionListener(this);
- mOverlayDetailSlider->addActionListener(this);
- mOverlayDetailField->addKeyListener(this);
- mParticleDetailSlider->addActionListener(this);
- mParticleDetailField->addKeyListener(this);
-
- mOverlayDetailField->setCaption(overlayDetailToString(mOverlayDetail));
- mOverlayDetailSlider->setValue(mOverlayDetail);
-
- mParticleDetailField->setCaption(particleDetailToString(mParticleDetail));
- mParticleDetailSlider->setValue(mParticleDetail);
// Do the layout
- LayoutHelper h(this);
-
- ContainerPlacer place = h.getPlacer(0, 0);
- place.getCell().setHAlign(LayoutCell::FILL);
-
+ getLayout().setHAlign(LayoutCell::FILL);
place(0, 0, scrollArea, 1, 4).setPadding(2).setHAlign(LayoutCell::FILL);
place(1, 0, space, 1, 4);
place(2, 0, mFsCheckBox);
place(2, 1, mOpenGLCheckBox);
place(2, 2, mCustomCursorCheckBox);
-
- place = h.getPlacer(0, 1);
- place.getCell().setHAlign(LayoutCell::FILL);
-
- place(0, 0, space, 3);
- place(0, 1, mDisableSDLTransparencyCheckBox, 4);
-
- place(0, 2, mFpsCheckBox);
- place(1, 2, mFpsSlider, 2);
- place(3, 2, mFpsLabel);
-
- place(0, 3, mParticleEffectsCheckBox, 4);
-
- place(0, 4, particleDetailLabel);
- place(1, 4, mParticleDetailSlider, 2);
- place(3, 4, mParticleDetailField);
-
- place(0, 5, overlayDetailLabel);
- place(1, 5, mOverlayDetailSlider, 2);
- place(3, 5, mOverlayDetailField);
-
- setDimension(gcn::Rectangle(0, 0, 370, 300));
+ place(2, 3, mDisableSDLTransparencyCheckBox, 4);
+ place(2, 4, mFpsCheckBox);
+ place(3, 4, mFpsSlider, 2);
+ place(5, 4, mFpsLabel);
}
Setup_Video::~Setup_Video()
@@ -344,7 +261,8 @@ void Setup_Video::apply()
}
else
{
- Client::instance()->videoResized(screenWidth, screenHeight);
+ Client::instance()->videoResized(graphics->getWidth(),
+ graphics->getHeight());
config.setValue("screen", fullscreen);
config.setValue("screenwidth", screenWidth);
@@ -402,8 +320,6 @@ void Setup_Video::apply()
// We sync old and new values at apply time
mFullScreenEnabled = config.getBoolValue("screen");
mCustomCursorEnabled = config.getBoolValue("customcursor");
- mParticleEffectsEnabled = config.getBoolValue("particleeffects");
- mOverlayDetail = config.getIntValue("OverlayDetail");
mOpenGLEnabled = config.getBoolValue("opengl");
mSDLTransparencyDisabled = config.getBoolValue("disableTransparency");
}
@@ -414,11 +330,8 @@ void Setup_Video::cancel()
mFsCheckBox->setSelected(mFullScreenEnabled);
mOpenGLCheckBox->setSelected(mOpenGLEnabled);
mCustomCursorCheckBox->setSelected(mCustomCursorEnabled);
- mParticleEffectsCheckBox->setSelected(mParticleEffectsEnabled);
mFpsSlider->setValue(mFps);
mFpsSlider->setEnabled(mFps > 0);
- mOverlayDetailSlider->setValue(mOverlayDetail);
- mParticleDetailSlider->setValue(mParticleDetail);
std::string text = mFpsCheckBox->isSelected() ? toString(mFps) : _("None");
mFpsLabel->setCaption(text);
mDisableSDLTransparencyCheckBox->setSelected(mSDLTransparencyDisabled);
@@ -432,7 +345,6 @@ void Setup_Video::cancel()
mModeList->setSelected(mModeListModel->getIndexOf(videoMode));
config.setValue("customcursor", mCustomCursorEnabled);
- config.setValue("particleeffects", mParticleEffectsEnabled);
config.setValue("opengl", mOpenGLEnabled);
config.setValue("disableTransparency", mSDLTransparencyDisabled);
}
@@ -445,31 +357,6 @@ void Setup_Video::action(const gcn::ActionEvent &event)
{
config.setValue("customcursor", mCustomCursorCheckBox->isSelected());
}
- else if (id == "particleeffects")
- {
- config.setValue("particleeffects",
- mParticleEffectsCheckBox->isSelected());
- Particle::enabled = mParticleEffectsCheckBox->isSelected();
-
- if (Game::instance())
- {
- new OkDialog(_("Particle Effect Settings Changed."),
- _("Changes will take effect on map change."));
- }
- }
- else if (id == "overlaydetailslider")
- {
- int val = (int) mOverlayDetailSlider->getValue();
- mOverlayDetailField->setCaption(overlayDetailToString(val));
- config.setValue("OverlayDetail", val);
- }
- else if (id == "particledetailslider")
- {
- int val = (int) mParticleDetailSlider->getValue();
- mParticleDetailField->setCaption(particleDetailToString(val));
- config.setValue("particleEmitterSkip", 3 - val);
- Particle::emitterSkip = 4 - val;
- }
else if (id == "fpslimitcheckbox" || id == "fpslimitslider")
{
int fps = (int) mFpsSlider->getValue();
diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h
index 7002a936..d09620fa 100644
--- a/src/gui/setup_video.h
+++ b/src/gui/setup_video.h
@@ -44,15 +44,10 @@ class Setup_Video : public SetupTab, public gcn::ActionListener,
void action(const gcn::ActionEvent &event);
- static const char *overlayDetailToString(int detail = -1);
-
- static const char *particleDetailToString(int detail = -1);
-
private:
bool mFullScreenEnabled;
bool mOpenGLEnabled;
bool mCustomCursorEnabled;
- bool mParticleEffectsEnabled;
int mFps;
bool mSDLTransparencyDisabled;
@@ -60,27 +55,16 @@ class Setup_Video : public SetupTab, public gcn::ActionListener,
//gcn::Label *scrollRadiusLabel;
//gcn::Label *scrollLazinessLabel;
- gcn::Label *overlayDetailLabel;
- gcn::Label *particleDetailLabel;
gcn::ListBox *mModeList;
gcn::CheckBox *mFsCheckBox;
gcn::CheckBox *mOpenGLCheckBox;
gcn::CheckBox *mCustomCursorCheckBox;
- gcn::CheckBox *mParticleEffectsCheckBox;
gcn::CheckBox *mFpsCheckBox;
gcn::Slider *mFpsSlider;
gcn::Label *mFpsLabel;
- int mOverlayDetail;
- gcn::Slider *mOverlayDetailSlider;
- gcn::Label *mOverlayDetailField;
-
- int mParticleDetail;
- gcn::Slider *mParticleDetailSlider;
- gcn::Label *mParticleDetailField;
-
gcn::CheckBox *mDisableSDLTransparencyCheckBox;
};
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index 485d5d5b..98db3cc1 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -31,7 +31,6 @@
#include "gui/widgets/button.h"
#include "gui/widgets/container.h"
#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
#include "gui/widgets/listbox.h"
#include "gui/widgets/progressbar.h"
#include "gui/widgets/scrollarea.h"
@@ -226,12 +225,8 @@ SkillDialog::SkillDialog():
setupWindow->registerWindowForReset(this);
mTabs = new TabbedArea();
- mPointsLabel = new Label("0");
- mIncreaseButton = new Button(_("Up"), "inc", this);
place(0, 0, mTabs, 5, 5);
- place(0, 5, mPointsLabel, 4);
- place(4, 5, mIncreaseButton);
center();
loadWindowState();
@@ -244,16 +239,8 @@ SkillDialog::~SkillDialog()
void SkillDialog::action(const gcn::ActionEvent &event)
{
- if (event.getId() == "inc")
- {
- SkillTab *tab = static_cast<SkillTab*>(mTabs->getSelectedTab());
- if (SkillInfo *info = tab->getSelectedInfo())
- Net::getPlayerHandler()->increaseSkill(info->id);
- }
- else if (event.getId() == "close")
- {
+ if (event.getId() == "close")
setVisible(false);
- }
}
std::string SkillDialog::update(int id)
@@ -272,10 +259,6 @@ std::string SkillDialog::update(int id)
void SkillDialog::update()
{
- mPointsLabel->setCaption(strprintf(_("Skill points available: %d"),
- PlayerInfo::getAttribute(SKILL_POINTS)));
- mPointsLabel->adjustSize();
-
for (SkillMap::iterator it = mSkills.begin(); it != mSkills.end(); it++)
{
(*it).second->update();
diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h
index 8487c1ae..3c09ec54 100644
--- a/src/gui/skilldialog.h
+++ b/src/gui/skilldialog.h
@@ -78,8 +78,6 @@ class SkillDialog : public Window, public gcn::ActionListener, public EventListe
typedef std::map<int, SkillInfo*> SkillMap;
SkillMap mSkills;
TabbedArea *mTabs;
- Label *mPointsLabel;
- Button *mIncreaseButton;
};
extern SkillDialog *skillDialog;
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index 4203a137..1b960d64 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -35,7 +35,6 @@
#include "gui/widgets/button.h"
#include "gui/widgets/container.h"
#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
#include "gui/widgets/linkhandler.h"
#include "gui/widgets/popup.h"
#include "gui/widgets/scrollarea.h"
diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp
index 7db5952a..53106da2 100644
--- a/src/gui/specialswindow.cpp
+++ b/src/gui/specialswindow.cpp
@@ -28,7 +28,6 @@
#include "gui/widgets/container.h"
#include "gui/widgets/icon.h"
#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
#include "gui/widgets/listbox.h"
#include "gui/widgets/progressbar.h"
#include "gui/widgets/scrollarea.h"
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index ebd54f33..430d47ed 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -29,7 +29,7 @@
#include "gui/widgets/button.h"
#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/layout.h"
#include "gui/widgets/progressbar.h"
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/vertcontainer.h"
@@ -65,7 +65,6 @@ class AttrDisplay : public Container
const int mId;
const std::string mName;
- LayoutHelper *mLayout;
Label *mLabel;
Label *mValue;
};
@@ -433,13 +432,10 @@ AttrDisplay::AttrDisplay(int id, const std::string &name):
mLabel->setAlignment(Graphics::CENTER);
mValue->setAlignment(Graphics::CENTER);
-
- mLayout = new LayoutHelper(this);
}
AttrDisplay::~AttrDisplay()
{
- delete mLayout;
}
std::string AttrDisplay::update()
@@ -458,9 +454,6 @@ DerDisplay::DerDisplay(int id, const std::string &name):
AttrDisplay(id, name)
{
// Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = mLayout->getPlacer(0, 0);
-
place(0, 0, mLabel, 3);
place(3, 0, mValue, 2);
@@ -474,8 +467,6 @@ ChangeDisplay::ChangeDisplay(int id, const std::string &name):
mInc = new Button(_("+"), "inc", this);
// Do the layout
- ContainerPlacer place = mLayout->getPlacer(0, 0);
-
place(0, 0, mLabel, 3);
place(4, 0, mValue, 2);
place(6, 0, mInc);
diff --git a/src/gui/textpopup.cpp b/src/gui/textpopup.cpp
index 57f80275..aca02a6d 100644
--- a/src/gui/textpopup.cpp
+++ b/src/gui/textpopup.cpp
@@ -43,10 +43,10 @@ TextPopup::TextPopup():
const int fontHeight = getFont()->getHeight();
mText1 = new Label;
- mText1->setPosition(getPadding(), getPadding());
+ mText1->setPosition(0, 0);
mText2 = new Label;
- mText2->setPosition(getPadding(), fontHeight + getPadding());
+ mText2->setPosition(0, fontHeight);
add(mText1);
add(mText2);
@@ -68,13 +68,10 @@ void TextPopup::show(int x, int y, const std::string &str1, const std::string &s
if (mText2->getWidth() > minWidth)
minWidth = mText2->getWidth();
- minWidth += 4 * getPadding();
- setWidth(minWidth);
-
if (!str2.empty())
- setHeight((getPadding() + mText1->getFont()->getHeight()) * 2);
+ setContentSize(minWidth, mText1->getFont()->getHeight() * 2);
else
- setHeight(2 * getPadding() + mText1->getFont()->getHeight());
+ setContentSize(minWidth, mText1->getFont()->getHeight());
const int distance = 20;
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 1b5b00c3..0aab399c 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -286,6 +286,10 @@ void Viewport::logic()
void Viewport::_followMouse()
{
Uint8 button = SDL_GetMouseState(&mMouseX, &mMouseY);
+
+ mMouseX /= graphics->getScale();
+ mMouseY /= graphics->getScale();
+
// If the left button is dragged
if (mPlayerFollowMouse && button & SDL_BUTTON(1))
{
@@ -313,6 +317,9 @@ void Viewport::_drawDebugPath(Graphics *graphics)
// Get the current mouse position
SDL_GetMouseState(&mMouseX, &mMouseY);
+ mMouseX /= graphics->getScale();
+ mMouseY /= graphics->getScale();
+
// Prepare the walkmask corresponding to the protocol
unsigned char walkMask;
switch (Net::getNetworkType())
diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp
index af4f0155..e1b99af7 100644
--- a/src/gui/widgets/container.cpp
+++ b/src/gui/widgets/container.cpp
@@ -21,7 +21,10 @@
#include "gui/widgets/container.h"
-Container::Container()
+#include "gui/widgets/layouthelper.h"
+
+Container::Container():
+ mLayoutHelper(0)
{
setOpaque(false);
}
@@ -30,4 +33,24 @@ Container::~Container()
{
while (!mWidgets.empty())
delete mWidgets.front();
+
+ delete mLayoutHelper;
+}
+
+Layout &Container::getLayout()
+{
+ if (!mLayoutHelper)
+ mLayoutHelper = new LayoutHelper(this);
+ return mLayoutHelper->getLayout();
+}
+
+LayoutCell &Container::place(int x, int y, gcn::Widget *wg, int w, int h)
+{
+ add(wg);
+ return getLayout().place(wg, x, y, w, h);
+}
+
+ContainerPlacer Container::getPlacer(int x, int y)
+{
+ return ContainerPlacer(this, &getLayout().at(x, y));
}
diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h
index e582f2a8..46b719a1 100644
--- a/src/gui/widgets/container.h
+++ b/src/gui/widgets/container.h
@@ -24,6 +24,11 @@
#include <guichan/widgets/container.hpp>
+class ContainerPlacer;
+class Layout;
+class LayoutCell;
+class LayoutHelper;
+
/**
* A widget container.
*
@@ -38,6 +43,25 @@ class Container : public gcn::Container
public:
Container();
~Container();
+
+ protected:
+ /**
+ * Gets the layout handler for this container.
+ */
+ Layout &getLayout();
+
+ /**
+ * Adds a widget to the container and sets it at given cell.
+ */
+ LayoutCell &place(int x, int y, gcn::Widget *wg, int w = 1, int h = 1);
+
+ /**
+ * Returns a proxy for adding widgets in an inner table of the layout.
+ */
+ ContainerPlacer getPlacer(int x, int y);
+
+ private:
+ LayoutHelper *mLayoutHelper;
};
#endif
diff --git a/src/gui/widgets/layouthelper.cpp b/src/gui/widgets/layouthelper.cpp
index 1a634fcd..e1006bd9 100644
--- a/src/gui/widgets/layouthelper.cpp
+++ b/src/gui/widgets/layouthelper.cpp
@@ -32,11 +32,6 @@ LayoutHelper::~LayoutHelper()
mContainer->removeWidgetListener(this);
}
-Layout &LayoutHelper::getLayout()
-{
- return mLayout;
-}
-
LayoutCell &LayoutHelper::place(int x, int y, gcn::Widget *wg, int w, int h)
{
mContainer->add(wg);
diff --git a/src/gui/widgets/layouthelper.h b/src/gui/widgets/layouthelper.h
index 055e6fa6..b8512212 100644
--- a/src/gui/widgets/layouthelper.h
+++ b/src/gui/widgets/layouthelper.h
@@ -34,14 +34,14 @@
class LayoutHelper : public gcn::WidgetListener
{
public:
- LayoutHelper(gcn::Container *container);
+ explicit LayoutHelper(gcn::Container *container);
~LayoutHelper();
/**
* Gets the layout handler.
*/
- Layout &getLayout();
+ Layout &getLayout() { return mLayout; }
/**
* Computes the position of the widgets according to the current
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index 1c7cfdd1..3b80fe5e 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -37,8 +37,8 @@
Popup::Popup(const std::string &name, const std::string &skin):
mPopupName(name),
- mMinWidth(100),
- mMinHeight(40),
+ mMinWidth(64),
+ mMinHeight(25),
mMaxWidth(graphics->getWidth()),
mMaxHeight(graphics->getHeight())
{
@@ -47,7 +47,7 @@ Popup::Popup(const std::string &name, const std::string &skin):
if (!windowContainer)
throw GCN_EXCEPTION("Popup::Popup(): no windowContainer set");
- setPadding(3);
+ setPadding(8);
// Loads the skin
mSkin = Theme::instance()->load(skin);
@@ -82,7 +82,9 @@ void Popup::draw(gcn::Graphics *graphics)
gcn::Rectangle Popup::getChildrenArea()
{
- return gcn::Rectangle(getPadding(), 0, getWidth() - getPadding() * 2,
+ return gcn::Rectangle(getPadding(),
+ getPadding(),
+ getWidth() - getPadding() * 2,
getHeight() - getPadding() * 2);
}
diff --git a/src/gui/widgets/resizegrip.cpp b/src/gui/widgets/resizegrip.cpp
index da97ac69..7b37b282 100644
--- a/src/gui/widgets/resizegrip.cpp
+++ b/src/gui/widgets/resizegrip.cpp
@@ -58,11 +58,11 @@ ResizeGrip::~ResizeGrip()
void ResizeGrip::draw(gcn::Graphics *graphics)
{
- if (config.getFloatValue("guialpha") != mAlpha)
- {
- mAlpha = config.getFloatValue("guialpha");
- gripImage->setAlpha(mAlpha);
- }
+ //if (config.getFloatValue("guialpha") != mAlpha)
+ //{
+ // mAlpha = config.getFloatValue("guialpha");
+ // gripImage->setAlpha(mAlpha);
+ //}
- static_cast<Graphics*>(graphics)->drawImage(gripImage, 0, 0);
+ //static_cast<Graphics*>(graphics)->drawImage(gripImage, 0, 0);
}
diff --git a/src/gui/widgets/setuptab.cpp b/src/gui/widgets/setuptab.cpp
index a1a493ad..dc183a50 100644
--- a/src/gui/widgets/setuptab.cpp
+++ b/src/gui/widgets/setuptab.cpp
@@ -23,5 +23,4 @@
SetupTab::SetupTab()
{
- setOpaque(false);
}
diff --git a/src/gui/widgets/vertcontainer.h b/src/gui/widgets/vertcontainer.h
index 10bc68c3..c2403afb 100644
--- a/src/gui/widgets/vertcontainer.h
+++ b/src/gui/widgets/vertcontainer.h
@@ -28,7 +28,7 @@
/**
* A widget container.
*
- * This container places it's contents veritcally.
+ * This container places its contents vertically.
*/
class VertContainer : public Container, public gcn::WidgetListener
{
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index c8788c75..406f55ef 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -68,8 +68,8 @@ Window::Window(const std::string &caption, bool modal, Window *parent,
instances++;
setFrameSize(0);
- setPadding(3);
- setTitleBarHeight(20);
+ setPadding(5);
+ setTitleBarHeight(25);
// Loads the skin
mSkin = Theme::instance()->load(skin);
@@ -123,7 +123,7 @@ void Window::draw(gcn::Graphics *graphics)
{
g->setColor(Theme::getThemeColor(Theme::TEXT));
g->setFont(getFont());
- g->drawText(getCaption(), 7, 5, gcn::Graphics::LEFT);
+ g->drawText(getCaption(), 7, 10, gcn::Graphics::LEFT);
}
// Draw Close Button
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index 12624bf1..f503c84c 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -62,8 +62,7 @@ WindowMenu::WindowMenu():
addButton(N_("Skills"), x, h, "button-icon-skills.png",
KeyboardConfig::KEY_WINDOW_SKILL);
- if (specialsWindow->hasSpecials())
- addButton(N_("Specials"), x, h, "button-icon-specials.png");
+ addButton(N_("Specials"), x, h, "button-icon-specials.png");
addButton(N_("Social"), x, h, "button-icon-social.png",
KeyboardConfig::KEY_WINDOW_SOCIAL);
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index 30f27e9f..cad41bd6 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -78,7 +78,6 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = {
{"keyWindowSetup", SDLK_F9, _("Setup Window")},
{"keyWindowDebug", SDLK_F10, _("Debug Window")},
{"keyWindowSocial", SDLK_F11, _("Social Window")},
- {"keyWindowEmoteBar", SDLK_F12, _("Emote Shortcut Window")},
{"keyWindowOutfit", SDLK_o, _("Outfits Window")},
{"keyWearOutfit", SDLK_RCTRL, _("Wear Outfit")},
{"keyCopyOutfit", SDLK_RALT, _("Copy Outfit")},
diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h
index 34aad4c4..6f40e03d 100644
--- a/src/keyboardconfig.h
+++ b/src/keyboardconfig.h
@@ -193,7 +193,6 @@ class KeyboardConfig
KEY_WINDOW_SETUP,
KEY_WINDOW_DEBUG,
KEY_WINDOW_SOCIAL,
- KEY_WINDOW_EMOTE_SHORTCUT,
KEY_WINDOW_OUTFIT,
KEY_WEAR_OUTFIT,
KEY_COPY_OUTFIT,
diff --git a/src/map.cpp b/src/map.cpp
index fa3d9a4c..b9bcb284 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -116,11 +116,6 @@ void MapLayer::setTile(int x, int y, Image *img)
setTile(x + y * mWidth, img);
}
-Image* MapLayer::getTile(int x, int y) const
-{
- return mTiles[x + y * mWidth];
-}
-
void MapLayer::draw(Graphics *graphics,
int startX, int startY,
int endX, int endY,
@@ -206,12 +201,17 @@ int MapLayer::getTileDrawWidth(int x1, int y1, int endX, int &width) const
Image *img1 = getTile(x1, y1);
int c = 0;
width = img1->getWidth();
+
+ // Images that don't match the tile width can't be drawn as a pattern
+ if (width != mMap->getTileWidth())
+ return c;
+
for (int x = x1 + 1; x < endX; x++)
{
Image *img = getTile(x, y1);
if (img != img1)
break;
- c ++;
+ c++;
width += img->getWidth();
}
return c;
diff --git a/src/map.h b/src/map.h
index b7917275..086ff4cc 100644
--- a/src/map.h
+++ b/src/map.h
@@ -108,7 +108,8 @@ class MapLayer
/**
* Get tile image, with x and y in layer coordinates.
*/
- Image *getTile(int x, int y) const;
+ Image *getTile(int x, int y) const
+ { return mTiles[x + y * mWidth]; }
/**
* Draws this layer to the given graphics context. The coordinates are
@@ -125,7 +126,7 @@ class MapLayer
const Actors &actors,
int debugFlags) const;
- bool isFringeLayer()
+ bool isFringeLayer() const
{ return mIsFringeLayer; }
int getTileDrawWidth(int x1, int y1, int endX, int &width) const;
diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp
index e809bfac..32b3feb5 100644
--- a/src/net/manaserv/charhandler.cpp
+++ b/src/net/manaserv/charhandler.cpp
@@ -290,11 +290,6 @@ void CharHandler::setCharCreateDialog(CharCreateDialog *window)
if (!mCharCreateDialog)
return;
-
- mCharCreateDialog->setAttributes(Attributes::getLabels(),
- Attributes::getCreationPoints(),
- Attributes::getAttributeMinimum(),
- Attributes::getAttributeMaximum());
}
void CharHandler::requestCharacters()
diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp
index 74a309e1..28fd47f6 100644
--- a/src/openglgraphics.cpp
+++ b/src/openglgraphics.cpp
@@ -33,6 +33,8 @@
#include <SDL.h>
+#include <cmath>
+
#ifndef GL_TEXTURE_RECTANGLE_ARB
#define GL_TEXTURE_RECTANGLE_ARB 0x84F5
#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8
@@ -44,7 +46,8 @@ GLuint OpenGLGraphics::mLastImage = 0;
OpenGLGraphics::OpenGLGraphics():
mAlpha(false), mTexture(false), mColorAlpha(false),
- mSync(false)
+ mSync(false),
+ mReduceInputLag(true)
{
mFloatTexArray = new GLfloat[vertexBufSize * 4];
mIntTexArray = new GLint[vertexBufSize * 4];
@@ -63,6 +66,11 @@ void OpenGLGraphics::setSync(bool sync)
mSync = sync;
}
+void OpenGLGraphics::setReduceInputLag(bool reduceInputLag)
+{
+ mReduceInputLag = reduceInputLag;
+}
+
bool OpenGLGraphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
{
logger->log("Setting video mode %dx%d %s",
@@ -70,8 +78,19 @@ bool OpenGLGraphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
int displayFlags = SDL_ANYFORMAT | SDL_OPENGL;
- mWidth = w;
- mHeight = h;
+ const double targetRatio = (double) 640 / 360; // 1.77778
+ const double requestedRatio = (double) w / h;
+
+ if (requestedRatio < targetRatio) {
+ // Screen is higher / narrower than target aspect ratio: calculate
+ // scale based on height.
+ mScale = (int) std::floor((double) h / 360);
+ } else {
+ mScale = (int) std::floor((double) w / 640);
+ }
+
+ mWidth = w / mScale;
+ mHeight = h / mScale;
mBpp = bpp;
mFullscreen = fs;
mHWAccel = hwaccel;
@@ -103,7 +122,7 @@ bool OpenGLGraphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
#endif
// Setup OpenGL
- glViewport(0, 0, w, h);
+ glViewport(0, 0, mWidth * mScale, mHeight * mScale);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
int gotDoubleBuffer;
SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &gotDoubleBuffer);
@@ -113,14 +132,17 @@ bool OpenGLGraphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
char const *glExtensions = (char const *)glGetString(GL_EXTENSIONS);
GLint texSize;
bool rectTex = strstr(glExtensions, "GL_ARB_texture_rectangle");
- if (rectTex)
+ bool npotTex = strstr(glExtensions, "GL_ARB_texture_non_power_of_two");
+ if (rectTex && !npotTex)
{
Image::mTextureType = GL_TEXTURE_RECTANGLE_ARB;
+ Image::mPowerOfTwoTextures = false;
glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB, &texSize);
}
else
{
Image::mTextureType = GL_TEXTURE_2D;
+ Image::mPowerOfTwoTextures = !npotTex;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texSize);
}
Image::mTextureSize = texSize;
@@ -162,8 +184,8 @@ static inline void drawQuad(Image *image,
dstX, dstY + height
};
- glVertexPointer(2, GL_FLOAT, 0, &vert);
- glTexCoordPointer(2, GL_INT, 0, &tex);
+ glVertexPointer(2, GL_INT, 0, &vert);
+ glTexCoordPointer(2, GL_FLOAT, 0, &tex);
glDrawArrays(GL_QUADS, 0, 4);
}
@@ -224,8 +246,8 @@ static inline void drawRescaledQuad(Image *image,
dstX, dstY + desiredHeight
};
- glVertexPointer(2, GL_FLOAT, 0, &vert);
- glTexCoordPointer(2, GL_INT, 0, &tex);
+ glVertexPointer(2, GL_INT, 0, &vert);
+ glTexCoordPointer(2, GL_FLOAT, 0, &tex);
glDrawArrays(GL_QUADS, 0, 4);
}
@@ -290,19 +312,6 @@ bool OpenGLGraphics::drawRescaledImage(Image *image, int srcX, int srcY,
int desiredWidth, int desiredHeight,
bool useColor)
{
- return drawRescaledImage(image, srcX, srcY,
- dstX, dstY,
- width, height,
- desiredWidth, desiredHeight,
- useColor, true);
-}
-
-bool OpenGLGraphics::drawRescaledImage(Image *image, int srcX, int srcY,
- int dstX, int dstY,
- int width, int height,
- int desiredWidth, int desiredHeight,
- bool useColor, bool smooth)
-{
if (!image)
return false;
@@ -313,11 +322,6 @@ bool OpenGLGraphics::drawRescaledImage(Image *image, int srcX, int srcY,
width, height, useColor);
}
- // When the desired image is smaller than the current one,
- // disable smooth effect.
- if (width > desiredWidth && height > desiredHeight)
- smooth = false;
-
srcX += image->mBounds.x;
srcY += image->mBounds.y;
@@ -332,20 +336,6 @@ bool OpenGLGraphics::drawRescaledImage(Image *image, int srcX, int srcY,
drawRescaledQuad(image, srcX, srcY, dstX, dstY, width, height,
desiredWidth, desiredHeight);
- if (smooth) // A basic smooth effect...
- {
- glColor4f(1.0f, 1.0f, 1.0f, 0.2f);
- drawRescaledQuad(image, srcX, srcY, dstX - 1, dstY - 1, width, height,
- desiredWidth + 1, desiredHeight + 1);
- drawRescaledQuad(image, srcX, srcY, dstX + 1, dstY + 1, width, height,
- desiredWidth - 1, desiredHeight - 1);
-
- drawRescaledQuad(image, srcX, srcY, dstX + 1, dstY, width, height,
- desiredWidth - 1, desiredHeight);
- drawRescaledQuad(image, srcX, srcY, dstX, dstY + 1, width, height,
- desiredWidth, desiredHeight - 1);
- }
-
if (!useColor)
{
glColor4ub(static_cast<GLubyte>(mColor.r),
@@ -633,9 +623,20 @@ void OpenGLGraphics::drawRescaledImagePattern(Image *image,
void OpenGLGraphics::updateScreen()
{
- glFlush();
- glFinish();
SDL_GL_SwapBuffers();
+
+ /*
+ * glFinish flushes all OpenGL commands and makes sure they have been
+ * executed before continuing. If we do not do this we allow the next
+ * frame to be prepared while the current one isn't even displaying yet,
+ * which can cause input lag that is especially noticable at mouse
+ * movement.
+ *
+ * The setting is optional since calling glFinish can reduce performance
+ * and increase CPU usage.
+ */
+ if (mReduceInputLag)
+ glFinish();
}
void OpenGLGraphics::_beginDraw()
@@ -646,20 +647,19 @@ void OpenGLGraphics::_beginDraw()
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glOrtho(0.0, (double)mTarget->w, (double)mTarget->h, 0.0, -1.0, 1.0);
+ glOrtho(0.0, (double) mWidth, (double) mHeight, 0.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_SCISSOR_TEST);
- glEnableClientState(GL_VERTEX_ARRAY);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- pushClipArea(gcn::Rectangle(0, 0, mTarget->w, mTarget->h));
+ pushClipArea(gcn::Rectangle(0, 0, mWidth, mHeight));
}
void OpenGLGraphics::_endDraw()
@@ -726,12 +726,15 @@ bool OpenGLGraphics::pushClipArea(gcn::Rectangle area)
transX += mClipStack.top().xOffset;
transY += mClipStack.top().yOffset;
+ int x = (int) (mClipStack.top().x * mScale);
+ int y = mTarget->h - (int) ((mClipStack.top().y +
+ mClipStack.top().height) * mScale);
+ int width = (int) (mClipStack.top().width * mScale);
+ int height = (int) (mClipStack.top().height * mScale);
+
glPushMatrix();
glTranslatef(transX, transY, 0);
- glScissor(mClipStack.top().x,
- mTarget->h - mClipStack.top().y - mClipStack.top().height,
- mClipStack.top().width,
- mClipStack.top().height);
+ glScissor(x, y, width, height);
return result;
}
@@ -743,11 +746,14 @@ void OpenGLGraphics::popClipArea()
if (mClipStack.empty())
return;
+ int x = (int) (mClipStack.top().x * mScale);
+ int y = mTarget->h - (int) ((mClipStack.top().y +
+ mClipStack.top().height) * mScale);
+ int width = (int) (mClipStack.top().width * mScale);
+ int height = (int) (mClipStack.top().height * mScale);
+
glPopMatrix();
- glScissor(mClipStack.top().x,
- mTarget->h - mClipStack.top().y - mClipStack.top().height,
- mClipStack.top().width,
- mClipStack.top().height);
+ glScissor(x, y, width, height);
}
void OpenGLGraphics::setColor(const gcn::Color& color)
@@ -791,10 +797,6 @@ void OpenGLGraphics::fillRectangle(const gcn::Rectangle& rect)
drawRectangle(rect, true);
}
-void OpenGLGraphics::setTargetPlane(int width, int height)
-{
-}
-
void OpenGLGraphics::setTexturingAndBlending(bool enable)
{
if (enable)
diff --git a/src/openglgraphics.h b/src/openglgraphics.h
index d61bf3db..63c32261 100644
--- a/src/openglgraphics.h
+++ b/src/openglgraphics.h
@@ -43,6 +43,16 @@ class OpenGLGraphics : public Graphics
void setSync(bool sync);
bool getSync() const { return mSync; }
+ /**
+ * Sets whether input lag should be reduced.
+ *
+ * This means waiting until the graphics card has finished drawing and
+ * displaying the current frame until continuing towards the next,
+ * possibly at the cost of performance and CPU usage.
+ */
+ void setReduceInputLag(bool reduceInputLag);
+ bool getReduceInputLag() const { return mReduceInputLag; }
+
bool setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel);
bool drawImage(Image *image,
@@ -52,7 +62,7 @@ class OpenGLGraphics : public Graphics
bool useColor);
/**
- * Draws a resclaled version of the image
+ * Draws a rescaled version of the image
*/
bool drawRescaledImage(Image *image, int srcX, int srcY,
int dstX, int dstY,
@@ -60,15 +70,6 @@ class OpenGLGraphics : public Graphics
int desiredWidth, int desiredHeight,
bool useColor);
- /**
- * Used to get the smooth rescale option over the standard function.
- */
- bool drawRescaledImage(Image *image, int srcX, int srcY,
- int dstX, int dstY,
- int width, int height,
- int desiredWidth, int desiredHeight,
- bool useColor, bool smooth);
-
void drawImagePattern(Image *image,
int x, int y,
int w, int h);
@@ -100,8 +101,6 @@ class OpenGLGraphics : public Graphics
void fillRectangle(const gcn::Rectangle &rect);
- void setTargetPlane(int width, int height);
-
/**
* Takes a screenshot and returns it as SDL surface.
*/
@@ -125,6 +124,7 @@ class OpenGLGraphics : public Graphics
bool mAlpha, mTexture;
bool mColorAlpha;
bool mSync;
+ bool mReduceInputLag;
};
#endif //USE_OPENGL
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 975bd647..7e592198 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -36,6 +36,7 @@
#ifdef USE_OPENGL
bool Image::mUseOpenGL = false;
+bool Image::mPowerOfTwoTextures = true;
int Image::mTextureType = 0;
int Image::mTextureSize = 0;
#endif
@@ -437,103 +438,113 @@ Image *Image::_SDLload(SDL_Surface *tmpImage)
}
#ifdef USE_OPENGL
-Image *Image::_GLload(SDL_Surface *tmpImage)
+Image *Image::_GLload(SDL_Surface *image)
{
- // Flush current error flag.
- glGetError();
+ // Flush current error flag.
+ glGetError();
- int width = tmpImage->w;
- int height = tmpImage->h;
- int realWidth = powerOfTwo(width);
- int realHeight = powerOfTwo(height);
+ int width = image->w;
+ int height = image->h;
+ int realWidth = powerOfTwo(width);
+ int realHeight = powerOfTwo(height);
- if (realWidth < width || realHeight < height)
- {
- logger->log("Warning: image too large, cropping to %dx%d texture!",
- tmpImage->w, tmpImage->h);
- }
-
- // Make sure the alpha channel is not used, but copied to destination
- SDL_SetAlpha(tmpImage, 0, SDL_ALPHA_OPAQUE);
+ if (realWidth < width || realHeight < height)
+ {
+ logger->log("Warning: image too large, cropping to %dx%d texture!",
+ realWidth, realHeight);
+ }
- // Determine 32-bit masks based on byte order
- Uint32 rmask, gmask, bmask, amask;
+ // Determine 32-bit masks based on byte order
+ Uint32 rmask, gmask, bmask, amask;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- rmask = 0xff000000;
- gmask = 0x00ff0000;
- bmask = 0x0000ff00;
- amask = 0x000000ff;
+ rmask = 0xff000000;
+ gmask = 0x00ff0000;
+ bmask = 0x0000ff00;
+ amask = 0x000000ff;
#else
- rmask = 0x000000ff;
- gmask = 0x0000ff00;
- bmask = 0x00ff0000;
- amask = 0xff000000;
+ rmask = 0x000000ff;
+ gmask = 0x0000ff00;
+ bmask = 0x00ff0000;
+ amask = 0xff000000;
#endif
- SDL_Surface *oldImage = tmpImage;
- tmpImage = SDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight,
- 32, rmask, gmask, bmask, amask);
+ bool needsConversion = !(realWidth == width &&
+ realHeight == height &&
+ image->format->BytesPerPixel == 4 &&
+ image->format->Rmask == rmask &&
+ image->format->Gmask == gmask &&
+ image->format->Bmask == bmask &&
+ image->format->Amask == amask);
+
+ if (needsConversion)
+ {
+ SDL_Surface *oldImage = image;
+ image = SDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight,
+ 32, rmask, gmask, bmask, amask);
- if (!tmpImage)
+ if (!image)
{
logger->log("Error, image convert failed: out of memory");
return NULL;
}
- SDL_BlitSurface(oldImage, NULL, tmpImage, NULL);
+ // Make sure the alpha channel is not used, but copied to destination
+ SDL_SetAlpha(oldImage, 0, SDL_ALPHA_OPAQUE);
+ SDL_BlitSurface(oldImage, NULL, image, NULL);
+ }
- GLuint texture;
- glGenTextures(1, &texture);
- OpenGLGraphics::bindTexture(mTextureType, texture);
+ GLuint texture;
+ glGenTextures(1, &texture);
+ OpenGLGraphics::bindTexture(mTextureType, texture);
- if (SDL_MUSTLOCK(tmpImage))
- SDL_LockSurface(tmpImage);
+ if (SDL_MUSTLOCK(image))
+ SDL_LockSurface(image);
- glTexImage2D(
- mTextureType, 0, 4,
- tmpImage->w, tmpImage->h,
- 0, GL_RGBA, GL_UNSIGNED_BYTE,
- tmpImage->pixels);
+ glTexImage2D(mTextureType, 0, GL_RGBA8,
+ image->w, image->h,
+ 0, GL_RGBA, GL_UNSIGNED_BYTE,
+ image->pixels);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- glTexParameteri(mTextureType, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(mTextureType, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ glTexParameteri(mTextureType, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(mTextureType, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- if (SDL_MUSTLOCK(tmpImage))
- SDL_UnlockSurface(tmpImage);
+ if (SDL_MUSTLOCK(image))
+ SDL_UnlockSurface(image);
- SDL_FreeSurface(tmpImage);
+ if (needsConversion)
+ SDL_FreeSurface(image);
- GLenum error = glGetError();
- if (error)
+ GLenum error = glGetError();
+ if (error)
+ {
+ std::string errmsg = "Unknown error";
+ switch (error)
{
- std::string errmsg = "Unknown error";
- switch (error)
- {
- case GL_INVALID_ENUM:
- errmsg = "GL_INVALID_ENUM";
- break;
- case GL_INVALID_VALUE:
- errmsg = "GL_INVALID_VALUE";
- break;
- case GL_INVALID_OPERATION:
- errmsg = "GL_INVALID_OPERATION";
- break;
- case GL_STACK_OVERFLOW:
- errmsg = "GL_STACK_OVERFLOW";
- break;
- case GL_STACK_UNDERFLOW:
- errmsg = "GL_STACK_UNDERFLOW";
- break;
- case GL_OUT_OF_MEMORY:
- errmsg = "GL_OUT_OF_MEMORY";
- break;
- }
- logger->log("Error: Image GL import failed: %s", errmsg.c_str());
- return NULL;
+ case GL_INVALID_ENUM:
+ errmsg = "GL_INVALID_ENUM";
+ break;
+ case GL_INVALID_VALUE:
+ errmsg = "GL_INVALID_VALUE";
+ break;
+ case GL_INVALID_OPERATION:
+ errmsg = "GL_INVALID_OPERATION";
+ break;
+ case GL_STACK_OVERFLOW:
+ errmsg = "GL_STACK_OVERFLOW";
+ break;
+ case GL_STACK_UNDERFLOW:
+ errmsg = "GL_STACK_UNDERFLOW";
+ break;
+ case GL_OUT_OF_MEMORY:
+ errmsg = "GL_OUT_OF_MEMORY";
+ break;
}
+ logger->log("Error: Image GL import failed: %s", errmsg.c_str());
+ return NULL;
+ }
- return new Image(texture, width, height, realWidth, realHeight);
+ return new Image(texture, width, height, realWidth, realHeight);
}
void Image::setLoadAsOpenGL(bool useOpenGL)
@@ -544,7 +555,7 @@ void Image::setLoadAsOpenGL(bool useOpenGL)
int Image::powerOfTwo(int input)
{
int value;
- if (mTextureType == GL_TEXTURE_2D)
+ if (mPowerOfTwoTextures)
{
value = 1;
while (value < input && value < mTextureSize)
@@ -565,11 +576,17 @@ Image *Image::getSubImage(int x, int y, int width, int height)
// Create a new clipped sub-image
#ifdef USE_OPENGL
if (mUseOpenGL)
- return new SubImage(this, mGLImage, x, y, width, height,
+ return new SubImage(this, mGLImage,
+ mBounds.x + x,
+ mBounds.y + y,
+ width, height,
mTexWidth, mTexHeight);
#endif
- return new SubImage(this, mSDLSurface, x, y, width, height);
+ return new SubImage(this, mSDLSurface,
+ mBounds.x + x,
+ mBounds.y + y,
+ width, height);
}
void Image::SDLterminateAlphaCache()
@@ -636,8 +653,3 @@ SubImage::~SubImage()
#endif
mParent->decRef();
}
-
-Image *SubImage::getSubImage(int x, int y, int w, int h)
-{
- return mParent->getSubImage(mBounds.x + x, mBounds.y + y, w, h);
-}
diff --git a/src/resources/image.h b/src/resources/image.h
index 7df74c3f..b762bf2a 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -84,7 +84,7 @@ class Image : public Resource
/**
* Frees the resources created by SDL.
*/
- virtual void unload();
+ void unload();
/**
* Tells is the image is loaded
@@ -95,13 +95,13 @@ class Image : public Resource
/**
* Returns the width of the image.
*/
- virtual int getWidth() const
+ int getWidth() const
{ return mBounds.w; }
/**
* Returns the height of the image.
*/
- virtual int getHeight() const
+ int getHeight() const
{ return mBounds.h; }
/**
@@ -113,7 +113,7 @@ class Image : public Resource
/**
* Sets the alpha value of this image.
*/
- virtual void setAlpha(float alpha);
+ void setAlpha(float alpha);
/**
* Returns the alpha value of this image.
@@ -127,7 +127,7 @@ class Image : public Resource
* @return <code>NULL</code> if creation failed and a valid
* object otherwise.
*/
- virtual Image *getSubImage(int x, int y, int width, int height);
+ Image *getSubImage(int x, int y, int width, int height);
/**
* Tells if the image has got an alpha channel
@@ -243,12 +243,13 @@ class Image : public Resource
*/
static int powerOfTwo(int input);
- static Image *_GLload(SDL_Surface *tmpImage);
+ static Image *_GLload(SDL_Surface *image);
GLuint mGLImage;
int mTexWidth, mTexHeight;
static bool mUseOpenGL;
+ static bool mPowerOfTwoTextures;
static int mTextureType;
static int mTextureSize;
#endif
@@ -269,14 +270,6 @@ class SubImage : public Image
~SubImage();
- /**
- * Creates a new image with the desired clipping rectangle.
- *
- * @return <code>NULL</code> if creation failed and a valid
- * image otherwise.
- */
- Image *getSubImage(int x, int y, int width, int height);
-
private:
Image *mParent;
};
diff --git a/src/resources/imageloader.cpp b/src/resources/imageloader.cpp
deleted file mode 100644
index 262ec98c..00000000
--- a/src/resources/imageloader.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * The Mana Client
- * Copyright (C) 2007-2009 The Mana World Development Team
- * Copyright (C) 2009-2012 The Mana Developers
- *
- * This file is part of The Mana Client.
- *
- * 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
- * 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/>.
- */
-
-#include "resources/imageloader.h"
-
-#include "resources/image.h"
-#include "resources/resourcemanager.h"
-
-#include <guichan/color.hpp>
-
-#include <guichan/sdl/sdlpixel.hpp>
-
-#include <cassert>
-
-ProxyImage::ProxyImage(SDL_Surface *s):
- mImage(NULL), mSDLImage(s)
-{
-}
-
-ProxyImage::~ProxyImage()
-{
- free();
-}
-
-void ProxyImage::free()
-{
- if (mSDLImage)
- {
- SDL_FreeSurface(mSDLImage);
- mSDLImage = NULL;
- }
- else if (mImage)
- {
- delete mImage;
- mImage = NULL;
- }
-}
-
-int ProxyImage::getWidth() const
-{
- return mSDLImage ? mSDLImage->w : mImage->getWidth();
-}
-
-int ProxyImage::getHeight() const
-{
- return mSDLImage ? mSDLImage->h : mImage->getHeight();
-}
-
-gcn::Color ProxyImage::getPixel(int x, int y)
-{
- assert(mSDLImage);
- return gcn::SDLgetPixel(mSDLImage, x, y);
-}
-
-void ProxyImage::putPixel(int x, int y, gcn::Color const &color)
-{
- assert(mSDLImage);
- gcn::SDLputPixel(mSDLImage, x, y, color);
-}
-
-void ProxyImage::convertToDisplayFormat()
-{
- assert(mSDLImage);
- /* The picture is most probably full of the pink pixels Guichan uses for
- transparency, as this function will only be called when setting an image
- font. Get rid of them. */
- SDL_SetColorKey(mSDLImage, SDL_SRCCOLORKEY,
- SDL_MapRGB(mSDLImage->format, 255, 0, 255));
- mImage = ::Image::load(mSDLImage);
- SDL_FreeSurface(mSDLImage);
- mSDLImage = NULL;
-}
-
-gcn::Image *ImageLoader::load(const std::string &filename, bool convert)
-{
- ResourceManager *resman = ResourceManager::getInstance();
- ProxyImage *i = new ProxyImage(resman->loadSDLSurface(filename));
- if (convert) i->convertToDisplayFormat();
- return i;
-}
diff --git a/src/resources/imageloader.h b/src/resources/imageloader.h
deleted file mode 100644
index 10592142..00000000
--- a/src/resources/imageloader.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * The Mana Client
- * Copyright (C) 2007-2009 The Mana World Development Team
- * Copyright (C) 2009-2012 The Mana Developers
- *
- * This file is part of The Mana Client.
- *
- * 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
- * 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/>.
- */
-
-#ifndef IMAGELOADER_H
-#define IMAGELOADER_H
-
-#include <guichan/image.hpp>
-#include <guichan/imageloader.hpp>
-
-#include <string>
-
-class Image;
-struct SDL_Surface;
-
-class ProxyImage : public gcn::Image
-{
- public:
- ProxyImage(SDL_Surface *);
- ~ProxyImage();
-
- void free();
- int getWidth() const;
- int getHeight() const;
- gcn::Color getPixel(int x, int y);
- void putPixel(int x, int y, gcn::Color const &color);
- void convertToDisplayFormat();
-
- /**
- * Gets the image handled by this proxy.
- */
- ::Image *getImage() const
- { return mImage; }
-
- private:
- ::Image *mImage; /**< The real image. */
-
- /**
- * An SDL surface kept around until Guichan is done reading pixels from
- * an OpenGL texture.
- */
- SDL_Surface *mSDLImage;
-};
-
-class ImageLoader : public gcn::ImageLoader
-{
- public:
- gcn::Image *load(const std::string &filename,
- bool convertToDisplayFormat);
-};
-
-#endif
diff --git a/src/resources/theme.cpp b/src/resources/theme.cpp
index e95a1fa9..4b46b003 100644
--- a/src/resources/theme.cpp
+++ b/src/resources/theme.cpp
@@ -396,6 +396,7 @@ static int readColorType(const std::string &type)
{
static std::string colors[] = {
"TEXT",
+ "NPC_DIALOG_TEXT",
"SHADOW",
"OUTLINE",
"PROGRESS_BAR",
diff --git a/src/resources/theme.h b/src/resources/theme.h
index b2dd10de..9c1ec293 100644
--- a/src/resources/theme.h
+++ b/src/resources/theme.h
@@ -121,6 +121,7 @@ class Theme : public Palette, public EventListener
enum ThemePalette {
TEXT,
+ NPC_DIALOG_TEXT,
SHADOW,
OUTLINE,
PROGRESS_BAR,