summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-03-01 19:13:11 +0300
committerAndrei Karas <akaras@inbox.ru>2014-03-01 19:13:11 +0300
commita260aeab234704ace8ba672b1d1ce57e18425e07 (patch)
treee215c6eeeae7e6c2ca4f4453718cef6ca9a8af6a /src
parent382067b05c4fe97bcf0da0143405375ec295f7c6 (diff)
parent2c62286a7ecf246e8a445dd7d00f618efae2a96a (diff)
downloadmv-a260aeab234704ace8ba672b1d1ce57e18425e07.tar.gz
mv-a260aeab234704ace8ba672b1d1ce57e18425e07.tar.bz2
mv-a260aeab234704ace8ba672b1d1ce57e18425e07.tar.xz
mv-a260aeab234704ace8ba672b1d1ce57e18425e07.zip
Merge branch 'master' into stable
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt207
-rw-r--r--src/Makefile.am236
-rw-r--r--src/actionmanager.cpp9
-rw-r--r--src/actormanager.cpp25
-rw-r--r--src/actormanager.h8
-rw-r--r--src/animatedsprite.cpp2
-rw-r--r--src/being/actorsprite.cpp6
-rw-r--r--src/being/actorsprite.h9
-rw-r--r--src/being/being.cpp288
-rw-r--r--src/being/being.h21
-rw-r--r--src/being/compoundsprite.cpp4
-rw-r--r--src/being/localplayer.cpp839
-rw-r--r--src/being/localplayer.h10
-rw-r--r--src/being/playerinfo.cpp19
-rw-r--r--src/being/playerrelations.cpp2
-rw-r--r--src/being/playerrelations.h19
-rw-r--r--src/client.cpp41
-rw-r--r--src/client.h13
-rw-r--r--src/commandhandler.cpp2
-rw-r--r--src/commandhandler.h5
-rw-r--r--src/commands.cpp23
-rw-r--r--src/configuration.cpp4
-rw-r--r--src/defaults.cpp1
-rw-r--r--src/defaults.h4
-rw-r--r--src/depricatedevent.cpp3
-rw-r--r--src/events/actionevent.h (renamed from src/guichan/include/guichan/actionevent.hpp)107
-rw-r--r--src/events/event.h (renamed from src/guichan/include/guichan/event.hpp)67
-rw-r--r--src/events/inputevent.h (renamed from src/input/inputevent.h)11
-rw-r--r--src/events/inputguievent.h187
-rw-r--r--src/events/keyevent.h (renamed from src/guichan/include/guichan/keyevent.hpp)152
-rw-r--r--src/events/mouseevent.h (renamed from src/guichan/include/guichan/mouseevent.hpp)198
-rw-r--r--src/events/selectionevent.h (renamed from src/guichan/include/guichan/selectionevent.hpp)50
-rw-r--r--src/eventsmanager.h2
-rw-r--r--src/flooritem.cpp19
-rw-r--r--src/game.cpp23
-rw-r--r--src/graphicsvertexes.h4
-rw-r--r--src/gui/base/basiccontainer.cpp (renamed from src/guichan/basiccontainer.cpp)28
-rw-r--r--src/gui/base/basiccontainer.hpp (renamed from src/guichan/include/guichan/basiccontainer.hpp)14
-rw-r--r--src/gui/base/gui.cpp (renamed from src/guichan/gui.cpp)32
-rw-r--r--src/gui/base/gui.hpp (renamed from src/guichan/include/guichan/gui.hpp)25
-rw-r--r--src/gui/base/widgets/button.cpp (renamed from src/guichan/widgets/button.cpp)32
-rw-r--r--src/gui/base/widgets/button.hpp (renamed from src/guichan/include/guichan/widgets/button.hpp)18
-rw-r--r--src/gui/base/widgets/checkbox.cpp (renamed from src/guichan/widgets/checkbox.cpp)25
-rw-r--r--src/gui/base/widgets/checkbox.hpp (renamed from src/guichan/include/guichan/widgets/checkbox.hpp)13
-rw-r--r--src/gui/base/widgets/container.cpp (renamed from src/guichan/widgets/container.cpp)12
-rw-r--r--src/gui/base/widgets/container.hpp (renamed from src/guichan/include/guichan/widgets/container.hpp)7
-rw-r--r--src/gui/base/widgets/label.cpp (renamed from src/guichan/widgets/label.cpp)17
-rw-r--r--src/gui/base/widgets/label.hpp (renamed from src/guichan/include/guichan/widgets/label.hpp)10
-rw-r--r--src/gui/base/widgets/listbox.cpp (renamed from src/guichan/widgets/listbox.cpp)33
-rw-r--r--src/gui/base/widgets/listbox.hpp (renamed from src/guichan/include/guichan/widgets/listbox.hpp)18
-rw-r--r--src/gui/base/widgets/radiobutton.cpp (renamed from src/guichan/widgets/radiobutton.cpp)24
-rw-r--r--src/gui/base/widgets/radiobutton.hpp (renamed from src/guichan/include/guichan/widgets/radiobutton.hpp)12
-rw-r--r--src/gui/base/widgets/scrollarea.cpp (renamed from src/guichan/widgets/scrollarea.cpp)43
-rw-r--r--src/gui/base/widgets/scrollarea.hpp (renamed from src/guichan/include/guichan/widgets/scrollarea.hpp)20
-rw-r--r--src/gui/base/widgets/slider.cpp (renamed from src/guichan/widgets/slider.cpp)25
-rw-r--r--src/gui/base/widgets/slider.hpp (renamed from src/guichan/include/guichan/widgets/slider.hpp)14
-rw-r--r--src/gui/base/widgets/textbox.cpp (renamed from src/guichan/widgets/textbox.cpp)29
-rw-r--r--src/gui/base/widgets/textbox.hpp (renamed from src/guichan/include/guichan/widgets/textbox.hpp)13
-rw-r--r--src/gui/base/widgets/textfield.cpp (renamed from src/guichan/widgets/textfield.cpp)24
-rw-r--r--src/gui/base/widgets/textfield.hpp (renamed from src/guichan/include/guichan/widgets/textfield.hpp)12
-rw-r--r--src/gui/cliprect.cpp (renamed from src/guichan/image.cpp)41
-rw-r--r--src/gui/cliprect.h (renamed from src/guichan/include/guichan/input.hpp)104
-rw-r--r--src/gui/color.cpp (renamed from src/guichan/keyinput.cpp)177
-rw-r--r--src/gui/color.h (renamed from src/guichan/include/guichan/color.hpp)179
-rw-r--r--src/gui/focushandler.cpp530
-rw-r--r--src/gui/focushandler.h377
-rw-r--r--src/gui/font.cpp (renamed from src/gui/sdlfont.cpp)136
-rw-r--r--src/gui/font.h (renamed from src/gui/sdlfont.h)94
-rw-r--r--src/gui/gui.cpp163
-rw-r--r--src/gui/gui.h57
-rw-r--r--src/gui/models/avatarlistmodel.h40
-rw-r--r--src/gui/models/beingslistmodel.h62
-rw-r--r--src/gui/models/colorlistmodel.h81
-rw-r--r--src/gui/models/colormodel.cpp (renamed from src/gui/widgets/colormodel.cpp)6
-rw-r--r--src/gui/models/colormodel.h (renamed from src/gui/widgets/colormodel.h)22
-rw-r--r--src/gui/models/extendedlistmodel.h (renamed from src/gui/widgets/extendedlistmodel.h)10
-rw-r--r--src/gui/models/extendednamesmodel.cpp (renamed from src/gui/widgets/extendednamesmodel.cpp)2
-rw-r--r--src/gui/models/extendednamesmodel.h (renamed from src/gui/widgets/extendednamesmodel.h)8
-rw-r--r--src/gui/models/fontsmodel.h (renamed from src/input/keyinput.cpp)34
-rw-r--r--src/gui/models/iconsmodel.h84
-rw-r--r--src/gui/models/ignorechoiceslistmodel.h55
-rw-r--r--src/gui/models/itemsmodel.h86
-rw-r--r--src/gui/models/listmodel.h (renamed from src/guichan/include/guichan/listmodel.hpp)49
-rw-r--r--src/gui/models/magicschoolmodel.h67
-rw-r--r--src/gui/models/namesmodel.cpp (renamed from src/gui/widgets/namesmodel.cpp)2
-rw-r--r--src/gui/models/namesmodel.h (renamed from src/gui/widgets/namesmodel.h)10
-rw-r--r--src/gui/models/playerrelationlistmodel.h67
-rw-r--r--src/gui/models/questsmodel.h (renamed from src/mouseinput.cpp)26
-rw-r--r--src/gui/models/serverslistmodel.h109
-rw-r--r--src/gui/models/shopitems.cpp (renamed from src/gui/widgets/shopitems.cpp)2
-rw-r--r--src/gui/models/shopitems.h (renamed from src/gui/widgets/shopitems.h)10
-rw-r--r--src/gui/models/skillmodel.cpp (renamed from src/gui/widgets/skillmodel.cpp)2
-rw-r--r--src/gui/models/skillmodel.h (renamed from src/gui/widgets/skillmodel.h)10
-rw-r--r--src/gui/models/sortlistmodelbuy.h65
-rw-r--r--src/gui/models/sortlistmodelinv.h65
-rw-r--r--src/gui/models/soundsmodel.h (renamed from src/gui/widgets/mouseevent.h)35
-rw-r--r--src/gui/models/tablemodel.cpp (renamed from src/gui/widgets/tablemodel.cpp)10
-rw-r--r--src/gui/models/tablemodel.h (renamed from src/gui/widgets/tablemodel.h)22
-rw-r--r--src/gui/models/targettypemodel.h58
-rw-r--r--src/gui/models/themesmodel.h47
-rw-r--r--src/gui/models/touchactionmodel.cpp84
-rw-r--r--src/gui/models/touchactionmodel.h (renamed from src/input/keyevent.cpp)50
-rw-r--r--src/gui/models/typelistmodel.h65
-rw-r--r--src/gui/models/updatelistmodel.h66
-rw-r--r--src/gui/models/updatetypemodel.h63
-rw-r--r--src/gui/models/worldlistmodel.h68
-rw-r--r--src/gui/palette.cpp30
-rw-r--r--src/gui/palette.h29
-rw-r--r--src/gui/popups/beingpopup.cpp5
-rw-r--r--src/gui/popups/itempopup.cpp7
-rw-r--r--src/gui/popups/itempopup.h3
-rw-r--r--src/gui/popups/popupmenu.cpp16
-rw-r--r--src/gui/popups/popupmenu.h19
-rw-r--r--src/gui/popups/speechbubble.cpp10
-rw-r--r--src/gui/popups/speechbubble.h4
-rw-r--r--src/gui/popups/spellpopup.cpp8
-rw-r--r--src/gui/popups/spellpopup.h5
-rw-r--r--src/gui/popups/statuspopup.cpp2
-rw-r--r--src/gui/popups/textpopup.cpp6
-rw-r--r--src/gui/popups/textpopup.h2
-rw-r--r--src/gui/rect.cpp (renamed from src/guichan/mouseinput.cpp)114
-rw-r--r--src/gui/rect.h (renamed from src/guichan/include/guichan/rectangle.hpp)129
-rw-r--r--src/gui/sdlfont_unittest.cc92
-rw-r--r--src/gui/sdlinput.cpp62
-rw-r--r--src/gui/sdlinput.h85
-rw-r--r--src/gui/theme.cpp12
-rw-r--r--src/gui/theme.h16
-rw-r--r--src/gui/userpalette.cpp8
-rw-r--r--src/gui/userpalette.h13
-rw-r--r--src/gui/viewport.cpp282
-rw-r--r--src/gui/viewport.h19
-rw-r--r--src/gui/widgets/avatarlistbox.cpp35
-rw-r--r--src/gui/widgets/avatarlistbox.h26
-rw-r--r--src/gui/widgets/browserbox.cpp54
-rw-r--r--src/gui/widgets/browserbox.h38
-rw-r--r--src/gui/widgets/browserbox_unittest.cc4
-rw-r--r--src/gui/widgets/button.cpp112
-rw-r--r--src/gui/widgets/button.h45
-rw-r--r--src/gui/widgets/characterdisplay.cpp17
-rw-r--r--src/gui/widgets/characterdisplay.h22
-rw-r--r--src/gui/widgets/characterviewbase.h6
-rw-r--r--src/gui/widgets/characterviewnormal.cpp3
-rw-r--r--src/gui/widgets/characterviewnormal.h2
-rw-r--r--src/gui/widgets/characterviewsmall.cpp4
-rw-r--r--src/gui/widgets/characterviewsmall.h4
-rw-r--r--src/gui/widgets/checkbox.cpp37
-rw-r--r--src/gui/widgets/checkbox.h19
-rw-r--r--src/gui/widgets/colorpage.cpp21
-rw-r--r--src/gui/widgets/colorpage.h4
-rw-r--r--src/gui/widgets/container.cpp7
-rw-r--r--src/gui/widgets/container.h13
-rw-r--r--src/gui/widgets/desktop.cpp27
-rw-r--r--src/gui/widgets/desktop.h13
-rw-r--r--src/gui/widgets/dropdown.cpp96
-rw-r--r--src/gui/widgets/dropdown.h65
-rw-r--r--src/gui/widgets/dropshortcutcontainer.cpp41
-rw-r--r--src/gui/widgets/dropshortcutcontainer.h24
-rw-r--r--src/gui/widgets/emotepage.cpp22
-rw-r--r--src/gui/widgets/emotepage.h22
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp35
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.h20
-rw-r--r--src/gui/widgets/extendedlistbox.cpp33
-rw-r--r--src/gui/widgets/extendedlistbox.h4
-rw-r--r--src/gui/widgets/flowcontainer.cpp11
-rw-r--r--src/gui/widgets/flowcontainer.h11
-rw-r--r--src/gui/widgets/guitable.cpp94
-rw-r--r--src/gui/widgets/guitable.h43
-rw-r--r--src/gui/widgets/horizontcontainer.cpp11
-rw-r--r--src/gui/widgets/horizontcontainer.h14
-rw-r--r--src/gui/widgets/icon.cpp19
-rw-r--r--src/gui/widgets/icon.h15
-rw-r--r--src/gui/widgets/inttextfield.cpp18
-rw-r--r--src/gui/widgets/inttextfield.h11
-rw-r--r--src/gui/widgets/itemcontainer.cpp56
-rw-r--r--src/gui/widgets/itemcontainer.h56
-rw-r--r--src/gui/widgets/itemlinkhandler.cpp20
-rw-r--r--src/gui/widgets/itemlinkhandler.h2
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp60
-rw-r--r--src/gui/widgets/itemshortcutcontainer.h25
-rw-r--r--src/gui/widgets/label.cpp31
-rw-r--r--src/gui/widgets/label.h17
-rw-r--r--src/gui/widgets/layout.cpp8
-rw-r--r--src/gui/widgets/layout.h17
-rw-r--r--src/gui/widgets/layouthelper.cpp10
-rw-r--r--src/gui/widgets/layouthelper.h8
-rw-r--r--src/gui/widgets/linkhandler.h4
-rw-r--r--src/gui/widgets/listbox.cpp56
-rw-r--r--src/gui/widgets/listbox.h35
-rw-r--r--src/gui/widgets/passwordfield.cpp2
-rw-r--r--src/gui/widgets/passwordfield.h2
-rw-r--r--src/gui/widgets/playerbox.cpp34
-rw-r--r--src/gui/widgets/playerbox.h20
-rw-r--r--src/gui/widgets/popup.cpp35
-rw-r--r--src/gui/widgets/popup.h21
-rw-r--r--src/gui/widgets/popuplist.cpp20
-rw-r--r--src/gui/widgets/popuplist.h24
-rw-r--r--src/gui/widgets/progressbar.cpp36
-rw-r--r--src/gui/widgets/progressbar.h33
-rw-r--r--src/gui/widgets/progressindicator.cpp11
-rw-r--r--src/gui/widgets/progressindicator.h11
-rw-r--r--src/gui/widgets/radiobutton.cpp34
-rw-r--r--src/gui/widgets/radiobutton.h17
-rw-r--r--src/gui/widgets/radiogroup.cpp2
-rw-r--r--src/gui/widgets/radiogroup.h9
-rw-r--r--src/gui/widgets/scrollarea.cpp312
-rw-r--r--src/gui/widgets/scrollarea.h80
-rw-r--r--src/gui/widgets/setupitem.cpp52
-rw-r--r--src/gui/widgets/setupitem.h59
-rw-r--r--src/gui/widgets/setuptouchitem.cpp64
-rw-r--r--src/gui/widgets/setuptouchitem.h20
-rw-r--r--src/gui/widgets/shoplistbox.cpp31
-rw-r--r--src/gui/widgets/shoplistbox.h16
-rw-r--r--src/gui/widgets/shortcutcontainer.cpp21
-rw-r--r--src/gui/widgets/shortcutcontainer.h28
-rw-r--r--src/gui/widgets/skillinfo.cpp3
-rw-r--r--src/gui/widgets/skillinfo.h4
-rw-r--r--src/gui/widgets/slider.cpp88
-rw-r--r--src/gui/widgets/slider.h30
-rw-r--r--src/gui/widgets/sliderlist.cpp23
-rw-r--r--src/gui/widgets/sliderlist.h24
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp48
-rw-r--r--src/gui/widgets/spellshortcutcontainer.h17
-rw-r--r--src/gui/widgets/tabbedarea.cpp123
-rw-r--r--src/gui/widgets/tabbedarea.h94
-rw-r--r--src/gui/widgets/tabs/chattab.cpp8
-rw-r--r--src/gui/widgets/tabs/chattab.h3
-rw-r--r--src/gui/widgets/tabs/guildchattab.h3
-rw-r--r--src/gui/widgets/tabs/langtab.cpp3
-rw-r--r--src/gui/widgets/tabs/langtab.h3
-rw-r--r--src/gui/widgets/tabs/setup_audio.cpp19
-rw-r--r--src/gui/widgets/tabs/setup_audio.h4
-rw-r--r--src/gui/widgets/tabs/setup_chat.cpp2
-rw-r--r--src/gui/widgets/tabs/setup_colors.cpp34
-rw-r--r--src/gui/widgets/tabs/setup_colors.h10
-rw-r--r--src/gui/widgets/tabs/setup_input.cpp14
-rw-r--r--src/gui/widgets/tabs/setup_input.h2
-rw-r--r--src/gui/widgets/tabs/setup_joystick.cpp9
-rw-r--r--src/gui/widgets/tabs/setup_joystick.h2
-rw-r--r--src/gui/widgets/tabs/setup_mods.cpp2
-rw-r--r--src/gui/widgets/tabs/setup_other.cpp5
-rw-r--r--src/gui/widgets/tabs/setup_perfomance.cpp5
-rw-r--r--src/gui/widgets/tabs/setup_players.cpp2
-rw-r--r--src/gui/widgets/tabs/setup_relations.cpp77
-rw-r--r--src/gui/widgets/tabs/setup_relations.h12
-rw-r--r--src/gui/widgets/tabs/setup_theme.cpp39
-rw-r--r--src/gui/widgets/tabs/setup_theme.h2
-rw-r--r--src/gui/widgets/tabs/setup_touch.cpp6
-rw-r--r--src/gui/widgets/tabs/setup_touch.h5
-rw-r--r--src/gui/widgets/tabs/setup_video.cpp18
-rw-r--r--src/gui/widgets/tabs/setup_video.h7
-rw-r--r--src/gui/widgets/tabs/setup_visual.cpp5
-rw-r--r--src/gui/widgets/tabs/setup_visual.h2
-rw-r--r--src/gui/widgets/tabs/setuptab.cpp4
-rw-r--r--src/gui/widgets/tabs/setuptab.h8
-rw-r--r--src/gui/widgets/tabs/setuptabscroll.cpp4
-rw-r--r--src/gui/widgets/tabs/setuptabscroll.h4
-rw-r--r--src/gui/widgets/tabs/tab.cpp91
-rw-r--r--src/gui/widgets/tabs/tab.h107
-rw-r--r--src/gui/widgets/tabs/whispertab.cpp3
-rw-r--r--src/gui/widgets/tabs/whispertab.h3
-rw-r--r--src/gui/widgets/tabstrip.cpp12
-rw-r--r--src/gui/widgets/tabstrip.h14
-rw-r--r--src/gui/widgets/textbox.cpp36
-rw-r--r--src/gui/widgets/textbox.h17
-rw-r--r--src/gui/widgets/textfield.cpp55
-rw-r--r--src/gui/widgets/textfield.h26
-rw-r--r--src/gui/widgets/textpreview.cpp45
-rw-r--r--src/gui/widgets/textpreview.h32
-rw-r--r--src/gui/widgets/vertcontainer.cpp13
-rw-r--r--src/gui/widgets/vertcontainer.h16
-rw-r--r--src/gui/widgets/widget.cpp666
-rw-r--r--src/gui/widgets/widget.h1230
-rw-r--r--src/gui/widgets/widget2.h23
-rw-r--r--src/gui/widgets/widgetgroup.cpp13
-rw-r--r--src/gui/widgets/widgetgroup.h17
-rw-r--r--src/gui/widgets/window.cpp254
-rw-r--r--src/gui/widgets/window.h245
-rw-r--r--src/gui/widgets/windowcontainer.cpp8
-rw-r--r--src/gui/widgets/windowcontainer.h10
-rw-r--r--src/gui/windowmenu.cpp38
-rw-r--r--src/gui/windowmenu.h26
-rw-r--r--src/gui/windows/botcheckerwindow.cpp24
-rw-r--r--src/gui/windows/botcheckerwindow.h10
-rw-r--r--src/gui/windows/buydialog.cpp61
-rw-r--r--src/gui/windows/buydialog.h13
-rw-r--r--src/gui/windows/buyselldialog.cpp6
-rw-r--r--src/gui/windows/buyselldialog.h7
-rw-r--r--src/gui/windows/changeemaildialog.cpp4
-rw-r--r--src/gui/windows/changeemaildialog.h7
-rw-r--r--src/gui/windows/changepassworddialog.cpp4
-rw-r--r--src/gui/windows/changepassworddialog.h7
-rw-r--r--src/gui/windows/charcreatedialog.cpp39
-rw-r--r--src/gui/windows/charcreatedialog.h16
-rw-r--r--src/gui/windows/charselectdialog.cpp30
-rw-r--r--src/gui/windows/charselectdialog.h15
-rw-r--r--src/gui/windows/chatwindow.cpp97
-rw-r--r--src/gui/windows/chatwindow.h30
-rw-r--r--src/gui/windows/confirmdialog.cpp6
-rw-r--r--src/gui/windows/confirmdialog.h7
-rw-r--r--src/gui/windows/connectiondialog.cpp8
-rw-r--r--src/gui/windows/connectiondialog.h9
-rw-r--r--src/gui/windows/debugwindow.cpp17
-rw-r--r--src/gui/windows/debugwindow.h6
-rw-r--r--src/gui/windows/didyouknowwindow.cpp15
-rw-r--r--src/gui/windows/didyouknowwindow.h8
-rw-r--r--src/gui/windows/editdialog.cpp4
-rw-r--r--src/gui/windows/editdialog.h7
-rw-r--r--src/gui/windows/editserverdialog.cpp63
-rw-r--r--src/gui/windows/editserverdialog.h48
-rw-r--r--src/gui/windows/emotewindow.cpp15
-rw-r--r--src/gui/windows/emotewindow.h6
-rw-r--r--src/gui/windows/equipmentwindow.cpp68
-rw-r--r--src/gui/windows/equipmentwindow.h25
-rw-r--r--src/gui/windows/helpwindow.cpp16
-rw-r--r--src/gui/windows/helpwindow.h11
-rw-r--r--src/gui/windows/inventorywindow.cpp100
-rw-r--r--src/gui/windows/inventorywindow.h34
-rw-r--r--src/gui/windows/itemamountwindow.cpp67
-rw-r--r--src/gui/windows/itemamountwindow.h16
-rw-r--r--src/gui/windows/killstats.cpp4
-rw-r--r--src/gui/windows/killstats.h9
-rw-r--r--src/gui/windows/logindialog.cpp93
-rw-r--r--src/gui/windows/logindialog.h13
-rw-r--r--src/gui/windows/minimap.cpp34
-rw-r--r--src/gui/windows/minimap.h8
-rw-r--r--src/gui/windows/ministatuswindow.cpp18
-rw-r--r--src/gui/windows/ministatuswindow.h13
-rw-r--r--src/gui/windows/npcdialog.cpp20
-rw-r--r--src/gui/windows/npcdialog.h14
-rw-r--r--src/gui/windows/npcpostdialog.cpp8
-rw-r--r--src/gui/windows/npcpostdialog.h6
-rw-r--r--src/gui/windows/okdialog.cpp6
-rw-r--r--src/gui/windows/okdialog.h6
-rw-r--r--src/gui/windows/outfitwindow.cpp35
-rw-r--r--src/gui/windows/outfitwindow.h18
-rw-r--r--src/gui/windows/questswindow.cpp30
-rw-r--r--src/gui/windows/questswindow.h6
-rw-r--r--src/gui/windows/quitdialog.cpp18
-rw-r--r--src/gui/windows/quitdialog.h13
-rw-r--r--src/gui/windows/registerdialog.cpp22
-rw-r--r--src/gui/windows/registerdialog.h16
-rw-r--r--src/gui/windows/selldialog.cpp33
-rw-r--r--src/gui/windows/selldialog.h12
-rw-r--r--src/gui/windows/serverdialog.cpp118
-rw-r--r--src/gui/windows/serverdialog.h67
-rw-r--r--src/gui/windows/setupwindow.cpp15
-rw-r--r--src/gui/windows/setupwindow.h8
-rw-r--r--src/gui/windows/shopwindow.cpp15
-rw-r--r--src/gui/windows/shopwindow.h12
-rw-r--r--src/gui/windows/shortcutwindow.cpp17
-rw-r--r--src/gui/windows/shortcutwindow.h8
-rw-r--r--src/gui/windows/skilldialog.cpp50
-rw-r--r--src/gui/windows/skilldialog.h9
-rw-r--r--src/gui/windows/socialwindow.cpp130
-rw-r--r--src/gui/windows/socialwindow.h11
-rw-r--r--src/gui/windows/statuswindow.cpp16
-rw-r--r--src/gui/windows/statuswindow.h8
-rw-r--r--src/gui/windows/textcommandeditor.cpp135
-rw-r--r--src/gui/windows/textcommandeditor.h11
-rw-r--r--src/gui/windows/textdialog.cpp8
-rw-r--r--src/gui/windows/textdialog.h7
-rw-r--r--src/gui/windows/tradewindow.cpp23
-rw-r--r--src/gui/windows/tradewindow.h12
-rw-r--r--src/gui/windows/unregisterdialog.cpp4
-rw-r--r--src/gui/windows/unregisterdialog.h7
-rw-r--r--src/gui/windows/updaterwindow.cpp25
-rw-r--r--src/gui/windows/updaterwindow.h14
-rw-r--r--src/gui/windows/whoisonline.cpp20
-rw-r--r--src/gui/windows/whoisonline.h12
-rw-r--r--src/gui/windows/worldselectdialog.cpp60
-rw-r--r--src/gui/windows/worldselectdialog.h13
-rw-r--r--src/guichan/actionevent.cpp88
-rw-r--r--src/guichan/cliprectangle.cpp107
-rw-r--r--src/guichan/color.cpp165
-rw-r--r--src/guichan/event.cpp87
-rw-r--r--src/guichan/exception.cpp120
-rw-r--r--src/guichan/focushandler.cpp571
-rw-r--r--src/guichan/font.cpp87
-rw-r--r--src/guichan/graphics.cpp179
-rw-r--r--src/guichan/include/guichan/cliprectangle.hpp129
-rw-r--r--src/guichan/include/guichan/exception.hpp196
-rw-r--r--src/guichan/include/guichan/focushandler.hpp417
-rw-r--r--src/guichan/include/guichan/font.hpp133
-rw-r--r--src/guichan/include/guichan/graphics.hpp294
-rw-r--r--src/guichan/include/guichan/inputevent.hpp177
-rw-r--r--src/guichan/include/guichan/keyinput.hpp289
-rw-r--r--src/guichan/include/guichan/mouseinput.hpp260
-rw-r--r--src/guichan/include/guichan/sdl/sdlpixel.hpp306
-rw-r--r--src/guichan/include/guichan/widget.hpp1232
-rw-r--r--src/guichan/include/guichan/widgets/window.hpp269
-rw-r--r--src/guichan/inputevent.cpp117
-rw-r--r--src/guichan/keyevent.cpp111
-rw-r--r--src/guichan/mouseevent.cpp121
-rw-r--r--src/guichan/rectangle.cpp156
-rw-r--r--src/guichan/selectionevent.cpp82
-rw-r--r--src/guichan/widget.cpp695
-rw-r--r--src/guichan/widgets/window.cpp233
-rw-r--r--src/guild.h2
-rw-r--r--src/imagesprite.cpp2
-rw-r--r--src/input/inputmanager.cpp35
-rw-r--r--src/input/inputmanager.h3
-rw-r--r--src/input/joystick.h2
-rw-r--r--src/input/key.cpp (renamed from src/guichan/key.cpp)69
-rw-r--r--src/input/key.h (renamed from src/guichan/include/guichan/key.hpp)140
-rw-r--r--src/input/keyboardconfig.h2
-rw-r--r--src/input/keydata.h2
-rw-r--r--src/input/keyevent.h66
-rw-r--r--src/input/keyinput.h203
-rw-r--r--src/input/mouseinput.h (renamed from src/guichan/include/guichan/image.hpp)204
-rw-r--r--src/input/multitouchmanager.cpp2
-rw-r--r--src/input/multitouchmanager.h2
-rw-r--r--src/listeners/actionlistener.h (renamed from src/guichan/include/guichan/actionlistener.hpp)61
-rw-r--r--src/listeners/actorspritelistener.h (renamed from src/being/actorspritelistener.h)6
-rw-r--r--src/listeners/configlistener.h (renamed from src/configlistener.h)6
-rw-r--r--src/listeners/deathlistener.h (renamed from src/guichan/include/guichan/deathlistener.hpp)55
-rw-r--r--src/listeners/depricatedlistener.cpp (renamed from src/depricatedlistener.cpp)2
-rw-r--r--src/listeners/depricatedlistener.h (renamed from src/depricatedlistener.h)6
-rw-r--r--src/listeners/focuslistener.h (renamed from src/guichan/include/guichan/focuslistener.hpp)63
-rw-r--r--src/listeners/keylistener.h (renamed from src/guichan/include/guichan/keylistener.hpp)67
-rw-r--r--src/listeners/mouselistener.h (renamed from src/guichan/include/guichan/mouselistener.hpp)161
-rw-r--r--src/listeners/playerrelationslistener.h (renamed from src/being/playerrelationslistener.h)6
-rw-r--r--src/listeners/selectionlistener.h (renamed from src/guichan/include/guichan/selectionlistener.hpp)65
-rw-r--r--src/listeners/widgetlistener.h (renamed from src/guichan/include/guichan/widgetlistener.hpp)99
-rw-r--r--src/localconsts.h7
-rw-r--r--src/logger.cpp3
-rw-r--r--src/main.h6
-rw-r--r--src/map.cpp129
-rw-r--r--src/map.h26
-rw-r--r--src/maplayer.cpp21
-rw-r--r--src/maplayer.h3
-rw-r--r--src/mouseinput.h63
-rw-r--r--src/net/download.cpp1
-rw-r--r--src/net/ea/buysellhandler.cpp2
-rw-r--r--src/net/ea/charserverhandler.cpp1
-rw-r--r--src/net/ea/charserverhandler.h9
-rw-r--r--src/net/ea/chathandler.cpp2
-rw-r--r--src/net/ea/chathandler.h6
-rw-r--r--src/net/ea/gamehandler.cpp2
-rw-r--r--src/net/ea/gamehandler.h6
-rw-r--r--src/net/ea/gui/guildtab.cpp3
-rw-r--r--src/net/ea/gui/guildtab.h3
-rw-r--r--src/net/ea/gui/partytab.h3
-rw-r--r--src/net/ea/guildhandler.cpp4
-rw-r--r--src/net/ea/guildhandler.h7
-rw-r--r--src/net/ea/inventoryhandler.cpp8
-rw-r--r--src/net/ea/inventoryhandler.h10
-rw-r--r--src/net/ea/itemhandler.cpp2
-rw-r--r--src/net/ea/itemhandler.h7
-rw-r--r--src/net/ea/loginhandler.cpp7
-rw-r--r--src/net/ea/loginhandler.h6
-rw-r--r--src/net/ea/npchandler.cpp2
-rw-r--r--src/net/ea/npchandler.h8
-rw-r--r--src/net/ea/partyhandler.cpp7
-rw-r--r--src/net/ea/partyhandler.h11
-rw-r--r--src/net/ea/playerhandler.cpp9
-rw-r--r--src/net/ea/playerhandler.h6
-rw-r--r--src/net/ea/skillhandler.cpp2
-rw-r--r--src/net/ea/skillhandler.h8
-rw-r--r--src/net/ea/tradehandler.cpp5
-rw-r--r--src/net/ea/tradehandler.h6
-rw-r--r--src/net/eathena/chathandler.cpp3
-rw-r--r--src/net/eathena/chathandler.h2
-rw-r--r--src/net/eathena/generalhandler.cpp1
-rw-r--r--src/net/eathena/messageout.cpp2
-rw-r--r--src/net/eathena/network.cpp1
-rw-r--r--src/net/eathena/network.h3
-rw-r--r--src/net/eathena/partyhandler.cpp1
-rw-r--r--src/net/loginhandler.h5
-rw-r--r--src/net/messagein.cpp25
-rw-r--r--src/net/messagein.h7
-rw-r--r--src/net/net.cpp11
-rw-r--r--src/net/serverinfo.h5
-rw-r--r--src/net/tmwa/chathandler.cpp3
-rw-r--r--src/net/tmwa/chathandler.h2
-rw-r--r--src/net/tmwa/generalhandler.cpp1
-rw-r--r--src/net/tmwa/messageout.cpp2
-rw-r--r--src/net/tmwa/network.cpp1
-rw-r--r--src/net/tmwa/network.h3
-rw-r--r--src/net/tmwa/partyhandler.cpp1
-rw-r--r--src/net/tmwa/pethandler.cpp3
-rw-r--r--src/net/tradehandler.h2
-rw-r--r--src/particle/imageparticle.cpp2
-rw-r--r--src/particle/particle.cpp8
-rw-r--r--src/particle/particle.h16
-rw-r--r--src/particle/textparticle.cpp10
-rw-r--r--src/particle/textparticle.h8
-rw-r--r--src/party.h2
-rw-r--r--src/render/graphics.cpp124
-rw-r--r--src/render/graphics.h182
-rw-r--r--src/render/mobileopenglgraphics.cpp28
-rw-r--r--src/render/mobileopenglgraphics.h2
-rw-r--r--src/render/normalopenglgraphics.cpp28
-rw-r--r--src/render/normalopenglgraphics.h2
-rw-r--r--src/render/nullopenglgraphics.cpp24
-rw-r--r--src/render/nullopenglgraphics.h2
-rw-r--r--src/render/openglgraphicsdef.hpp16
-rw-r--r--src/render/safeopenglgraphics.cpp26
-rw-r--r--src/render/safeopenglgraphics.h2
-rw-r--r--src/render/sdl2graphics.cpp92
-rw-r--r--src/render/sdl2graphics.h55
-rw-r--r--src/render/sdl2softwaregraphics.cpp53
-rw-r--r--src/render/sdl2softwaregraphics.h12
-rw-r--r--src/render/sdlgraphics.cpp54
-rw-r--r--src/render/sdlgraphics.h12
-rw-r--r--src/render/surfacegraphics.cpp6
-rw-r--r--src/render/surfacegraphics.h10
-rw-r--r--src/resources/atlasmanager.cpp2
-rw-r--r--src/resources/db/monsterdb.cpp6
-rw-r--r--src/resources/db/weaponsdb.cpp76
-rw-r--r--src/resources/db/weaponsdb.h44
-rw-r--r--src/resources/dye.cpp2
-rw-r--r--src/resources/dye.h2
-rw-r--r--src/resources/mapreader.cpp1
-rw-r--r--src/simpleanimation.cpp6
-rw-r--r--src/soundmanager.h2
-rw-r--r--src/statuseffect.cpp3
-rw-r--r--src/statuseffect.h7
-rw-r--r--src/test/testlauncher.cpp12
-rw-r--r--src/text.cpp30
-rw-r--r--src/text.h24
-rw-r--r--src/touchactions.cpp4
-rw-r--r--src/touchmanager.cpp19
-rw-r--r--src/touchmanager.h11
-rw-r--r--src/utils/files.cpp3
-rw-r--r--src/utils/mathutils.h6
-rw-r--r--src/utils/paths.cpp2
-rw-r--r--src/utils/sdlpixel.h236
-rw-r--r--src/utils/stringutils.cpp2
-rw-r--r--src/utils/stringutils.h2
-rw-r--r--src/utils/translation/poparser.cpp2
-rw-r--r--src/utils/translation/poparser.h4
-rw-r--r--src/utils/xml.h2
-rw-r--r--src/utils/xmlutils.cpp63
-rw-r--r--src/utils/xmlutils.h (renamed from src/input/inputevent.cpp)21
-rw-r--r--src/utils/xmlutils_unittest.cc70
535 files changed, 11567 insertions, 14332 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 29e5afcb0..054ab4823 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -47,7 +47,7 @@ ELSEIF (CMAKE_SYSTEM_NAME STREQUAL Linux)
SET(EXTRA_LIBRARIES rt)
ENDIF()
-SET(FLAGS "${FLAGS} -DUSE_MUMBLE -DUSE_INTERNALGUICHAN")
+SET(FLAGS "${FLAGS} -DUSE_MUMBLE")
IF (WITH_OPENGL)
FIND_PACKAGE(OpenGL REQUIRED)
@@ -62,7 +62,6 @@ IF (USE_X11)
ENDIF (USE_X11)
INCLUDE_DIRECTORIES(
- "guichan/include"
${CMAKE_CURRENT_SOURCE_DIR}
${SDL_INCLUDE_DIR}
${SDLIMAGE_INCLUDE_DIR}
@@ -108,6 +107,9 @@ MARK_AS_ADVANCED(SDL_LIBRARY)
SET(SRCS
gui/widgets/avatarlistbox.cpp
gui/widgets/avatarlistbox.h
+ gui/models/avatarlistmodel.h
+ gui/models/beingslistmodel.h
+ gui/models/colorlistmodel.h
gui/widgets/tabs/battletab.cpp
gui/widgets/tabs/battletab.h
gui/widgets/browserbox.cpp
@@ -125,8 +127,8 @@ SET(SRCS
gui/widgets/tabs/chattab.h
gui/widgets/checkbox.cpp
gui/widgets/checkbox.h
- gui/widgets/colormodel.cpp
- gui/widgets/colormodel.h
+ gui/models/colormodel.cpp
+ gui/models/colormodel.h
gui/widgets/colorpage.cpp
gui/widgets/colorpage.h
gui/widgets/container.cpp
@@ -139,9 +141,13 @@ SET(SRCS
gui/widgets/emoteshortcutcontainer.h
gui/widgets/extendedlistbox.cpp
gui/widgets/extendedlistbox.h
- gui/widgets/extendedlistmodel.h
- gui/widgets/extendednamesmodel.cpp
- gui/widgets/extendednamesmodel.h
+ gui/models/extendedlistmodel.h
+ gui/models/extendednamesmodel.cpp
+ gui/models/extendednamesmodel.h
+ gui/models/fontsmodel.h
+ gui/models/iconsmodel.h
+ gui/models/ignorechoiceslistmodel.h
+ gui/models/itemsmodel.h
gui/widgets/flowcontainer.cpp
gui/widgets/flowcontainer.h
gui/widgets/tabs/gmtab.cpp
@@ -177,9 +183,11 @@ SET(SRCS
gui/widgets/linkhandler.h
gui/widgets/listbox.cpp
gui/widgets/listbox.h
- gui/widgets/mouseevent.h
- gui/widgets/namesmodel.cpp
- gui/widgets/namesmodel.h
+ gui/models/namesmodel.cpp
+ gui/models/namesmodel.h
+ gui/models/playerrelationlistmodel.h
+ gui/models/questsmodel.h
+ gui/models/serverslistmodel.h
gui/widgets/passwordfield.cpp
gui/widgets/passwordfield.h
gui/widgets/playerbox.cpp
@@ -206,8 +214,8 @@ SET(SRCS
gui/widgets/tabs/setuptabscroll.h
gui/widgets/setuptouchitem.cpp
gui/widgets/setuptouchitem.h
- gui/widgets/shopitems.cpp
- gui/widgets/shopitems.h
+ gui/models/shopitems.cpp
+ gui/models/shopitems.h
gui/widgets/shoplistbox.cpp
gui/widgets/shoplistbox.h
gui/widgets/shortcutcontainer.cpp
@@ -216,8 +224,11 @@ SET(SRCS
gui/widgets/skilldata.h
gui/widgets/skillinfo.cpp
gui/widgets/skillinfo.h
- gui/widgets/skillmodel.cpp
- gui/widgets/skillmodel.h
+ gui/models/skillmodel.cpp
+ gui/models/skillmodel.h
+ gui/models/sortlistmodelbuy.h
+ gui/models/sortlistmodelinv.h
+ gui/models/soundsmodel.h
gui/widgets/slider.cpp
gui/widgets/slider.h
gui/widgets/sliderlist.cpp
@@ -228,8 +239,16 @@ SET(SRCS
gui/widgets/tabbedarea.h
gui/widgets/guitable.cpp
gui/widgets/guitable.h
- gui/widgets/tablemodel.cpp
- gui/widgets/tablemodel.h
+ gui/models/tablemodel.cpp
+ gui/models/tablemodel.h
+ gui/models/targettypemodel.h
+ gui/models/touchactionmodel.cpp
+ gui/models/touchactionmodel.h
+ gui/models/typelistmodel.h
+ gui/models/updatetypemodel.h
+ gui/models/updatelistmodel.h
+ gui/models/worldlistmodel.h
+ gui/models/themesmodel.h
gui/widgets/tabstrip.cpp
gui/widgets/tabstrip.h
gui/widgets/textbox.cpp
@@ -366,8 +385,8 @@ SET(SRCS
gui/widgets/tabs/setup_visual.cpp
gui/widgets/tabs/setup_visual.h
gui/setupactiondata.h
- gui/sdlfont.cpp
- gui/sdlfont.h
+ gui/font.cpp
+ gui/font.h
gui/windows/shopwindow.cpp
gui/windows/shopwindow.h
gui/windows/shortcutwindow.cpp
@@ -506,6 +525,8 @@ SET(SRCS
resources/sdlmusic.h
resources/db/sounddb.cpp
resources/db/sounddb.h
+ resources/db/weaponsdb.cpp
+ resources/db/weaponsdb.h
resources/soundeffect.cpp
resources/soundeffect.h
resources/soundinfo.h
@@ -568,6 +589,8 @@ SET(SRCS
utils/mkdir.h
utils/xml.cpp
utils/xml.h
+ utils/xmlutils.cpp
+ utils/xmlutils.h
test/testlauncher.cpp
test/testlauncher.h
test/testmain.cpp
@@ -578,7 +601,7 @@ SET(SRCS
being/actor.h
being/actorsprite.cpp
being/actorsprite.h
- being/actorspritelistener.h
+ listeners/actorspritelistener.h
actormanager.cpp
actormanager.h
animatedsprite.cpp
@@ -608,7 +631,7 @@ SET(SRCS
commands.h
being/compoundsprite.cpp
being/compoundsprite.h
- configlistener.h
+ listeners/configlistener.h
configuration.cpp
configuration.h
debug.h
@@ -616,8 +639,8 @@ SET(SRCS
defaults.h
depricatedevent.cpp
depricatedevent.h
- depricatedlistener.cpp
- depricatedlistener.h
+ listeners/depricatedlistener.cpp
+ listeners/depricatedlistener.h
dragdrop.h
effectmanager.cpp
effectmanager.h
@@ -660,17 +683,13 @@ SET(SRCS
textcommand.h
input/inputmanager.cpp
input/inputmanager.h
- input/inputevent.cpp
- input/inputevent.h
+ events/inputevent.h
input/joystick.cpp
input/joystick.h
input/keyboardconfig.cpp
input/keyboardconfig.h
input/keyboarddata.h
input/keydata.h
- input/keyevent.cpp
- input/keyevent.h
- input/keyinput.cpp
input/keyinput.h
input/multitouchmanager.cpp
input/multitouchmanager.h
@@ -691,8 +710,7 @@ SET(SRCS
render/mgl.h
render/mobileopenglgraphics.cpp
render/mobileopenglgraphics.h
- mouseinput.cpp
- mouseinput.h
+ input/mouseinput.h
mumblemanager.cpp
mumblemanager.h
navigationmanager.cpp
@@ -725,7 +743,7 @@ SET(SRCS
being/playerinfo.h
being/playerrelations.cpp
being/playerrelations.h
- being/playerrelationslistener.h
+ listeners/playerrelationslistener.h
position.cpp
position.h
properties.h
@@ -770,81 +788,56 @@ SET(SRCS
vector.h
walklayer.cpp
walklayer.h
- )
-
-SET(SRCS_GUICHAN
- guichan/include/guichan/actionevent.hpp
- guichan/include/guichan/actionlistener.hpp
- guichan/include/guichan/basiccontainer.hpp
- guichan/include/guichan/cliprectangle.hpp
- guichan/include/guichan/color.hpp
- guichan/include/guichan/deathlistener.hpp
- guichan/include/guichan/event.hpp
- guichan/include/guichan/exception.hpp
- guichan/include/guichan/focushandler.hpp
- guichan/include/guichan/focuslistener.hpp
- guichan/include/guichan/font.hpp
- guichan/include/guichan/graphics.hpp
- guichan/include/guichan/gui.hpp
- guichan/include/guichan/image.hpp
- guichan/include/guichan/input.hpp
- guichan/include/guichan/inputevent.hpp
- guichan/include/guichan/key.hpp
- guichan/include/guichan/keyevent.hpp
- guichan/include/guichan/keyinput.hpp
- guichan/include/guichan/keylistener.hpp
- guichan/include/guichan/listmodel.hpp
- guichan/include/guichan/mouseevent.hpp
- guichan/include/guichan/mouseinput.hpp
- guichan/include/guichan/mouselistener.hpp
- guichan/include/guichan/rectangle.hpp
- guichan/include/guichan/selectionevent.hpp
- guichan/include/guichan/selectionlistener.hpp
- guichan/include/guichan/sdl/sdlpixel.hpp
- guichan/include/guichan/widget.hpp
- guichan/include/guichan/widgetlistener.hpp
- guichan/include/guichan/widgets/button.hpp
- guichan/include/guichan/widgets/checkbox.hpp
- guichan/include/guichan/widgets/container.hpp
- guichan/include/guichan/widgets/label.hpp
- guichan/include/guichan/widgets/listbox.hpp
- guichan/include/guichan/widgets/radiobutton.hpp
- guichan/include/guichan/widgets/scrollarea.hpp
- guichan/include/guichan/widgets/slider.hpp
- guichan/include/guichan/widgets/textbox.hpp
- guichan/include/guichan/widgets/textfield.hpp
- guichan/include/guichan/widgets/window.hpp
- guichan/actionevent.cpp
- guichan/basiccontainer.cpp
- guichan/cliprectangle.cpp
- guichan/color.cpp
- guichan/event.cpp
- guichan/exception.cpp
- guichan/focushandler.cpp
- guichan/font.cpp
- guichan/graphics.cpp
- guichan/gui.cpp
- guichan/image.cpp
- guichan/inputevent.cpp
- guichan/key.cpp
- guichan/keyevent.cpp
- guichan/keyinput.cpp
- guichan/mouseevent.cpp
- guichan/mouseinput.cpp
- guichan/rectangle.cpp
- guichan/selectionevent.cpp
- guichan/widget.cpp
- guichan/widgets/button.cpp
- guichan/widgets/checkbox.cpp
- guichan/widgets/container.cpp
- guichan/widgets/label.cpp
- guichan/widgets/listbox.cpp
- guichan/widgets/radiobutton.cpp
- guichan/widgets/scrollarea.cpp
- guichan/widgets/slider.cpp
- guichan/widgets/textbox.cpp
- guichan/widgets/textfield.cpp
- guichan/widgets/window.cpp
+ events/actionevent.h
+ listeners/actionlistener.h
+ gui/base/basiccontainer.hpp
+ gui/cliprect.h
+ gui/color.h
+ listeners/deathlistener.h
+ events/event.h
+ listeners/focuslistener.h
+ gui/base/gui.hpp
+ events/inputguievent.h
+ input/key.h
+ events/keyevent.h
+ listeners/keylistener.h
+ gui/models/listmodel.h
+ gui/models/magicschoolmodel.h
+ events/mouseevent.h
+ listeners/mouselistener.h
+ gui/rect.h
+ events/selectionevent.h
+ listeners/selectionlistener.h
+ utils/sdlpixel.h
+ gui/widgets/widget.h
+ listeners/widgetlistener.h
+ gui/base/widgets/button.hpp
+ gui/base/widgets/checkbox.hpp
+ gui/base/widgets/container.hpp
+ gui/base/widgets/label.hpp
+ gui/base/widgets/listbox.hpp
+ gui/base/widgets/radiobutton.hpp
+ gui/base/widgets/scrollarea.hpp
+ gui/base/widgets/slider.hpp
+ gui/base/widgets/textbox.hpp
+ gui/base/widgets/textfield.hpp
+ gui/base/basiccontainer.cpp
+ gui/cliprect.cpp
+ gui/color.cpp
+ gui/base/gui.cpp
+ input/key.cpp
+ gui/rect.cpp
+ gui/widgets/widget.cpp
+ gui/base/widgets/button.cpp
+ gui/base/widgets/checkbox.cpp
+ gui/base/widgets/container.cpp
+ gui/base/widgets/label.cpp
+ gui/base/widgets/listbox.cpp
+ gui/base/widgets/radiobutton.cpp
+ gui/base/widgets/scrollarea.cpp
+ gui/base/widgets/slider.cpp
+ gui/base/widgets/textbox.cpp
+ gui/base/widgets/textfield.cpp
)
SET(SRCS_EVOL
@@ -1000,9 +993,9 @@ ENDIF ()
SET (PROGRAMS manaplus)
IF (ENABLE_EATHENA)
- ADD_EXECUTABLE(manaplus WIN32 ${SRCS_GUICHAN} ${SRCS} ${SRCS_EATHENA} ${SRCS_TMWA} ${SRCS_EVOL})
+ ADD_EXECUTABLE(manaplus WIN32 ${SRCS} ${SRCS_EATHENA} ${SRCS_TMWA} ${SRCS_EVOL})
ELSE(ENABLE_EATHENA)
- ADD_EXECUTABLE(manaplus WIN32 ${SRCS_GUICHAN} ${SRCS} ${SRCS_TMWA} ${SRCS_EVOL})
+ ADD_EXECUTABLE(manaplus WIN32 ${SRCS} ${SRCS_TMWA} ${SRCS_EVOL})
ENDIF(ENABLE_EATHENA)
TARGET_LINK_LIBRARIES(manaplus
diff --git a/src/Makefile.am b/src/Makefile.am
index 7fb4541a1..2b1eb4c68 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -25,30 +25,15 @@ else
manaplus_SOURCES =
endif
-if USE_INTERNALGUICHAN
-dyecmd_CXXFLAGS = -I$(srcdir)/guichan/include -DUSE_INTERNALGUICHAN
-dyecmd_SOURCES = guichan/actionevent.cpp \
- guichan/cliprectangle.cpp \
- guichan/color.cpp \
- guichan/event.cpp \
- guichan/exception.cpp \
- guichan/font.cpp \
- guichan/graphics.cpp \
- guichan/rectangle.cpp \
- guichan/widget.cpp \
- guichan/include/guichan/actionevent.hpp \
- guichan/include/guichan/cliprectangle.hpp \
- guichan/include/guichan/color.hpp \
- guichan/include/guichan/event.hpp \
- guichan/include/guichan/exception.hpp \
- guichan/include/guichan/font.hpp \
- guichan/include/guichan/graphics.hpp \
- guichan/include/guichan/rectangle.hpp \
- guichan/include/guichan/widget.hpp
-else
dyecmd_CXXFLAGS =
-dyecmd_SOURCES =
-endif
+dyecmd_SOURCES = gui/cliprect.cpp \
+ gui/color.cpp \
+ gui/rect.cpp \
+ events/actionevent.h \
+ gui/cliprect.h \
+ gui/color.h \
+ events/event.h \
+ gui/rect.h
dyecmd_SOURCES += dyetool/dyemain.cpp \
animatedsprite.cpp \
@@ -133,6 +118,8 @@ dyecmd_SOURCES += dyetool/dyemain.cpp \
utils/timer.h \
utils/xml.cpp \
utils/xml.h \
+ utils/xmlutils.cpp \
+ utils/xmlutils.h \
utils/translation/podict.cpp \
utils/translation/podict.h
@@ -163,85 +150,63 @@ manaplus_CXXFLAGS += -DUSE_SDL2
endif
endif
-if USE_INTERNALGUICHAN
-manaplus_CXXFLAGS += -I$(srcdir)/guichan/include -DUSE_INTERNALGUICHAN
-manaplus_SOURCES += guichan/include/guichan/actionevent.hpp \
- guichan/include/guichan/actionlistener.hpp \
- guichan/include/guichan/basiccontainer.hpp \
- guichan/include/guichan/cliprectangle.hpp \
- guichan/include/guichan/color.hpp \
- guichan/include/guichan/deathlistener.hpp \
- guichan/include/guichan/event.hpp \
- guichan/include/guichan/exception.hpp \
- guichan/include/guichan/focushandler.hpp \
- guichan/include/guichan/focuslistener.hpp \
- guichan/include/guichan/font.hpp \
- guichan/include/guichan/graphics.hpp \
- guichan/include/guichan/gui.hpp \
- guichan/include/guichan/image.hpp \
- guichan/include/guichan/input.hpp \
- guichan/include/guichan/inputevent.hpp \
- guichan/include/guichan/key.hpp \
- guichan/include/guichan/keyevent.hpp \
- guichan/include/guichan/keyinput.hpp \
- guichan/include/guichan/keylistener.hpp \
- guichan/include/guichan/listmodel.hpp \
- guichan/include/guichan/mouseevent.hpp \
- guichan/include/guichan/mouseinput.hpp \
- guichan/include/guichan/mouselistener.hpp \
- guichan/include/guichan/rectangle.hpp \
- guichan/include/guichan/selectionevent.hpp \
- guichan/include/guichan/selectionlistener.hpp \
- guichan/include/guichan/sdl/sdlpixel.hpp \
- guichan/include/guichan/widget.hpp \
- guichan/include/guichan/widgetlistener.hpp \
- guichan/include/guichan/widgets/button.hpp \
- guichan/include/guichan/widgets/checkbox.hpp \
- guichan/include/guichan/widgets/container.hpp \
- guichan/include/guichan/widgets/label.hpp \
- guichan/include/guichan/widgets/listbox.hpp \
- guichan/include/guichan/widgets/radiobutton.hpp \
- guichan/include/guichan/widgets/scrollarea.hpp \
- guichan/include/guichan/widgets/slider.hpp \
- guichan/include/guichan/widgets/textbox.hpp \
- guichan/include/guichan/widgets/textfield.hpp \
- guichan/include/guichan/widgets/window.hpp
-
-manaplus_SOURCES += guichan/actionevent.cpp \
- guichan/basiccontainer.cpp \
- guichan/cliprectangle.cpp \
- guichan/color.cpp \
- guichan/event.cpp \
- guichan/exception.cpp \
- guichan/focushandler.cpp \
- guichan/font.cpp \
- guichan/graphics.cpp \
- guichan/gui.cpp \
- guichan/image.cpp \
- guichan/inputevent.cpp \
- guichan/key.cpp \
- guichan/keyevent.cpp \
- guichan/keyinput.cpp \
- guichan/mouseevent.cpp \
- guichan/mouseinput.cpp \
- guichan/rectangle.cpp \
- guichan/selectionevent.cpp \
- guichan/widget.cpp \
- guichan/widgets/button.cpp \
- guichan/widgets/checkbox.cpp \
- guichan/widgets/container.cpp \
- guichan/widgets/label.cpp \
- guichan/widgets/listbox.cpp \
- guichan/widgets/radiobutton.cpp \
- guichan/widgets/scrollarea.cpp \
- guichan/widgets/slider.cpp \
- guichan/widgets/textbox.cpp \
- guichan/widgets/textfield.cpp \
- guichan/widgets/window.cpp
-endif
+manaplus_SOURCES += events/actionevent.h \
+ listeners/actionlistener.h \
+ gui/base/basiccontainer.hpp \
+ gui/cliprect.h \
+ gui/color.h \
+ listeners/deathlistener.h \
+ events/event.h \
+ listeners/focuslistener.h \
+ render/graphics.h \
+ gui/base/gui.hpp \
+ events/inputguievent.h \
+ input/key.h \
+ events/keyevent.h \
+ listeners/keylistener.h \
+ gui/models/listmodel.h \
+ gui/models/magicschoolmodel.h \
+ events/mouseevent.h \
+ listeners/mouselistener.h \
+ gui/rect.h \
+ events/selectionevent.h \
+ listeners/selectionlistener.h \
+ utils/sdlpixel.h \
+ gui/widgets/widget.h \
+ listeners/widgetlistener.h \
+ gui/base/widgets/button.hpp \
+ gui/base/widgets/checkbox.hpp \
+ gui/base/widgets/container.hpp \
+ gui/base/widgets/label.hpp \
+ gui/base/widgets/listbox.hpp \
+ gui/base/widgets/radiobutton.hpp \
+ gui/base/widgets/scrollarea.hpp \
+ gui/base/widgets/slider.hpp \
+ gui/base/widgets/textbox.hpp \
+ gui/base/widgets/textfield.hpp \
+ gui/base/basiccontainer.cpp \
+ gui/cliprect.cpp \
+ gui/color.cpp \
+ gui/base/gui.cpp \
+ input/key.cpp \
+ gui/rect.cpp \
+ gui/widgets/widget.cpp \
+ gui/base/widgets/button.cpp \
+ gui/base/widgets/checkbox.cpp \
+ gui/base/widgets/container.cpp \
+ gui/base/widgets/label.cpp \
+ gui/base/widgets/listbox.cpp \
+ gui/base/widgets/radiobutton.cpp \
+ gui/base/widgets/scrollarea.cpp \
+ gui/base/widgets/slider.cpp \
+ gui/base/widgets/textbox.cpp \
+ gui/base/widgets/textfield.cpp
manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
gui/widgets/avatarlistbox.h \
+ gui/models/avatarlistmodel.h \
+ gui/models/beingslistmodel.h \
+ gui/models/colorlistmodel.h \
gui/widgets/tabs/battletab.cpp \
gui/widgets/tabs/battletab.h \
gui/widgets/browserbox.cpp \
@@ -259,8 +224,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
gui/widgets/tabs/chattab.h \
gui/widgets/checkbox.cpp \
gui/widgets/checkbox.h \
- gui/widgets/colormodel.cpp \
- gui/widgets/colormodel.h \
+ gui/models/colormodel.cpp \
+ gui/models/colormodel.h \
gui/widgets/colorpage.cpp \
gui/widgets/colorpage.h \
gui/widgets/container.cpp \
@@ -273,9 +238,13 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
gui/widgets/emoteshortcutcontainer.h \
gui/widgets/extendedlistbox.cpp \
gui/widgets/extendedlistbox.h \
- gui/widgets/extendedlistmodel.h \
- gui/widgets/extendednamesmodel.cpp \
- gui/widgets/extendednamesmodel.h \
+ gui/models/extendedlistmodel.h \
+ gui/models/extendednamesmodel.cpp \
+ gui/models/extendednamesmodel.h \
+ gui/models/fontsmodel.h \
+ gui/models/iconsmodel.h \
+ gui/models/ignorechoiceslistmodel.h \
+ gui/models/itemsmodel.h \
gui/widgets/flowcontainer.cpp \
gui/widgets/flowcontainer.h \
gui/widgets/tabs/gmtab.cpp \
@@ -313,9 +282,11 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
gui/widgets/linkhandler.h \
gui/widgets/listbox.cpp \
gui/widgets/listbox.h \
- gui/widgets/mouseevent.h \
- gui/widgets/namesmodel.cpp \
- gui/widgets/namesmodel.h \
+ gui/models/namesmodel.cpp \
+ gui/models/namesmodel.h \
+ gui/models/playerrelationlistmodel.h \
+ gui/models/questsmodel.h \
+ gui/models/serverslistmodel.h \
gui/widgets/passwordfield.cpp \
gui/widgets/passwordfield.h \
gui/widgets/playerbox.cpp \
@@ -342,8 +313,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
gui/widgets/tabs/setuptabscroll.h \
gui/widgets/setuptouchitem.cpp \
gui/widgets/setuptouchitem.h \
- gui/widgets/shopitems.cpp \
- gui/widgets/shopitems.h \
+ gui/models/shopitems.cpp \
+ gui/models/shopitems.h \
gui/widgets/shoplistbox.cpp \
gui/widgets/shoplistbox.h \
gui/widgets/shortcutcontainer.cpp \
@@ -352,8 +323,11 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
gui/widgets/skilldata.h \
gui/widgets/skillinfo.cpp \
gui/widgets/skillinfo.h \
- gui/widgets/skillmodel.cpp \
- gui/widgets/skillmodel.h \
+ gui/models/skillmodel.cpp \
+ gui/models/skillmodel.h \
+ gui/models/sortlistmodelbuy.h \
+ gui/models/sortlistmodelinv.h \
+ gui/models/soundsmodel.h \
gui/widgets/slider.cpp \
gui/widgets/slider.h \
gui/widgets/sliderlist.cpp \
@@ -362,8 +336,16 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
gui/widgets/tabs/tab.h \
gui/widgets/tabbedarea.cpp \
gui/widgets/tabbedarea.h \
- gui/widgets/tablemodel.cpp \
- gui/widgets/tablemodel.h \
+ gui/models/tablemodel.cpp \
+ gui/models/tablemodel.h \
+ gui/models/targettypemodel.h \
+ gui/models/touchactionmodel.cpp \
+ gui/models/touchactionmodel.h \
+ gui/models/typelistmodel.h \
+ gui/models/updatetypemodel.h \
+ gui/models/updatelistmodel.h \
+ gui/models/worldlistmodel.h \
+ gui/models/themesmodel.h \
gui/widgets/tabstrip.cpp \
gui/widgets/tabstrip.h \
gui/widgets/textbox.cpp \
@@ -500,8 +482,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
gui/widgets/tabs/setup_visual.cpp \
gui/widgets/tabs/setup_visual.h \
gui/setupactiondata.h \
- gui/sdlfont.cpp \
- gui/sdlfont.h \
+ gui/font.cpp \
+ gui/font.h \
gui/windows/shopwindow.cpp \
gui/windows/shopwindow.h \
gui/windows/shortcutwindow.cpp \
@@ -642,6 +624,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
resources/sdlmusic.h \
resources/db/sounddb.cpp \
resources/db/sounddb.h \
+ resources/db/weaponsdb.cpp \
+ resources/db/weaponsdb.h \
resources/soundeffect.cpp \
resources/soundeffect.h \
resources/soundinfo.h \
@@ -706,6 +690,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
utils/mutex.h \
utils/xml.cpp \
utils/xml.h \
+ utils/xmlutils.cpp \
+ utils/xmlutils.h \
test/testlauncher.cpp \
test/testlauncher.h \
test/testmain.cpp \
@@ -716,7 +702,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
being/actor.h \
being/actorsprite.cpp \
being/actorsprite.h \
- being/actorspritelistener.h \
+ listeners/actorspritelistener.h \
actormanager.cpp \
actormanager.h \
animatedsprite.cpp \
@@ -746,7 +732,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
commands.h \
being/compoundsprite.cpp \
being/compoundsprite.h \
- configlistener.h \
+ listeners/configlistener.h \
configuration.cpp \
configuration.h \
debug.h \
@@ -754,8 +740,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
defaults.h \
depricatedevent.cpp \
depricatedevent.h \
- depricatedlistener.cpp \
- depricatedlistener.h \
+ listeners/depricatedlistener.cpp \
+ listeners/depricatedlistener.h \
dragdrop.h \
dropshortcut.cpp \
dropshortcut.h \
@@ -796,8 +782,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
spellshortcut.h \
textcommand.cpp \
textcommand.h \
- input/inputevent.cpp \
- input/inputevent.h \
+ events/inputevent.h \
input/inputmanager.cpp \
input/inputmanager.h \
input/joystick.cpp \
@@ -806,9 +791,6 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
input/keyboardconfig.h \
input/keyboarddata.h \
input/keydata.h \
- input/keyevent.cpp \
- input/keyevent.h \
- input/keyinput.cpp \
input/keyinput.h \
input/multitouchmanager.cpp \
input/multitouchmanager.h \
@@ -829,8 +811,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
render/mgl.h \
render/mobileopenglgraphics.cpp \
render/mobileopenglgraphics.h \
- mouseinput.cpp \
- mouseinput.h \
+ input/mouseinput.h \
navigationmanager.cpp \
navigationmanager.h \
render/normalopenglgraphics.cpp \
@@ -861,7 +842,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
being/playerinfo.h \
being/playerrelations.cpp \
being/playerrelations.h \
- being/playerrelationslistener.h \
+ listeners/playerrelationslistener.h \
position.cpp \
position.h \
properties.h \
@@ -1058,6 +1039,7 @@ manaplus_SOURCES += \
gui/widgets/browserbox_unittest.cc \
utils/files_unittest.cc \
utils/stringutils_unittest.cc \
+ utils/xmlutils_unittest.cc \
resources/dye_unittest.cc
endif
diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp
index 1c7dbce14..b8ea34286 100644
--- a/src/actionmanager.cpp
+++ b/src/actionmanager.cpp
@@ -31,9 +31,9 @@
#include "being/playerinfo.h"
#include "being/playerrelations.h"
-#include "input/inputevent.h"
#include "input/inputmanager.h"
+#include "gui/gui.h"
#include "gui/sdlinput.h"
#include "gui/viewport.h"
@@ -44,7 +44,6 @@
#include "gui/windows/questswindow.h"
#include "gui/windows/quitdialog.h"
#include "gui/windows/whoisonline.h"
-
#include "gui/windows/botcheckerwindow.h"
#include "gui/windows/buyselldialog.h"
#include "gui/windows/chatwindow.h"
@@ -219,7 +218,7 @@ impHandler0(mouseClick)
int mouseX, mouseY;
Gui::getMouseState(&mouseX, &mouseY);
- guiInput->simulateMouseClick(mouseX, mouseY, gcn::MouseEvent::RIGHT);
+ guiInput->simulateMouseClick(mouseX, mouseY, MouseEvent::RIGHT);
return true;
}
@@ -234,12 +233,12 @@ impHandler0(ok)
// Close the config window, cancelling changes if opened
else if (setupWindow && setupWindow->isWindowVisible())
{
- setupWindow->action(gcn::ActionEvent(nullptr, "cancel"));
+ setupWindow->action(ActionEvent(nullptr, "cancel"));
return true;
}
else if (NpcDialog *const dialog = NpcDialog::getActive())
{
- dialog->action(gcn::ActionEvent(nullptr, "ok"));
+ dialog->action(ActionEvent(nullptr, "ok"));
return true;
}
return false;
diff --git a/src/actormanager.cpp b/src/actormanager.cpp
index 9661dc2fe..bc325abe8 100644
--- a/src/actormanager.cpp
+++ b/src/actormanager.cpp
@@ -137,23 +137,10 @@ class SortBeingFunctor final
return being1->getDistance() < being2->getDistance();
}
- int d1, d2;
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() == ServerInfo::MANASERV)
- {
- const Vector &pos1 = being1->getPosition();
- d1 = abs((static_cast<int>(pos1.x)) - x)
- + abs((static_cast<int>(pos1.y)) - y);
- const Vector &pos2 = being2->getPosition();
- d2 = abs((static_cast<int>(pos2.x)) - x)
- + abs((static_cast<int>(pos2.y)) - y);
- }
- else
-#endif
- {
- d1 = abs(being1->getTileX() - x) + abs(being1->getTileY() - y);
- d2 = abs(being2->getTileX() - x) + abs(being2->getTileY() - y);
- }
+ const int d1 = abs(being1->getTileX() - x)
+ + abs(being1->getTileY() - y);
+ const int d2 = abs(being2->getTileX() - x)
+ + abs(being2->getTileY() - y);
if (d1 != d2)
return d1 < d2;
@@ -1269,7 +1256,7 @@ void ActorManager::printAllToChat() const
}
void ActorManager::printBeingsToChat(const ActorSprites &beings,
- const std::string &header) const
+ const std::string &header)
{
if (!debugChatTab)
return;
@@ -1294,7 +1281,7 @@ void ActorManager::printBeingsToChat(const ActorSprites &beings,
}
void ActorManager::printBeingsToChat(const std::vector<Being*> &beings,
- const std::string &header) const
+ const std::string &header)
{
if (!debugChatTab)
return;
diff --git a/src/actormanager.h b/src/actormanager.h
index 17bd696d6..f7e306b2a 100644
--- a/src/actormanager.h
+++ b/src/actormanager.h
@@ -211,11 +211,11 @@ class ActorManager final: public ConfigListener
void printAllToChat() const;
- void printBeingsToChat(const ActorSprites &beings,
- const std::string &header) const;
+ static void printBeingsToChat(const ActorSprites &beings,
+ const std::string &header);
- void printBeingsToChat(const std::vector<Being*> &beings,
- const std::string &header) const;
+ static void printBeingsToChat(const std::vector<Being*> &beings,
+ const std::string &header);
void getPlayerNames(StringVect &names,
const bool npcNames) const;
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp
index 93f8c6009..97424fbfb 100644
--- a/src/animatedsprite.cpp
+++ b/src/animatedsprite.cpp
@@ -294,7 +294,7 @@ void AnimatedSprite::draw(Graphics *const graphics,
if (image->getAlpha() != mAlpha)
image->setAlpha(mAlpha);
- graphics->drawImage2(image,
+ graphics->drawImage(image,
posX + mFrame->offsetX, posY + mFrame->offsetY);
}
diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp
index 1426e481e..bbb016525 100644
--- a/src/being/actorsprite.cpp
+++ b/src/being/actorsprite.cpp
@@ -21,15 +21,19 @@
#include "being/actorsprite.h"
+#include "animatedsprite.h"
#include "configuration.h"
#include "imagesprite.h"
#include "statuseffect.h"
-#include "being/actorspritelistener.h"
#include "being/localplayer.h"
#include "gui/theme.h"
+#include "listeners/actorspritelistener.h"
+
+#include "particle/particle.h"
+
#include "resources/resourcemanager.h"
#include "utils/checkutils.h"
diff --git a/src/being/actorsprite.h b/src/being/actorsprite.h
index f9876fa79..444232ddd 100644
--- a/src/being/actorsprite.h
+++ b/src/being/actorsprite.h
@@ -183,14 +183,7 @@ public:
{ return getPixelX() - mapTileSize / 2; }
int getActorY() const
- {
-#ifdef MANASERV_SUPPORT
- return getPixelY() + ((Net::getNetworkType() == ServerInfo::MANASERV)
- ? 15 : mapTileSize);
-#else
- return getPixelY() - mapTileSize;
-#endif
- }
+ { return getPixelY() - mapTileSize; }
protected:
/**
diff --git a/src/being/being.cpp b/src/being/being.cpp
index fef3ca53a..41c3bc40c 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -39,7 +39,8 @@
#include "particle/particle.h"
#include "particle/particleinfo.h"
-#include "gui/sdlfont.h"
+#include "gui/font.h"
+#include "gui/gui.h"
#include "gui/popups/speechbubble.h"
@@ -370,50 +371,7 @@ void Being::setDestination(const int dstX, const int dstY)
if (!mMap)
return;
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() != ServerInfo::MANASERV)
-#endif
- {
- setPath(mMap->findPath(mX, mY, dstX, dstY, getWalkMask()));
- return;
- }
-
-#ifdef MANASERV_SUPPORT
- // Don't handle flawed destinations from server...
- if (dstX == 0 || dstY == 0)
- return;
-
- // If the destination is unwalkable, don't bother trying to get there
- if (!mMap->getWalk(dstX / mapTileSize, dstY / mapTileSize))
- return;
-
- Position dest = mMap->checkNodeOffsets(getCollisionRadius(), getWalkMask(),
- dstX, dstY);
- Path thisPath = mMap->findPixelPath(static_cast<int>(mPos.x),
- static_cast<int>(mPos.y), dest.x, dest.y,
- static_cast<int>(getCollisionRadius()),
- static_cast<unsigned char>(getWalkMask()));
-
- if (thisPath.empty())
- {
- // If there is no path but the destination is on the same walkable tile,
- // we accept it.
- if (static_cast<int>(mPos.x) / mapTileSize == dest.x / mapTileSize
- && static_cast<int>(mPos.y) / mapTileSize == dest.y / mapTileSize)
- {
- mDest.x = static_cast<float>(dest.x);
- mDest.y = static_cast<float>(dest.y);
- }
- setPath(Path());
- return;
- }
-
- // The destination is valid, so we set it.
- mDest.x = static_cast<float>(dest.x);
- mDest.y = static_cast<float>(dest.y);
-
- setPath(thisPath);
-#endif
+ setPath(mMap->findPath(mX, mY, dstX, dstY, getWalkMask()));
}
void Being::clearPath()
@@ -427,12 +385,7 @@ void Being::setPath(const Path &path)
if (mPath.empty())
return;
-#ifdef MANASERV_SUPPORT
- if ((Net::getNetworkType() != ServerInfo::MANASERV) &&
- mAction != MOVE && mAction != DEAD)
-#else
if (mAction != MOVE && mAction != DEAD)
-#endif
{
nextTile();
mActionTime = tick_time;
@@ -519,7 +472,7 @@ void Being::setSpeech(const std::string &text, const std::string &channel,
mText = new Text(mSpeech,
getPixelX(), getPixelY() - getHeight(),
- gcn::Graphics::CENTER,
+ Graphics::CENTER,
&userPalette->getColor(UserPalette::PARTICLE),
true);
}
@@ -537,11 +490,11 @@ void Being::takeDamage(Being *const attacker, const int amount,
if (!userPalette || !attacker)
return;
- gcn::Font *font = nullptr;
+ Font *font = nullptr;
// TRANSLATORS: hit or miss message in attacks
const std::string damage = amount ? toString(amount) : type == FLEE ?
_("dodge") : _("miss");
- const gcn::Color *color;
+ const Color *color;
if (gui)
font = gui->getInfoParticleFont();
@@ -770,13 +723,8 @@ void Being::handleAttack(Being *const victim, const int damage,
else if (mInfo->getAttack(attackId))
fireMissile(victim, mInfo->getAttack(attackId)->mMissileParticle);
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() != ServerInfo::MANASERV)
-#endif
- {
- reset();
- mActionTime = tick_time;
- }
+ reset();
+ mActionTime = tick_time;
if (this != player_node)
{
@@ -823,13 +771,8 @@ void Being::handleSkill(Being *const victim, const int damage,
if (data)
fireMissile(victim, data->particle);
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() != ServerInfo::MANASERV)
-#endif
- {
- reset();
- mActionTime = tick_time;
- }
+ reset();
+ mActionTime = tick_time;
if (this != player_node)
{
@@ -1442,157 +1385,68 @@ void Being::logic()
}
int frameCount = static_cast<int>(getFrameCount());
-#ifdef MANASERV_SUPPORT
- if ((Net::getNetworkType() == ServerInfo::MANASERV) && (mAction != DEAD))
- {
- const Vector dest = (mPath.empty()) ?
- mDest : Vector(static_cast<float>(mPath.front().x),
- static_cast<float>(mPath.front().y));
- // This is a hack that stops NPCs from running off the map...
- if (mDest.x <= 0 && mDest.y <= 0)
- {
- BLOCK_END("Being::logic")
- return;
- }
-
- // The Vector representing the difference between current position
- // and the next destination path node.
- Vector dir = dest - mPos;
-
- const float nominalLength = dir.length();
+ switch (mAction)
+ {
+ case STAND:
+ case SIT:
+ case DEAD:
+ case HURT:
+ case SPAWN:
+ default:
+ break;
- // When we've not reached our destination, move to it.
- if (nominalLength > 0.0F && !mWalkSpeed.isNull())
+ case MOVE:
{
- // The deplacement of a point along a vector is calculated
- // using the Unit Vector (â) multiplied by the point speed.
- // â = a / ||a|| (||a|| is the a length.)
- // Then, diff = (dir/||dir||) * speed.
- const Vector normalizedDir = dir.normalized();
- Vector diff(normalizedDir.x * mWalkSpeed.x,
- normalizedDir.y * mWalkSpeed.y);
-
- // Test if we don't miss the destination by a move too far:
- if (diff.length() > nominalLength)
- {
- setPosition(mPos + dir);
-
- // Also, if the destination is reached, try to get the next
- // path point, if existing.
- if (!mPath.empty())
- mPath.pop_front();
- }
- // Otherwise, go to it using the nominal speed.
- else
+ if (static_cast<float>(get_elapsed_time(
+ mActionTime)) >= mSpeed)
{
- setPosition(mPos + diff);
- }
-
- if (mAction != MOVE)
- setAction(MOVE, 0);
-
- // Update the player sprite direction.
- // N.B.: We only change this if the distance is more than one pixel.
- if (nominalLength > 1.0F)
- {
- int direction = 0;
- const float dx = std::abs(dir.x);
- float dy = std::abs(dir.y);
-
- // When not using mouse for the player, we slightly prefer
- // UP and DOWN position, especially when walking diagonally.
- if (player_node && this == player_node &&
- !player_node->isPathSetByMouse())
- {
- dy = dy + 2;
- }
-
- if (dx > dy)
- direction |= (dir.x > 0) ? RIGHT : LEFT;
- else
- direction |= (dir.y > 0) ? DOWN : UP;
-
- setDirection(static_cast<uint8_t>(direction));
+ nextTile();
}
+ break;
}
- else if (!mPath.empty())
- {
- // If the current path node has been reached,
- // remove it and go to the next one.
- mPath.pop_front();
- }
- else if (mAction == MOVE)
- {
- setAction(STAND, 0);
- }
- }
- else
- if (Net::getNetworkType() != ServerInfo::MANASERV)
-#endif
- {
- switch (mAction)
- {
- case STAND:
- case SIT:
- case DEAD:
- case HURT:
- case SPAWN:
- default:
- break;
- case MOVE:
- {
- if (static_cast<float>(get_elapsed_time(
- mActionTime)) >= mSpeed)
- {
- nextTile();
- }
+ case ATTACK:
+ {
+ if (!mActionTime)
break;
- }
- case ATTACK:
+ int curFrame = 0;
+ if (mAttackSpeed)
{
- if (!mActionTime)
- break;
-
- int curFrame = 0;
- if (mAttackSpeed)
- {
- curFrame = (get_elapsed_time(mActionTime) * frameCount)
- / mAttackSpeed;
- }
+ curFrame = (get_elapsed_time(mActionTime) * frameCount)
+ / mAttackSpeed;
+ }
- if (this == player_node && curFrame >= frameCount)
- nextTile();
+ if (this == player_node && curFrame >= frameCount)
+ nextTile();
- break;
- }
+ break;
}
+ }
- if (mAction == MOVE)
- {
- const int xOffset = getXOffset();
- const int yOffset = getYOffset();
- int offset = xOffset;
- if (!offset)
- offset = yOffset;
+ if (mAction == MOVE)
+ {
+ const int xOffset = getXOffset();
+ const int yOffset = getYOffset();
+ int offset = xOffset;
+ if (!offset)
+ offset = yOffset;
- mSortOffsetY = (mOldHeight * mapTileSize / 2)
- + (mOffsetY * mapTileSize / 2)
- * (mapTileSize - abs(offset)) / mapTileSize;
- const int yOffset2 = yOffset - mSortOffsetY;
+ mSortOffsetY = (mOldHeight * mapTileSize / 2)
+ + (mOffsetY * mapTileSize / 2)
+ * (mapTileSize - abs(offset)) / mapTileSize;
+ const int yOffset2 = yOffset - mSortOffsetY;
- // Update pixel coordinates
- setPosition(static_cast<float>(mX * mapTileSize
- + mapTileSize / 2 + xOffset), static_cast<float>(
- mY * mapTileSize + mapTileSize + yOffset2));
- }
- else
- {
- setPosition(static_cast<float>(mX * mapTileSize + mapTileSize / 2),
- static_cast<float>(mY * mapTileSize + mapTileSize));
- }
+ // Update pixel coordinates
+ setPosition(static_cast<float>(mX * mapTileSize
+ + mapTileSize / 2 + xOffset), static_cast<float>(
+ mY * mapTileSize + mapTileSize + yOffset2));
+ }
+ else
+ {
+ setPosition(static_cast<float>(mX * mapTileSize + mapTileSize / 2),
+ static_cast<float>(mY * mapTileSize + mapTileSize));
}
if (mEmotionSprite)
@@ -1847,9 +1701,7 @@ void Being::drawSpeech(const int offsetX, const int offsetY)
mSpeechBubble->setPosition(px - (mSpeechBubble->getWidth() / 2),
py - getHeight() - (mSpeechBubble->getHeight()));
mSpeechBubble->setVisible(true);
-#ifdef USE_INTERNALGUICHAN
mSpeechBubble->requestMoveToBackground();
-#endif
}
else if (mSpeechTime > 0 && speech == TEXT_OVERHEAD)
{
@@ -1858,7 +1710,7 @@ void Being::drawSpeech(const int offsetX, const int offsetY)
if (!mText && userPalette)
{
mText = new Text(mSpeech, getPixelX(), getPixelY() - getHeight(),
- gcn::Graphics::CENTER, &Theme::getThemeColor(
+ Graphics::CENTER, &Theme::getThemeColor(
Theme::BUBBLE_TEXT), true);
}
}
@@ -2005,7 +1857,7 @@ void Being::showName()
displayName.append(", ").append(toString(getDamageTaken()));
}
- gcn::Font *font = nullptr;
+ Font *font = nullptr;
if (player_node && player_node->getTarget() == this
&& mType != MONSTER)
{
@@ -2021,12 +1873,12 @@ void Being::showName()
mDispName = new FlashText(displayName,
getPixelX() + mInfo->getNameOffsetX(),
getPixelY() + mInfo->getNameOffsetY(),
- gcn::Graphics::CENTER, mNameColor, font);
+ Graphics::CENTER, mNameColor, font);
}
else
{
mDispName = new FlashText(displayName, getPixelX(), getPixelY(),
- gcn::Graphics::CENTER, mNameColor, font);
+ Graphics::CENTER, mNameColor, font);
}
updateCoords();
@@ -2516,12 +2368,12 @@ void Being::drawSpriteAt(Graphics *const graphics,
graphics->setColor(userPalette->
getColorWithAlpha(UserPalette::PORTAL_HIGHLIGHT));
- graphics->fillRectangle(gcn::Rectangle(x, y,
+ graphics->fillRectangle(Rect(x, y,
mapTileSize, mapTileSize));
if (mDrawHotKeys && !mName.empty())
{
- gcn::Font *const font = gui->getFont();
+ Font *const font = gui->getFont();
if (font)
{
graphics->setColor(userPalette->getColor(UserPalette::BEING));
@@ -2542,7 +2394,7 @@ void Being::drawSpriteAt(Graphics *const graphics,
graphics->setColor(userPalette->getColorWithAlpha(
UserPalette::MONSTER_ATTACK_RANGE));
- graphics->fillRectangle(gcn::Rectangle(
+ graphics->fillRectangle(Rect(
x - attackRange, y - attackRange,
2 * attackRange + mapTileSize, 2 * attackRange + mapTileSize));
}
@@ -2607,14 +2459,14 @@ void Being::drawHpBar(Graphics *const graphics, const int maxHP, const int hp,
|| (!hp && maxHP == damage))
{
graphics->setColor(userPalette->getColorWithAlpha(color1));
- graphics->fillRectangle(gcn::Rectangle(
+ graphics->fillRectangle(Rect(
x, y, dx, height));
return;
}
else if (width - dx <= 0)
{
graphics->setColor(userPalette->getColorWithAlpha(color2));
- graphics->fillRectangle(gcn::Rectangle(
+ graphics->fillRectangle(Rect(
x, y, width, height));
return;
}
@@ -2624,26 +2476,25 @@ void Being::drawHpBar(Graphics *const graphics, const int maxHP, const int hp,
if (hp == maxHP)
{
graphics->setColor(userPalette->getColorWithAlpha(color1));
- graphics->fillRectangle(gcn::Rectangle(
+ graphics->fillRectangle(Rect(
x, y, dx, height));
return;
}
else if (width - dx <= 0)
{
graphics->setColor(userPalette->getColorWithAlpha(color2));
- graphics->fillRectangle(gcn::Rectangle(
+ graphics->fillRectangle(Rect(
x, y, width, height));
return;
}
}
graphics->setColor(userPalette->getColorWithAlpha(color1));
- graphics->fillRectangle(gcn::Rectangle(
+ graphics->fillRectangle(Rect(
x, y, dx, height));
graphics->setColor(userPalette->getColorWithAlpha(color2));
- graphics->fillRectangle(gcn::Rectangle(
- x + dx, y, width - dx, height));
+ graphics->fillRectangle(Rect(x + dx, y, width - dx, height));
}
void Being::setHP(const int hp)
@@ -3297,6 +3148,7 @@ void Being::removePet(const int id)
actorManager->erase(pet);
mPets.erase(it);
delete pet;
+ return;
}
}
}
diff --git a/src/being/being.h b/src/being/being.h
index b9039bce3..2521eb0c3 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -23,12 +23,8 @@
#ifndef BEING_BEING_H
#define BEING_BEING_H
-#include "equipment.h"
-
#include "resources/beinginfo.h"
-#include <guichan/color.hpp>
-
#include <map>
#include "localconsts.h"
@@ -45,6 +41,8 @@ static const int DEFAULT_BEING_HEIGHT = 32;
class AnimatedSprite;
class BeingCacheEntry;
+class Color;
+class Equipment;
class FlashText;
class Guild;
class ItemInfo;
@@ -474,17 +472,13 @@ class Being : public ActorSprite, public ConfigListener
}
/**
- * Sets the walk speed.
- * in pixels per second for eAthena,
- * in tiles per second for Manaserv.
+ * Sets the walk speed in pixels per second.
*/
void setWalkSpeed(Vector speed)
{ mWalkSpeed = speed; mSpeed = speed.x; }
/**
- * Gets the walk speed.
- * in pixels per second for eAthena,
- * in tiles per second for Manaserv (0.1 precision).
+ * Gets the walk speed in pixels per second.
*/
Vector getWalkSpeed() const A_WARN_UNUSED
{ return mWalkSpeed; }
@@ -967,7 +961,7 @@ class Being : public ActorSprite, public ConfigListener
* Holds a text object when the being displays it's name, 0 otherwise
*/
FlashText *mDispName;
- const gcn::Color *mNameColor;
+ const Color *mNameColor;
/** Engine-related infos about weapon. */
const ItemInfo *mEquippedWeapon;
@@ -977,7 +971,7 @@ class Being : public ActorSprite, public ConfigListener
Path mPath;
Text *mText;
- const gcn::Color *mTextColor;
+ const Color *mTextColor;
Vector mDest; /**< destination coordinates. */
@@ -1039,8 +1033,7 @@ class Being : public ActorSprite, public ConfigListener
/**
* Walk speed for x and y movement values.
- * In pixels per second for eAthena,
- * In pixels per ticks for Manaserv.
+ * In pixels per second.
* @see MILLISECONDS_IN_A_TICK
*/
Vector mWalkSpeed;
diff --git a/src/being/compoundsprite.cpp b/src/being/compoundsprite.cpp
index 27e48caa7..ea4a2067f 100644
--- a/src/being/compoundsprite.cpp
+++ b/src/being/compoundsprite.cpp
@@ -123,12 +123,12 @@ void CompoundSprite::draw(Graphics *const graphics,
if (mAlpha == 1.0F && mImage)
{
- graphics->drawImage2(mImage, posX + mOffsetX, posY + mOffsetY);
+ graphics->drawImage(mImage, posX + mOffsetX, posY + mOffsetY);
}
else if (mAlpha && mAlphaImage)
{
mAlphaImage->setAlpha(mAlpha);
- graphics->drawImage2(mAlphaImage,
+ graphics->drawImage(mAlphaImage,
posX + mOffsetX, posY + mOffsetY);
}
else
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 86db69d8d..3d9d06bef 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -23,6 +23,7 @@
#include "being/localplayer.h"
#include "actormanager.h"
+#include "animatedsprite.h"
#include "client.h"
#include "configuration.h"
#include "dropshortcut.h"
@@ -43,7 +44,6 @@
#include "input/keyboardconfig.h"
#include "gui/gui.h"
-#include "gui/sdlfont.h"
#include "gui/viewport.h"
#include "gui/windows/chatwindow.h"
@@ -51,7 +51,6 @@
#include "gui/windows/okdialog.h"
#include "gui/windows/outfitwindow.h"
#include "gui/windows/shopwindow.h"
-#include "gui/windows/skilldialog.h"
#include "gui/windows/socialwindow.h"
#include "gui/windows/updaterwindow.h"
@@ -68,6 +67,7 @@
#include "resources/iteminfo.h"
#include "resources/db/emotedb.h"
+#include "resources/db/weaponsdb.h"
#include "utils/gettext.h"
#include "utils/timer.h"
@@ -85,6 +85,8 @@ typedef std::map<int, Guild*>::const_iterator GuildMapCIter;
LocalPlayer *player_node = nullptr;
+class SkillDialog;
+
extern std::list<BeingCacheEntry*> beingInfoCache;
extern OkDialog *weightNotice;
extern int weightNoticeTime;
@@ -284,10 +286,6 @@ void LocalPlayer::logic()
mMessageTime--;
}
-#ifdef MANASERV_SUPPORT
- PlayerInfo::logic();
-#endif
-
if (mTarget)
{
if (mTarget->getType() == ActorSprite::NPC)
@@ -298,23 +296,10 @@ void LocalPlayer::logic()
else
{
// Find whether target is in range
-#ifdef MANASERV_SUPPORT
- const int rangeX =
- (Net::getNetworkType() == ServerInfo::MANASERV) ?
- static_cast<int>(abs(static_cast<int>(mTarget->getPosition().x
- - getPosition().x))) :
- static_cast<int>(abs(mTarget->getTileX() - getTileX()));
- const int rangeY =
- (Net::getNetworkType() == ServerInfo::MANASERV) ?
- static_cast<int>(abs(static_cast<int>(mTarget->getPosition().y
- - getPosition().y))) :
- static_cast<int>(abs(mTarget->getTileY() - getTileY()));
-#else
const int rangeX = static_cast<int>(
abs(mTarget->getTileX() - getTileX()));
const int rangeY = static_cast<int>(
abs(mTarget->getTileY() - getTileY()));
-#endif
const int attackRange = getAttackRange();
const TargetCursorType targetType = rangeX > attackRange ||
rangeY > attackRange ?
@@ -418,475 +403,58 @@ void LocalPlayer::setGMLevel(const int level)
}
}
-#ifdef MANASERV_SUPPORT
-Position LocalPlayer::getNextWalkPosition(const unsigned char dir) const
+void LocalPlayer::nextTile(unsigned char dir A_UNUSED = 0)
{
- // Compute where the next tile will be set.
- int dx = 0, dy = 0;
- if (dir & Being::UP)
- dy--;
- if (dir & Being::DOWN)
- dy++;
- if (dir & Being::LEFT)
- dx--;
- if (dir & Being::RIGHT)
- dx++;
-
- const Vector &pos = getPosition();
-
- // If no map or no direction is given, give back the current player position
- if (!mMap || (!dx && !dy))
- return Position(static_cast<int>(pos.x), static_cast<int>(pos.y));
-
- const int posX = static_cast<int>(pos.x);
- const int posY = static_cast<int>(pos.y);
- // Get the current tile pos and its offset
- const int tileX = posX / mMap->getTileWidth();
- const int tileY = posY / mMap->getTileHeight();
- const int offsetX = posX % mMap->getTileWidth();
- const int offsetY = posY % mMap->getTileHeight();
- const unsigned char walkMask = getWalkMask();
- const int radius = getCollisionRadius();
-
- // Get the walkability of every surrounding tiles.
- bool wTopLeft = mMap->getWalk(tileX - 1, tileY - 1, walkMask);
- const bool wTop = mMap->getWalk(tileX, tileY - 1, walkMask);
- bool wTopRight = mMap->getWalk(tileX + 1, tileY - 1, walkMask);
- const bool wLeft = mMap->getWalk(tileX - 1, tileY, walkMask);
- const bool wRight = mMap->getWalk(tileX + 1, tileY, walkMask);
- bool wBottomLeft = mMap->getWalk(tileX - 1, tileY + 1, walkMask);
- const bool wBottom = mMap->getWalk(tileX, tileY + 1, walkMask);
- bool wBottomRight = mMap->getWalk(tileX + 1, tileY + 1, walkMask);
-
- // Make diagonals unwalkable when both straight directions are blocking
- if (!wTop)
+ const Party *const party = Party::getParty(1);
+ if (party)
{
- if (!wRight)
- wTopRight = false;
- if (!wLeft)
- wTopLeft = false;
- }
- if (!wBottom)
- {
- if (!wRight)
- wBottomRight = false;
- if (!wLeft)
- wBottomLeft = false;
- }
-
- // We'll make tests for each desired direction
-
- // Handle diagonal cases by setting the way back to a straight direction
- // when necessary.
- if (dx && dy)
- {
- // Going top-right
- if (dx > 0 && dy < 0)
- {
- if (!wTopRight)
- {
- // Choose a straight direction when diagonal target is blocked
- if (!wTop && wRight)
- {
- dy = 0;
- }
- else if (wTop && !wRight)
- {
- dx = 0;
- }
- else if (!wTop && !wRight)
- {
- return Position(tileX * mapTileSize + mapTileSize - radius,
- tileY * mapTileSize + getCollisionRadius());
- }
- else // Both straight direction are walkable
- {
- // Go right when below the corner
- if (offsetY >= (offsetX / mMap->getTileHeight()
- - (offsetX / mMap->getTileWidth()
- * mMap->getTileHeight()) ))
- {
- dy = 0;
- }
- else // Go up otherwise
- {
- dx = 0;
- }
- }
- }
- else // The diagonal is walkable
- {
- return mMap->checkNodeOffsets(radius, walkMask,
- Position(posX + mapTileSize, posY - mapTileSize));
- }
- }
-
- // Going top-left
- if (dx < 0 && dy < 0)
+ PartyMember *const pm = party->getMember(getName());
+ if (pm)
{
- if (!wTopLeft)
- {
- // Choose a straight direction when diagonal target is blocked
- if (!wTop && wLeft)
- {
- dy = 0;
- }
- else if (wTop && !wLeft)
- {
- dx = 0;
- }
- else if (!wTop && !wLeft)
- {
- return Position(tileX * mapTileSize + radius,
- tileY * mapTileSize + radius);
- }
- else // Both straight direction are walkable
- {
- // Go left when below the corner
- if (offsetY >= (offsetX / mMap->getTileWidth()
- * mMap->getTileHeight()))
- {
- dy = 0;
- }
- else // Go up otherwise
- {
- dx = 0;
- }
- }
- }
- else // The diagonal is walkable
- {
- return mMap->checkNodeOffsets(radius, walkMask,
- Position(posX - mapTileSize, posY - mapTileSize));
- }
- }
-
- // Going bottom-left
- if (dx < 0 && dy > 0)
- {
- if (!wBottomLeft)
- {
- // Choose a straight direction when diagonal target is blocked
- if (!wBottom && wLeft)
- {
- dy = 0;
- }
- else if (wBottom && !wLeft)
- {
- dx = 0;
- }
- else if (!wBottom && !wLeft)
- {
- return Position(tileX * mapTileSize + radius,
- tileY * mapTileSize + mapTileSize - radius);
- }
- else // Both straight direction are walkable
- {
- // Go down when below the corner
- if (offsetY >= (offsetX / mMap->getTileHeight()
- - (offsetX / mMap->getTileWidth()
- * mMap->getTileHeight())))
- {
- dx = 0;
- }
- else // Go left otherwise
- {
- dy = 0;
- }
- }
- }
- else // The diagonal is walkable
- {
- return mMap->checkNodeOffsets(radius, walkMask,
- Position(posX - mapTileSize, posY + mapTileSize));
- }
- }
-
- // Going bottom-right
- if (dx > 0 && dy > 0)
- {
- if (!wBottomRight)
- {
- // Choose a straight direction when diagonal target is blocked
- if (!wBottom && wRight)
- {
- dy = 0;
- }
- else if (wBottom && !wRight)
- {
- dx = 0;
- }
- else if (!wBottom && !wRight)
- {
- return Position(tileX * mapTileSize + mapTileSize - radius,
- tileY * mapTileSize + mapTileSize - radius);
- }
- else // Both straight direction are walkable
- {
- // Go down when below the corner
- if (offsetY >= (offsetX / mMap->getTileWidth()
- * mMap->getTileHeight()))
- {
- dx = 0;
- }
- else // Go right otherwise
- {
- dy = 0;
- }
- }
- }
- else // The diagonal is walkable
- {
- return mMap->checkNodeOffsets(radius, walkMask,
- Position(posX + mapTileSize, posY + mapTileSize));
- }
+ pm->setX(mX);
+ pm->setY(mY);
}
- } // End of diagonal cases
+ }
- // Straight directions
- // Right direction
- if (dx > 0 && !dy)
+ if (mPath.empty())
{
- // If the straight destination is blocked,
- // Make the player go the closest possible.
- if (!wRight)
- {
- return Position(tileX * mapTileSize + mapTileSize - radius, posY);
- }
- else
- {
- if (!wTopRight)
- {
- // If we're going to collide with the top-right corner
- if (offsetY - radius < 0)
- {
- // We make the player corrects its offset
- // before going further
- return Position(tileX * mapTileSize + mapTileSize - radius,
- tileY * mapTileSize + radius);
- }
- }
+ if (mPickUpTarget)
+ pickUp(mPickUpTarget);
- if (!wBottomRight)
- {
- // If we're going to collide with the bottom-right corner
- if (offsetY + radius > mapTileSize)
- {
- // We make the player corrects its offset
- // before going further
- return Position(tileX * mapTileSize + mapTileSize - radius,
- tileY * mapTileSize + mapTileSize - radius);
- }
- }
- // If the way is clear, step up one checked tile ahead.
- return mMap->checkNodeOffsets(radius, walkMask,
- Position(posX + mapTileSize, posY));
- }
+ if (mWalkingDir)
+ startWalking(mWalkingDir);
}
-
- // Left direction
- if (dx < 0 && !dy)
+ else if (mPath.size() == 1)
{
- // If the straight destination is blocked,
- // Make the player go the closest possible.
- if (!wLeft)
- {
- return Position(tileX * mapTileSize + radius, posY);
- }
- else
- {
- if (!wTopLeft)
- {
- // If we're going to collide with the top-left corner
- if (offsetY - radius < 0)
- {
- // We make the player corrects its offset
- // before going further
- return Position(tileX * mapTileSize + radius,
- tileY * mapTileSize + radius);
- }
- }
-
- if (!wBottomLeft)
- {
- // If we're going to collide with the bottom-left corner
- if (offsetY + radius > mapTileSize)
- {
- // We make the player corrects its offset
- // before going further
- return Position(tileX * mapTileSize + radius,
- tileY * mapTileSize + mapTileSize - radius);
- }
- }
- // If the way is clear, step up one checked tile ahead.
- return mMap->checkNodeOffsets(radius, walkMask,
- Position(posX - mapTileSize, posY));
- }
+ if (mPickUpTarget)
+ pickUp(mPickUpTarget);
}
- // Up direction
- if (!dx && dy < 0)
+ if (mGoingToTarget && mTarget && withinAttackRange(mTarget))
{
- // If the straight destination is blocked,
- // Make the player go the closest possible.
- if (!wTop)
- {
- return Position(posX, tileY * mapTileSize + radius);
- }
- else
- {
- if (!wTopLeft)
- {
- // If we're going to collide with the top-left corner
- if (offsetX - radius < 0)
- {
- // We make the player corrects its offset
- // before going further
- return Position(tileX * mapTileSize + radius,
- tileY * mapTileSize + radius);
- }
- }
-
- if (!wTopRight)
- {
- // If we're going to collide with the top-right corner
- if (offsetX + radius > mapTileSize)
- {
- // We make the player corrects its offset
- // before going further
- return Position(tileX * mapTileSize + mapTileSize - radius,
- tileY * mapTileSize + radius);
- }
- }
- // If the way is clear, step up one checked tile ahead.
- return mMap->checkNodeOffsets(radius,
- walkMask, Position(posX, posY - mapTileSize));
- }
+ mAction = Being::STAND;
+ attack(mTarget, true);
+ mGoingToTarget = false;
+ mPath.clear();
+ return;
}
-
- // Down direction
- if (!dx && dy > 0)
+ else if (mGoingToTarget && !mTarget)
{
- // If the straight destination is blocked,
- // Make the player go the closest possible.
- if (!wBottom)
- {
- return Position(posX, tileY * mapTileSize + mapTileSize - radius);
- }
- else
- {
- if (!wBottomLeft)
- {
- // If we're going to collide with the bottom-left corner
- if (offsetX - radius < 0)
- {
- // We make the player corrects its offset
- // before going further
- return Position(tileX * mapTileSize + radius,
- tileY * mapTileSize + mapTileSize - radius);
- }
- }
-
- if (!wBottomRight)
- {
- // If we're going to collide with the bottom-right corner
- if (offsetX + radius > mapTileSize)
- {
- // We make the player corrects its offset
- // before going further
- return Position(tileX * mapTileSize + mapTileSize - radius,
- tileY * mapTileSize + mapTileSize - radius);
- }
- }
- // If the way is clear, step up one checked tile ahead.
- return mMap->checkNodeOffsets(radius,
- walkMask, Position(posX, posY + mapTileSize));
- }
+ mGoingToTarget = false;
+ mPath.clear();
}
- // Return the current position if everything else has failed.
- return Position(posX, posY);
-}
-#endif
-
-void LocalPlayer::nextTile(unsigned char dir A_UNUSED = 0)
-{
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() != ServerInfo::MANASERV)
-#endif
+ if (mPath.empty())
{
- const Party *const party = Party::getParty(1);
- if (party)
- {
- PartyMember *const pm = party->getMember(getName());
- if (pm)
- {
- pm->setX(mX);
- pm->setY(mY);
- }
- }
-
- if (mPath.empty())
- {
- if (mPickUpTarget)
- pickUp(mPickUpTarget);
-
- if (mWalkingDir)
- startWalking(mWalkingDir);
- }
- else if (mPath.size() == 1)
- {
- if (mPickUpTarget)
- pickUp(mPickUpTarget);
- }
-
- if (mGoingToTarget && mTarget && withinAttackRange(mTarget))
- {
- mAction = Being::STAND;
- attack(mTarget, true);
- mGoingToTarget = false;
- mPath.clear();
- return;
- }
- else if (mGoingToTarget && !mTarget)
- {
- mGoingToTarget = false;
- mPath.clear();
- }
-
- if (mPath.empty())
- {
- if (mNavigatePath.empty() || mAction != MOVE)
- setAction(STAND);
- else
- mNextStep = true;
- }
+ if (mNavigatePath.empty() || mAction != MOVE)
+ setAction(STAND);
else
- {
- Being::nextTile();
- }
+ mNextStep = true;
}
-#ifdef MANASERV_SUPPORT
else
{
- if (!mMap || !dir)
- return;
-
- const Vector &pos = getPosition();
- const Position destination = getNextWalkPosition(dir);
-
- if (static_cast<int>(pos.x) != destination.x
- || static_cast<int>(pos.y) != destination.y)
- {
- setDestination(destination.x, destination.y);
- }
- else if (dir != mDirection)
- {
- Net::getPlayerHandler()->setDirection(dir);
- setDirection(dir);
- }
+ Being::nextTile();
}
-#endif
}
bool LocalPlayer::pickUp(FloorItem *const item)
@@ -914,29 +482,18 @@ bool LocalPlayer::pickUp(FloorItem *const item)
}
else if (mPickUpType >= 4 && mPickUpType <= 6)
{
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() == ServerInfo::MANASERV)
- {
- setDestination(item->getPixelX() + 16, item->getPixelY() + 16);
- mPickUpTarget = item;
- mPickUpTarget->addActorSpriteListener(this);
- }
+ const Vector &playerPos = getPosition();
+ const Path debugPath = mMap->findPath(
+ static_cast<int>(playerPos.x - mapTileSize / 2) / mapTileSize,
+ static_cast<int>(playerPos.y - mapTileSize) / mapTileSize,
+ item->getTileX(), item->getTileY(), getWalkMask(), 0);
+ if (!debugPath.empty())
+ navigateTo(item->getTileX(), item->getTileY());
else
-#endif
- {
- const Vector &playerPos = getPosition();
- const Path debugPath = mMap->findPath(
- static_cast<int>(playerPos.x - mapTileSize / 2) / mapTileSize,
- static_cast<int>(playerPos.y - mapTileSize) / mapTileSize,
- item->getTileX(), item->getTileY(), getWalkMask(), 0);
- if (!debugPath.empty())
- navigateTo(item->getTileX(), item->getTileY());
- else
- setDestination(item->getTileX(), item->getTileY());
+ setDestination(item->getTileX(), item->getTileY());
- mPickUpTarget = item;
- mPickUpTarget->addActorSpriteListener(this);
- }
+ mPickUpTarget = item;
+ mPickUpTarget->addActorSpriteListener(this);
}
return true;
}
@@ -1022,17 +579,7 @@ void LocalPlayer::setDestination(const int x, const int y)
}
Being::setDestination(x, y);
-
-#ifdef MANASERV_SUPPORT
- // Manaserv:
- // If the destination given to being class is accepted,
- // we inform the Server.
- if ((x == mDest.x && y == mDest.y)
- || Net::getNetworkType() != ServerInfo::MANASERV)
-#endif
- {
- Net::getPlayerHandler()->setDestination(x, y, mDirection);
- }
+ Net::getPlayerHandler()->setDestination(x, y, mDirection);
}
}
}
@@ -1040,51 +587,11 @@ void LocalPlayer::setDestination(const int x, const int y)
void LocalPlayer::setWalkingDir(const unsigned char dir)
{
// This function is called by Game::handleInput()
-
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() == ServerInfo::MANASERV)
- {
- // First if player is pressing key for the direction he is already
- // going, do nothing more...
-
- // Else if he is pressing a key, and its different from what he has
- // been pressing, stop (do not send this stop to the server) and
- // start in the new direction
- if (dir && (dir != getWalkingDir()))
- stopWalking(false);
-
- // Else, he is not pressing a key,
- // and the current path hasn't been sent by mouse,
- // then, stop (sending to server).
- else if (!dir)
- {
- if (!mPathSetByMouse)
- stopWalking(true);
- return;
- }
-
- // If the delay to send another walk message to the server hasn't
- // expired, don't do anything or we could get disconnected for
- // spamming the server
- if (get_elapsed_time(mLocalWalkTime) < walkingKeyboardDelay)
- return;
- }
-#endif
-
mWalkingDir = dir;
// If we're not already walking, start walking.
if (mAction != MOVE && dir)
- {
startWalking(dir);
- }
-#ifdef MANASERV_SUPPORT
- else if (mAction == MOVE && (Net::getNetworkType()
- == ServerInfo::MANASERV))
- {
- nextTile(dir);
- }
-#endif
}
void LocalPlayer::startWalking(const unsigned char dir)
@@ -1098,18 +605,7 @@ void LocalPlayer::startWalking(const unsigned char dir)
if (mAction == MOVE && !mPath.empty())
{
// Just finish the current action, otherwise we get out of sync
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() == ServerInfo::MANASERV)
- {
- const Vector &pos = getPosition();
- Being::setDestination(static_cast<int>(pos.x),
- static_cast<int>(pos.y));
- }
- else
-#endif
- {
- Being::setDestination(mX, mY);
- }
+ Being::setDestination(mX, mY);
return;
}
@@ -1123,43 +619,32 @@ void LocalPlayer::startWalking(const unsigned char dir)
if (dir & RIGHT)
dx++;
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() != ServerInfo::MANASERV)
-#endif
- {
- const unsigned char walkMask = getWalkMask();
- // Prevent skipping corners over colliding tiles
- if (dx && !mMap->getWalk(mX + dx, mY, walkMask))
- dx = 0;
- if (dy && !mMap->getWalk(mX, mY + dy, walkMask))
- dy = 0;
+ const unsigned char walkMask = getWalkMask();
+ // Prevent skipping corners over colliding tiles
+ if (dx && !mMap->getWalk(mX + dx, mY, walkMask))
+ dx = 0;
+ if (dy && !mMap->getWalk(mX, mY + dy, walkMask))
+ dy = 0;
- // Choose a straight direction when diagonal target is blocked
- if (dx && dy && !mMap->getWalk(mX + dx, mY + dy, walkMask))
- dx = 0;
+ // Choose a straight direction when diagonal target is blocked
+ if (dx && dy && !mMap->getWalk(mX + dx, mY + dy, walkMask))
+ dx = 0;
- // Walk to where the player can actually go
- if ((dx || dy) && mMap->getWalk(mX + dx, mY + dy, walkMask))
- {
- setDestination(mX + dx, mY + dy);
- }
- else if (dir != mDirection)
- {
- // If the being can't move, just change direction
+ // Walk to where the player can actually go
+ if ((dx || dy) && mMap->getWalk(mX + dx, mY + dy, walkMask))
+ {
+ setDestination(mX + dx, mY + dy);
+ }
+ else if (dir != mDirection)
+ {
+ // If the being can't move, just change direction
// if (client->limitPackets(PACKET_DIRECTION))
- {
- Net::getPlayerHandler()->setDirection(dir);
- setDirection(dir);
- }
+ {
+ Net::getPlayerHandler()->setDirection(dir);
+ setDirection(dir);
}
}
-#ifdef MANASERV_SUPPORT
- else
- {
- nextTile(dir);
- }
-#endif
}
void LocalPlayer::stopWalking(const bool sendToServer)
@@ -1236,18 +721,6 @@ bool LocalPlayer::emote(const uint8_t emotion)
void LocalPlayer::attack(Being *const target, const bool keep,
const bool dontChangeEquipment)
{
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() == ServerInfo::MANASERV)
- {
- if (mLastAction != -1)
- return;
-
- // Can only attack when standing still
- if (mAction != STAND && mAction != ATTACK)
- return;
- }
-#endif
-
mKeepAttacking = keep;
if (!target || target->getType() == ActorSprite::NPC)
@@ -1256,59 +729,30 @@ void LocalPlayer::attack(Being *const target, const bool keep,
if (mTarget != target)
setTarget(target);
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() == ServerInfo::MANASERV)
- {
- const Vector &plaPos = this->getPosition();
- const Vector &tarPos = mTarget->getPosition();
- const int dist_x = static_cast<int>(plaPos.x - tarPos.x);
- const int dist_y = static_cast<int>(plaPos.y - tarPos.y);
+ const int dist_x = target->getTileX() - mX;
+ const int dist_y = target->getTileY() - mY;
- if (abs(dist_y) >= abs(dist_x))
- {
- if (dist_y < 0)
- setDirection(DOWN);
- else
- setDirection(UP);
- }
- else
- {
- if (dist_x < 0)
- setDirection(RIGHT);
- else
- setDirection(LEFT);
- }
+ // Must be standing or sitting to attack
+ if (mAction != STAND && mAction != SIT)
+ return;
- mLastAction = tick_time;
+ if (abs(dist_y) >= abs(dist_x))
+ {
+ if (dist_y > 0)
+ setDirection(DOWN);
+ else
+ setDirection(UP);
}
else
-#endif
{
- const int dist_x = target->getTileX() - mX;
- const int dist_y = target->getTileY() - mY;
-
- // Must be standing or sitting to attack
- if (mAction != STAND && mAction != SIT)
- return;
-
- if (abs(dist_y) >= abs(dist_x))
- {
- if (dist_y > 0)
- setDirection(DOWN);
- else
- setDirection(UP);
- }
+ if (dist_x > 0)
+ setDirection(RIGHT);
else
- {
- if (dist_x > 0)
- setDirection(RIGHT);
- else
- setDirection(LEFT);
- }
-
- mActionTime = tick_time;
+ setDirection(LEFT);
}
+ mActionTime = tick_time;
+
if (target->getType() != Being::PLAYER || checAttackPermissions(target))
{
setAction(ATTACK);
@@ -1322,11 +766,7 @@ void LocalPlayer::attack(Being *const target, const bool keep,
Net::getPlayerHandler()->attack(target->getId(), mServerAttack);
}
-#ifdef MANASERV_SUPPORT
- if ((Net::getNetworkType() != ServerInfo::MANASERV) && !keep)
-#else
if (!keep)
-#endif
stopAttack();
}
@@ -1474,20 +914,8 @@ bool LocalPlayer::withinAttackRange(const Being *const target,
if (fixDistance && range == 1)
range = 2;
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() == ServerInfo::MANASERV)
- {
- const Vector &targetPos = target->getPosition();
- const Vector &pos = getPosition();
- dx = static_cast<int>(abs(static_cast<int>(targetPos.x - pos.x)));
- dy = static_cast<int>(abs(static_cast<int>(targetPos.y - pos.y)));
- }
- else
-#endif
- {
- dx = static_cast<int>(abs(target->getTileX() - mX));
- dy = static_cast<int>(abs(target->getTileY() - mY));
- }
+ dx = static_cast<int>(abs(target->getTileX() - mX));
+ dy = static_cast<int>(abs(target->getTileY() - mY));
return !(dx > range || dy > range);
}
@@ -1497,22 +925,9 @@ void LocalPlayer::setGotoTarget(Being *const target)
return;
mPickUpTarget = nullptr;
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() == ServerInfo::MANASERV)
- {
- mTarget = target;
- mGoingToTarget = true;
- const Vector &targetPos = target->getPosition();
- setDestination(static_cast<int>(targetPos.x),
- static_cast<int>(targetPos.y));
- }
- else
-#endif
- {
- setTarget(target);
- mGoingToTarget = true;
- setDestination(target->getTileX(), target->getTileY());
- }
+ setTarget(target);
+ mGoingToTarget = true;
+ setDestination(target->getTileX(), target->getTileY());
}
void LocalPlayer::handleStatusEffect(StatusEffect *const effect,
@@ -2336,23 +1751,14 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const
// if attack distance for sword
if (allowSword)
{
- // finding sword
- item = inv->findItem(571, 0);
-
- if (!item)
- item = inv->findItem(570, 0);
-
- if (!item)
- item = inv->findItem(579, 0);
-
- if (!item)
- item = inv->findItem(867, 0);
-
- if (!item)
- item = inv->findItem(536, 0);
-
- if (!item)
- item = inv->findItem(758, 0);
+ // searching swords
+ const WeaponsInfos &swords = WeaponsDB::getSwords();
+ FOR_EACH (WeaponsInfosIter, it, swords)
+ {
+ item = inv->findItem(*it, 0);
+ if (item)
+ break;
+ }
// no swords
if (!item)
@@ -2365,10 +1771,14 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const
// if need equip shield too
if (mAttackWeaponType == 3)
{
- // finding shield
- item = inv->findItem(601, 0);
- if (!item)
- item = inv->findItem(602, 0);
+ // searching shield
+ const WeaponsInfos &shields = WeaponsDB::getShields();
+ FOR_EACH (WeaponsInfosIter, it, shields)
+ {
+ item = inv->findItem(*it, 0);
+ if (item)
+ break;
+ }
if (item && !item->isEquipped())
PlayerInfo::equipItem(item, true);
}
@@ -2376,11 +1786,14 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const
// big distance. allowed only bow
else
{
- // finding bow
- item = inv->findItem(545, 0);
-
- if (!item)
- item = inv->findItem(530, 0);
+ // searching bow
+ const WeaponsInfos &bows = WeaponsDB::getBows();
+ FOR_EACH (WeaponsInfosIter, it, bows)
+ {
+ item = inv->findItem(*it, 0);
+ if (item)
+ break;
+ }
// no bow
if (!item)
@@ -2827,24 +2240,24 @@ void LocalPlayer::crazyMoveA()
move(1, -1);
break;
case 'f':
- if (mDirection | UP)
+ if (mDirection & UP)
dy = -1;
- else if (mDirection | DOWN)
+ else if (mDirection & DOWN)
dy = 1;
- if (mDirection | LEFT)
+ if (mDirection & LEFT)
dx = -1;
- else if (mDirection | RIGHT)
+ else if (mDirection & RIGHT)
dx = 1;
move(dx, dy);
break;
case 'b':
- if (mDirection | UP)
+ if (mDirection & UP)
dy = 1;
- else if (mDirection | DOWN)
+ else if (mDirection & DOWN)
dy = -1;
- if (mDirection | LEFT)
+ if (mDirection & LEFT)
dx = 1;
- else if (mDirection | RIGHT)
+ else if (mDirection & RIGHT)
dx = -1;
move(dx, dy);
break;
@@ -3192,16 +2605,6 @@ bool LocalPlayer::pickUpItems(int pickUpType)
void LocalPlayer::moveByDirection(const unsigned char dir)
{
int dx = 0, dy = 0;
-#ifdef MANASERV_SUPPORT
- if (dir & UP)
- dy -= mapTileSize;
- if (dir & DOWN)
- dy += mapTileSize;
- if (dir & LEFT)
- dx -= mapTileSize;
- if (dir & RIGHT)
- dx += mapTileSize;
-#else
if (dir & UP)
dy--;
if (dir & DOWN)
@@ -3210,8 +2613,6 @@ void LocalPlayer::moveByDirection(const unsigned char dir)
dx--;
if (dir & RIGHT)
dx++;
-#endif
-
move(dx, dy);
}
@@ -4385,7 +3786,7 @@ void LocalPlayer::setTestParticle(const std::string &fileName,
}
}
-void AwayListener::action(const gcn::ActionEvent &event)
+void AwayListener::action(const ActionEvent &event)
{
if (event.getId() == "ok" && player_node && player_node->getAway())
{
diff --git a/src/being/localplayer.h b/src/being/localplayer.h
index 6ba12bd56..5664b03b6 100644
--- a/src/being/localplayer.h
+++ b/src/being/localplayer.h
@@ -23,14 +23,14 @@
#ifndef BEING_LOCALPLAYER_H
#define BEING_LOCALPLAYER_H
-#include "depricatedlistener.h"
+#include "listeners/depricatedlistener.h"
-#include "being/actorspritelistener.h"
#include "being/being.h"
#include "gui/userpalette.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/actorspritelistener.h"
#include <vector>
@@ -41,10 +41,10 @@ class FloorItem;
class Map;
class OkDialog;
-class AwayListener final : public gcn::ActionListener
+class AwayListener final : public ActionListener
{
public:
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
};
/**
diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp
index c9b10b4a6..728fe786f 100644
--- a/src/being/playerinfo.cpp
+++ b/src/being/playerinfo.cpp
@@ -48,11 +48,6 @@ int mCharId = 0;
Inventory *mInventory = nullptr;
Equipment *mEquipment = nullptr;
-#ifdef MANASERV_SUPPORT
-std::map<int, Special> mSpecials;
-signed char mSpecialRechargeUpdateNeeded = 0;
-#endif
-
bool mTrading = false;
int mLevelProgress = 0;
std::set<int> mProtectedItems;
@@ -365,20 +360,6 @@ int getCharId()
void logic()
{
-#ifdef MANASERV_SUPPORT
- if ((mSpecialRechargeUpdateNeeded % 11) == 0)
- {
- mSpecialRechargeUpdateNeeded = 0;
- FOR_EACH (SpecialsMap::iterator, it, mSpecials)
- {
- Special &special = it->second;
- special.currentMana += special.recharge;
- if (special.currentMana > special.neededMana)
- special.currentMana = special.neededMana;
- }
- }
- mSpecialRechargeUpdateNeeded++;
-#endif
}
bool isTrading()
diff --git a/src/being/playerrelations.cpp b/src/being/playerrelations.cpp
index a04c77e76..4404791ca 100644
--- a/src/being/playerrelations.cpp
+++ b/src/being/playerrelations.cpp
@@ -30,6 +30,8 @@
#include "utils/dtor.h"
#include "utils/gettext.h"
+#include "listeners/playerrelationslistener.h"
+
#include <algorithm>
#include "debug.h"
diff --git a/src/being/playerrelations.h b/src/being/playerrelations.h
index 360930879..c9a884d2e 100644
--- a/src/being/playerrelations.h
+++ b/src/being/playerrelations.h
@@ -25,25 +25,24 @@
#include "utils/stringvector.h"
-#include "being/playerrelationslistener.h"
-
#include <list>
#include <map>
#include "localconsts.h"
class Being;
+class PlayerRelationsListener;
struct PlayerRelation final
{
- static const unsigned int EMOTE = (1 << 0);
- static const unsigned int SPEECH_FLOAT = (1 << 1);
- static const unsigned int SPEECH_LOG = (1 << 2);
- static const unsigned int WHISPER = (1 << 3);
- static const unsigned int TRADE = (1 << 4);
- static const unsigned int INVISIBLE = (1 << 5);
- static const unsigned int BLACKLIST = (1 << 6);
- static const unsigned int ENEMY = (1 << 7);
+ static const unsigned int EMOTE = (1U << 0);
+ static const unsigned int SPEECH_FLOAT = (1U << 1);
+ static const unsigned int SPEECH_LOG = (1U << 2);
+ static const unsigned int WHISPER = (1U << 3);
+ static const unsigned int TRADE = (1U << 4);
+ static const unsigned int INVISIBLE = (1U << 5);
+ static const unsigned int BLACKLIST = (1U << 6);
+ static const unsigned int ENEMY = (1U << 7);
static const unsigned int RELATIONS_NR = 7;
static const unsigned int RELATION_PERMISSIONS[RELATIONS_NR];
diff --git a/src/client.cpp b/src/client.cpp
index ab3add135..5d635f522 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -85,6 +85,8 @@
#include "net/netconsts.h"
#include "net/partyhandler.h"
+#include "particle/particle.h"
+
#include "resources/imagehelper.h"
#include "resources/openglimagehelper.h"
#include "resources/surfaceimagehelper.h"
@@ -101,18 +103,15 @@
#include "resources/db/moddb.h"
#include "resources/db/monsterdb.h"
#include "resources/db/npcdb.h"
-#ifdef MANASERV_SUPPORT
-#include "resources/db/specialdb.h"
-#endif
#include "resources/db/palettedb.h"
#include "resources/db/petdb.h"
+#include "resources/db/weaponsdb.h"
#include "utils/base64.h"
#include "utils/cpu.h"
#include "utils/files.h"
#include "utils/fuzzer.h"
#include "utils/gettext.h"
-#include "utils/files.h"
#include "utils/mkdir.h"
#include "utils/paths.h"
#include "utils/physfstools.h"
@@ -174,7 +173,7 @@ UserPalette *userPalette = nullptr;
SoundManager soundManager;
RenderType openGLMode = RENDER_SOFTWARE;
-void ErrorListener::action(const gcn::ActionEvent &event)
+void ErrorListener::action(const ActionEvent &event)
{
if (event.getId() == "yes")
openBrowser(client->getSupportUrl());
@@ -193,26 +192,26 @@ int textures_count = 0;
extern "C" char const *_nl_locale_name_default(void);
#endif
-class AccountListener final : public gcn::ActionListener
+class AccountListener final : public ActionListener
{
public:
- void action(const gcn::ActionEvent &)
+ void action(const ActionEvent &)
{
client->setState(STATE_CHAR_SELECT);
}
} accountListener;
-class LoginListener final : public gcn::ActionListener
+class LoginListener final : public ActionListener
{
public:
- void action(const gcn::ActionEvent &)
+ void action(const ActionEvent &)
{
client->setState(STATE_PRE_LOGIN);
}
} loginListener;
Client::Client(const Options &options) :
- gcn::ActionListener(),
+ ActionListener(),
mOptions(options),
mConfigDir(),
mServerConfigDir(),
@@ -613,10 +612,10 @@ static void updateProgress(int cnt)
{
const int progress = cnt + loadingProgressCounter;
const int h = mainGraphics->mHeight;
- mainGraphics->setColor(gcn::Color(255, 255, 255));
+ mainGraphics->setColor(Color(255, 255, 255));
const int maxSize = mainGraphics->mWidth - 100;
const int width = maxSize * progress / 450;
- mainGraphics->fillRectangle(gcn::Rectangle(50, h - 100, width, 50));
+ mainGraphics->fillRectangle(Rect(50, h - 100, width, 50));
mainGraphics->updateScreen();
}
@@ -837,6 +836,7 @@ void Client::gameClear()
MonsterDB::unload();
NPCDB::unload();
AvatarDB::unload();
+ WeaponsDB::unload();
PaletteDB::unload();
PETDB::unload();
StatusEffect::unload();
@@ -1351,7 +1351,7 @@ int Client::gameExec()
if (mOptions.chooseDefault)
{
static_cast<WorldSelectDialog*>(mCurrentDialog)
- ->action(gcn::ActionEvent(nullptr, "ok"));
+ ->action(ActionEvent(nullptr, "ok"));
}
}
}
@@ -1463,10 +1463,8 @@ int Client::gameExec()
ItemDB::load();
Being::load();
MonsterDB::load();
-#ifdef MANASERV_SUPPORT
- SpecialDB::load();
-#endif
AvatarDB::load();
+ WeaponsDB::load();
NPCDB::load();
PETDB::load();
EmoteDB::load();
@@ -1529,8 +1527,7 @@ int Client::gameExec()
mCurrentDialog = new ConnectionDialog(
// TRANSLATORS: connection dialog header
_("Connecting to the game server"),
- Net::getNetworkType() != ServerInfo::MANASERV ?
- STATE_CHOOSE_SERVER : STATE_SWITCH_CHARACTER);
+ STATE_CHOOSE_SERVER);
mCurrentDialog->postInit();
Net::getGameHandler()->connect();
BLOCK_END("Client::gameExec STATE_CONNECT_GAME")
@@ -1853,7 +1850,7 @@ void Client::optionChanged(const std::string &name)
}
}
-void Client::action(const gcn::ActionEvent &event)
+void Client::action(const ActionEvent &event)
{
std::string tab;
const std::string &eventId = event.getId();
@@ -1913,6 +1910,12 @@ void Client::initRootDir()
Configuration portable;
portable.init(portableName);
+ if (mOptions.brandingPath.empty())
+ {
+ branding.init(portableName);
+ branding.setDefaultValues(getBrandingDefaults());
+ }
+
logger->log("Portable file: %s", portableName.c_str());
if (mOptions.localDataDir.empty())
diff --git a/src/client.h b/src/client.h
index 22567ae94..0e6528ca3 100644
--- a/src/client.h
+++ b/src/client.h
@@ -23,11 +23,11 @@
#ifndef CLIENT_H
#define CLIENT_H
-#include "configlistener.h"
+#include "listeners/configlistener.h"
#include "net/serverinfo.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
#include <SDL.h>
@@ -57,10 +57,10 @@ extern unsigned int tmwServerVersion;
extern int start_time;
extern int textures_count;
-class ErrorListener : public gcn::ActionListener
+class ErrorListener : public ActionListener
{
public:
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
};
extern std::string errorMessage;
@@ -142,7 +142,8 @@ struct PacketLimit
* The core part of the client. This class initializes all subsystems, runs
* the event loop, and shuts everything down again.
*/
-class Client final : public ConfigListener, public gcn::ActionListener
+class Client final : public ConfigListener,
+ public ActionListener
{
public:
/**
@@ -301,7 +302,7 @@ public:
void optionChanged(const std::string &name) override final;
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void initTradeFilter() const;
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp
index 6d3881432..ef8acc26c 100644
--- a/src/commandhandler.cpp
+++ b/src/commandhandler.cpp
@@ -22,6 +22,8 @@
#include "commandhandler.h"
+#include "commands.h"
+
#include "input/inputmanager.h"
#include "gui/widgets/tabs/chattab.h"
diff --git a/src/commandhandler.h b/src/commandhandler.h
index de1561d74..b2b74d77d 100644
--- a/src/commandhandler.h
+++ b/src/commandhandler.h
@@ -23,15 +23,16 @@
#ifndef COMMANDHANDLER_H
#define COMMANDHANDLER_H
-#include "commands.h"
-
#include <list>
+#include <map>
#include <string>
#include "localconsts.h"
class ChatTab;
+struct CommandInfo;
+
extern ChatTab *localChatTab;
typedef std::map<std::string, const CommandInfo*> CommandsMap;
diff --git a/src/commands.cpp b/src/commands.cpp
index 04cd84166..0cc5cee8a 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -1024,7 +1024,7 @@ impHandler0(cacheInfo)
return;
/*
- SDLFont *const font = dynamic_cast<SDLFont *const>(chatWindow->getFont());
+ Font *const font = chatWindow->getFont();
if (!font)
return;
@@ -1323,7 +1323,8 @@ static int uploadUpdate(void *ptr,
static void uploadFile(const std::string &str,
const std::string &fileName,
- const std::string &addStr)
+ const std::string &addStr,
+ ChatTab *const tab)
{
UploadChatInfo *const info = new UploadChatInfo();
Net::Download *const upload = new Net::Download(info,
@@ -1333,35 +1334,39 @@ static void uploadFile(const std::string &str,
info->upload = upload;
info->text = str;
info->addStr = addStr;
+ info->tab = tab;
upload->setFile(fileName);
upload->start();
}
-impHandler0(uploadConfig)
+impHandler2(uploadConfig)
{
uploadFile(_("Uploaded config into:"),
config.getFileName(),
- "?xml");
+ "?xml",
+ tab);
}
-impHandler0(uploadServerConfig)
+impHandler2(uploadServerConfig)
{
uploadFile(_("Uploaded server config into:"),
serverConfig.getFileName(),
- "?xml");
+ "?xml",
+ tab);
}
-impHandler0(uploadLog)
+impHandler2(uploadLog)
{
uploadFile(_("Uploaded log into:"),
client->getLogFileName(),
- "?txt");
+ "?txt",
+ tab);
}
impHandler0(testsdlfont)
{
#if defined USE_OPENGL && defined DEBUG_SDLFONT
- SDLFont *font = new SDLFont("fonts/dejavusans.ttf", 18);
+ Font *font = new Font("fonts/dejavusans.ttf", 18);
timespec time1;
timespec time2;
NullOpenGLGraphics *nullGraphics = new NullOpenGLGraphics;
diff --git a/src/configuration.cpp b/src/configuration.cpp
index d4b9f122b..ed2adfc61 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -22,8 +22,10 @@
#include "configuration.h"
-#include "configlistener.h"
#include "logger.h"
+#include "variabledata.h"
+
+#include "listeners/configlistener.h"
#include "utils/paths.h"
diff --git a/src/defaults.cpp b/src/defaults.cpp
index c343f9f11..7a110a539 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -22,6 +22,7 @@
#include "defaults.h"
#include "graphicsmanager.h"
+#include "variabledata.h"
#include "being/being.h"
diff --git a/src/defaults.h b/src/defaults.h
index e4ba4d5ae..abc9eb50c 100644
--- a/src/defaults.h
+++ b/src/defaults.h
@@ -22,13 +22,13 @@
#ifndef DEFAULTS_H
#define DEFAULTS_H
-#include "variabledata.h"
-
#include <map>
#include <string>
#include "localconsts.h"
+class VariableData;
+
typedef std::map<std::string, VariableData*> DefaultsData;
VariableData* createData(const int defData) A_WARN_UNUSED;
diff --git a/src/depricatedevent.cpp b/src/depricatedevent.cpp
index 8d021e2f3..fc499c47b 100644
--- a/src/depricatedevent.cpp
+++ b/src/depricatedevent.cpp
@@ -21,9 +21,10 @@
#include "depricatedevent.h"
-#include "depricatedlistener.h"
#include "variabledata.h"
+#include "listeners/depricatedlistener.h"
+
#include "debug.h"
DepricatedListenMap DepricatedEvent::mBindings;
diff --git a/src/guichan/include/guichan/actionevent.hpp b/src/events/actionevent.h
index b0f75a039..25f936cdd 100644
--- a/src/guichan/include/guichan/actionevent.hpp
+++ b/src/events/actionevent.h
@@ -61,73 +61,76 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef GCN_ACTIONEVENT_HPP
-#define GCN_ACTIONEVENT_HPP
+#ifndef EVENTS_ACTIONEVENT_H
+#define EVENTS_ACTIONEVENT_H
-#include "guichan/event.hpp"
+#include "events/event.h"
#include <string>
#include "localconsts.h"
-namespace gcn
-{
- class Widget;
+class Widget;
- /**
- * Represents an action event. An action event is an event
- * that can be fired by a widget whenever an action has occured.
- * What exactly an action is is up to the widget that fires
- * the action event. An example is a Button which fires an action
- * event as soon as the Button is clicked, another example is
- * TextField which fires an action event as soon as the enter
- * key is pressed.
- *
- * Any object can listen for actions from widgets by implementing
- * the ActionListener interface.
- *
- * If you have implement a widget of your own it's a good idea to
- * let the widget fire action events whenever you feel an action
- * has occured so action listeners of the widget can be informed
- * of the state of the widget.
- *
- * @see Widget::addActionListener, Widget::removeActionListener,
- * Widget::distributeActionEvent
- * @author Olof Naessén
- * @since 0.6.0
- */
- class ActionEvent final : public Event
- {
+/**
+ * Represents an action event. An action event is an event
+ * that can be fired by a widget whenever an action has occured.
+ * What exactly an action is is up to the widget that fires
+ * the action event. An example is a Button which fires an action
+ * event as soon as the Button is clicked, another example is
+ * TextField which fires an action event as soon as the enter
+ * key is pressed.
+ *
+ * Any object can listen for actions from widgets by implementing
+ * the ActionListener interface.
+ *
+ * If you have implement a widget of your own it's a good idea to
+ * let the widget fire action events whenever you feel an action
+ * has occured so action listeners of the widget can be informed
+ * of the state of the widget.
+ *
+ * @see Widget::addActionListener, Widget::removeActionListener,
+ * Widget::distributeActionEvent
+ * @author Olof Naessén
+ * @since 0.6.0
+ */
+class ActionEvent final : public Event
+{
public:
/**
- * Constructor.
- *
- * @param source The source widget of the event.
- * @param id An identifier of the event.
- */
- ActionEvent(Widget *const source, const std::string &id);
+ * Constructor.
+ *
+ * @param source The source widget of the event.
+ * @param id An identifier of the event.
+ */
+ ActionEvent(Widget *const source, const std::string &id) :
+ Event(source),
+ mId(id)
+ {
+ }
/**
- * Destructor.
- */
- virtual ~ActionEvent();
+ * Destructor.
+ */
+ virtual ~ActionEvent()
+ { }
/**
- * Gets the identifier of the event. An identifier can
- * be used to distinguish from two actions from the same
- * widget or to let many widgets fire the same widgets
- * that should be treated equally.
- *
- * @return The identifier of the event.
- */
- const std::string& getId() const A_WARN_UNUSED;
+ * Gets the identifier of the event. An identifier can
+ * be used to distinguish from two actions from the same
+ * widget or to let many widgets fire the same widgets
+ * that should be treated equally.
+ *
+ * @return The identifier of the event.
+ */
+ const std::string &getId() const A_WARN_UNUSED
+ { return mId; }
protected:
/**
- * Holds the identifier of the event.
- */
+ * Holds the identifier of the event.
+ */
std::string mId;
- };
-} // namespace gcn
+};
-#endif // GCN_ACTIONEVENT_HPP
+#endif // EVENTS_ACTIONEVENT_H
diff --git a/src/guichan/include/guichan/event.hpp b/src/events/event.h
index 2a1f4ca4b..63ccb207d 100644
--- a/src/guichan/include/guichan/event.hpp
+++ b/src/events/event.h
@@ -61,53 +61,54 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef GCN_EVENT_HPP
-#define GCN_EVENT_HPP
+#ifndef EVENTS_EVENT_H
+#define EVENTS_EVENT_H
#include "localconsts.h"
-namespace gcn
-{
- class Widget;
+class Widget;
- /**
- * Base class for all events. All events in Guichan should
- * inherit from this class.
- *
- * @author Olof Naessén
- * @since 0.6.0
- */
- class Event
- {
+/**
+ * Base class for all events. All events in Guichan should
+ * inherit from this class.
+ *
+ * @author Olof Naessén
+ * @since 0.6.0
+ */
+class Event
+{
public:
/**
- * Constructor.
- *
- * @param source The source widget of the event.
- */
- explicit Event(Widget *const source);
+ * Constructor.
+ *
+ * @param source The source widget of the event.
+ */
+ explicit Event(Widget *const source) :
+ mSource(source)
+ { }
A_DELETE_COPY(Event)
/**
- * Destructor.
- */
- virtual ~Event();
+ * Destructor.
+ */
+ virtual ~Event()
+ { }
/**
- * Gets the source widget of the event. The function
- * is used to tell which widget fired an event.
- *
- * @return The source widget of the event.
- */
- Widget* getSource() const A_WARN_UNUSED;
+ * Gets the source widget of the event. The function
+ * is used to tell which widget fired an event.
+ *
+ * @return The source widget of the event.
+ */
+ Widget* getSource() const A_WARN_UNUSED
+ { return mSource; }
protected:
/**
- * Holds the source widget of the event.
- */
+ * Holds the source widget of the event.
+ */
Widget* mSource;
- };
-} // namespace gcn
+};
-#endif // end GCN_EVENT_HPP
+#endif // EVENTS_EVENT_H
diff --git a/src/input/inputevent.h b/src/events/inputevent.h
index 61f80c8e2..2d8a36796 100644
--- a/src/input/inputevent.h
+++ b/src/events/inputevent.h
@@ -18,8 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef INPUT_INPUTEVENT_H
-#define INPUT_INPUTEVENT_H
+#ifndef EVENTS_INPUTEVENT_H
+#define EVENTS_INPUTEVENT_H
#include <map>
#include <vector>
@@ -41,11 +41,14 @@ typedef KeyTimeMap::iterator KeyTimeMapIter;
struct InputEvent final
{
- InputEvent(const int action0, const int mask0);
+ InputEvent(const int action0, const int mask0) :
+ action(action0),
+ mask(mask0)
+ { }
int action;
int mask;
};
-#endif // INPUT_INPUTEVENT_H
+#endif // EVENTS_INPUTEVENT_H
diff --git a/src/events/inputguievent.h b/src/events/inputguievent.h
new file mode 100644
index 000000000..2e5136ea2
--- /dev/null
+++ b/src/events/inputguievent.h
@@ -0,0 +1,187 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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/>.
+ */
+
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef EVENTS_INPUTGUIEVENT_H
+#define EVENTS_INPUTGUIEVENT_H
+
+#include "events/event.h"
+
+/**
+ * Base class for all events concerning input.
+ *
+ * @author Olof Naessén
+ * @since 0.6.0
+ */
+class InputGuiEvent: public Event
+{
+ public:
+ /**
+ * Constructor.
+ *
+ * @param source The source widget of the event.
+ * @param isShiftPressed True if shift is pressed, false otherwise.
+ * @param isControlPressed True if control is pressed, false otherwise.
+ * @param isAltPressed True if alt is pressed, false otherwise.
+ * @param isMetaPressed True if meta is pressed, false otherwise.
+ */
+ InputGuiEvent(Widget *const source,
+ const bool shiftPressed,
+ const bool controlPressed,
+ const bool altPressed,
+ const bool metaPressed) :
+ Event(source),
+ mShiftPressed(shiftPressed),
+ mControlPressed(controlPressed),
+ mAltPressed(altPressed),
+ mMetaPressed(metaPressed),
+ mIsConsumed(false)
+ { }
+
+ /**
+ * Checks if shift is pressed.
+ *
+ * @return True if shift was pressed at the same time as the key,
+ * false otherwise.
+ */
+ bool isShiftPressed() const A_WARN_UNUSED
+ { return mShiftPressed; }
+
+ /**
+ * Checks if control is pressed.
+ *
+ * @return True if control was pressed at the same time as the key,
+ * false otherwise.
+ */
+ bool isControlPressed() const A_WARN_UNUSED
+ { return mControlPressed; }
+
+ /**
+ * Checks if alt is pressed.
+ *
+ * @return True if alt was pressed at the same time as the key,
+ * false otherwise.
+ */
+ bool isAltPressed() const A_WARN_UNUSED
+ { return mAltPressed; }
+
+ /**
+ * Checks whether meta is pressed.
+ *
+ * @return True if meta was pressed at the same time as the key,
+ * false otherwise.
+ */
+ bool isMetaPressed() const A_WARN_UNUSED
+ { return mMetaPressed; }
+
+ /**
+ * Marks the event as consumed. Input event listeners may discard
+ * consumed input or act on consumed input. An example of a widget
+ * that discards consumed input is the ScrollArea widget that
+ * discards consumed mouse wheel events so the ScrollArea will not
+ * scroll if for instance a Slider's value inside the ScrollArea was
+ * changed with the mouse wheel.
+ *
+ * @see isConsumed
+ */
+ void consume()
+ { mIsConsumed = true; }
+
+ /**
+ * Checks if the input event is consumed.
+ *
+ * @return True if the input event is consumed,
+ * false otherwise.
+ * @see consume
+ */
+ bool isConsumed() const A_WARN_UNUSED
+ { return mIsConsumed; }
+
+ protected:
+ /**
+ * True if shift is pressed, false otherwise.
+ */
+ bool mShiftPressed;
+
+ /**
+ * True if control is pressed, false otherwise.
+ */
+ bool mControlPressed;
+
+ /**
+ * True if alt is pressed, false otherwise.
+ */
+ bool mAltPressed;
+
+ /**
+ * True if meta is pressed, false otherwise.
+ */
+ bool mMetaPressed;
+
+ /**
+ * True if the input event is consumed,
+ * false otherwise.
+ */
+ bool mIsConsumed;
+};
+
+#endif // EVENTS_INPUTGUIEVENT_H
diff --git a/src/guichan/include/guichan/keyevent.hpp b/src/events/keyevent.h
index b3a91f640..360d229d7 100644
--- a/src/guichan/include/guichan/keyevent.hpp
+++ b/src/events/keyevent.h
@@ -61,25 +61,25 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef GCN_KEYEVENT_HPP
-#define GCN_KEYEVENT_HPP
+#ifndef EVENTS_KEYEVENT_H
+#define EVENTS_KEYEVENT_H
-#include "guichan/inputevent.hpp"
-#include "guichan/key.hpp"
+#include "events/inputguievent.h"
+#include "input/key.h"
-namespace gcn
-{
- class Widget;
+#include <string>
+
+class Widget;
- /**
- * Represents a key event.
- */
- class KeyEvent: public InputEvent
- {
+/**
+ * Represents a key event.
+ */
+class KeyEvent: public InputGuiEvent
+{
public:
/**
- * Key event types.
- */
+ * Key event types.
+ */
enum
{
PRESSED = 0,
@@ -87,18 +87,18 @@ namespace gcn
};
/**
- * Constructor.
- *
- * @param source The source widget of the event.
- * @param shiftPressed True if shift is pressed, false otherwise.
- * @param controlPressed True if control is pressed, false otherwise.
- * @param altPressed True if alt is pressed, false otherwise.
- * @param metaPressed True if meta is pressed, false otherwise.
- * @param type The type of the event. A value from KeyEventType.
- * @param numericPad True if the event occured on the numeric pad,
- * false otherwise.
- * @param key The key of the event.
- */
+ * Constructor.
+ *
+ * @param source The source widget of the event.
+ * @param shiftPressed True if shift is pressed, false otherwise.
+ * @param controlPressed True if control is pressed, false otherwise.
+ * @param altPressed True if alt is pressed, false otherwise.
+ * @param metaPressed True if meta is pressed, false otherwise.
+ * @param type The type of the event. A value from KeyEventType.
+ * @param numericPad True if the event occured on the numeric pad,
+ * false otherwise.
+ * @param key The key of the event.
+ */
KeyEvent(Widget *const source,
const bool shiftPressed,
const bool controlPressed,
@@ -106,52 +106,86 @@ namespace gcn
const bool metaPressed,
const unsigned int type,
const bool numericPad,
- const Key& key);
+ const int actionId,
+ const Key &key) :
+ InputGuiEvent(source,
+ shiftPressed,
+ controlPressed,
+ altPressed,
+ metaPressed),
+ mKey(key),
+#ifdef USE_SDL2
+ mText(),
+#endif
+ mType(type),
+ mActionId(actionId),
+ mIsNumericPad(numericPad)
+ { }
/**
- * Destructor.
- */
- virtual ~KeyEvent();
+ * Destructor.
+ */
+ virtual ~KeyEvent()
+ { }
/**
- * Gets the type of the event.
- *
- * @return The type of the event.
- */
- unsigned int getType() const A_WARN_UNUSED;
+ * Gets the type of the event.
+ *
+ * @return The type of the event.
+ */
+ unsigned int getType() const A_WARN_UNUSED
+ { return mType; }
/**
- * Checks if the key event occured on the numeric pad.
- *
- * @return True if key event occured on the numeric pad,
- * false otherwise.
- *
- */
- bool isNumericPad() const A_WARN_UNUSED;
+ * Checks if the key event occured on the numeric pad.
+ *
+ * @return True if key event occured on the numeric pad,
+ * false otherwise.
+ *
+ */
+ bool isNumericPad() const A_WARN_UNUSED
+ { return mIsNumericPad; }
/**
- * Gets the key of the event.
- *
- * @return The key of the event.
- */
- const Key& getKey() const A_WARN_UNUSED;
+ * Gets the key of the event.
+ *
+ * @return The key of the event.
+ */
+ const Key &getKey() const A_WARN_UNUSED
+ { return mKey; }
+
+ int getActionId() const A_WARN_UNUSED
+ { return mActionId; }
+
+#ifdef USE_SDL2
+ void setText(const std::string &text)
+ { mText = text; }
+
+ std::string getText() const
+ { return mText; }
+#endif
protected:
+ /**
+ * Holds the key of the key event.
+ */
+ Key mKey;
+
+#ifdef USE_SDL2
+ std::string mText;
+#endif
+
/**
- * Holds the type of the key event.
- */
+ * Holds the type of the key event.
+ */
unsigned int mType;
+ int mActionId;
+
/**
- * True if the numeric pad was used, false otherwise.
- */
+ * True if the numeric pad was used, false otherwise.
+ */
bool mIsNumericPad;
+};
- /**
- * Holds the key of the key event.
- */
- Key mKey;
- };
-} // namespace gcn
-
-#endif // end GCN_KEYEVENT_HPP
+#endif // EVENTS_KEYEVENT_H
diff --git a/src/guichan/include/guichan/mouseevent.hpp b/src/events/mouseevent.h
index 57af098ab..a717980f9 100644
--- a/src/guichan/include/guichan/mouseevent.hpp
+++ b/src/events/mouseevent.h
@@ -61,40 +61,42 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef GCN_MOUSEEVENT_HPP
-#define GCN_MOUSEEVENT_HPP
+#ifndef EVENTS_MOUSEEVENT_H
+#define EVENTS_MOUSEEVENT_H
-#include "guichan/inputevent.hpp"
+#include "events/inputguievent.h"
namespace gcn
{
class Gui;
- class Widget;
-
- /**
- * Represents a mouse event.
- *
- * @author Olof Naessén
- * @since 0.6.0
- */
- class MouseEvent: public InputEvent
- {
+}
+
+class Widget;
+
+/**
+ * Represents a mouse event.
+ *
+ * @author Olof Naessén
+ * @since 0.6.0
+ */
+class MouseEvent: public InputGuiEvent
+{
public:
/**
- * Constructor.
- *
- * @param source The source widget of the mouse event.
- * @param shiftPressed True if shift is pressed, false otherwise.
- * @param controlPressed True if control is pressed, false otherwise.
- * @param altPressed True if alt is pressed, false otherwise.
- * @param metaPressed True if meta is pressed, false otherwise.
- * @param type The type of the mouse event.
- * @param button The button of the mouse event.
- * @param x The x coordinate of the event relative to the source widget.
- * @param y The y coordinate of the event relative the source widget.
- * @param clickCount The number of clicks generated with the same button.
- * It's set to zero if another button is used.
- */
+ * Constructor.
+ *
+ * @param source The source widget of the mouse event.
+ * @param shiftPressed True if shift is pressed, false otherwise.
+ * @param controlPressed True if control is pressed, false otherwise.
+ * @param altPressed True if alt is pressed, false otherwise.
+ * @param metaPressed True if meta is pressed, false otherwise.
+ * @param type The type of the mouse event.
+ * @param button The button of the mouse event.
+ * @param x The x coordinate of the event relative to the source widget.
+ * @param y The y coordinate of the event relative the source widget.
+ * @param clickCount The number of clicks generated with the same button.
+ * It's set to zero if another button is used.
+ */
MouseEvent(Widget *const source,
const bool shiftPressed,
const bool controlPressed,
@@ -104,53 +106,76 @@ namespace gcn
const unsigned int button,
const int x,
const int y,
- const int clickCount);
+ const int clickCount) :
+ InputGuiEvent(source,
+ shiftPressed,
+ controlPressed,
+ altPressed,
+ metaPressed),
+ mType(type),
+ mButton(button),
+ mX(x),
+ mY(y),
+ mClickCount(clickCount)
+ {
+ }
/**
- * Gets the button of the mouse event.
- *
- * @return The button of the mouse event.
- */
- unsigned int getButton() const A_WARN_UNUSED;
+ * Gets the button of the mouse event.
+ *
+ * @return The button of the mouse event.
+ */
+ unsigned int getButton() const A_WARN_UNUSED
+ { return mButton; }
/**
- * Gets the x coordinate of the mouse event.
- * The coordinate relative to widget the mouse listener
- * receiving the events have registered to.
- *
- * @return The x coordinate of the mouse event.
- * @see Widget::addMouseListener, Widget::removeMouseListener
- */
- int getX() const A_WARN_UNUSED;
+ * Gets the x coordinate of the mouse event.
+ * The coordinate relative to widget the mouse listener
+ * receiving the events have registered to.
+ *
+ * @return The x coordinate of the mouse event.
+ * @see Widget::addMouseListener, Widget::removeMouseListener
+ */
+ int getX() const A_WARN_UNUSED
+ { return mX; }
/**
- * Gets the y coordinate of the mouse event.
- * The coordinate relative to widget the mouse listener
- * receiving the events have registered to.
- *
- * @return The y coordinate of the mouse event.
- * @see Widget::addMouseListener, Widget::removeMouseListener
- */
- int getY() const A_WARN_UNUSED;
+ * Gets the y coordinate of the mouse event.
+ * The coordinate relative to widget the mouse listener
+ * receiving the events have registered to.
+ *
+ * @return The y coordinate of the mouse event.
+ * @see Widget::addMouseListener, Widget::removeMouseListener
+ */
+ int getY() const A_WARN_UNUSED
+ { return mY; }
/**
- * Gets the number of clicks generated with the same button.
- * It's set to zero if another button is used.
- *
- * @return The number of clicks generated with the same button.
- */
- int getClickCount() const A_WARN_UNUSED;
+ * Gets the number of clicks generated with the same button.
+ * It's set to zero if another button is used.
+ *
+ * @return The number of clicks generated with the same button.
+ */
+ int getClickCount() const A_WARN_UNUSED
+ { return mClickCount; }
/**
- * Gets the type of the event.
- *
- * @return The type of the event.
- */
- unsigned int getType() const A_WARN_UNUSED;
+ * Gets the type of the event.
+ *
+ * @return The type of the event.
+ */
+ unsigned int getType() const A_WARN_UNUSED
+ { return mType; }
+
+ void setX(int n)
+ { mX = n; }
+
+ void setY(int n)
+ { mY = n; }
/**
- * Mouse event types.
- */
+ * Mouse event types.
+ */
enum
{
MOVED = 0,
@@ -165,8 +190,8 @@ namespace gcn
};
/**
- * Mouse button types.
- */
+ * Mouse button types.
+ */
enum
{
EMPTY = 0,
@@ -177,41 +202,40 @@ namespace gcn
protected:
/**
- * Holds the type of the mouse event.
- */
+ * Holds the type of the mouse event.
+ */
unsigned int mType;
/**
- * Holds the button of the mouse event.
- */
+ * Holds the button of the mouse event.
+ */
unsigned int mButton;
/**
- * Holds the x-coordinate of the mouse event.
- */
+ * Holds the x-coordinate of the mouse event.
+ */
int mX;
/**
- * Holds the y-coordinate of the mouse event.
- */
+ * Holds the y-coordinate of the mouse event.
+ */
int mY;
/**
- * The number of clicks generated with the same button.
- * It's set to zero if another button is used.
- */
+ * The number of clicks generated with the same button.
+ * It's set to zero if another button is used.
+ */
int mClickCount;
/**
- * Gui is a friend of this class in order to be able to manipulate
- * the protected member variables of this class and at the same time
- * keep the MouseEvent class as const as possible. Gui needs to
- * update the x och y coordinates for the coordinates to be relative
- * to widget the mouse listener receiving the events have registered
- * to.
- */
- friend class Gui;
- };
-} // namespace gcn
-
-#endif // GCN_MOUSEEVENT_HPP
+ * Gui is a friend of this class in order to be able to manipulate
+ * the protected member variables of this class and at the same time
+ * keep the MouseEvent class as const as possible. Gui needs to
+ * update the x och y coordinates for the coordinates to be relative
+ * to widget the mouse listener receiving the events have registered
+ * to.
+ */
+ friend class gcn::Gui;
+};
+
+#endif // EVENTS_MOUSEEVENT_H
diff --git a/src/guichan/include/guichan/selectionevent.hpp b/src/events/selectionevent.h
index a4a3da0b3..927b66f77 100644
--- a/src/guichan/include/guichan/selectionevent.hpp
+++ b/src/events/selectionevent.h
@@ -61,38 +61,38 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef GCN_SELECTIONEVENT_HPP
-#define GCN_SELECTIONEVENT_HPP
+#ifndef EVENTS_SELECTIONEVENT_H
+#define EVENTS_SELECTIONEVENT_H
-#include "guichan/event.hpp"
+#include "events/event.h"
#include "localconsts.h"
-namespace gcn
-{
- class Widget;
+class Widget;
- /**
- * Represents a selection event.
- *
- * @author Olof Naessén
- * @since 0.8.0
- */
- class SelectionEvent final: public Event
- {
+/**
+ * Represents a selection event.
+ *
+ * @author Olof Naessén
+ * @since 0.8.0
+ */
+class SelectionEvent final: public Event
+{
public:
/**
- * Constructor.
- *
- * @param source source The widget of the selection event.
- */
- explicit SelectionEvent(Widget *const source);
+ * Constructor.
+ *
+ * @param source source The widget of the selection event.
+ */
+ explicit SelectionEvent(Widget *const source) :
+ Event(source)
+ { }
/**
- * Destructor.
- */
- virtual ~SelectionEvent();
- };
-} // namespace gcn
+ * Destructor.
+ */
+ virtual ~SelectionEvent()
+ { }
+};
-#endif // end GCN_SELECTIONEVENT_HPP
+#endif // EVENTS_SELECTIONEVENT_H
diff --git a/src/eventsmanager.h b/src/eventsmanager.h
index 5433a83fb..e54c4dee4 100644
--- a/src/eventsmanager.h
+++ b/src/eventsmanager.h
@@ -21,7 +21,7 @@
#ifndef EVENTSMANAGER_H
#define EVENTSMANAGER_H
-#include "configlistener.h"
+#include "listeners/configlistener.h"
#include <string>
diff --git a/src/flooritem.cpp b/src/flooritem.cpp
index bf8b54f0b..9ffa8f64a 100644
--- a/src/flooritem.cpp
+++ b/src/flooritem.cpp
@@ -26,8 +26,8 @@
#include "render/graphics.h"
+#include "gui/font.h"
#include "gui/gui.h"
-#include "gui/sdlfont.h"
#include "gui/userpalette.h"
#include "resources/iteminfo.h"
@@ -109,7 +109,7 @@ void FloorItem::draw(Graphics *const graphics,
BLOCK_START("FloorItem::draw")
const int x = mX * mMap->getTileWidth() + offsetX;
const int y = mY * mMap->getTileHeight() + offsetY;
- gcn::Font *font = nullptr;
+ Font *font = nullptr;
if (mHighlight)
{
@@ -122,24 +122,23 @@ void FloorItem::draw(Graphics *const graphics,
if (curTime > mDropTime + 28 && curTime < mDropTime + 50)
{
- graphics->setColor(gcn::Color(80, 200, 20, 200));
- graphics->fillRectangle(gcn::Rectangle(
+ graphics->setColor(Color(80, 200, 20, 200));
+ graphics->fillRectangle(Rect(
x, y, dx, dy));
}
else if (curTime > mDropTime + 19
&& curTime < mDropTime + 28)
{
- graphics->setColor(gcn::Color(200, 80, 20,
+ graphics->setColor(Color(200, 80, 20,
80 + 10 * (curTime - mDropTime - 18)));
- graphics->fillRectangle(gcn::Rectangle(
+ graphics->fillRectangle(Rect(
x, y, dx, dy));
}
else if (curTime > mDropTime && curTime < mDropTime + 20)
{
- graphics->setColor(gcn::Color(20, 20, 255,
+ graphics->setColor(Color(20, 20, 255,
7 * (curTime - mDropTime)));
- graphics->fillRectangle(gcn::Rectangle(
- x, y, dx, dy));
+ graphics->fillRectangle(Rect(x, y, dx, dy));
}
}
}
@@ -153,7 +152,7 @@ void FloorItem::draw(Graphics *const graphics,
{
if (font && mAmount > 1)
{
-// graphics->setColor(gcn::Color(255, 255, 255, 100));
+// graphics->setColor(Color(255, 255, 255, 100));
graphics->setColor(userPalette->getColor(
UserPalette::FLOOR_ITEM_TEXT));
font->drawString(graphics, toString(mAmount), x, y);
diff --git a/src/game.cpp b/src/game.cpp
index 26807b8b6..253c4bff2 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -49,9 +49,6 @@
#include "input/keyboardconfig.h"
#include "gui/gui.h"
-#ifdef MANASERV_SUPPORT
-#include "gui/specialswindow.h"
-#endif
#include "gui/viewport.h"
#include "gui/windowmenu.h"
@@ -139,9 +136,6 @@ DebugWindow *debugWindow = nullptr;
ShortcutWindow *itemShortcutWindow = nullptr;
ShortcutWindow *emoteShortcutWindow = nullptr;
OutfitWindow *outfitWindow = nullptr;
-#ifdef MANASERV_SUPPORT
-SpecialsWindow *specialsWindow = nullptr;
-#endif
ShortcutWindow *dropShortcutWindow = nullptr;
ShortcutWindow *spellShortcutWindow = nullptr;
WhoIsOnline *whoIsOnline = nullptr;
@@ -236,7 +230,7 @@ static void createGuiWindows()
for (unsigned f = 0; f < SHORTCUT_TABS; f ++)
{
itemShortcutWindow->addTab(toString(f + 1),
- new ItemShortcutContainer(f));
+ new ItemShortcutContainer(nullptr, f));
}
if (config.getBoolValue("showDidYouKnow"))
{
@@ -245,20 +239,20 @@ static void createGuiWindows()
}
emoteShortcutWindow = new ShortcutWindow("EmoteShortcut",
- new EmoteShortcutContainer, "emotes.xml", 130, 480);
+ new EmoteShortcutContainer(nullptr),
+ "emotes.xml",
+ 130, 480);
outfitWindow = new OutfitWindow();
-#ifdef MANASERV_SUPPORT
- specialsWindow = new SpecialsWindow();
-#endif
dropShortcutWindow = new ShortcutWindow("DropShortcut",
- new DropShortcutContainer, "drops.xml");
+ new DropShortcutContainer(nullptr),
+ "drops.xml");
spellShortcutWindow = new ShortcutWindow("SpellShortcut", "spells.xml",
265, 328);
for (unsigned f = 0; f < SPELL_SHORTCUT_TABS; f ++)
{
spellShortcutWindow->addTab(toString(f + 1),
- new SpellShortcutContainer(f));
+ new SpellShortcutContainer(nullptr, f));
}
botCheckerWindow = new BotCheckerWindow;
@@ -370,9 +364,6 @@ static void destroyGuiWindows()
del_0(itemShortcutWindow)
del_0(emoteShortcutWindow)
del_0(outfitWindow)
-#ifdef MANASERV_SUPPORT
- del_0(specialsWindow)
-#endif
del_0(socialWindow)
del_0(dropShortcutWindow);
del_0(spellShortcutWindow);
diff --git a/src/graphicsvertexes.h b/src/graphicsvertexes.h
index 15256113f..8746bcce3 100644
--- a/src/graphicsvertexes.h
+++ b/src/graphicsvertexes.h
@@ -38,10 +38,12 @@
#endif
-#include "resources/image.h"
+#include <SDL_video.h>
#include <vector>
+class Image;
+
struct DoubleRect final
{
SDL_Rect src;
diff --git a/src/guichan/basiccontainer.cpp b/src/gui/base/basiccontainer.cpp
index 239a8544e..f323366ad 100644
--- a/src/guichan/basiccontainer.cpp
+++ b/src/gui/base/basiccontainer.cpp
@@ -65,15 +65,10 @@
* For comments regarding functions please see the header file.
*/
-#include "guichan/basiccontainer.hpp"
+#include "gui/base/basiccontainer.hpp"
#include <algorithm>
-#include "guichan/exception.hpp"
-#include "guichan/focushandler.hpp"
-#include "guichan/graphics.hpp"
-#include "guichan/mouseinput.hpp"
-
#include "debug.h"
namespace gcn
@@ -95,8 +90,6 @@ namespace gcn
return;
}
}
-
- throw GCN_EXCEPTION("There is no such widget in this container.");
}
void BasicContainer::moveToBottom(Widget* widget)
@@ -105,11 +98,10 @@ namespace gcn
iter = std::find(mWidgets.begin(), mWidgets.end(), widget);
if (iter == mWidgets.end())
- throw GCN_EXCEPTION("There is no such widget in this container.");
+ return;
mWidgets.erase(iter);
mWidgets.insert(mWidgets.begin(), widget);
-// mWidgets.push_front(widget);
}
void BasicContainer::death(const Event& event)
@@ -118,14 +110,14 @@ namespace gcn
iter = std::find(mWidgets.begin(), mWidgets.end(), event.getSource());
if (iter == mWidgets.end())
- throw GCN_EXCEPTION("There is no such widget in this container.");
+ return;
mWidgets.erase(iter);
}
- Rectangle BasicContainer::getChildrenArea()
+ Rect BasicContainer::getChildrenArea()
{
- return Rectangle(0, 0, getWidth(), getHeight());
+ return Rect(0, 0, getWidth(), getHeight());
}
void BasicContainer::focusNext()
@@ -190,7 +182,7 @@ namespace gcn
Widget *BasicContainer::getWidgetAt(int x, int y)
{
- const Rectangle r = getChildrenArea();
+ const Rect r = getChildrenArea();
if (!r.isPointInRect(x, y))
return nullptr;
@@ -259,8 +251,6 @@ namespace gcn
return;
}
}
-
- throw GCN_EXCEPTION("There is no such widget in this container.");
}
void BasicContainer::clear()
@@ -292,7 +282,7 @@ namespace gcn
// draw it before drawing the widget
if (widget->getFrameSize() > 0)
{
- Rectangle rec = widget->getDimension();
+ Rect rec = widget->getDimension();
const int frame = widget->getFrameSize();
const int frame2 = frame * 2;
rec.x -= frame;
@@ -329,9 +319,9 @@ namespace gcn
BLOCK_END("BasicContainer::logicChildren")
}
- void BasicContainer::showWidgetPart(Widget* widget, Rectangle area)
+ void BasicContainer::showWidgetPart(Widget* widget, Rect area)
{
- const Rectangle widgetArea = getChildrenArea();
+ const Rect widgetArea = getChildrenArea();
area.x += widget->getX();
area.y += widget->getY();
diff --git a/src/guichan/include/guichan/basiccontainer.hpp b/src/gui/base/basiccontainer.hpp
index a3fb18528..e1947c652 100644
--- a/src/guichan/include/guichan/basiccontainer.hpp
+++ b/src/gui/base/basiccontainer.hpp
@@ -64,11 +64,11 @@
#ifndef GCN_BASICCONTAINER_HPP
#define GCN_BASICCONTAINER_HPP
-#include <list>
#include <vector>
-#include "guichan/deathlistener.hpp"
-#include "guichan/widget.hpp"
+#include "gui/widgets/widget.h"
+
+#include "listeners/deathlistener.h"
namespace gcn
{
@@ -84,7 +84,9 @@ namespace gcn
public DeathListener
{
public:
- BasicContainer() :
+ explicit BasicContainer(const Widget2 *const widget) :
+ Widget(widget),
+ DeathListener(),
mWidgets()
{ }
@@ -106,7 +108,7 @@ namespace gcn
* itself to be visible.
* @param rectangle The rectangle to be visible.
*/
- virtual void showWidgetPart(Widget* widget, Rectangle area);
+ virtual void showWidgetPart(Widget* widget, Rect area);
// Inherited from Widget
@@ -114,7 +116,7 @@ namespace gcn
virtual void moveToBottom(Widget* widget);
- virtual Rectangle getChildrenArea() A_WARN_UNUSED;
+ virtual Rect getChildrenArea() A_WARN_UNUSED;
virtual void focusNext();
diff --git a/src/guichan/gui.cpp b/src/gui/base/gui.cpp
index fa50812de..8985ec062 100644
--- a/src/guichan/gui.cpp
+++ b/src/gui/base/gui.cpp
@@ -65,18 +65,16 @@
* For comments regarding functions please see the header file.
*/
-#include "guichan/gui.hpp"
-
-#include "guichan/basiccontainer.hpp"
-#include "guichan/exception.hpp"
-#include "guichan/focushandler.hpp"
-#include "guichan/graphics.hpp"
-#include "guichan/input.hpp"
-#include "guichan/keyinput.hpp"
-#include "guichan/keylistener.hpp"
-#include "guichan/mouseinput.hpp"
-#include "guichan/mouselistener.hpp"
-#include "guichan/widget.hpp"
+#include "gui/base/gui.hpp"
+
+#include "gui/widgets/widget.h"
+
+#include "gui/focushandler.h"
+
+#include "input/mouseinput.h"
+
+#include "listeners/keylistener.h"
+#include "listeners/mouselistener.h"
#include "debug.h"
@@ -137,12 +135,12 @@ namespace gcn
return mGraphics;
}
- void Gui::setInput(Input* input)
+ void Gui::setInput(SDLInput* input)
{
mInput = input;
}
- Input* Gui::getInput() const
+ SDLInput* Gui::getInput() const
{
return mInput;
}
@@ -530,7 +528,7 @@ namespace gcn
(*it)->mouseClicked(mouseEvent);
break;
default:
- throw GCN_EXCEPTION("Unknown mouse event type.");
+ break;
}
}
@@ -606,7 +604,7 @@ namespace gcn
(*it)->keyReleased(keyEvent);
break;
default:
- throw GCN_EXCEPTION("Unknown key event type.");
+ break;
}
}
}
@@ -639,7 +637,7 @@ namespace gcn
(*it)->keyReleased(keyEvent);
break;
default:
- throw GCN_EXCEPTION("Unknown key event type.");
+ break;
}
if (keyEvent.isConsumed())
diff --git a/src/guichan/include/guichan/gui.hpp b/src/gui/base/gui.hpp
index 5aca51f4e..4ea923400 100644
--- a/src/guichan/include/guichan/gui.hpp
+++ b/src/gui/base/gui.hpp
@@ -67,18 +67,19 @@
#include <list>
#include <deque>
-#include "guichan/keyevent.hpp"
-#include "guichan/mouseevent.hpp"
-#include "guichan/mouseinput.hpp"
+#include "localconsts.h"
+
+class Event;
+class FocusHandler;
+class Graphics;
+class KeyEvent;
+class KeyListener;
+class MouseInput;
+class SDLInput;
+class Widget;
namespace gcn
{
- class FocusHandler;
- class Graphics;
- class Input;
- class KeyListener;
- class Widget;
-
// The following comment will appear in the doxygen main page.
/**
* @mainpage
@@ -176,7 +177,7 @@ namespace gcn
* SDLInput
* @since 0.1.0
*/
- virtual void setInput(Input* input);
+ virtual void setInput(SDLInput* input);
/**
* Gets the input object being used for input handling.
@@ -187,7 +188,7 @@ namespace gcn
* SDLInput
* @since 0.1.0
*/
- virtual Input* getInput() const A_WARN_UNUSED;
+ virtual SDLInput* getInput() const A_WARN_UNUSED;
/**
* Performs logic of the GUI. By calling this function all logic
@@ -416,7 +417,7 @@ namespace gcn
/**
* Holds the input implementation used.
*/
- Input* mInput;
+ SDLInput* mInput;
/**
* Holds the focus handler for the Gui.
diff --git a/src/guichan/widgets/button.cpp b/src/gui/base/widgets/button.cpp
index 1226e157a..2d6afa672 100644
--- a/src/guichan/widgets/button.cpp
+++ b/src/gui/base/widgets/button.cpp
@@ -65,24 +65,21 @@
* For comments regarding functions please see the header file.
*/
-#include "guichan/widgets/button.hpp"
+#include "gui/base/widgets/button.hpp"
-#include "guichan/exception.hpp"
-#include "guichan/font.hpp"
-#include "guichan/graphics.hpp"
-#include "guichan/key.hpp"
-#include "guichan/mouseevent.hpp"
-#include "guichan/mouseinput.hpp"
+#include "events/mouseevent.h"
+
+#include "render/graphics.h"
#include "debug.h"
namespace gcn
{
- Button::Button() :
- gcn::Widget(),
- gcn::MouseListener(),
- gcn::KeyListener(),
- gcn::FocusListener(),
+ Button::Button(const Widget2 *const widget) :
+ Widget(widget),
+ MouseListener(),
+ KeyListener(),
+ FocusListener(),
mCaption(),
mHasMouse(false),
mKeyPressed(false),
@@ -99,11 +96,12 @@ namespace gcn
addFocusListener(this);
}
- Button::Button(const std::string& caption) :
- gcn::Widget(),
- gcn::MouseListener(),
- gcn::KeyListener(),
- gcn::FocusListener(),
+ Button::Button(const Widget2 *const widget,
+ const std::string& caption) :
+ Widget(widget),
+ MouseListener(),
+ KeyListener(),
+ FocusListener(),
mCaption(caption),
mHasMouse(false),
mKeyPressed(false),
diff --git a/src/guichan/include/guichan/widgets/button.hpp b/src/gui/base/widgets/button.hpp
index 91c526d4f..99e5db4f4 100644
--- a/src/guichan/include/guichan/widgets/button.hpp
+++ b/src/gui/base/widgets/button.hpp
@@ -66,12 +66,13 @@
#include <string>
-#include "guichan/focuslistener.hpp"
-#include "guichan/graphics.hpp"
-#include "guichan/keylistener.hpp"
-#include "guichan/mouseevent.hpp"
-#include "guichan/mouselistener.hpp"
-#include "guichan/widget.hpp"
+#include "listeners/focuslistener.h"
+#include "listeners/keylistener.h"
+#include "listeners/mouselistener.h"
+
+#include "gui/widgets/widget.h"
+
+#include "render/graphics.h"
namespace gcn
{
@@ -93,7 +94,7 @@ namespace gcn
/**
* Constructor.
*/
- Button();
+ explicit Button(const Widget2 *const widget);
/**
* Constructor. The button will be automatically resized
@@ -101,7 +102,8 @@ namespace gcn
*
* @param caption The caption of the button.
*/
- explicit Button(const std::string& caption);
+ Button(const Widget2 *const widget,
+ const std::string& caption);
A_DELETE_COPY(Button)
diff --git a/src/guichan/widgets/checkbox.cpp b/src/gui/base/widgets/checkbox.cpp
index 4b3c7b966..476fb3c6b 100644
--- a/src/guichan/widgets/checkbox.cpp
+++ b/src/gui/base/widgets/checkbox.cpp
@@ -65,22 +65,17 @@
* For comments regarding functions please see the header file.
*/
-#include "guichan/widgets/checkbox.hpp"
-
-#include "guichan/font.hpp"
-#include "guichan/graphics.hpp"
-#include "guichan/key.hpp"
-#include "guichan/mouseinput.hpp"
+#include "gui/base/widgets/checkbox.hpp"
#include "debug.h"
namespace gcn
{
- CheckBox::CheckBox() :
- gcn::Widget(),
- gcn::MouseListener(),
- gcn::KeyListener(),
+ CheckBox::CheckBox(const Widget2 *const widget) :
+ Widget(widget),
+ MouseListener(),
+ KeyListener(),
mSelected(false),
mCaption()
{
@@ -89,10 +84,12 @@ namespace gcn
addKeyListener(this);
}
- CheckBox::CheckBox(const std::string &caption, bool selected) :
- gcn::Widget(),
- gcn::MouseListener(),
- gcn::KeyListener(),
+ CheckBox::CheckBox(const Widget2 *const widget,
+ const std::string &caption,
+ bool selected) :
+ Widget(widget),
+ MouseListener(),
+ KeyListener(),
mSelected(selected),
mCaption()
{
diff --git a/src/guichan/include/guichan/widgets/checkbox.hpp b/src/gui/base/widgets/checkbox.hpp
index 465de566d..6fcb04767 100644
--- a/src/guichan/include/guichan/widgets/checkbox.hpp
+++ b/src/gui/base/widgets/checkbox.hpp
@@ -66,9 +66,10 @@
#include <string>
-#include "guichan/keylistener.hpp"
-#include "guichan/mouselistener.hpp"
-#include "guichan/widget.hpp"
+#include "listeners/keylistener.h"
+#include "listeners/mouselistener.h"
+
+#include "gui/widgets/widget.h"
namespace gcn
{
@@ -89,7 +90,7 @@ namespace gcn
/**
* Contructor.
*/
- CheckBox();
+ explicit CheckBox(const Widget2 *const widget);
/**
* Constructor. The check box will be automatically resized
@@ -98,7 +99,9 @@ namespace gcn
* @param caption The caption of the check box.
* @param marked True if the check box is selected, false otherwise.
*/
- CheckBox(const std::string &caption, bool selected = false);
+ CheckBox(const Widget2 *const widget,
+ const std::string &caption,
+ bool selected = false);
A_DELETE_COPY(CheckBox)
diff --git a/src/guichan/widgets/container.cpp b/src/gui/base/widgets/container.cpp
index 7ea07e529..53a900ec4 100644
--- a/src/guichan/widgets/container.cpp
+++ b/src/gui/base/widgets/container.cpp
@@ -65,18 +65,18 @@
* For comments regarding functions please see the header file.
*/
-#include "guichan/widgets/container.hpp"
+#include "gui/base/widgets/container.hpp"
-#include "guichan/exception.hpp"
-#include "guichan/graphics.hpp"
+
+#include "render/graphics.h"
#include "debug.h"
namespace gcn
{
- Container::Container() :
- BasicContainer(),
+ Container::Container(const Widget2 *const widget) :
+ BasicContainer(widget),
mOpaque(true)
{
}
@@ -91,7 +91,7 @@ namespace gcn
if (isOpaque())
{
graphics->setColor(getBaseColor());
- graphics->fillRectangle(Rectangle(0, 0, getWidth(), getHeight()));
+ graphics->fillRectangle(Rect(0, 0, getWidth(), getHeight()));
}
drawChildren(graphics);
diff --git a/src/guichan/include/guichan/widgets/container.hpp b/src/gui/base/widgets/container.hpp
index b6efbf361..3e6c0a587 100644
--- a/src/guichan/include/guichan/widgets/container.hpp
+++ b/src/gui/base/widgets/container.hpp
@@ -64,10 +64,7 @@
#ifndef GCN_CONTAINER_HPP
#define GCN_CONTAINER_HPP
-#include <list>
-
-#include "guichan/basiccontainer.hpp"
-#include "guichan/graphics.hpp"
+#include "gui/base/basiccontainer.hpp"
namespace gcn
{
@@ -88,7 +85,7 @@ namespace gcn
*
* @see setOpaque, isOpaque
*/
- Container();
+ explicit Container(const Widget2 *const widget);
/**
* Destructor.
diff --git a/src/guichan/widgets/label.cpp b/src/gui/base/widgets/label.cpp
index 92962e907..d2293a957 100644
--- a/src/guichan/widgets/label.cpp
+++ b/src/gui/base/widgets/label.cpp
@@ -65,25 +65,26 @@
* For comments regarding functions please see the header file.
*/
-#include "guichan/widgets/label.hpp"
+#include "gui/base/widgets/label.hpp"
-#include "guichan/exception.hpp"
-#include "guichan/font.hpp"
-#include "guichan/graphics.hpp"
+#include "gui/font.h"
+
+#include "render/graphics.h"
#include "debug.h"
namespace gcn
{
- Label::Label() :
- gcn::Widget(),
+ Label::Label(const Widget2 *const widget) :
+ Widget(widget),
mCaption(),
mAlignment(Graphics::LEFT)
{
}
- Label::Label(const std::string& caption) :
- gcn::Widget(),
+ Label::Label(const Widget2 *const widget,
+ const std::string& caption) :
+ Widget(widget),
mCaption(caption),
mAlignment(Graphics::LEFT)
{
diff --git a/src/guichan/include/guichan/widgets/label.hpp b/src/gui/base/widgets/label.hpp
index a8c2ae7ea..fd0d54f8e 100644
--- a/src/guichan/include/guichan/widgets/label.hpp
+++ b/src/gui/base/widgets/label.hpp
@@ -66,8 +66,9 @@
#include <string>
-#include "guichan/graphics.hpp"
-#include "guichan/widget.hpp"
+#include "gui/widgets/widget.h"
+
+#include "render/graphics.h"
namespace gcn
{
@@ -80,7 +81,7 @@ namespace gcn
/**
* Constructor.
*/
- Label();
+ explicit Label(const Widget2 *const widget);
/**
* Constructor. The label will be automatically resized
@@ -88,7 +89,8 @@ namespace gcn
*
* @param caption The caption of the label.
*/
- explicit Label(const std::string& caption);
+ Label(const Widget2 *const widget,
+ const std::string& caption);
A_DELETE_COPY(Label)
diff --git a/src/guichan/widgets/listbox.cpp b/src/gui/base/widgets/listbox.cpp
index 9122e8cc8..2e9606f0a 100644
--- a/src/guichan/widgets/listbox.cpp
+++ b/src/gui/base/widgets/listbox.cpp
@@ -65,24 +65,22 @@
* For comments regarding functions please see the header file.
*/
-#include "guichan/widgets/listbox.hpp"
+#include "gui/base/widgets/listbox.hpp"
-#include "guichan/basiccontainer.hpp"
-#include "guichan/font.hpp"
-#include "guichan/graphics.hpp"
-#include "guichan/key.hpp"
-#include "guichan/listmodel.hpp"
-#include "guichan/mouseinput.hpp"
-#include "guichan/selectionlistener.hpp"
+#include "gui/font.h"
+
+#include "gui/models/listmodel.h"
+
+#include "listeners/selectionlistener.h"
#include "debug.h"
namespace gcn
{
- ListBox::ListBox() :
- gcn::Widget(),
- gcn::MouseListener(),
- gcn::KeyListener(),
+ ListBox::ListBox(const Widget2 *const widget) :
+ Widget(widget),
+ MouseListener(),
+ KeyListener(),
mSelected(-1),
mListModel(nullptr),
mWrappingEnabled(false),
@@ -95,10 +93,11 @@ namespace gcn
addKeyListener(this);
}
- ListBox::ListBox(ListModel *listModel) :
- gcn::Widget(),
- gcn::MouseListener(),
- gcn::KeyListener(),
+ ListBox::ListBox(const Widget2 *const widget,
+ ListModel *listModel) :
+ Widget(widget),
+ MouseListener(),
+ KeyListener(),
mSelected(-1),
mListModel(listModel),
mWrappingEnabled(false),
@@ -140,7 +139,7 @@ namespace gcn
mSelected = selected;
}
- Rectangle scroll;
+ Rect scroll;
if (mSelected < 0)
scroll.y = 0;
diff --git a/src/guichan/include/guichan/widgets/listbox.hpp b/src/gui/base/widgets/listbox.hpp
index d28664455..079e5a7d5 100644
--- a/src/guichan/include/guichan/widgets/listbox.hpp
+++ b/src/gui/base/widgets/listbox.hpp
@@ -66,15 +66,16 @@
#include <list>
-#include "guichan/keylistener.hpp"
-#include "guichan/listmodel.hpp"
-#include "guichan/mouselistener.hpp"
-#include "guichan/widget.hpp"
+#include "gui/widgets/widget.h"
+
+#include "listeners/keylistener.h"
+#include "listeners/mouselistener.h"
+
+class ListModel;
+class SelectionListener;
namespace gcn
{
- class SelectionListener;
-
/**
* An implementation of a list box where an item can be selected.
*
@@ -95,14 +96,15 @@ namespace gcn
/**
* Constructor.
*/
- ListBox();
+ explicit ListBox(const Widget2 *const widget);
/**
* Constructor.
*
* @param listModel the list model to use.
*/
- explicit ListBox(ListModel *listModel);
+ ListBox(const Widget2 *const widget,
+ ListModel *listModel);
A_DELETE_COPY(ListBox)
diff --git a/src/guichan/widgets/radiobutton.cpp b/src/gui/base/widgets/radiobutton.cpp
index 26ce731ed..f9d68555a 100644
--- a/src/guichan/widgets/radiobutton.cpp
+++ b/src/gui/base/widgets/radiobutton.cpp
@@ -65,12 +65,7 @@
* For comments regarding functions please see the header file.
*/
-#include "guichan/widgets/radiobutton.hpp"
-
-#include "guichan/font.hpp"
-#include "guichan/graphics.hpp"
-#include "guichan/key.hpp"
-#include "guichan/mouseinput.hpp"
+#include "gui/base/widgets/radiobutton.hpp"
#include "debug.h"
@@ -78,10 +73,10 @@ namespace gcn
{
RadioButton::GroupMap RadioButton::mGroupMap;
- RadioButton::RadioButton() :
- gcn::Widget(),
- gcn::MouseListener(),
- gcn::KeyListener(),
+ RadioButton::RadioButton(const Widget2 *const widget) :
+ Widget(widget),
+ MouseListener(),
+ KeyListener(),
mSelected(false),
mCaption(),
mGroup()
@@ -93,12 +88,13 @@ namespace gcn
addKeyListener(this);
}
- RadioButton::RadioButton(const std::string &caption,
+ RadioButton::RadioButton(const Widget2 *const widget,
+ const std::string &caption,
const std::string &group,
bool selected) :
- gcn::Widget(),
- gcn::MouseListener(),
- gcn::KeyListener(),
+ Widget(widget),
+ MouseListener(),
+ KeyListener(),
mSelected(false),
mCaption(),
mGroup()
diff --git a/src/guichan/include/guichan/widgets/radiobutton.hpp b/src/gui/base/widgets/radiobutton.hpp
index 2a93a82ee..a86a4eed3 100644
--- a/src/guichan/include/guichan/widgets/radiobutton.hpp
+++ b/src/gui/base/widgets/radiobutton.hpp
@@ -67,9 +67,10 @@
#include <map>
#include <string>
-#include "guichan/keylistener.hpp"
-#include "guichan/mouselistener.hpp"
-#include "guichan/widget.hpp"
+#include "listeners/keylistener.h"
+#include "listeners/mouselistener.h"
+
+#include "gui/widgets/widget.h"
namespace gcn
{
@@ -92,7 +93,7 @@ namespace gcn
/**
* Constructor.
*/
- RadioButton();
+ explicit RadioButton(const Widget2 *const widget);
/**
* Constructor. The radio button will be automatically resized
@@ -102,7 +103,8 @@ namespace gcn
* @param group The group the radio button should belong to.
* @param selected True if the radio button should be selected.
*/
- RadioButton(const std::string &caption,
+ RadioButton(const Widget2 *const widget,
+ const std::string &caption,
const std::string &group,
bool selected = false);
diff --git a/src/guichan/widgets/scrollarea.cpp b/src/gui/base/widgets/scrollarea.cpp
index ddc4405e2..665830ce4 100644
--- a/src/guichan/widgets/scrollarea.cpp
+++ b/src/gui/base/widgets/scrollarea.cpp
@@ -65,18 +65,15 @@
* For comments regarding functions please see the header file.
*/
-#include "guichan/widgets/scrollarea.hpp"
-
-#include "guichan/exception.hpp"
-#include "guichan/graphics.hpp"
+#include "gui/base/widgets/scrollarea.hpp"
#include "debug.h"
namespace gcn
{
- ScrollArea::ScrollArea() :
- gcn::BasicContainer(),
- gcn::MouseListener(),
+ ScrollArea::ScrollArea(const Widget2 *const widget) :
+ gcn::BasicContainer(widget),
+ MouseListener(),
mVScroll(0),
mHScroll(0),
mScrollbarWidth(12),
@@ -101,9 +98,10 @@ namespace gcn
addMouseListener(this);
}
- ScrollArea::ScrollArea(Widget *const content) :
- gcn::BasicContainer(),
- gcn::MouseListener(),
+ ScrollArea::ScrollArea(const Widget2 *const widget,
+ Widget *const content) :
+ gcn::BasicContainer(widget),
+ MouseListener(),
mVScroll(0),
mHScroll(0),
mScrollbarWidth(12),
@@ -129,11 +127,12 @@ namespace gcn
addMouseListener(this);
}
- ScrollArea::ScrollArea(Widget *content,
+ ScrollArea::ScrollArea(const Widget2 *const widget,
+ Widget *content,
ScrollPolicy hPolicy,
ScrollPolicy vPolicy) :
- gcn::BasicContainer(),
- gcn::MouseListener(),
+ gcn::BasicContainer(widget),
+ MouseListener(),
mVScroll(0),
mHScroll(0),
mScrollbarWidth(12),
@@ -299,8 +298,6 @@ namespace gcn
{
if (width > 0)
mScrollbarWidth = width;
- else
- throw GCN_EXCEPTION("Width should be greater then 0.");
}
int ScrollArea::getScrollbarWidth() const
@@ -445,7 +442,7 @@ namespace gcn
break;
default:
- throw GCN_EXCEPTION("Horizontal scroll policy invalid.");
+ break;
}
switch (mVPolicy)
@@ -470,27 +467,27 @@ namespace gcn
}
break;
default:
- throw GCN_EXCEPTION("Vertical scroll policy invalid.");
+ break;
}
}
- Rectangle ScrollArea::getChildrenArea()
+ Rect ScrollArea::getChildrenArea()
{
- const Rectangle area = Rectangle(0, 0,
+ const Rect area = Rect(0, 0,
mVBarVisible ? (getWidth() - mScrollbarWidth) : getWidth(),
mHBarVisible ? (getHeight() - mScrollbarWidth) : getHeight());
if (area.width < 0 || area.height < 0)
- return Rectangle();
+ return Rect();
return area;
}
- void ScrollArea::showWidgetPart(Widget* widget, Rectangle area)
+ void ScrollArea::showWidgetPart(Widget* widget, Rect area)
{
const Widget *const content = getContent();
if (widget != content)
- throw GCN_EXCEPTION("Widget not content widget");
+ return;
BasicContainer::showWidgetPart(widget, area);
@@ -542,7 +539,7 @@ namespace gcn
checkPolicies();
}
- void ScrollArea::setDimension(const Rectangle& dimension)
+ void ScrollArea::setDimension(const Rect& dimension)
{
Widget::setDimension(dimension);
checkPolicies();
diff --git a/src/guichan/include/guichan/widgets/scrollarea.hpp b/src/gui/base/widgets/scrollarea.hpp
index 30fa64abc..879792019 100644
--- a/src/guichan/include/guichan/widgets/scrollarea.hpp
+++ b/src/gui/base/widgets/scrollarea.hpp
@@ -64,10 +64,8 @@
#ifndef GCN_SCROLLAREA_HPP
#define GCN_SCROLLAREA_HPP
-#include <string>
-
-#include "guichan/basiccontainer.hpp"
-#include "guichan/mouselistener.hpp"
+#include "gui/base/basiccontainer.hpp"
+#include "listeners/mouselistener.h"
namespace gcn
{
@@ -100,14 +98,15 @@ namespace gcn
/**
* Constructor.
*/
- ScrollArea();
+ explicit ScrollArea(const Widget2 *const widget);
/**
* Constructor.
*
* @param content The content of the scroll area.
*/
- explicit ScrollArea(Widget *const content);
+ ScrollArea(const Widget2 *const widget,
+ Widget *const content);
/**
* Constructor.
@@ -118,7 +117,8 @@ namespace gcn
* @param vPolicy The policy for the vertical scrollbar. See enum with
* policies.
*/
- ScrollArea(Widget *content,
+ ScrollArea(const Widget2 *const widget,
+ Widget *content,
ScrollPolicy hPolicy,
ScrollPolicy vPolicy);
@@ -345,9 +345,9 @@ namespace gcn
// Inherited from BasicContainer
- virtual void showWidgetPart(Widget* widget, Rectangle area);
+ virtual void showWidgetPart(Widget* widget, Rect area);
- virtual Rectangle getChildrenArea();
+ virtual Rect getChildrenArea();
virtual Widget *getWidgetAt(int x, int y);
@@ -362,7 +362,7 @@ namespace gcn
void setHeight(int height);
- void setDimension(const Rectangle& dimension);
+ void setDimension(const Rect& dimension);
// Inherited from MouseListener
diff --git a/src/guichan/widgets/slider.cpp b/src/gui/base/widgets/slider.cpp
index 849101fd8..40c73ceb5 100644
--- a/src/guichan/widgets/slider.cpp
+++ b/src/gui/base/widgets/slider.cpp
@@ -65,20 +65,17 @@
* For comments regarding functions please see the header file.
*/
-#include "guichan/widgets/slider.hpp"
-
-#include "guichan/graphics.hpp"
-#include "guichan/key.hpp"
-#include "guichan/mouseinput.hpp"
+#include "gui/base/widgets/slider.hpp"
#include "debug.h"
namespace gcn
{
- Slider::Slider(const double scaleEnd) :
- gcn::Widget(),
- gcn::MouseListener(),
- gcn::KeyListener(),
+ Slider::Slider(const Widget2 *const widget,
+ const double scaleEnd) :
+ Widget(widget),
+ MouseListener(),
+ KeyListener(),
mDragged(false),
mValue(0),
mStepLength(scaleEnd / 10),
@@ -94,10 +91,12 @@ namespace gcn
addKeyListener(this);
}
- Slider::Slider(const double scaleStart, const double scaleEnd) :
- gcn::Widget(),
- gcn::MouseListener(),
- gcn::KeyListener(),
+ Slider::Slider(const Widget2 *const widget,
+ const double scaleStart,
+ const double scaleEnd) :
+ Widget(widget),
+ MouseListener(),
+ KeyListener(),
mDragged(false),
mValue(scaleStart),
mStepLength((scaleEnd - scaleStart) / 10),
diff --git a/src/guichan/include/guichan/widgets/slider.hpp b/src/gui/base/widgets/slider.hpp
index 04f774b21..9d5adc6d8 100644
--- a/src/guichan/include/guichan/widgets/slider.hpp
+++ b/src/gui/base/widgets/slider.hpp
@@ -64,9 +64,10 @@
#ifndef GCN_SLIDER_HPP
#define GCN_SLIDER_HPP
-#include "guichan/keylistener.hpp"
-#include "guichan/mouselistener.hpp"
-#include "guichan/widget.hpp"
+#include "listeners/keylistener.h"
+#include "listeners/mouselistener.h"
+
+#include "gui/widgets/widget.h"
namespace gcn
{
@@ -98,7 +99,8 @@ namespace gcn
*
* @param scaleEnd The end value of the slider scale.
*/
- explicit Slider(const double scaleEnd = 1.0);
+ explicit Slider(const Widget2 *const widget,
+ const double scaleEnd = 1.0);
/**
* Constructor.
@@ -106,7 +108,9 @@ namespace gcn
* @param scaleStart The start value of the slider scale.
* @param scaleEnd The end value of the slider scale.
*/
- Slider(const double scaleStart, const double scaleEnd);
+ Slider(const Widget2 *const widget,
+ const double scaleStart,
+ const double scaleEnd);
A_DELETE_COPY(Slider)
diff --git a/src/guichan/widgets/textbox.cpp b/src/gui/base/widgets/textbox.cpp
index e3bfd39f5..f74db9a29 100644
--- a/src/guichan/widgets/textbox.cpp
+++ b/src/gui/base/widgets/textbox.cpp
@@ -65,22 +65,20 @@
* For comments regarding functions please see the header file.
*/
-#include "guichan/widgets/textbox.hpp"
+#include "gui/base/widgets/textbox.hpp"
-#include "guichan/basiccontainer.hpp"
-#include "guichan/font.hpp"
-#include "guichan/graphics.hpp"
-#include "guichan/key.hpp"
-#include "guichan/mouseinput.hpp"
+#include "gui/font.h"
+
+#include "render/graphics.h"
#include "debug.h"
namespace gcn
{
- TextBox::TextBox() :
- gcn::Widget(),
- gcn::MouseListener(),
- gcn::KeyListener(),
+ TextBox::TextBox(const Widget2 *const widget) :
+ Widget(widget),
+ MouseListener(),
+ KeyListener(),
mTextRows(),
mCaretColumn(0),
mCaretRow(0),
@@ -95,10 +93,11 @@ namespace gcn
adjustSize();
}
- TextBox::TextBox(const std::string& text) :
- gcn::Widget(),
- gcn::MouseListener(),
- gcn::KeyListener(),
+ TextBox::TextBox(const Widget2 *const widget,
+ const std::string& text) :
+ Widget(widget),
+ MouseListener(),
+ KeyListener(),
mTextRows(),
mCaretColumn(0),
mCaretRow(0),
@@ -305,7 +304,7 @@ namespace gcn
void TextBox::scrollToCaret()
{
- Rectangle scroll;
+ Rect scroll;
scroll.x = getFont()->getWidth(
mTextRows[mCaretRow].substr(0, mCaretColumn));
scroll.y = getFont()->getHeight() * mCaretRow;
diff --git a/src/guichan/include/guichan/widgets/textbox.hpp b/src/gui/base/widgets/textbox.hpp
index a75b52115..148b4f007 100644
--- a/src/guichan/include/guichan/widgets/textbox.hpp
+++ b/src/gui/base/widgets/textbox.hpp
@@ -64,13 +64,13 @@
#ifndef GCN_TEXTBOX_HPP
#define GCN_TEXTBOX_HPP
-#include <ctime>
#include <string>
#include <vector>
-#include "guichan/keylistener.hpp"
-#include "guichan/mouselistener.hpp"
-#include "guichan/widget.hpp"
+#include "listeners/keylistener.h"
+#include "listeners/mouselistener.h"
+
+#include "gui/widgets/widget.h"
namespace gcn
{
@@ -86,14 +86,15 @@ namespace gcn
/**
* Constructor.
*/
- TextBox();
+ explicit TextBox(const Widget2 *const widget);
/**
* Constructor.
*
* @param text The default text of the text box.
*/
- explicit TextBox(const std::string& text);
+ TextBox(const Widget2 *const widget,
+ const std::string& text);
A_DELETE_COPY(TextBox)
diff --git a/src/guichan/widgets/textfield.cpp b/src/gui/base/widgets/textfield.cpp
index 1e4309266..c2cead500 100644
--- a/src/guichan/widgets/textfield.cpp
+++ b/src/gui/base/widgets/textfield.cpp
@@ -65,21 +65,18 @@
* For comments regarding functions please see the header file.
*/
-#include "guichan/widgets/textfield.hpp"
+#include "gui/base/widgets/textfield.hpp"
-#include "guichan/font.hpp"
-#include "guichan/graphics.hpp"
-#include "guichan/key.hpp"
-#include "guichan/mouseinput.hpp"
+#include "gui/font.h"
#include "debug.h"
namespace gcn
{
- TextField::TextField() :
- gcn::Widget(),
- gcn::MouseListener(),
- gcn::KeyListener(),
+ TextField::TextField(const Widget2 *const widget) :
+ Widget(widget),
+ MouseListener(),
+ KeyListener(),
mText(),
mCaretPosition(0),
mXScroll(0)
@@ -90,10 +87,11 @@ namespace gcn
addKeyListener(this);
}
- TextField::TextField(const std::string& text) :
- gcn::Widget(),
- gcn::MouseListener(),
- gcn::KeyListener(),
+ TextField::TextField(const Widget2 *const widget,
+ const std::string& text) :
+ Widget(widget),
+ MouseListener(),
+ KeyListener(),
mText(text),
mCaretPosition(0),
mXScroll(0)
diff --git a/src/guichan/include/guichan/widgets/textfield.hpp b/src/gui/base/widgets/textfield.hpp
index b1293045f..e9df238ba 100644
--- a/src/guichan/include/guichan/widgets/textfield.hpp
+++ b/src/gui/base/widgets/textfield.hpp
@@ -64,9 +64,10 @@
#ifndef GCN_TEXTFIELD_HPP
#define GCN_TEXTFIELD_HPP
-#include "guichan/keylistener.hpp"
-#include "guichan/mouselistener.hpp"
-#include "guichan/widget.hpp"
+#include "listeners/keylistener.h"
+#include "listeners/mouselistener.h"
+
+#include "gui/widgets/widget.h"
#include <string>
@@ -84,7 +85,7 @@ namespace gcn
/**
* Constructor.
*/
- TextField();
+ explicit TextField(const Widget2 *const widget);
/**
* Constructor. The text field will be automatically resized
@@ -92,7 +93,8 @@ namespace gcn
*
* @param text The default text of the text field.
*/
- explicit TextField(const std::string& text);
+ TextField(const Widget2 *const widget,
+ const std::string& text);
A_DELETE_COPY(TextField)
diff --git a/src/guichan/image.cpp b/src/gui/cliprect.cpp
index d60df27a7..5255a4c98 100644
--- a/src/guichan/image.cpp
+++ b/src/gui/cliprect.cpp
@@ -65,19 +65,40 @@
* For comments regarding functions please see the header file.
*/
-#include "guichan/image.hpp"
-
-#include "guichan/exception.hpp"
+#include "gui/cliprect.h"
#include "debug.h"
-namespace gcn
+ClipRect::ClipRect() :
+ Rect(),
+ xOffset(0),
+ yOffset(0)
+{
+ x = 0;
+ y = 0;
+ width = 0;
+ height = 0;
+}
+
+ClipRect::ClipRect(const int x0, const int y0,
+ const int width0, const int height0,
+ const int xOffset0, const int yOffset0) :
+ Rect(),
+ xOffset(xOffset0),
+ yOffset(yOffset0)
+{
+ x = x0;
+ y = y0;
+ width = width0;
+ height = height0;
+}
+
+const ClipRect& ClipRect::operator=(const Rect& other)
{
- Image::Image()
- {
- }
+ x = other.x;
+ y = other.y;
+ width = other.width;
+ height = other.height;
- Image::~Image()
- {
- }
+ return *this;
}
diff --git a/src/guichan/include/guichan/input.hpp b/src/gui/cliprect.h
index 71a15ce85..88a7ab5a4 100644
--- a/src/guichan/include/guichan/input.hpp
+++ b/src/gui/cliprect.h
@@ -61,74 +61,66 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef GCN_INPUT_HPP
-#define GCN_INPUT_HPP
+#ifndef GUI_CLIPRECT_H
+#define GUI_CLIPRECT_H
+
+#include "gui/rect.h"
#include "localconsts.h"
-namespace gcn
+/**
+ * A rectangle used when dealing with clipping. A clip rectangle is
+ * a regular rectangle extended with variables for x offsets and y
+ * offsets. The offsets are used for calculations from relative
+ * screen coordinates to actual screen coordinates.
+ */
+class ClipRect final : public Rect
{
- class KeyInput;
- class MouseInput;
-
- /**
- * Abstract class for providing functions for user input.
- *
- * Guichan contains implementations of Input for common
- * libraries like the Allegro library, the HGE library,
- * and the SDL library.
- * To make Guichan usable with other libraries, an Input
- * class must be implemented.
- *
- * @see AllegroInput, HGEInput, OpenLayerInput,
- * SDLInput
- */
- class Input
- {
public:
/**
- * Destructor.
- */
- virtual ~Input(){ }
-
- /**
- * Checks if the key queue is empty, or not.
- *
- * @return True if the key queue is empty,
- * false otherwise.
- */
- virtual bool isKeyQueueEmpty() A_WARN_UNUSED = 0;
+ * Constructor.
+ */
+ ClipRect();
/**
- * Dequeues the key input queue.
- *
- * @return The first key input in the key input queue.
- */
- virtual KeyInput dequeueKeyInput() = 0;
+ * Constructor.
+ *
+ * @param x0 The rectangle x coordinate.
+ * @param y0 The rectangle y coordinate.
+ * @param width0 The rectangle width.
+ * @param height0 The rectangle height.
+ * @param xOffset0 The offset of the x coordinate. Used to for
+ * calculating the actual screen coordinate from
+ * the relative screen coordinate.
+ * @param yOffset0 The offset of the y coordinate. Used to for
+ * calculating the actual screen coordinate from
+ * the relative screen coordinate.
+ */
+ ClipRect(const int x0,
+ const int y0,
+ const int width0,
+ const int height0,
+ const int xOffset0,
+ const int yOffset0);
/**
- * Checks if the mouse queue is empyt, or not.
- *
- * @return True if the mouse queue is empty,
- * false otherwise.
- */
- virtual bool isMouseQueueEmpty() A_WARN_UNUSED = 0;
+ * Copy constructor. Copies x, y, width and height
+ * field from a rectangle to a clip rectangle.
+ *
+ * @param other The rectangle to copy data from.
+ * @returns A clip rectangle with data copyied from a rectangle.
+ */
+ const ClipRect& operator=(const Rect& other);
/**
- * Dequeues the mouse input queue.
- *
- * @return The first mouse input in the mouse input queue.
- */
- virtual MouseInput dequeueMouseInput() = 0;
+ * Holds the x offset of the x coordinate.
+ */
+ int xOffset;
/**
- * Polls all exsisting input. Called when input should
- * be polled. The function exists for compatibility reason
- * where some libraries need to poll input at a certain
- * logic rate.
- */
- virtual void _pollInput() = 0;
- };
-} // namespace gcn
+ * Holds the y offset of the y coordinate.
+ */
+ int yOffset;
+};
-#endif // end GCN_INPUT_HPP
+#endif // GUI_CLIPRECT_H
diff --git a/src/guichan/keyinput.cpp b/src/gui/color.cpp
index a18113c8d..aa9ffe840 100644
--- a/src/guichan/keyinput.cpp
+++ b/src/gui/color.cpp
@@ -65,90 +65,101 @@
* For comments regarding functions please see the header file.
*/
-#include "guichan/keyinput.hpp"
+#include "gui/color.h"
#include "debug.h"
-namespace gcn
+Color::Color() :
+ r(0U),
+ g(0U),
+ b(0U),
+ a(255U)
{
- KeyInput::KeyInput(const Key& key, unsigned int type) :
- mKey(key),
- mType(type),
- mShiftPressed(false),
- mControlPressed(false),
- mAltPressed(false),
- mMetaPressed(false),
- mNumericPad(false)
- {
- }
-
- void KeyInput::setType(unsigned int type)
- {
- mType = type;
- }
-
- int KeyInput::getType() const
- {
- return mType;
- }
-
- void KeyInput::setKey(const Key& key)
- {
- mKey = key;
- }
-
- const Key& KeyInput::getKey() const
- {
- return mKey;
- }
-
- bool KeyInput::isShiftPressed() const
- {
- return mShiftPressed;
- }
-
- void KeyInput::setShiftPressed(bool pressed)
- {
- mShiftPressed = pressed;
- }
-
- bool KeyInput::isControlPressed() const
- {
- return mControlPressed;
- }
-
- void KeyInput::setControlPressed(bool pressed)
- {
- mControlPressed = pressed;
- }
-
- bool KeyInput::isAltPressed() const
- {
- return mAltPressed;
- }
-
- void KeyInput::setAltPressed(bool pressed)
- {
- mAltPressed = pressed;
- }
-
- bool KeyInput::isMetaPressed() const
- {
- return mMetaPressed;
- }
-
- void KeyInput::setMetaPressed(bool pressed)
- {
- mMetaPressed = pressed;
- }
-
- bool KeyInput::isNumericPad() const
- {
- return mNumericPad;
- }
-
- void KeyInput::setNumericPad(bool numpad)
- {
- mNumericPad = numpad;
- }
-} // namespace gcn
+}
+
+Color::Color(const unsigned int color) :
+ r((color >> 16) & 0xFF),
+ g((color >> 8) & 0xFF),
+ b(color & 0xFF),
+ a(255U)
+{
+}
+
+Color::Color(const unsigned int ar,
+ const unsigned int ag,
+ const unsigned int ab,
+ const unsigned int aa) :
+ r(ar),
+ g(ag),
+ b(ab),
+ a(aa)
+{
+}
+
+Color Color::operator+(const Color& color) const
+{
+ Color result(r + color.r,
+ g + color.g,
+ b + color.b,
+ 255U);
+
+ result.r = (result.r > 255U ? 255U : result.r);
+ result.g = (result.g > 255U ? 255U : result.g);
+ result.b = (result.b > 255U ? 255U : result.b);
+
+ return result;
+}
+
+Color Color::operator-(const Color& color) const
+{
+ Color result(r - color.r,
+ g - color.g,
+ b - color.b,
+ 255U);
+
+ result.r = (result.r > 255U ? 255U : result.r);
+ result.g = (result.g > 255U ? 255U : result.g);
+ result.b = (result.b > 255U ? 255U : result.b);
+
+ return result;
+}
+
+Color Color::operator*(const float value) const
+{
+ Color result(static_cast<int>(static_cast<float>(r) * value),
+ static_cast<int>(static_cast<float>(g) * value),
+ static_cast<int>(static_cast<float>(b) * value),
+ a);
+
+ result.r = (result.r > 255U ? 255U : result.r);
+ result.g = (result.g > 255U ? 255U : result.g);
+ result.b = (result.b > 255U ? 255U : result.b);
+
+ return result;
+}
+
+bool Color::operator==(const Color& color) const
+{
+ return r == color.r && g == color.g && b == color.b && a == color.a;
+}
+
+bool Color::operator!=(const Color& color) const
+{
+ return !(r == color.r && g == color.g && b == color.b && a == color.a);
+}
+
+std::ostream& operator<<(std::ostream& out,
+ const Color& color)
+{
+ out << "Color [r = "
+ << color.r
+ << ", g = "
+ << color.g
+ << ", b = "
+ << color.b
+ << ", a = "
+ << color.a
+ << "]";
+
+ return out;
+}
diff --git a/src/guichan/include/guichan/color.hpp b/src/gui/color.h
index c32adb2e9..db8fda970 100644
--- a/src/guichan/include/guichan/color.hpp
+++ b/src/gui/color.h
@@ -61,132 +61,133 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef GCN_COLOR_HPP
-#define GCN_COLOR_HPP
+#ifndef GUI_COLOR_H
+#define GUI_COLOR_H
#include <iostream>
#include "localconsts.h"
-namespace gcn
+/**
+ * Represents a color with red, green, blue and alpha components.
+ */
+class Color final
{
- /**
- * Represents a color with red, green, blue and alpha components.
- */
- class Color final
- {
public:
/**
- * Constructor. Initializes the color to black.
- */
+ * Constructor. Initializes the color to black.
+ */
Color();
/**
- * Constructor. Constructs a color from the bytes in an integer.
- * Call it with a hexadecimal constant for HTML-style color representation.
- * The alpha component is 255 by default.
- *
- * EXAMPLE: Color(0xff50a0) constructs a very nice pinkish color.
- *
- * NOTE: Because of this constructor, integers will be automatically
- * casted to a color by your compiler.
- *
- * @param color The color to initialise the object with.
- */
- explicit Color(const int color);
+ * Constructor. Constructs a color from the bytes in an integer.
+ * Call it with a hexadecimal constant for HTML-style color
+ * representation.
+ * The alpha component is 255 by default.
+ *
+ * EXAMPLE: Color(0xff50a0) constructs a very nice pinkish color.
+ *
+ * NOTE: Because of this constructor, integers will be automatically
+ * casted to a color by your compiler.
+ *
+ * @param color The color to initialise the object with.
+ */
+ explicit Color(const unsigned int color);
/**
- * Constructor. The default alpha value is 255.
- *
- * @param r Red color component (range 0-255).
- * @param g Green color component (range 0-255).
- * @param b Blue color component (range 0-255).
- * @param a Alpha, used for transparency. A value of 0 means
- * totaly transparent, 255 is totaly opaque.
- */
- Color(const int r, const int g, const int b, const int a = 255);
+ * Constructor. The default alpha value is 255.
+ *
+ * @param r Red color component (range 0-255).
+ * @param g Green color component (range 0-255).
+ * @param b Blue color component (range 0-255).
+ * @param a Alpha, used for transparency. A value of 0 means
+ * totaly transparent, 255 is totaly opaque.
+ */
+ Color(const unsigned int r,
+ const unsigned int g,
+ const unsigned int b,
+ const unsigned int a = 255);
/**
- * Adds the RGB values of two colors together. The values will be
- * clamped if they go out of range.
- *
- * WARNING: This function will reset the alpha value of the
- * returned color to 255.
- *
- * @param color A color to add to this color.
- * @return The added colors with an alpha value set to 255.
- */
+ * Adds the RGB values of two colors together. The values will be
+ * clamped if they go out of range.
+ *
+ * WARNING: This function will reset the alpha value of the
+ * returned color to 255.
+ *
+ * @param color A color to add to this color.
+ * @return The added colors with an alpha value set to 255.
+ */
Color operator+(const Color& color) const;
/**
- * Subtracts the RGB values of one color from another.
- * The values will be clamped if they go out of range.
- *
- * WARNING: This function will reset the alpha value of the
- * returned color to 255.
- *
- * @param color A color to subtract from this color.
- * @return The subtracted colors with an alpha value set to 255.
- */
+ * Subtracts the RGB values of one color from another.
+ * The values will be clamped if they go out of range.
+ *
+ * WARNING: This function will reset the alpha value of the
+ * returned color to 255.
+ *
+ * @param color A color to subtract from this color.
+ * @return The subtracted colors with an alpha value set to 255.
+ */
Color operator-(const Color& color) const;
/**
- * Multiplies the RGB values of a color with a float value.
- * The values will be clamped if they go out of range.
- *
- * @param value The value to multiply the color with.
- * @return The multiplied colors. The alpha value will, unlike
- * the add and subtract operations, be multiplied as
- * well.
- */
+ * Multiplies the RGB values of a color with a float value.
+ * The values will be clamped if they go out of range.
+ *
+ * @param value The value to multiply the color with.
+ * @return The multiplied colors. The alpha value will, unlike
+ * the add and subtract operations, be multiplied as
+ * well.
+ */
Color operator*(const float value) const;
/**
- * Compares two colors.
- *
- * @return True if the two colors have the same RGBA components
- * false otherwise.
- */
+ * Compares two colors.
+ *
+ * @return True if the two colors have the same RGBA components
+ * false otherwise.
+ */
bool operator==(const Color& color) const;
/**
- * Compares two colors.
- *
- * @return True if the two colors have different RGBA components,
- * false otherwise.
- */
+ * Compares two colors.
+ *
+ * @return True if the two colors have different RGBA components,
+ * false otherwise.
+ */
bool operator!=(const Color& color) const;
/**
- * Output operator for output.
- *
- * @param out The stream to output to.
- * @param color The color to output.
- */
+ * Output operator for output.
+ *
+ * @param out The stream to output to.
+ * @param color The color to output.
+ */
friend std::ostream& operator<<(std::ostream& out,
const Color& Color);
/**
- * Holds the red color component (range 0-255).
- */
- int r;
+ * Holds the red color component (range 0-255).
+ */
+ unsigned int r;
/**
- * Holds the green color component (range 0-255).
- */
- int g;
+ * Holds the green color component (range 0-255).
+ */
+ unsigned int g;
/**
- * Holds the blue color component (range 0-255).
- */
- int b;
+ * Holds the blue color component (range 0-255).
+ */
+ unsigned int b;
/**
- * Holds the alpha color component. A value of 0 means totally
- * transparent while a value of 255 is considered opaque.
- */
- int a;
- };
-} // namespace gcn
-
-#endif // end GCN_COLOR_HPP
+ * Holds the alpha color component. A value of 0 means totally
+ * transparent while a value of 255 is considered opaque.
+ */
+ unsigned int a;
+};
+
+#endif // GUI_COLOR_H
diff --git a/src/gui/focushandler.cpp b/src/gui/focushandler.cpp
index cd780e12d..928b3b72e 100644
--- a/src/gui/focushandler.cpp
+++ b/src/gui/focushandler.cpp
@@ -20,15 +20,74 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include "gui/focushandler.h"
#include "gui/gui.h"
#include "gui/widgets/window.h"
+#include "listeners/focuslistener.h"
+
#include "debug.h"
-void FocusHandler::requestModalFocus(gcn::Widget *widget)
+FocusHandler::FocusHandler() :
+ mWidgets(),
+ mFocusedWidget(nullptr),
+ mModalFocusedWidget(nullptr),
+ mModalMouseInputFocusedWidget(nullptr),
+ mDraggedWidget(nullptr),
+ mLastWidgetWithMouse(nullptr),
+ mLastWidgetWithModalFocus(nullptr),
+ mLastWidgetWithModalMouseInputFocus(nullptr),
+ mLastWidgetPressed(nullptr),
+ mModalStack()
+{
+}
+
+void FocusHandler::requestModalFocus(Widget *widget)
{
/* If there is another widget with modal focus, remove its modal focus
* and put it on the modal widget stack.
@@ -39,45 +98,217 @@ void FocusHandler::requestModalFocus(gcn::Widget *widget)
mModalFocusedWidget = nullptr;
}
- gcn::FocusHandler::requestModalFocus(widget);
+ mModalFocusedWidget = widget;
+ if (mFocusedWidget && !mFocusedWidget->isModalFocused())
+ focusNone();
}
-void FocusHandler::releaseModalFocus(gcn::Widget *widget)
+void FocusHandler::releaseModalFocus(Widget *widget)
{
mModalStack.remove(widget);
if (mModalFocusedWidget == widget)
{
- gcn::FocusHandler::releaseModalFocus(widget);
+ if (mModalFocusedWidget == widget)
+ mModalFocusedWidget = nullptr;
/* Check if there were any previously modal widgets that'd still like
* to regain their modal focus.
*/
if (!mModalStack.empty())
{
- gcn::FocusHandler::requestModalFocus(mModalStack.front());
+ requestModalFocus(mModalStack.front());
mModalStack.pop_front();
}
}
}
-void FocusHandler::remove(gcn::Widget *widget)
+void FocusHandler::remove(Widget *widget)
{
releaseModalFocus(widget);
- gcn::FocusHandler::remove(widget);
+ if (isFocused(widget))
+ mFocusedWidget = nullptr;
+
+ for (WidgetIterator iter = mWidgets.begin();
+ iter != mWidgets.end(); ++iter)
+ {
+ if ((*iter) == widget)
+ {
+ mWidgets.erase(iter);
+ break;
+ }
+ }
+
+ if (mDraggedWidget == widget)
+ {
+ mDraggedWidget = nullptr;
+ return;
+ }
+
+ if (mLastWidgetWithMouse == widget)
+ {
+ mLastWidgetWithMouse = nullptr;
+ return;
+ }
+
+ if (mLastWidgetWithModalFocus == widget)
+ {
+ mLastWidgetWithModalFocus = nullptr;
+ return;
+ }
+
+ if (mLastWidgetWithModalMouseInputFocus == widget)
+ {
+ mLastWidgetWithModalMouseInputFocus = nullptr;
+ return;
+ }
+
+ if (mLastWidgetPressed == widget)
+ {
+ mLastWidgetPressed = nullptr;
+ return;
+ }
}
void FocusHandler::tabNext()
{
- gcn::FocusHandler::tabNext();
+ if (mFocusedWidget)
+ {
+ if (!mFocusedWidget->isTabOutEnabled())
+ return;
+ }
+
+ if (mWidgets.empty())
+ {
+ mFocusedWidget = nullptr;
+ return;
+ }
+
+ int i;
+ int focusedWidget = -1;
+ const int sz = static_cast<int>(mWidgets.size());
+ for (i = 0; i < sz; ++ i)
+ {
+ if (mWidgets[i] == mFocusedWidget)
+ focusedWidget = i;
+ }
+ const int focused = focusedWidget;
+ bool done = false;
+
+ // i is a counter that ensures that the following loop
+ // won't get stuck in an infinite loop
+ i = sz;
+ do
+ {
+ ++ focusedWidget;
+
+ if (i == 0)
+ {
+ focusedWidget = -1;
+ break;
+ }
+
+ -- i;
+
+ if (focusedWidget >= sz)
+ focusedWidget = 0;
+
+ if (focusedWidget == focused)
+ return;
+
+ const Widget *const widget = mWidgets.at(focusedWidget);
+ if (widget->isFocusable() && widget->isTabInEnabled() &&
+ (!mModalFocusedWidget || widget->isModalFocused()))
+ {
+ done = true;
+ }
+ }
+ while (!done);
+
+ if (focusedWidget >= 0)
+ {
+ mFocusedWidget = mWidgets.at(focusedWidget);
+ Event focusEvent(mFocusedWidget);
+ distributeFocusGainedEvent(focusEvent);
+ }
+
+ if (focused >= 0)
+ {
+ Event focusEvent(mWidgets.at(focused));
+ distributeFocusLostEvent(focusEvent);
+ }
checkForWindow();
}
void FocusHandler::tabPrevious()
{
- gcn::FocusHandler::tabPrevious();
+ if (mFocusedWidget)
+ {
+ if (!mFocusedWidget->isTabOutEnabled())
+ return;
+ }
+
+ if (mWidgets.empty())
+ {
+ mFocusedWidget = nullptr;
+ return;
+ }
+
+ int i;
+ int focusedWidget = -1;
+ const int sz = static_cast<int>(mWidgets.size());
+ for (i = 0; i < sz; ++ i)
+ {
+ if (mWidgets[i] == mFocusedWidget)
+ focusedWidget = i;
+ }
+ const int focused = focusedWidget;
+ bool done = false;
+
+ // i is a counter that ensures that the following loop
+ // won't get stuck in an infinite loop
+ i = sz;
+ do
+ {
+ -- focusedWidget;
+
+ if (i == 0)
+ {
+ focusedWidget = -1;
+ break;
+ }
+
+ -- i;
+
+ if (focusedWidget <= 0)
+ focusedWidget = sz - 1;
+
+ if (focusedWidget == focused)
+ return;
+
+ const Widget *const widget = mWidgets.at(focusedWidget);
+ if (widget->isFocusable() && widget->isTabInEnabled() &&
+ (!mModalFocusedWidget || widget->isModalFocused()))
+ {
+ done = true;
+ }
+ }
+ while (!done);
+
+ if (focusedWidget >= 0)
+ {
+ mFocusedWidget = mWidgets.at(focusedWidget);
+ Event focusEvent(mFocusedWidget);
+ distributeFocusGainedEvent(focusEvent);
+ }
+
+ if (focused >= 0)
+ {
+ Event focusEvent(mWidgets.at(focused));
+ distributeFocusLostEvent(focusEvent);
+ }
checkForWindow();
}
@@ -86,7 +317,7 @@ void FocusHandler::checkForWindow() const
{
if (mFocusedWidget)
{
- gcn::Widget *widget = mFocusedWidget->getParent();
+ Widget *widget = mFocusedWidget->getParent();
while (widget)
{
@@ -103,9 +334,284 @@ void FocusHandler::checkForWindow() const
}
}
-void FocusHandler::distributeFocusGainedEvent(const gcn::Event &focusEvent)
+void FocusHandler::distributeFocusGainedEvent(const Event &focusEvent)
{
if (gui)
gui->distributeGlobalFocusGainedEvent(focusEvent);
- gcn::FocusHandler::distributeFocusGainedEvent(focusEvent);
+
+ Widget *const sourceWidget = focusEvent.getSource();
+
+ std::list<FocusListener*> focusListeners
+ = sourceWidget->_getFocusListeners();
+
+ // Send the event to all focus listeners of the widget.
+ for (std::list<FocusListener*>::const_iterator
+ it = focusListeners.begin();
+ it != focusListeners.end();
+ ++ it)
+ {
+ (*it)->focusGained(focusEvent);
+ }
+}
+
+void FocusHandler::requestFocus(Widget* widget)
+{
+ if (!widget || widget == mFocusedWidget)
+ return;
+
+ int toBeFocusedIndex = -1;
+ for (unsigned int i = 0, sz = static_cast<unsigned int>(
+ mWidgets.size()); i < sz; ++i)
+ {
+ if (mWidgets[i] == widget)
+ {
+ toBeFocusedIndex = i;
+ break;
+ }
+ }
+
+ if (toBeFocusedIndex < 0)
+ return;
+
+ Widget *const oldFocused = mFocusedWidget;
+
+ if (oldFocused != widget)
+ {
+ mFocusedWidget = mWidgets.at(toBeFocusedIndex);
+
+ if (oldFocused)
+ {
+ Event focusEvent(oldFocused);
+ distributeFocusLostEvent(focusEvent);
+ }
+
+ Event focusEvent(mWidgets.at(toBeFocusedIndex));
+ distributeFocusGainedEvent(focusEvent);
+ }
+}
+
+void FocusHandler::requestModalMouseInputFocus(Widget* widget)
+{
+ if (mModalMouseInputFocusedWidget
+ && mModalMouseInputFocusedWidget != widget)
+ {
+ return;
+ }
+
+ mModalMouseInputFocusedWidget = widget;
+}
+
+void FocusHandler::releaseModalMouseInputFocus(Widget* widget)
+{
+ if (mModalMouseInputFocusedWidget == widget)
+ mModalMouseInputFocusedWidget = nullptr;
+}
+
+Widget* FocusHandler::getFocused() const
+{
+ return mFocusedWidget;
+}
+
+Widget* FocusHandler::getModalFocused() const
+{
+ return mModalFocusedWidget;
+}
+
+Widget* FocusHandler::getModalMouseInputFocused() const
+{
+ return mModalMouseInputFocusedWidget;
+}
+
+void FocusHandler::focusNext()
+{
+ int i;
+ int focusedWidget = -1;
+ const int sz = static_cast<int>(mWidgets.size());
+ for (i = 0; i < sz; ++i)
+ {
+ if (mWidgets[i] == mFocusedWidget)
+ focusedWidget = i;
+ }
+ const int focused = focusedWidget;
+
+ // i is a counter that ensures that the following loop
+ // won't get stuck in an infinite loop
+ i = sz;
+ do
+ {
+ ++ focusedWidget;
+
+ if (i == 0)
+ {
+ focusedWidget = -1;
+ break;
+ }
+
+ -- i;
+
+ if (focusedWidget >= sz)
+ focusedWidget = 0;
+
+ if (focusedWidget == focused)
+ return;
+ }
+ while (!mWidgets.at(focusedWidget)->isFocusable());
+
+ if (focusedWidget >= 0)
+ {
+ mFocusedWidget = mWidgets.at(focusedWidget);
+
+ Event focusEvent(mFocusedWidget);
+ distributeFocusGainedEvent(focusEvent);
+ }
+
+ if (focused >= 0)
+ {
+ Event focusEvent(mWidgets.at(focused));
+ distributeFocusLostEvent(focusEvent);
+ }
+}
+
+void FocusHandler::focusPrevious()
+{
+ if (mWidgets.empty())
+ {
+ mFocusedWidget = nullptr;
+ return;
+ }
+
+ int i;
+ int focusedWidget = -1;
+ const int sz = static_cast<int>(mWidgets.size());
+ for (i = 0; i < sz; ++ i)
+ {
+ if (mWidgets[i] == mFocusedWidget)
+ focusedWidget = i;
+ }
+ const int focused = focusedWidget;
+
+ // i is a counter that ensures that the following loop
+ // won't get stuck in an infinite loop
+ i = sz;
+ do
+ {
+ -- focusedWidget;
+
+ if (i == 0)
+ {
+ focusedWidget = -1;
+ break;
+ }
+
+ -- i;
+
+ if (focusedWidget <= 0)
+ focusedWidget = sz - 1;
+
+ if (focusedWidget == focused)
+ return;
+ }
+ while (!mWidgets.at(focusedWidget)->isFocusable());
+
+ if (focusedWidget >= 0)
+ {
+ mFocusedWidget = mWidgets.at(focusedWidget);
+ Event focusEvent(mFocusedWidget);
+ distributeFocusGainedEvent(focusEvent);
+ }
+
+ if (focused >= 0)
+ {
+ Event focusEvent(mWidgets.at(focused));
+ distributeFocusLostEvent(focusEvent);
+ }
+}
+
+bool FocusHandler::isFocused(const Widget* widget) const
+{
+ return mFocusedWidget == widget;
+}
+
+void FocusHandler::add(Widget* widget)
+{
+ mWidgets.push_back(widget);
+}
+
+void FocusHandler::focusNone()
+{
+ if (mFocusedWidget)
+ {
+ Widget *const focused = mFocusedWidget;
+ mFocusedWidget = nullptr;
+
+ Event focusEvent(focused);
+ distributeFocusLostEvent(focusEvent);
+ }
+}
+
+void FocusHandler::distributeFocusLostEvent(const Event& focusEvent)
+{
+ Widget *const sourceWidget = focusEvent.getSource();
+
+ std::list<FocusListener*> focusListeners
+ = sourceWidget->_getFocusListeners();
+
+ // Send the event to all focus listeners of the widget.
+ for (std::list<FocusListener*>::const_iterator
+ it = focusListeners.begin();
+ it != focusListeners.end();
+ ++ it)
+ {
+ (*it)->focusLost(focusEvent);
+ }
+}
+
+Widget* FocusHandler::getDraggedWidget()
+{
+ return mDraggedWidget;
+}
+
+void FocusHandler::setDraggedWidget(Widget* draggedWidget)
+{
+ mDraggedWidget = draggedWidget;
+}
+
+Widget* FocusHandler::getLastWidgetWithMouse()
+{
+ return mLastWidgetWithMouse;
+}
+
+void FocusHandler::setLastWidgetWithMouse(Widget* lastWidgetWithMouse)
+{
+ mLastWidgetWithMouse = lastWidgetWithMouse;
+}
+
+Widget* FocusHandler::getLastWidgetWithModalFocus()
+{
+ return mLastWidgetWithModalFocus;
+}
+
+void FocusHandler::setLastWidgetWithModalFocus(Widget* widget)
+{
+ mLastWidgetWithModalFocus = widget;
+}
+
+Widget* FocusHandler::getLastWidgetWithModalMouseInputFocus()
+{
+ return mLastWidgetWithModalMouseInputFocus;
+}
+
+void FocusHandler::setLastWidgetWithModalMouseInputFocus(Widget* widget)
+{
+ mLastWidgetWithModalMouseInputFocus = widget;
+}
+
+Widget* FocusHandler::getLastWidgetPressed()
+{
+ return mLastWidgetPressed;
+}
+
+void FocusHandler::setLastWidgetPressed(Widget* lastWidgetPressed)
+{
+ mLastWidgetPressed = lastWidgetPressed;
}
diff --git a/src/gui/focushandler.h b/src/gui/focushandler.h
index e32b9afa1..f12819e75 100644
--- a/src/gui/focushandler.h
+++ b/src/gui/focushandler.h
@@ -20,59 +20,307 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#ifndef GUI_FOCUSHANDLER_H
#define GUI_FOCUSHANDLER_H
-#include <guichan/focushandler.hpp>
+#include "gui/focushandler.h"
#include <list>
+#include <vector>
#include "localconsts.h"
+class Event;
+class Widget;
+
/**
* The focus handler. This focus handler does exactly the same as the Guichan
* focus handler, but keeps a stack of modal widgets to be able to handle
* multiple modal focus requests.
*/
-class FocusHandler final : public gcn::FocusHandler
+class FocusHandler final
{
public:
- FocusHandler() :
- mModalStack()
- { }
+ FocusHandler();
A_DELETE_COPY(FocusHandler)
/**
- * Sets modal focus to a widget. When there is already a modal widget
- * then that widget loses modal focus and will regain it after this
- * widget releases his modal focus.
- */
- void requestModalFocus(gcn::Widget *widget) override final;
+ * Requests focus for a widget. Focus will only be granted to a widget
+ * if it's focusable and if no other widget has modal focus.
+ * If a widget receives focus a focus event will be sent to the
+ * focus listeners of the widget.
+ *
+ * @param widget The widget to request focus for.
+ * @see isFocused, Widget::requestFocus
+ */
+ void requestFocus(Widget* widget);
/**
- * Releases modal focus of a widget. When this widget had modal focus
- * and there are other widgets that had also requested modal focus,
- * then modal focus will be transfered to the last of those.
- */
- void releaseModalFocus(gcn::Widget *widget) override final;
+ * Requests modal focus for a widget. Focus will only be granted
+ * to a widget if it's focusable and if no other widget has modal
+ * focus.
+ *
+ * @param widget The widget to request modal focus for.
+ * @throws Exception when another widget already has modal focus.
+ * @see releaseModalFocus, Widget::requestModalFocus
+ */
+ void requestModalFocus(Widget* widget);
/**
- * Removes a widget from the focus handler. Also makes sure no dangling
- * pointers remain in modal focus stack.
- */
- void remove(gcn::Widget *widget) override final;
+ * Requests modal mouse input focus for a widget. Focus will only
+ * be granted to a widget if it's focusable and if no other widget
+ * has modal mouse input focus.
+ *
+ * Modal mouse input focus means no other widget then the widget with
+ * modal mouse input focus will receive mouse input. The widget with
+ * modal mouse input focus will also receive mouse input no matter what
+ * the mouse input is or where the mouse input occurs.
+ *
+ * @param widget The widget to focus for modal mouse input focus.
+ * @throws Exception when another widget already has modal mouse input
+ * focus.
+ * @see releaseModalMouseInputFocus, Widget::requestModalMouseInputFocus
+ */
+ void requestModalMouseInputFocus(Widget* widget);
/**
- * Overloaded to allow windows to move to the top when one of their
- * widgets is tabbed to when tabbing through focusable elements.
- */
- void tabNext() override final;
+ * Releases modal focus if the widget has modal focus.
+ * If the widget doesn't have modal focus no relase will occur.
+ *
+ * @param widget The widget to release modal focus for.
+ * @see reuqestModalFocus, Widget::releaseModalFocus
+ */
+ void releaseModalFocus(Widget* widget);
+
+ /**
+ * Releases modal mouse input focus if the widget has modal mouse input
+ * focus. If the widget doesn't have modal mouse input focus no relase
+ * will occur.
+ *
+ * @param widget the widget to release modal mouse input focus for.
+ * @see requestModalMouseInputFocus, Widget::releaseModalMouseInputFocus
+ */
+ void releaseModalMouseInputFocus(Widget* widget);
+
+ /**
+ * Checks if a widget is focused.
+ *
+ * @param widget The widget to check.
+ * @return True if the widget is focused, false otherwise.
+ * @see Widget::isFocused
+ */
+ bool isFocused(const Widget* widget) const;
+
+ /**
+ * Gets the widget with focus.
+ *
+ * @return The widget with focus. NULL if no widget has focus.
+ */
+ Widget* getFocused() const A_WARN_UNUSED;
+
+ /**
+ * Gets the widget with modal focus.
+ *
+ * @return The widget with modal focus. NULL if no widget has
+ * modal focus.
+ */
+ Widget* getModalFocused() const A_WARN_UNUSED;
+
+ /**
+ * Gets the widget with modal mouse input focus.
+ *
+ * @return The widget with modal mouse input focus. NULL if
+ * no widget has modal mouse input focus.
+ */
+ Widget* getModalMouseInputFocused() const A_WARN_UNUSED;
+
+ /**
+ * Focuses the next widget added to a conainer.
+ * If no widget has focus the first widget gets focus. The order
+ * in which the widgets are focused is determined by the order
+ * they were added to a container.
+ *
+ * @see focusPrevious
+ */
+ void focusNext();
+
+ /**
+ * Focuses the previous widget added to a contaienr.
+ * If no widget has focus the first widget gets focus. The order
+ * in which the widgets are focused is determined by the order
+ * they were added to a container.
+ *
+ * @see focusNext
+ */
+ void focusPrevious();
+
+ /**
+ * Adds a widget to by handles by the focus handler.
+ *
+ * @param widget The widget to add.
+ * @see remove
+ */
+ void add(Widget* widget);
+
+ /**
+ * Removes a widget from the focus handler.
+ *
+ * @param widget The widget to remove.
+ * @see add
+ */
+ void remove(Widget* widget);
+
+ /**
+ * Focuses nothing. A focus event will also be sent to the
+ * focused widget's focus listeners if a widget has focus.
+ */
+ void focusNone();
+
+ /**
+ * Focuses the next widget which allows tabbing in unless
+ * the current focused Widget disallows tabbing out.
+ *
+ * @see tabPrevious
+ */
+ void tabNext();
+
+ /**
+ * Focuses the previous widget which allows tabbing in unless
+ * current focused widget disallows tabbing out.
+ *
+ * @see tabNext
+ */
+ void tabPrevious();
+
+ /**
+ * Gets the widget being dragged. Used by the Gui class to
+ * keep track of the dragged widget.
+ *
+ * @return the widget being dragged.
+ * @see setDraggedWidget
+ */
+ Widget* getDraggedWidget() A_WARN_UNUSED;
+
+ /**
+ * Sets the widget being dragged. Used by the Gui class to
+ * keep track of the dragged widget.
+ *
+ * @param draggedWidget The widget being dragged.
+ * @see getDraggedWidget
+ */
+ void setDraggedWidget(Widget* draggedWidget);
+
+ /**
+ * Gets the last widget with the mouse. Used by the Gui class
+ * to keep track the last widget with the mouse.
+ *
+ * @return The last widget with the mouse.
+ * @see setLastWidgetWithMouse
+ */
+ Widget* getLastWidgetWithMouse() A_WARN_UNUSED;
+
+ /**
+ * Sets the last widget with the mouse. Used by the Gui class
+ * to keep track the last widget with the mouse.
+ *
+ * @param lastWidgetWithMouse The last widget with the mouse.
+ * @see getLastWidgetWithMouse
+ */
+ void setLastWidgetWithMouse(Widget* lastWidgetWithMouse);
+
+ /**
+ * Gets the last widget with modal focus.
+ *
+ * @return The last widget with modal focus.
+ * @see setLastWidgetWithModalFocus
+ */
+ Widget* getLastWidgetWithModalFocus() A_WARN_UNUSED;
- void tabPrevious() override final;
+ /**
+ * Sets the last widget with modal focus.
+ *
+ * @param widget The last widget with modal focus.
+ * @see getLastWidgetWithModalFocus
+ */
+ void setLastWidgetWithModalFocus(Widget* widget);
+
+ /**
+ * Gets the last widget with modal mouse input focus.
+ *
+ * @return The last widget with modal mouse input focus.
+ * @see setLastWidgetWithModalMouseInputFocus
+ */
+ Widget* getLastWidgetWithModalMouseInputFocus() A_WARN_UNUSED;
+
+ /**
+ * Sets the last widget with modal mouse input focus.
+ *
+ * @param widget The last widget with modal mouse input focus.
+ * @see getLastWidgetWithModalMouseInputFocus
+ */
+ void setLastWidgetWithModalMouseInputFocus(Widget* widget);
+
+ /**
+ * Gets the last widget pressed. Used by the Gui class to keep track
+ * of pressed widgets.
+ *
+ * @return The last widget pressed.
+ * @see setLastWidgetPressed
+ */
+ Widget* getLastWidgetPressed() A_WARN_UNUSED;
- void distributeFocusGainedEvent(const gcn::Event &focusEvent)
- override final;
+ /**
+ * Sets the last widget pressed. Used by the Gui class to keep track
+ * of pressed widgets.
+ *
+ * @param lastWidgetPressed The last widget pressed.
+ * @see getLastWidgetPressed
+ */
+ void setLastWidgetPressed(Widget* lastWidgetPressed);
private:
/**
@@ -82,9 +330,84 @@ class FocusHandler final : public gcn::FocusHandler
void checkForWindow() const;
/**
+ * Distributes a focus lost event.
+ *
+ * @param focusEvent the event to distribute.
+ * @since 0.7.0
+ */
+ static void distributeFocusLostEvent(const Event& focusEvent);
+
+ /**
+ * Distributes a focus gained event.
+ *
+ * @param focusEvent the event to distribute.
+ * @since 0.7.0
+ */
+ static void distributeFocusGainedEvent(const Event& focusEvent);
+
+ /**
+ * Typedef.
+ */
+ typedef std::vector<Widget*> WidgetVector;
+
+ /**
+ * Typedef.
+ */
+ typedef WidgetVector::iterator WidgetIterator;
+
+ /**
+ * Holds the widgets currently being handled by the
+ * focus handler.
+ */
+ WidgetVector mWidgets;
+
+ /**
+ * Holds the focused widget. NULL if no widget has focus.
+ */
+ Widget* mFocusedWidget;
+
+ /**
+ * Holds the modal focused widget. NULL if no widget has
+ * modal focused.
+ */
+ Widget* mModalFocusedWidget;
+
+ /**
+ * Holds the modal mouse input focused widget. NULL if no widget
+ * is being dragged.
+ */
+ Widget* mModalMouseInputFocusedWidget;
+
+ /**
+ * Holds the dragged widget. NULL if no widget is
+ * being dragged.
+ */
+ Widget* mDraggedWidget;
+
+ /**
+ * Holds the last widget with the mouse.
+ */
+ Widget* mLastWidgetWithMouse;
+
+ /**
+ * Holds the last widget with modal focus.
+ */
+ Widget* mLastWidgetWithModalFocus;
+
+ /**
+ * Holds the last widget with modal mouse input focus.
+ */
+ Widget* mLastWidgetWithModalMouseInputFocus;
+
+ /**
+ * Holds the last widget pressed.
+ */
+ Widget* mLastWidgetPressed;
+
+ /**
* Stack of widgets that have requested modal forcus.
*/
- std::list<gcn::Widget*> mModalStack;
+ std::list<Widget*> mModalStack;
};
#endif // GUI_FOCUSHANDLER_H
diff --git a/src/gui/sdlfont.cpp b/src/gui/font.cpp
index f97970a26..8c022f99d 100644
--- a/src/gui/sdlfont.cpp
+++ b/src/gui/font.cpp
@@ -21,7 +21,50 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "gui/sdlfont.h"
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "gui/font.h"
#include "logger.h"
#include "main.h"
@@ -34,13 +77,10 @@
#include "resources/surfaceimagehelper.h"
#include "utils/paths.h"
-#include "utils/physfsrwops.h"
#include "utils/sdlcheckutils.h"
#include "utils/stringutils.h"
#include "utils/timer.h"
-#include <guichan/exception.hpp>
-
#include "debug.h"
const unsigned int CACHE_SIZE = 256;
@@ -50,7 +90,7 @@ const unsigned int CACHE_SIZE_SMALL3 = 170;
const unsigned int CLEAN_TIME = 7;
const int OUTLINE_SIZE = 1;
-bool SDLFont::mSoftMode(false);
+bool Font::mSoftMode(false);
char *strBuf = nullptr;
@@ -59,8 +99,8 @@ int sdlTextChunkCnt = 0;
#endif
SDLTextChunkSmall::SDLTextChunkSmall(const std::string &text0,
- const gcn::Color &color0,
- const gcn::Color &color1) :
+ const Color &color0,
+ const Color &color1) :
text(text0),
color(color0),
color2(color1)
@@ -85,7 +125,7 @@ bool SDLTextChunkSmall::operator<(const SDLTextChunkSmall &chunk) const
if (chunk.text != text)
return chunk.text > text;
- const gcn::Color &c = chunk.color;
+ const Color &c = chunk.color;
if (c.r != color.r)
return c.r > color.r;
if (c.g != color.g)
@@ -93,7 +133,7 @@ bool SDLTextChunkSmall::operator<(const SDLTextChunkSmall &chunk) const
if (c.b != color.b)
return c.b > color.b;
- const gcn::Color &c2 = chunk.color2;
+ const Color &c2 = chunk.color2;
if (c2.r != color2.r)
return c2.r > color2.r;
if (c2.g != color2.g)
@@ -101,14 +141,14 @@ bool SDLTextChunkSmall::operator<(const SDLTextChunkSmall &chunk) const
if (c2.b != color2.b)
return c2.b > color2.b;
- if (c.a != color.a && SDLFont::mSoftMode)
+ if (c.a != color.a && Font::mSoftMode)
return c.a > color.a;
return false;
}
-SDLTextChunk::SDLTextChunk(const std::string &text0, const gcn::Color &color0,
- const gcn::Color &color1) :
+SDLTextChunk::SDLTextChunk(const std::string &text0, const Color &color0,
+ const Color &color1) :
img(nullptr),
text(text0),
color(color0),
@@ -337,9 +377,9 @@ void TextChunkList::clear()
static int fontCounter;
-SDLFont::SDLFont(std::string filename,
- const int size,
- const int style) :
+Font::Font(std::string filename,
+ const int size,
+ const int style) :
mFont(nullptr),
mCreateCounter(0),
mDeleteCounter(0),
@@ -350,7 +390,7 @@ SDLFont::SDLFont(std::string filename,
mSoftMode = imageHelper->useOpenGL() == RENDER_SOFTWARE;
if (TTF_Init() == -1)
{
- throw GCN_EXCEPTION("Unable to initialize SDL_ttf: " +
+ logger->error("Unable to initialize SDL_ttf: " +
std::string(TTF_GetError()));
}
}
@@ -373,15 +413,15 @@ SDLFont::SDLFont(std::string filename,
mFont = openFont(fixDirSeparators(backFile).c_str(), size);
if (!mFont)
{
- throw GCN_EXCEPTION("SDLSDLFont::SDLSDLFont: " +
- std::string(TTF_GetError()));
+ logger->error("Font::Font: " +
+ std::string(TTF_GetError()));
}
}
TTF_SetFontStyle(mFont, style);
}
-SDLFont::~SDLFont()
+Font::~Font()
{
TTF_CloseFont(mFont);
mFont = nullptr;
@@ -395,7 +435,7 @@ SDLFont::~SDLFont()
}
}
-TTF_Font *SDLFont::openFont(const char *const name, const int size)
+TTF_Font *Font::openFont(const char *const name, const int size)
{
// disabled for now because some systems like gentoo cant use it
// #ifdef USE_SDL2
@@ -409,9 +449,9 @@ TTF_Font *SDLFont::openFont(const char *const name, const int size)
// #endif
}
-void SDLFont::loadFont(std::string filename,
- const int size,
- const int style)
+void Font::loadFont(std::string filename,
+ const int size,
+ const int style)
{
if (fontCounter == 0 && TTF_Init() == -1)
{
@@ -425,7 +465,7 @@ void SDLFont::loadFont(std::string filename,
if (!font)
{
- logger->log("SDLSDLFont::SDLSDLFont: " +
+ logger->log("Font::Font: " +
std::string(TTF_GetError()));
return;
}
@@ -438,20 +478,20 @@ void SDLFont::loadFont(std::string filename,
clear();
}
-void SDLFont::clear()
+void Font::clear()
{
for (size_t f = 0; f < CACHES_NUMBER; f ++)
mCache[f].clear();
}
-void SDLFont::drawString(gcn::Graphics *const graphics,
- const std::string &text,
- const int x, const int y)
+void Font::drawString(Graphics *const graphics,
+ const std::string &text,
+ const int x, const int y)
{
- BLOCK_START("SDLFont::drawString")
+ BLOCK_START("Font::drawString")
if (text.empty())
{
- BLOCK_END("SDLFont::drawString")
+ BLOCK_END("Font::drawString")
return;
}
@@ -459,8 +499,8 @@ void SDLFont::drawString(gcn::Graphics *const graphics,
if (!g)
return;
- gcn::Color col = g->getColor();
- const gcn::Color &col2 = g->getColor2();
+ Color col = g->getColor();
+ const Color &col2 = g->getColor2();
const float alpha = static_cast<float>(col.a) / 255.0F;
/* The alpha value is ignored at string generation so avoid caching the
@@ -482,7 +522,7 @@ void SDLFont::drawString(gcn::Graphics *const graphics,
if (image)
{
image->setAlpha(alpha);
- g->drawImage2(image, x, y);
+ g->drawImage(image, x, y);
}
}
else
@@ -504,14 +544,14 @@ void SDLFont::drawString(gcn::Graphics *const graphics,
const Image *const image = chunk2->img;
if (image)
- g->drawImage2(image, x, y);
+ g->drawImage(image, x, y);
}
- BLOCK_END("SDLFont::drawString")
+ BLOCK_END("Font::drawString")
}
-void SDLFont::slowLogic(const int rnd)
+void Font::slowLogic(const int rnd)
{
- BLOCK_START("SDLFont::slowLogic")
+ BLOCK_START("Font::slowLogic")
if (!mCleanTime)
{
mCleanTime = cur_time + CLEAN_TIME + rnd;
@@ -521,10 +561,10 @@ void SDLFont::slowLogic(const int rnd)
doClean();
mCleanTime = cur_time + CLEAN_TIME + rnd;
}
- BLOCK_END("SDLFont::slowLogic")
+ BLOCK_END("Font::slowLogic")
}
-int SDLFont::getWidth(const std::string &text) const
+int Font::getWidth(const std::string &text) const
{
if (text.empty())
return 0;
@@ -552,12 +592,12 @@ int SDLFont::getWidth(const std::string &text) const
return w;
}
-int SDLFont::getHeight() const
+int Font::getHeight() const
{
return TTF_FontHeight(mFont);
}
-void SDLFont::doClean()
+void Font::doClean()
{
for (unsigned int f = 0; f < CACHES_NUMBER; f ++)
{
@@ -599,7 +639,19 @@ void SDLFont::doClean()
}
}
-const TextChunkList *SDLFont::getCache() const
+int Font::getStringIndexAt(const std::string& text, const int x) const
+{
+ const size_t sz = text.size();
+ for (size_t i = 0; i < sz; ++i)
+ {
+ if (getWidth(text.substr(0, i)) > x)
+ return i;
+ }
+
+ return static_cast<int>(sz);
+}
+
+const TextChunkList *Font::getCache() const
{
return mCache;
}
diff --git a/src/gui/sdlfont.h b/src/gui/font.h
index b2638f835..12ba473d8 100644
--- a/src/gui/sdlfont.h
+++ b/src/gui/font.h
@@ -21,11 +21,53 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef GUI_SDLFONT_H
-#define GUI_SDLFONT_H
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
-#include <guichan/color.hpp>
-#include <guichan/font.hpp>
+#ifndef GUI_FONT_H
+#define GUI_FONT_H
+
+#include "gui/color.h"
#include <SDL_ttf.h>
@@ -34,6 +76,8 @@
#include "localconsts.h"
+class Color;
+class Graphics;
class Image;
const unsigned int CACHES_NUMBER = 256;
@@ -41,8 +85,8 @@ const unsigned int CACHES_NUMBER = 256;
class SDLTextChunkSmall
{
public:
- SDLTextChunkSmall(const std::string &text0, const gcn::Color &color0,
- const gcn::Color &color1);
+ SDLTextChunkSmall(const std::string &text0, const Color &color0,
+ const Color &color1);
SDLTextChunkSmall(const SDLTextChunkSmall &old);
@@ -50,15 +94,15 @@ class SDLTextChunkSmall
bool operator<(const SDLTextChunkSmall &chunk) const;
std::string text;
- gcn::Color color;
- gcn::Color color2;
+ Color color;
+ Color color2;
};
class SDLTextChunk final
{
public:
- SDLTextChunk(const std::string &text0, const gcn::Color &color0,
- const gcn::Color &color1);
+ SDLTextChunk(const std::string &text0, const Color &color0,
+ const Color &color1);
A_DELETE_COPY(SDLTextChunk)
@@ -70,8 +114,8 @@ class SDLTextChunk final
Image *img;
std::string text;
- gcn::Color color;
- gcn::Color color2;
+ Color color;
+ Color color2;
SDLTextChunk *prev;
SDLTextChunk *next;
};
@@ -106,34 +150,33 @@ class TextChunkList final
*
* <b>NOTE:</b> This class initializes SDL_ttf as necessary.
*/
-class SDLFont final : public gcn::Font
+class Font final
{
public:
- SDLFont(std::string filename,
- const int size,
- const int style = 0);
+ Font(std::string filename,
+ const int size,
+ const int style = 0);
- A_DELETE_COPY(SDLFont)
+ A_DELETE_COPY(Font)
- ~SDLFont();
+ ~Font();
void loadFont(std::string filename,
const int size,
const int style = 0);
- int getWidth(const std::string &text) const override
- final A_WARN_UNUSED;
+ int getWidth(const std::string &text) const A_WARN_UNUSED;
- int getHeight() const override final A_WARN_UNUSED;
+ int getHeight() const A_WARN_UNUSED;
const TextChunkList *getCache() const A_WARN_UNUSED;
/**
* @see Font::drawString
*/
- void drawString(gcn::Graphics *const graphics,
+ void drawString(Graphics *const graphics,
const std::string &text,
- const int x, const int y) override final;
+ const int x, const int y);
void clear();
@@ -147,6 +190,9 @@ class SDLFont final : public gcn::Font
int getDeleteCounter() const A_WARN_UNUSED
{ return mDeleteCounter; }
+ int getStringIndexAt(const std::string& text,
+ const int x) const A_WARN_UNUSED;
+
static bool mSoftMode;
private:
@@ -165,4 +211,4 @@ class SDLFont final : public gcn::Font
extern int sdlTextChunkCnt;
#endif
-#endif // GUI_SDLFONT_H
+#endif // GUI_FONT_H
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 126fc9a3b..5914e43d9 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -20,18 +20,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "mouseinput.h"
-
#include "gui/gui.h"
#include "gui/focushandler.h"
+#include "gui/font.h"
#include "gui/palette.h"
-#include "gui/sdlfont.h"
#include "gui/sdlinput.h"
#include "gui/theme.h"
#include "gui/viewport.h"
-#include "gui/widgets/mouseevent.h"
+#include "events/mouseevent.h"
+
#include "gui/widgets/window.h"
#include "client.h"
@@ -39,9 +38,13 @@
#include "dragdrop.h"
#include "touchmanager.h"
+#include "events/keyevent.h"
+
+#include "listeners/focuslistener.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
#include "input/keyinput.h"
+#include "input/mouseinput.h"
#include "resources/cursor.h"
#include "resources/image.h"
@@ -51,8 +54,6 @@
#include "utils/langs.h"
#include "utils/timer.h"
-#include <guichan/exception.hpp>
-
#include "debug.h"
// Guichan stuff
@@ -60,7 +61,7 @@ Gui *gui = nullptr;
SDLInput *guiInput = nullptr;
// Bolded font
-SDLFont *boldFont = nullptr;
+Font *boldFont = nullptr;
class GuiConfigListener final : public ConfigListener
{
@@ -160,16 +161,7 @@ void Gui::postInit(Graphics *const graphics)
if (fontFile.empty())
fontFile = branding.getStringValue("font");
- try
- {
- mGuiFont = new SDLFont(fontFile, fontSize);
- }
- catch (const gcn::Exception &e)
- {
- logger->error(std::string("Unable to load '").append(fontFile)
- .append("': ").append(e.getMessage()));
- }
-
+ mGuiFont = new Font(fontFile, fontSize);
// Set particle font
fontFile = config.getValue("particleFont", "");
@@ -188,65 +180,28 @@ void Gui::postInit(Graphics *const graphics)
if (fontFile.empty())
fontFile = branding.getStringValue("particleFont");
- try
- {
- mInfoParticleFont = new SDLFont(
- fontFile, fontSize, TTF_STYLE_BOLD);
- }
- catch (const gcn::Exception &e)
- {
- logger->error(std::string("Unable to load '").append(fontFile)
- .append("': ").append(e.getMessage()));
- }
-
+ mInfoParticleFont = new Font(fontFile, fontSize, TTF_STYLE_BOLD);
// Set bold font
fontFile = config.getValue("boldFont", "");
if (fontFile.empty())
fontFile = branding.getStringValue("boldFont");
- try
- {
- boldFont = new SDLFont(fontFile, fontSize);
- }
- catch (const gcn::Exception &e)
- {
- logger->error(std::string("Unable to load '").append(fontFile)
- .append("': ").append(e.getMessage()));
- }
-
+ boldFont = new Font(fontFile, fontSize);
// Set help font
fontFile = config.getValue("helpFont", "");
if (fontFile.empty())
fontFile = branding.getStringValue("helpFont");
- try
- {
- mHelpFont = new SDLFont(fontFile, fontSize);
- }
- catch (const gcn::Exception &e)
- {
- logger->error(std::string("Unable to load '").append(fontFile)
- .append("': ").append(e.getMessage()));
- }
-
+ mHelpFont = new Font(fontFile, fontSize);
// Set secure font
fontFile = config.getValue("secureFont", "");
if (fontFile.empty())
fontFile = branding.getStringValue("secureFont");
- try
- {
- mSecureFont = new SDLFont(fontFile, fontSize);
- }
- catch (const gcn::Exception &e)
- {
- logger->error(std::string("Unable to load '").append(fontFile)
- .append("': ").append(e.getMessage()));
- }
-
+ mSecureFont = new Font(fontFile, fontSize);
// Set npc font
const int npcFontSize = config.getIntValue("npcfontSize");
@@ -266,17 +221,9 @@ void Gui::postInit(Graphics *const graphics)
if (fontFile.empty())
fontFile = branding.getStringValue("npcFont");
- try
- {
- mNpcFont = new SDLFont(fontFile, npcFontSize);
- }
- catch (const gcn::Exception &e)
- {
- logger->error(std::string("Unable to load '").append(fontFile)
- .append("': ").append(e.getMessage()));
- }
+ mNpcFont = new Font(fontFile, npcFontSize);
- gcn::Widget::setGlobalFont(mGuiFont);
+ Widget::setGlobalFont(mGuiFont);
// Initialize mouse cursor and listen for changes to the option
setUseCustomCursor(config.getBoolValue("customcursor"));
@@ -473,7 +420,7 @@ bool Gui::handleKeyInput2()
// change focus.
if (!keyEventConsumed && mTabbing && keyInput.getActionId()
== static_cast<int>(Input::KEY_GUI_TAB)
- && keyInput.getType() == gcn::KeyInput::PRESSED)
+ && keyInput.getType() == KeyInput::PRESSED)
{
if (keyInput.isShiftPressed())
mFocusHandler->tabPrevious();
@@ -499,13 +446,12 @@ void Gui::draw()
if ((client->getMouseFocused() || button & SDL_BUTTON(1))
&& mMouseCursors && mCustomCursor && mMouseCursorAlpha > 0.0F)
{
- Graphics *g2 = static_cast<Graphics*>(mGraphics);
const Image *const image = dragDrop.getItemImage();
if (image)
{
const int posX = mouseX - (image->mBounds.w / 2);
const int posY = mouseY - (image->mBounds.h / 2);
- g2->drawImage2(image, posX, posY);
+ mGraphics->drawImage(image, posX, posY);
}
if (mGuiFont)
{
@@ -514,8 +460,8 @@ void Gui::draw()
{
const int posX = mouseX - mGuiFont->getWidth(str) / 2;
const int posY = mouseY + (image ? image->mBounds.h / 2 : 0);
- g2->setColorAll(mForegroundColor, mForegroundColor2);
- mGuiFont->drawString(g2, str, posX, posY);
+ mGraphics->setColorAll(mForegroundColor, mForegroundColor2);
+ mGuiFont->drawString(mGraphics, str, posX, posY);
}
}
@@ -523,7 +469,7 @@ void Gui::draw()
if (mouseCursor)
{
mouseCursor->setAlpha(mMouseCursorAlpha);
- g2->drawImage2(mouseCursor, mouseX - 15, mouseY - 17);
+ mGraphics->drawImage(mouseCursor, mouseX - 15, mouseY - 17);
}
}
@@ -579,20 +525,20 @@ void Gui::setUseCustomCursor(const bool customCursor)
}
}
-void Gui::handleMouseMoved(const gcn::MouseInput &mouseInput)
+void Gui::handleMouseMoved(const MouseInput &mouseInput)
{
gcn::Gui::handleMouseMoved(mouseInput);
mMouseInactivityTimer = 0;
}
-void Gui::handleMousePressed(const gcn::MouseInput &mouseInput)
+void Gui::handleMousePressed(const MouseInput &mouseInput)
{
const int x = mouseInput.getX();
const int y = mouseInput.getY();
const unsigned int button = mouseInput.getButton();
const int timeStamp = mouseInput.getTimeStamp();
- gcn::Widget *sourceWidget = getMouseEventSource(x, y);
+ Widget *sourceWidget = getMouseEventSource(x, y);
if (mFocusHandler->getDraggedWidget())
sourceWidget = mFocusHandler->getDraggedWidget();
@@ -655,14 +601,14 @@ void Gui::updateFonts()
mNpcFont->loadFont(fontFile, npcFontSize);
}
-void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button,
+void Gui::distributeMouseEvent(Widget* source, int type, int button,
int x, int y, bool force,
bool toSourceOnly)
{
if (!source || !mFocusHandler)
return;
- gcn::Widget* widget = source;
+ Widget* widget = source;
if (!force && mFocusHandler->getModalFocused() != nullptr
&& !widget->isModalFocused())
@@ -680,12 +626,12 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button,
mAltPressed, mMetaPressed, type, button,
x, y, mClickCount);
- gcn::Widget* parent = source;
+ Widget* parent = source;
while (parent)
{
// If the widget has been removed due to input
// cancel the distribution.
- if (!gcn::Widget::widgetExists(widget))
+ if (!Widget::widgetExists(widget))
break;
parent = widget->getParent();
@@ -698,42 +644,42 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button,
mouseEvent.setX(x - widgetX);
mouseEvent.setY(y - widgetY);
- std::list<gcn::MouseListener*> mouseListeners
+ std::list<MouseListener*> mouseListeners
= widget->_getMouseListeners();
// Send the event to all mouse listeners of the widget.
- for (std::list<gcn::MouseListener*>::const_iterator
+ for (std::list<MouseListener*>::const_iterator
it = mouseListeners.begin();
it != mouseListeners.end(); ++ it)
{
switch (mouseEvent.getType())
{
- case gcn::MouseEvent::ENTERED:
+ case MouseEvent::ENTERED:
(*it)->mouseEntered(mouseEvent);
break;
- case gcn::MouseEvent::EXITED:
+ case MouseEvent::EXITED:
(*it)->mouseExited(mouseEvent);
break;
- case gcn::MouseEvent::MOVED:
+ case MouseEvent::MOVED:
(*it)->mouseMoved(mouseEvent);
break;
- case gcn::MouseEvent::PRESSED:
+ case MouseEvent::PRESSED:
(*it)->mousePressed(mouseEvent);
break;
- case gcn::MouseEvent::RELEASED:
+ case MouseEvent::RELEASED:
case 100: // manual hack for release on target after drag
(*it)->mouseReleased(mouseEvent);
break;
- case gcn::MouseEvent::WHEEL_MOVED_UP:
+ case MouseEvent::WHEEL_MOVED_UP:
(*it)->mouseWheelMovedUp(mouseEvent);
break;
- case gcn::MouseEvent::WHEEL_MOVED_DOWN:
+ case MouseEvent::WHEEL_MOVED_DOWN:
(*it)->mouseWheelMovedDown(mouseEvent);
break;
- case gcn::MouseEvent::DRAGGED:
+ case MouseEvent::DRAGGED:
(*it)->mouseDragged(mouseEvent);
break;
- case gcn::MouseEvent::CLICKED:
+ case MouseEvent::CLICKED:
(*it)->mouseClicked(mouseEvent);
break;
default:
@@ -745,11 +691,11 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button,
break;
}
- const gcn::Widget *const swap = widget;
+ const Widget *const swap = widget;
widget = parent;
parent = swap->getParent();
- if (type == gcn::MouseEvent::RELEASED)
+ if (type == MouseEvent::RELEASED)
dragDrop.clear();
// If a non modal focused widget has been reach
@@ -794,7 +740,7 @@ MouseEvent *Gui::createMouseEvent(Window *const widget)
mouseX - x, mouseY - y, mClickCount);
}
-void Gui::getAbsolutePosition(gcn::Widget *restrict widget,
+void Gui::getAbsolutePosition(Widget *restrict widget,
int &restrict x, int &restrict y)
{
x = 0;
@@ -836,32 +782,31 @@ void Gui::handleMouseInput()
#endif
switch (mouseInput.getType())
{
- case gcn::MouseInput::PRESSED:
+ case MouseInput::PRESSED:
handleMousePressed(mouseInput);
break;
- case gcn::MouseInput::RELEASED:
+ case MouseInput::RELEASED:
handleMouseReleased(mouseInput);
break;
- case gcn::MouseInput::MOVED:
+ case MouseInput::MOVED:
handleMouseMoved(mouseInput);
break;
- case gcn::MouseInput::WHEEL_MOVED_DOWN:
+ case MouseInput::WHEEL_MOVED_DOWN:
handleMouseWheelMovedDown(mouseInput);
break;
- case gcn::MouseInput::WHEEL_MOVED_UP:
+ case MouseInput::WHEEL_MOVED_UP:
handleMouseWheelMovedUp(mouseInput);
break;
default:
- throw GCN_EXCEPTION("Unknown mouse input type.");
break;
}
}
BLOCK_END("Gui::handleMouseInput")
}
-void Gui::handleMouseReleased(const gcn::MouseInput &mouseInput)
+void Gui::handleMouseReleased(const MouseInput &mouseInput)
{
- gcn::Widget *sourceWidget = getMouseEventSource(
+ Widget *sourceWidget = getMouseEventSource(
mouseInput.getX(), mouseInput.getY());
int sourceWidgetX, sourceWidgetY;
@@ -870,7 +815,7 @@ void Gui::handleMouseReleased(const gcn::MouseInput &mouseInput)
if (sourceWidget != mFocusHandler->getLastWidgetPressed())
mFocusHandler->setLastWidgetPressed(nullptr);
- gcn::Widget *oldWidget = sourceWidget;
+ Widget *oldWidget = sourceWidget;
sourceWidget = mFocusHandler->getDraggedWidget();
if (oldWidget != sourceWidget)
{
@@ -911,17 +856,17 @@ void Gui::handleMouseReleased(const gcn::MouseInput &mouseInput)
mFocusHandler->setDraggedWidget(nullptr);
}
-void Gui::addGlobalFocusListener(gcn::FocusListener* focusListener)
+void Gui::addGlobalFocusListener(FocusListener* focusListener)
{
mFocusListeners.push_back(focusListener);
}
-void Gui::removeGlobalFocusListener(gcn::FocusListener* focusListener)
+void Gui::removeGlobalFocusListener(FocusListener* focusListener)
{
mFocusListeners.remove(focusListener);
}
-void Gui::distributeGlobalFocusGainedEvent(const gcn::Event &focusEvent)
+void Gui::distributeGlobalFocusGainedEvent(const Event &focusEvent)
{
for (FocusListenerIterator iter = mFocusListeners.begin();
iter != mFocusListeners.end();
@@ -931,7 +876,7 @@ void Gui::distributeGlobalFocusGainedEvent(const gcn::Event &focusEvent)
}
}
-void Gui::removeDragged(gcn::Widget *widget)
+void Gui::removeDragged(Widget *widget)
{
if (!mFocusHandler)
return;
diff --git a/src/gui/gui.h b/src/gui/gui.h
index 5fddc7df7..4038bbec4 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -23,18 +23,19 @@
#ifndef GUI_GUI_H
#define GUI_GUI_H
-#include <guichan/color.hpp>
-#include <guichan/focuslistener.hpp>
-#include <guichan/gui.hpp>
+#include "gui/color.h"
+
+#include "gui/base/gui.hpp"
#include "localconsts.h"
+class FocusListener;
class Graphics;
class GuiConfigListener;
class ImageSet;
class MouseEvent;
class MouseInput;
-class SDLFont;
+class Font;
class SDLInput;
class Window;
@@ -89,38 +90,38 @@ class Gui final : public gcn::Gui
*/
void videoResized() const;
- gcn::FocusHandler *getFocusHandler() const A_WARN_UNUSED
+ FocusHandler *getFocusHandler() const A_WARN_UNUSED
{ return mFocusHandler; }
/**
* Return game font.
*/
- SDLFont *getFont() const A_WARN_UNUSED
+ Font *getFont() const A_WARN_UNUSED
{ return mGuiFont; }
/**
* Return help font.
*/
- SDLFont *getHelpFont() const A_WARN_UNUSED
+ Font *getHelpFont() const A_WARN_UNUSED
{ return mHelpFont; }
/**
* Return secure font.
*/
- SDLFont *getSecureFont() const A_WARN_UNUSED
+ Font *getSecureFont() const A_WARN_UNUSED
{ return mSecureFont; }
/**
* Return npc font.
*/
- SDLFont *getNpcFont() const A_WARN_UNUSED
+ Font *getNpcFont() const A_WARN_UNUSED
{ return mNpcFont; }
/**
* Return the Font used for "Info Particles", i.e. ones showing, what
* you picked up, etc.
*/
- SDLFont *getInfoParticleFont() const A_WARN_UNUSED
+ Font *getInfoParticleFont() const A_WARN_UNUSED
{ return mInfoParticleFont; }
/**
@@ -147,17 +148,17 @@ class Gui final : public gcn::Gui
MouseEvent *createMouseEvent(Window *const widget) A_WARN_UNUSED;
- static void getAbsolutePosition(gcn::Widget *restrict widget,
+ static void getAbsolutePosition(Widget *restrict widget,
int &restrict x,
int &restrict y);
- void addGlobalFocusListener(gcn::FocusListener* focusListener);
+ void addGlobalFocusListener(FocusListener* focusListener);
- void removeGlobalFocusListener(gcn::FocusListener* focusListener);
+ void removeGlobalFocusListener(FocusListener* focusListener);
- void distributeGlobalFocusGainedEvent(const gcn::Event &focusEvent);
+ void distributeGlobalFocusGainedEvent(const Event &focusEvent);
- void removeDragged(gcn::Widget *widget);
+ void removeDragged(Widget *widget);
int getLastMouseX() const
{ return mLastMouseX; }
@@ -168,25 +169,25 @@ class Gui final : public gcn::Gui
static uint32_t getMouseState(int *const x, int *const y);
protected:
- void handleMouseMoved(const gcn::MouseInput &mouseInput);
+ void handleMouseMoved(const MouseInput &mouseInput);
- void handleMouseReleased(const gcn::MouseInput &mouseInput);
+ void handleMouseReleased(const MouseInput &mouseInput);
- void handleMousePressed(const gcn::MouseInput &mouseInput);
+ void handleMousePressed(const MouseInput &mouseInput);
void handleMouseInput();
- void distributeMouseEvent(gcn::Widget* source, int type, int button,
+ void distributeMouseEvent(Widget* source, int type, int button,
int x, int y, bool force = false,
bool toSourceOnly = false);
private:
GuiConfigListener *mConfigListener;
- SDLFont *mGuiFont; /**< The global GUI font */
- SDLFont *mInfoParticleFont; /**< Font for Info Particles */
- SDLFont *mHelpFont; /**< Font for Help Window */
- SDLFont *mSecureFont; /**< Font for secure labels */
- SDLFont *mNpcFont; /**< Font for npc text */
+ Font *mGuiFont; /**< The global GUI font */
+ Font *mInfoParticleFont; /**< Font for Info Particles */
+ Font *mHelpFont; /**< Font for Help Window */
+ Font *mSecureFont; /**< Font for secure labels */
+ Font *mNpcFont; /**< Font for npc text */
ImageSet *mMouseCursors; /**< Mouse cursor images */
float mMouseCursorAlpha;
int mMouseInactivityTimer;
@@ -195,11 +196,11 @@ class Gui final : public gcn::Gui
uint16_t mLastMouseRealX;
uint16_t mLastMouseRealY;
#endif
- typedef std::list<gcn::FocusListener*> FocusListenerList;
+ typedef std::list<FocusListener*> FocusListenerList;
typedef FocusListenerList::iterator FocusListenerIterator;
FocusListenerList mFocusListeners;
- gcn::Color mForegroundColor;
- gcn::Color mForegroundColor2;
+ Color mForegroundColor;
+ Color mForegroundColor2;
int mTime;
bool mCustomCursor; /**< Show custom cursor */
bool mDoubleClick;
@@ -211,6 +212,6 @@ extern SDLInput *guiInput; /**< GUI input */
/**
* Bolded text font
*/
-extern SDLFont *boldFont;
+extern Font *boldFont;
#endif // GUI_GUI_H
diff --git a/src/gui/models/avatarlistmodel.h b/src/gui/models/avatarlistmodel.h
new file mode 100644
index 000000000..2bbd64878
--- /dev/null
+++ b/src/gui/models/avatarlistmodel.h
@@ -0,0 +1,40 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2010 The Mana Developers
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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 GUI_MODELS_AVATARLISTMODEL_H
+#define GUI_MODELS_AVATARLISTMODEL_H
+
+#include "avatar.h"
+
+#include "gui/models/listmodel.h"
+
+#include <string>
+
+class AvatarListModel : public ListModel
+{
+ public:
+ virtual Avatar *getAvatarAt(const int i) A_WARN_UNUSED = 0;
+
+ std::string getElementAt(int i) override final A_WARN_UNUSED
+ { return getAvatarAt(i)->getName(); }
+};
+
+#endif // GUI_MODELS_AVATARLISTMODEL_H
diff --git a/src/gui/models/beingslistmodel.h b/src/gui/models/beingslistmodel.h
new file mode 100644
index 000000000..9f3c48bcc
--- /dev/null
+++ b/src/gui/models/beingslistmodel.h
@@ -0,0 +1,62 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2010 The Mana Developers
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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 GUI_MODELS_BEINGSLISTMODEL_H
+#define GUI_MODELS_BEINGSLISTMODEL_H
+
+#include "gui/models/avatarlistmodel.h"
+
+class BeingsListModel final : public AvatarListModel
+{
+ public:
+ BeingsListModel() :
+ AvatarListModel(),
+ mMembers()
+ {
+ }
+
+ A_DELETE_COPY(BeingsListModel)
+
+ ~BeingsListModel()
+ {
+ delete_all(mMembers);
+ mMembers.clear();
+ }
+
+ std::vector<Avatar*> *getMembers()
+ {
+ return &mMembers;
+ }
+
+ Avatar *getAvatarAt(int index) override final
+ {
+ return mMembers[index];
+ }
+
+ int getNumberOfElements() override final
+ {
+ return static_cast<int>(mMembers.size());
+ }
+
+ std::vector<Avatar*> mMembers;
+};
+
+#endif // GUI_MODELS_BEINGSLISTMODEL_H
diff --git a/src/gui/models/colorlistmodel.h b/src/gui/models/colorlistmodel.h
new file mode 100644
index 000000000..d4b2e4237
--- /dev/null
+++ b/src/gui/models/colorlistmodel.h
@@ -0,0 +1,81 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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 GUI_MODELS_COLORLISTMODEL_H
+#define GUI_MODELS_COLORLISTMODEL_H
+
+#include "gui/models/listmodel.h"
+
+#include "utils/gettext.h"
+
+const char *COLOR_NAME[14] =
+{
+ // TRANSLATORS: chat color
+ N_("default"),
+ // TRANSLATORS: chat color
+ N_("black"),
+ // TRANSLATORS: chat color
+ N_("red"),
+ // TRANSLATORS: chat color
+ N_("green"),
+ // TRANSLATORS: chat color
+ N_("blue"),
+ // TRANSLATORS: chat color
+ N_("gold"),
+ // TRANSLATORS: chat color
+ N_("yellow"),
+ // TRANSLATORS: chat color
+ N_("pink"),
+ // TRANSLATORS: chat color
+ N_("purple"),
+ // TRANSLATORS: chat color
+ N_("grey"),
+ // TRANSLATORS: chat color
+ N_("brown"),
+ // TRANSLATORS: chat color
+ N_("rainbow 1"),
+ // TRANSLATORS: chat color
+ N_("rainbow 2"),
+ // TRANSLATORS: chat color
+ N_("rainbow 3"),
+};
+
+class ColorListModel final : public ListModel
+{
+ public:
+ ~ColorListModel()
+ { }
+
+ int getNumberOfElements()
+ {
+ return 14;
+ }
+
+ std::string getElementAt(int i)
+ {
+ if (i >= getNumberOfElements() || i < 0)
+ return "???";
+ return gettext(COLOR_NAME[i]);
+ }
+};
+
+#endif // GUI_MODELS_COLORLISTMODEL_H
diff --git a/src/gui/widgets/colormodel.cpp b/src/gui/models/colormodel.cpp
index 7e59553e3..47486d735 100644
--- a/src/gui/widgets/colormodel.cpp
+++ b/src/gui/models/colormodel.cpp
@@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "gui/widgets/colormodel.h"
+#include "gui/models/colormodel.h"
#include "gui/widgets/widget2.h"
@@ -56,8 +56,8 @@ const ColorPair *ColorModel::getColorAt(const int i) const
return &mColors[i];
}
-void ColorModel::add(const std::string &name, const gcn::Color *const color1,
- const gcn::Color *const color2)
+void ColorModel::add(const std::string &name, const Color *const color1,
+ const Color *const color2)
{
mNames.push_back(name);
mColors.push_back(ColorPair(color1, color2));
diff --git a/src/gui/widgets/colormodel.h b/src/gui/models/colormodel.h
index 8b9226159..f3d6f3617 100644
--- a/src/gui/widgets/colormodel.h
+++ b/src/gui/models/colormodel.h
@@ -18,31 +18,31 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef GUI_WIDGETS_COLORMODEL_H
-#define GUI_WIDGETS_COLORMODEL_H
+#ifndef GUI_MODELS_COLORMODEL_H
+#define GUI_MODELS_COLORMODEL_H
#include "utils/stringvector.h"
-#include <guichan/color.hpp>
-#include <guichan/listmodel.hpp>
+#include "gui/models/listmodel.h"
#include "localconsts.h"
+class Color;
class Widget2;
struct ColorPair
{
- ColorPair(const gcn::Color* c1, const gcn::Color* c2) :
+ ColorPair(const Color* c1, const Color* c2) :
color1(c1),
color2(c2)
{
}
- const gcn::Color* color1;
- const gcn::Color* color2;
+ const Color* color1;
+ const Color* color2;
};
-class ColorModel : public gcn::ListModel
+class ColorModel : public ListModel
{
public:
ColorModel();
@@ -63,8 +63,8 @@ class ColorModel : public gcn::ListModel
size_t size() A_WARN_UNUSED
{ return mNames.size(); }
- void add(const std::string &name, const gcn::Color *const color1,
- const gcn::Color *const color2);
+ void add(const std::string &name, const Color *const color1,
+ const Color *const color2);
static ColorModel *createDefault(const Widget2 *const widget);
@@ -73,4 +73,4 @@ class ColorModel : public gcn::ListModel
std::vector<ColorPair> mColors;
};
-#endif // GUI_WIDGETS_COLORMODEL_H
+#endif // GUI_MODELS_COLORMODEL_H
diff --git a/src/gui/widgets/extendedlistmodel.h b/src/gui/models/extendedlistmodel.h
index 0299ef7ed..5d859e781 100644
--- a/src/gui/widgets/extendedlistmodel.h
+++ b/src/gui/models/extendedlistmodel.h
@@ -18,17 +18,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef GUI_WIDGETS_EXTENDEDLISTMODEL_H
-#define GUI_WIDGETS_EXTENDEDLISTMODEL_H
+#ifndef GUI_MODELS_EXTENDEDLISTMODEL_H
+#define GUI_MODELS_EXTENDEDLISTMODEL_H
#include "resources/image.h"
-#include <guichan/listmodel.hpp>
+#include "gui/models/listmodel.h"
-class ExtendedListModel : public gcn::ListModel
+class ExtendedListModel : public ListModel
{
public:
virtual const Image *getImageAt(int i) A_WARN_UNUSED = 0;
};
-#endif // GUI_WIDGETS_EXTENDEDLISTMODEL_H
+#endif // GUI_MODELS_EXTENDEDLISTMODEL_H
diff --git a/src/gui/widgets/extendednamesmodel.cpp b/src/gui/models/extendednamesmodel.cpp
index a8a21d98d..c986085db 100644
--- a/src/gui/widgets/extendednamesmodel.cpp
+++ b/src/gui/models/extendednamesmodel.cpp
@@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "gui/widgets/extendednamesmodel.h"
+#include "gui/models/extendednamesmodel.h"
#include "debug.h"
diff --git a/src/gui/widgets/extendednamesmodel.h b/src/gui/models/extendednamesmodel.h
index 93e87cfa0..383a93951 100644
--- a/src/gui/widgets/extendednamesmodel.h
+++ b/src/gui/models/extendednamesmodel.h
@@ -18,12 +18,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef GUI_WIDGETS_EXTENDEDNAMESMODEL_H
-#define GUI_WIDGETS_EXTENDEDNAMESMODEL_H
+#ifndef GUI_MODELS_EXTENDEDNAMESMODEL_H
+#define GUI_MODELS_EXTENDEDNAMESMODEL_H
#include "utils/stringvector.h"
-#include "gui/widgets/extendedlistmodel.h"
+#include "gui/models/extendedlistmodel.h"
class ExtendedNamesModel : public ExtendedListModel
{
@@ -56,4 +56,4 @@ class ExtendedNamesModel : public ExtendedListModel
std::vector<Image*> mImages;
};
-#endif // GUI_WIDGETS_EXTENDEDNAMESMODEL_H
+#endif // GUI_MODELS_EXTENDEDNAMESMODEL_H
diff --git a/src/input/keyinput.cpp b/src/gui/models/fontsmodel.h
index d04305e0e..036e3f9c4 100644
--- a/src/input/keyinput.cpp
+++ b/src/gui/models/fontsmodel.h
@@ -1,6 +1,7 @@
/*
* The ManaPlus Client
- * Copyright (C) 2012-2014 The ManaPlus Developers
+ * Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011-2014 The ManaPlus Developers
*
* This file is part of The ManaPlus Client.
*
@@ -18,21 +19,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "input/keyinput.h"
+#ifndef GUI_MODELS_FONTSMODEL_H
+#define GUI_MODELS_FONTSMODEL_H
-#include "debug.h"
+#include "gui/theme.h"
-KeyInput::KeyInput() :
- gcn::KeyInput(),
-#ifdef USE_SDL2
- mActionId(-2),
- mText()
-#else
- mActionId(-2)
-#endif
-{
-}
+#include "gui/models/namesmodel.h"
+
+#include "localconsts.h"
-KeyInput::~KeyInput()
+class FontsModel final : public NamesModel
{
-}
+ public:
+ FontsModel() :
+ NamesModel()
+ { Theme::fillFontsList(mNames); }
+
+ ~FontsModel()
+ { }
+};
+
+#endif // GUI_MODELS_FONTSMODEL_H
diff --git a/src/gui/models/iconsmodel.h b/src/gui/models/iconsmodel.h
new file mode 100644
index 000000000..c3031169c
--- /dev/null
+++ b/src/gui/models/iconsmodel.h
@@ -0,0 +1,84 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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 GUI_MODELS_ICONSMODEL_H
+#define GUI_MODELS_ICONSMODEL_H
+
+#include "gui/models/listmodel.h"
+
+#include "resources/iteminfo.h"
+
+#include "resources/db/itemdb.h"
+
+#include "localconsts.h"
+
+class IconsModel final : public ListModel
+{
+ public:
+ IconsModel() :
+ mStrings()
+ {
+ const std::map<int, ItemInfo*> &items = ItemDB::getItemInfos();
+ std::list<std::string> tempStrings;
+
+ for (std::map<int, ItemInfo*>::const_iterator
+ i = items.begin(), i_end = items.end();
+ i != i_end; ++i)
+ {
+ if (i->first < 0)
+ continue;
+
+ const ItemInfo &info = (*i->second);
+ const std::string name = info.getName();
+ if (name != "unnamed" && !info.getName().empty()
+ && info.getName() != "unnamed")
+ {
+ tempStrings.push_back(name);
+ }
+ }
+ tempStrings.sort();
+ mStrings.push_back("");
+ FOR_EACH (std::list<std::string>::const_iterator, i, tempStrings)
+ mStrings.push_back(*i);
+ }
+
+ A_DELETE_COPY(IconsModel)
+
+ ~IconsModel()
+ { }
+
+ int getNumberOfElements() override final
+ {
+ return static_cast<int>(mStrings.size());
+ }
+
+ std::string getElementAt(int i) override final
+ {
+ if (i < 0 || i >= getNumberOfElements())
+ return "???";
+ return mStrings.at(i);
+ }
+ private:
+ StringVect mStrings;
+};
+
+#endif // GUI_MODELS_ICONSMODEL_H
diff --git a/src/gui/models/ignorechoiceslistmodel.h b/src/gui/models/ignorechoiceslistmodel.h
new file mode 100644
index 000000000..8ba3eadb1
--- /dev/null
+++ b/src/gui/models/ignorechoiceslistmodel.h
@@ -0,0 +1,55 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2008-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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 GUI_MODELS_IGNORECHOICESLISTMODEL_H
+#define GUI_MODELS_IGNORECHOICESLISTMODEL_H
+
+#include "being/playerrelations.h"
+
+#include "gui/models/playerrelationlistmodel.h"
+
+/**
+ * Class for choosing one of the various `what to do when ignoring a player' options
+ */
+class IgnoreChoicesListModel final : public ListModel
+{
+ public:
+ ~IgnoreChoicesListModel()
+ { }
+
+ int getNumberOfElements() override final
+ {
+ return static_cast<int>(player_relations.
+ getPlayerIgnoreStrategies()->size());
+ }
+
+ std::string getElementAt(int i) override final
+ {
+ if (i >= getNumberOfElements() || i < 0)
+ return "???";
+
+ return (*player_relations.getPlayerIgnoreStrategies())
+ [i]->mDescription;
+ }
+};
+
+#endif // GUI_MODELS_IGNORECHOICESLISTMODEL_H
diff --git a/src/gui/models/itemsmodel.h b/src/gui/models/itemsmodel.h
new file mode 100644
index 000000000..808ae0f04
--- /dev/null
+++ b/src/gui/models/itemsmodel.h
@@ -0,0 +1,86 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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 GUI_MODELS_ITEMSMODEL_H
+#define GUI_MODELS_ITEMSMODEL_H
+
+#include "gui/models/listmodel.h"
+
+#include "resources/iteminfo.h"
+
+#include "resources/db/itemdb.h"
+
+#include "utils/gettext.h"
+
+#include "localconsts.h"
+
+class ItemsModal final : public ListModel
+{
+ public:
+ ItemsModal() :
+ mStrings()
+ {
+ const std::map<int, ItemInfo*> &items = ItemDB::getItemInfos();
+ std::list<std::string> tempStrings;
+
+ for (std::map<int, ItemInfo*>::const_iterator
+ i = items.begin(), i_end = items.end();
+ i != i_end; ++i)
+ {
+ if (i->first < 0)
+ continue;
+
+ const ItemInfo &info = *i->second;
+ const std::string name = info.getName();
+ if (name != "unnamed" && !info.getName().empty()
+ && info.getName() != "unnamed")
+ {
+ tempStrings.push_back(name);
+ }
+ }
+ tempStrings.sort();
+ FOR_EACH (std::list<std::string>::const_iterator, i, tempStrings)
+ mStrings.push_back(*i);
+ }
+
+ A_DELETE_COPY(ItemsModal)
+
+ ~ItemsModal()
+ { }
+
+ int getNumberOfElements() override final
+ {
+ return static_cast<int>(mStrings.size());
+ }
+
+ std::string getElementAt(int i) override final
+ {
+ if (i < 0 || i >= getNumberOfElements())
+ return "???";
+ return mStrings.at(i);
+ }
+
+ private:
+ StringVect mStrings;
+};
+
+#endif // GUI_MODELS_ITEMSMODEL_H
diff --git a/src/guichan/include/guichan/listmodel.hpp b/src/gui/models/listmodel.h
index 4b98f46fe..dfce6d4d5 100644
--- a/src/guichan/include/guichan/listmodel.hpp
+++ b/src/gui/models/listmodel.h
@@ -61,46 +61,43 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef GCN_LISTMODEL_HPP
-#define GCN_LISTMODEL_HPP
+#ifndef GUI_MODELS_LISTMODEL_H
+#define GUI_MODELS_LISTMODEL_H
#include <string>
#include "localconsts.h"
-namespace gcn
+/**
+ * An interface for a model that represents a list. It is
+ * used in certain widgets, like the ListBox, to handle a
+ * lists with string elements. If you want to use widgets
+ * like ListBox, make a derived class from this class that
+ * represents your list.
+ */
+class ListModel
{
- /**
- * An interface for a model that represents a list. It is
- * used in certain widgets, like the ListBox, to handle a
- * lists with string elements. If you want to use widgets
- * like ListBox, make a derived class from this class that
- * represents your list.
- */
- class ListModel
- {
public:
/**
- * Destructor.
- */
+ * Destructor.
+ */
virtual ~ListModel()
{ }
/**
- * Gets the number of elements in the list.
- *
- * @return The number of elements in the list
- */
+ * Gets the number of elements in the list.
+ *
+ * @return The number of elements in the list
+ */
virtual int getNumberOfElements() A_WARN_UNUSED = 0;
/**
- * Gets an element at a certain index in the list.
- *
- * @param i An index in the list.
- * @return An element as a string at the a certain index.
- */
+ * Gets an element at a certain index in the list.
+ *
+ * @param i An index in the list.
+ * @return An element as a string at the a certain index.
+ */
virtual std::string getElementAt(int i) A_WARN_UNUSED = 0;
- };
-} // namespace gcn
+};
-#endif // end GCN_LISTMODEL_HPP
+#endif // GUI_MODELS_LISTMODEL_H
diff --git a/src/gui/models/magicschoolmodel.h b/src/gui/models/magicschoolmodel.h
new file mode 100644
index 000000000..1f7c4f0f7
--- /dev/null
+++ b/src/gui/models/magicschoolmodel.h
@@ -0,0 +1,67 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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 GUI_MODELS_MAGICSCHOOLMODEL_H
+#define GUI_MODELS_MAGICSCHOOLMODEL_H
+
+#include "gui/models/listmodel.h"
+
+#include "utils/gettext.h"
+
+#include "localconsts.h"
+
+const char *MAGIC_SCHOOL_TEXT[6] =
+{
+ // TRANSLATORS: magic school
+ N_("General Magic"),
+ // TRANSLATORS: magic school
+ N_("Life Magic"),
+ // TRANSLATORS: magic school
+ N_("War Magic"),
+ // TRANSLATORS: magic school
+ N_("Transmute Magic"),
+ // TRANSLATORS: magic school
+ N_("Nature Magic"),
+ // TRANSLATORS: magic school
+ N_("Astral Magic")
+};
+
+class MagicSchoolModel final : public ListModel
+{
+ public:
+ ~MagicSchoolModel()
+ { }
+
+ int getNumberOfElements() override final
+ {
+ return 6;
+ }
+
+ std::string getElementAt(int i) override final
+ {
+ if (i >= getNumberOfElements() || i < 0)
+ return "???";
+ return MAGIC_SCHOOL_TEXT[i];
+ }
+};
+
+#endif // GUI_MODELS_MAGICSCHOOLMODEL_H
diff --git a/src/gui/widgets/namesmodel.cpp b/src/gui/models/namesmodel.cpp
index 339f835d5..54a10c2cf 100644
--- a/src/gui/widgets/namesmodel.cpp
+++ b/src/gui/models/namesmodel.cpp
@@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "gui/widgets/namesmodel.h"
+#include "gui/models/namesmodel.h"
#include "utils/gettext.h"
diff --git a/src/gui/widgets/namesmodel.h b/src/gui/models/namesmodel.h
index f70dd2571..96d16de36 100644
--- a/src/gui/widgets/namesmodel.h
+++ b/src/gui/models/namesmodel.h
@@ -18,16 +18,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef GUI_WIDGETS_NAMESMODEL_H
-#define GUI_WIDGETS_NAMESMODEL_H
+#ifndef GUI_MODELS_NAMESMODEL_H
+#define GUI_MODELS_NAMESMODEL_H
#include "utils/stringvector.h"
-#include <guichan/listmodel.hpp>
+#include "gui/models/listmodel.h"
#include "localconsts.h"
-class NamesModel : public gcn::ListModel
+class NamesModel : public ListModel
{
public:
NamesModel();
@@ -58,4 +58,4 @@ class NamesModel : public gcn::ListModel
StringVect mNames;
};
-#endif // GUI_WIDGETS_NAMESMODEL_H
+#endif // GUI_MODELS_NAMESMODEL_H
diff --git a/src/gui/models/playerrelationlistmodel.h b/src/gui/models/playerrelationlistmodel.h
new file mode 100644
index 000000000..bc343de02
--- /dev/null
+++ b/src/gui/models/playerrelationlistmodel.h
@@ -0,0 +1,67 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2008-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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 GUI_MODELS_PLAYERRELATIONLISTMODEL_H
+#define GUI_MODELS_PLAYERRELATIONLISTMODEL_H
+
+#include "being/playerrelations.h"
+
+#include "utils/gettext.h"
+
+static const char *const RELATION_NAMES[PlayerRelation::RELATIONS_NR] =
+{
+ // TRANSLATORS: relation type
+ N_("Neutral"),
+ // TRANSLATORS: relation type
+ N_("Friend"),
+ // TRANSLATORS: relation type
+ N_("Disregarded"),
+ // TRANSLATORS: relation type
+ N_("Ignored"),
+ // TRANSLATORS: relation type
+ N_("Erased"),
+ // TRANSLATORS: relation type
+ N_("Blacklisted"),
+ // TRANSLATORS: relation type
+ N_("Enemy")
+};
+
+class PlayerRelationListModel final : public ListModel
+{
+ public:
+ ~PlayerRelationListModel()
+ { }
+
+ int getNumberOfElements() override final
+ {
+ return PlayerRelation::RELATIONS_NR;
+ }
+
+ std::string getElementAt(int i) override final
+ {
+ if (i >= getNumberOfElements() || i < 0)
+ return "";
+ return gettext(RELATION_NAMES[i]);
+ }
+};
+
+#endif // GUI_MODELS_PLAYERRELATIONLISTMODEL_H
diff --git a/src/mouseinput.cpp b/src/gui/models/questsmodel.h
index 208690935..d9421f402 100644
--- a/src/mouseinput.cpp
+++ b/src/gui/models/questsmodel.h
@@ -18,17 +18,23 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "mouseinput.h"
+#ifndef GUI_MODELS_QUESTSMODEL_H
+#define GUI_MODELS_QUESTSMODEL_H
-#include "debug.h"
+#include "gui/models/extendednamesmodel.h"
-MouseInput::MouseInput() :
- gcn::MouseInput(),
- mRealX(0),
- mRealY(0)
+class QuestsModel final : public ExtendedNamesModel
{
-}
+ public:
+ QuestsModel() :
+ ExtendedNamesModel()
+ {
+ }
-MouseInput::~MouseInput()
-{
-}
+ A_DELETE_COPY(QuestsModel)
+
+ ~QuestsModel()
+ { }
+};
+
+#endif // GUI_MODELS_QUESTSMODEL_H
diff --git a/src/gui/models/serverslistmodel.h b/src/gui/models/serverslistmodel.h
new file mode 100644
index 000000000..630d9664e
--- /dev/null
+++ b/src/gui/models/serverslistmodel.h
@@ -0,0 +1,109 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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 GUI_MODELS_SERVERSLISTMODEL_H
+#define GUI_MODELS_SERVERSLISTMODEL_H
+
+#include "net/serverinfo.h"
+
+#include "utils/mutex.h"
+
+#include "gui/models/listmodel.h"
+
+#include "net/serverinfo.h"
+
+#include <string>
+#include <vector>
+
+class ServerDialog;
+
+/**
+ * Server and Port List Model
+ */
+class ServersListModel final : public ListModel
+{
+ public:
+ typedef std::pair<int, std::string> VersionString;
+
+ ServersListModel(ServerInfos *const servers,
+ ServerDialog *const parent) :
+ mServers(servers),
+ mVersionStrings(servers->size(), VersionString(0, "")),
+ mParent(parent)
+ {
+ }
+
+ A_DELETE_COPY(ServersListModel)
+
+ /**
+ * Used to get number of line in the list
+ */
+ int getNumberOfElements() override final A_WARN_UNUSED
+ {
+ MutexLocker lock = mParent->lock();
+ return static_cast<int>(mServers->size());
+ }
+
+ /**
+ * Used to get an element from the list
+ */
+ std::string getElementAt(int elementIndex)
+ override final A_WARN_UNUSED
+ {
+ MutexLocker lock = mParent->lock();
+ const ServerInfo &server = mServers->at(elementIndex);
+ std::string myServer;
+ myServer.append(server.hostname);
+ return myServer;
+ }
+
+ /**
+ * Used to get the corresponding Server struct
+ */
+ const ServerInfo &getServer(const int elementIndex) const A_WARN_UNUSED
+ { return mServers->at(elementIndex); }
+
+ void setVersionString(const int index, const std::string &version)
+ {
+ if (index < 0 || index >= static_cast<int>(mVersionStrings.size()))
+ return;
+
+ if (version.empty() || !gui)
+ {
+ mVersionStrings[index] = VersionString(0, "");
+ }
+ else
+ {
+ mVersionStrings[index] = VersionString(
+ gui->getFont()->getWidth(version), version);
+ }
+ }
+
+ private:
+ typedef std::vector<VersionString> VersionStrings;
+
+ ServerInfos *mServers;
+ VersionStrings mVersionStrings;
+ ServerDialog *mParent;
+};
+
+#endif // GUI_MODELS_SERVERSLISTMODEL_H
diff --git a/src/gui/widgets/shopitems.cpp b/src/gui/models/shopitems.cpp
index 2ac65253d..492409e76 100644
--- a/src/gui/widgets/shopitems.cpp
+++ b/src/gui/models/shopitems.cpp
@@ -20,7 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "gui/widgets/shopitems.h"
+#include "gui/models/shopitems.h"
#include "shopitem.h"
diff --git a/src/gui/widgets/shopitems.h b/src/gui/models/shopitems.h
index 4803d6fed..925354960 100644
--- a/src/gui/widgets/shopitems.h
+++ b/src/gui/models/shopitems.h
@@ -20,10 +20,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef GUI_WIDGETS_SHOPITEMS_H
-#define GUI_WIDGETS_SHOPITEMS_H
+#ifndef GUI_MODELS_SHOPITEMS_H
+#define GUI_MODELS_SHOPITEMS_H
-#include <guichan/listmodel.hpp>
+#include "gui/models/listmodel.h"
#include <string>
#include <vector>
@@ -41,7 +41,7 @@ class ShopItem;
*
* This functionality can be enabled in the constructor.
*/
-class ShopItems final : public gcn::ListModel
+class ShopItems final : public ListModel
{
public:
/**
@@ -138,4 +138,4 @@ class ShopItems final : public gcn::ListModel
bool mMergeDuplicates;
};
-#endif // GUI_WIDGETS_SHOPITEMS_H
+#endif // GUI_MODELS_SHOPITEMS_H
diff --git a/src/gui/widgets/skillmodel.cpp b/src/gui/models/skillmodel.cpp
index 3244feec4..706bbdee2 100644
--- a/src/gui/widgets/skillmodel.cpp
+++ b/src/gui/models/skillmodel.cpp
@@ -20,7 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "gui/widgets/skillmodel.h"
+#include "gui/models/skillmodel.h"
#include "gui/widgets/skilldata.h"
diff --git a/src/gui/widgets/skillmodel.h b/src/gui/models/skillmodel.h
index 0f77dccfe..11746118e 100644
--- a/src/gui/widgets/skillmodel.h
+++ b/src/gui/models/skillmodel.h
@@ -20,17 +20,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef GUI_WIDGETS_SKILLMODEL_H
-#define GUI_WIDGETS_SKILLMODEL_H
+#ifndef GUI_MODELS_SKILLMODEL_H
+#define GUI_MODELS_SKILLMODEL_H
#include "gui/widgets/skillinfo.h"
-#include <guichan/listmodel.hpp>
+#include "gui/models/listmodel.h"
#include <string>
#include "localconsts.h"
-class SkillModel final : public gcn::ListModel
+class SkillModel final : public ListModel
{
public:
SkillModel();
@@ -52,4 +52,4 @@ class SkillModel final : public gcn::ListModel
SkillList mVisibleSkills;
};
-#endif // GUI_WIDGETS_SKILLMODEL_H
+#endif // GUI_MODELS_SKILLMODEL_H
diff --git a/src/gui/models/sortlistmodelbuy.h b/src/gui/models/sortlistmodelbuy.h
new file mode 100644
index 000000000..1647ae822
--- /dev/null
+++ b/src/gui/models/sortlistmodelbuy.h
@@ -0,0 +1,65 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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 GUI_MODELS_SORTLISTMODELBUY_H
+#define GUI_MODELS_SORTLISTMODELBUY_H
+
+#include "gui/models/listmodel.h"
+
+#include "utils/gettext.h"
+
+static const char *const SORT_NAME_BUY[7] =
+{
+ // TRANSLATORS: buy dialog sort type.
+ N_("unsorted"),
+ // TRANSLATORS: buy dialog sort type.
+ N_("by price"),
+ // TRANSLATORS: buy dialog sort type.
+ N_("by name"),
+ // TRANSLATORS: buy dialog sort type.
+ N_("by id"),
+ // TRANSLATORS: buy dialog sort type.
+ N_("by weight"),
+ // TRANSLATORS: buy dialog sort type.
+ N_("by amount"),
+ // TRANSLATORS: buy dialog sort type.
+ N_("by type")
+};
+
+class SortListModelBuy final : public ListModel
+{
+ public:
+ ~SortListModelBuy()
+ { }
+
+ int getNumberOfElements()
+ { return 7; }
+
+ std::string getElementAt(int i)
+ {
+ if (i >= getNumberOfElements() || i < 0)
+ return "???";
+ return gettext(SORT_NAME_BUY[i]);
+ }
+};
+
+#endif // GUI_MODELS_SORTLISTMODELBUY_H
diff --git a/src/gui/models/sortlistmodelinv.h b/src/gui/models/sortlistmodelinv.h
new file mode 100644
index 000000000..ae0982af6
--- /dev/null
+++ b/src/gui/models/sortlistmodelinv.h
@@ -0,0 +1,65 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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 GUI_MODELS_SORTLISTMODELINV_H
+#define GUI_MODELS_SORTLISTMODELINV_H
+
+#include "gui/models/listmodel.h"
+
+#include "utils/gettext.h"
+
+#include <string>
+
+static const char *const SORT_NAME_INVENTORY[6] =
+{
+ // TRANSLATORS: inventory sort mode
+ N_("default"),
+ // TRANSLATORS: inventory sort mode
+ N_("by name"),
+ // TRANSLATORS: inventory sort mode
+ N_("by id"),
+ // TRANSLATORS: inventory sort mode
+ N_("by weight"),
+ // TRANSLATORS: inventory sort mode
+ N_("by amount"),
+ // TRANSLATORS: inventory sort mode
+ N_("by type")
+};
+
+class SortListModelInv final : public ListModel
+{
+ public:
+ ~SortListModelInv()
+ { }
+
+ int getNumberOfElements() override final
+ { return 6; }
+
+ std::string getElementAt(int i) override final
+ {
+ if (i >= getNumberOfElements() || i < 0)
+ return "???";
+
+ return gettext(SORT_NAME_INVENTORY[i]);
+ }
+};
+
+#endif // GUI_MODELS_SORTLISTMODELINV_H
diff --git a/src/gui/widgets/mouseevent.h b/src/gui/models/soundsmodel.h
index b7c0cc94c..3ac679d37 100644
--- a/src/gui/widgets/mouseevent.h
+++ b/src/gui/models/soundsmodel.h
@@ -19,30 +19,29 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef GUI_WIDGETS_MOUSEEVENT_H
-#define GUI_WIDGETS_MOUSEEVENT_H
+#ifndef GUI_MODELS_SOUNDSMODEL_H
+#define GUI_MODELS_SOUNDSMODEL_H
-#include <guichan/mouseevent.hpp>
-#include <guichan/widget.hpp>
+#include "gui/theme.h"
-class MouseEvent final : public gcn::MouseEvent
+#include "gui/models/namesmodel.h"
+
+#include "utils/gettext.h"
+
+#include "localconsts.h"
+
+class SoundsModel final : public NamesModel
{
public:
- MouseEvent(gcn::Widget* source, bool shiftPressed,
- bool controlPressed, bool altPressed,
- bool metaPressed, unsigned int type, unsigned int button,
- int x, int y, int clickCount) :
- gcn::MouseEvent(source, shiftPressed, controlPressed,
- altPressed, metaPressed, type, button, x, y,
- clickCount)
+ SoundsModel() :
+ NamesModel()
{
+ mNames.push_back(gettext("(no sound)"));
+ Theme::fillSoundsList(mNames);
}
- void setX(int n)
- { mX = n; }
-
- void setY(int n)
- { mY = n; }
+ ~SoundsModel()
+ { }
};
-#endif // GUI_WIDGETS_MOUSEEVENT_H
+#endif // GUI_MODELS_SOUNDSMODEL_H
diff --git a/src/gui/widgets/tablemodel.cpp b/src/gui/models/tablemodel.cpp
index f244f51f4..aad66a6ad 100644
--- a/src/gui/widgets/tablemodel.cpp
+++ b/src/gui/models/tablemodel.cpp
@@ -20,11 +20,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "gui/widgets/tablemodel.h"
+#include "gui/models/tablemodel.h"
#include "utils/dtor.h"
-#include <guichan/widget.hpp>
+#include "gui/widgets/widget.h"
#include "debug.h"
@@ -89,7 +89,7 @@ void StaticTableModel::resize()
}
void StaticTableModel::set(const int row, const int column,
- gcn::Widget *const widget)
+ Widget *const widget)
{
if (!widget || row >= mRows || row < 0
|| column >= mColumns || column < 0)
@@ -119,8 +119,8 @@ void StaticTableModel::set(const int row, const int column,
signalAfterUpdate();
}
-gcn::Widget *StaticTableModel::getElementAt(const int row,
- const int column) const
+Widget *StaticTableModel::getElementAt(const int row,
+ const int column) const
{
return mTableModel[WIDGET_AT(row, column)];
}
diff --git a/src/gui/widgets/tablemodel.h b/src/gui/models/tablemodel.h
index 1273c6873..032facadd 100644
--- a/src/gui/widgets/tablemodel.h
+++ b/src/gui/models/tablemodel.h
@@ -20,18 +20,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef GUI_WIDGETS_TABLEMODEL_H
-#define GUI_WIDGETS_TABLEMODEL_H
+#ifndef GUI_MODELS_TABLEMODEL_H
+#define GUI_MODELS_TABLEMODEL_H
#include <set>
#include <vector>
#include "localconsts.h"
-namespace gcn
-{
- class Widget;
-}
+class Widget;
class TableModelListener
{
@@ -83,7 +80,7 @@ public:
/**
* Retrieves the widget stored at the specified location within the table.
*/
- virtual gcn::Widget *getElementAt(const int row, const int column)
+ virtual Widget *getElementAt(const int row, const int column)
const A_WARN_UNUSED = 0;
virtual void installListener(TableModelListener *const listener);
@@ -125,7 +122,7 @@ public:
* The model is resized to accomodate the widget's width and height,
* unless column width / row height have been fixed.
*/
- void set(const int row, const int column, gcn::Widget *const widget);
+ void set(const int row, const int column, Widget *const widget);
/**
* Fixes the column width for a given column; this overrides dynamic width
@@ -153,15 +150,14 @@ public:
int getWidth() const A_WARN_UNUSED;
int getHeight() const A_WARN_UNUSED;
int getColumnWidth(const int index) const override final A_WARN_UNUSED;
- gcn::Widget *getElementAt(const int row,
- const int column) const
- override final A_WARN_UNUSED;
+ Widget *getElementAt(const int row,
+ const int column) const override final A_WARN_UNUSED;
protected:
int mRows, mColumns;
int mHeight;
- std::vector<gcn::Widget *> mTableModel;
+ std::vector<Widget *> mTableModel;
std::vector<int> mWidths;
};
-#endif // GUI_WIDGETS_TABLEMODEL_H
+#endif // GUI_MODELS_TABLEMODEL_H
diff --git a/src/gui/models/targettypemodel.h b/src/gui/models/targettypemodel.h
new file mode 100644
index 000000000..d049585a5
--- /dev/null
+++ b/src/gui/models/targettypemodel.h
@@ -0,0 +1,58 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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 GUI_MODELS_TARGETTYPEMODEL_H
+#define GUI_MODELS_TARGETTYPEMODEL_H
+
+#include "gui/models/listmodel.h"
+
+#include "utils/gettext.h"
+
+const char *TARGET_TYPE_TEXT[3] =
+{
+ // TRANSLATORS: target type
+ N_("No Target"),
+ // TRANSLATORS: target type
+ N_("Allow Target"),
+ // TRANSLATORS: target type
+ N_("Need Target")
+};
+
+class TargetTypeModel final : public ListModel
+{
+ public:
+ ~TargetTypeModel()
+ { }
+
+ int getNumberOfElements() override final
+ {
+ return 3;
+ }
+
+ std::string getElementAt(int i) override final
+ {
+ if (i >= getNumberOfElements() || i < 0)
+ return "???";
+ return TARGET_TYPE_TEXT[i];
+ }
+};
+
+#endif // GUI_MODELS_TARGETTYPEMODEL_H
diff --git a/src/gui/models/themesmodel.h b/src/gui/models/themesmodel.h
new file mode 100644
index 000000000..7f76534f0
--- /dev/null
+++ b/src/gui/models/themesmodel.h
@@ -0,0 +1,47 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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 GUI_MODELS_THEMESMODEL_H
+#define GUI_MODELS_THEMESMODEL_H
+
+#include "gui/theme.h"
+
+#include "gui/models/namesmodel.h"
+
+#include "utils/gettext.h"
+
+#include "localconsts.h"
+
+class ThemesModel final : public NamesModel
+{
+ public:
+ ThemesModel() :
+ NamesModel()
+ {
+ mNames.push_back(gettext("(default)"));
+ Theme::fillSkinsList(mNames);
+ }
+
+ ~ThemesModel()
+ { }
+};
+
+#endif // GUI_MODELS_THEMESMODEL_H
diff --git a/src/gui/models/touchactionmodel.cpp b/src/gui/models/touchactionmodel.cpp
new file mode 100644
index 000000000..b32d1479f
--- /dev/null
+++ b/src/gui/models/touchactionmodel.cpp
@@ -0,0 +1,84 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2012-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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 "gui/setupactiondata.h"
+
+#include "gui/models/touchactionmodel.h"
+
+#include <algorithm>
+
+#include "debug.h"
+
+static class SortTouchActionFunctor final
+{
+ public:
+ bool operator() (const SetupActionData *const data1,
+ const SetupActionData *const data2) const
+ {
+ if (!data1 || !data2)
+ return false;
+ return data1->name < data2->name;
+ }
+} touchActionSorter;
+
+TouchActionsModel::TouchActionsModel() :
+ NamesModel(),
+ mActionId(),
+ mActionToSelection()
+{
+ std::vector<SetupActionData*> data;
+
+ for (int f = 0, sz = touchActionDataSize; f < sz; f ++)
+ {
+ int k = 0;
+ while (!touchActionData[f][k].name.empty())
+ {
+ data.push_back(&touchActionData[f][k]);
+ k ++;
+ }
+ }
+
+ std::sort(data.begin(), data.end(), touchActionSorter);
+ int cnt = 0;
+ FOR_EACH (std::vector<SetupActionData*>::iterator, it, data)
+ {
+ const SetupActionData *const data1 = *it;
+ mNames.push_back(data1->name);
+ mActionId.push_back(data1->actionId);
+ mActionToSelection[data1->actionId] = cnt;
+ cnt ++;
+ }
+}
+
+int TouchActionsModel::getActionFromSelection(const int sel) const
+{
+ if (sel < 0 || sel > static_cast<signed int>(mActionId.size()))
+ return -1;
+ return mActionId[sel];
+}
+
+int TouchActionsModel::getSelectionFromAction(const int action) const
+{
+ const std::map<int, int>::const_iterator it
+ = mActionToSelection.find(action);
+ if (it == mActionToSelection.end())
+ return 0;
+ return (*it).second;
+}
diff --git a/src/input/keyevent.cpp b/src/gui/models/touchactionmodel.h
index 5695cd99b..00abe89e2 100644
--- a/src/input/keyevent.cpp
+++ b/src/gui/models/touchactionmodel.h
@@ -18,30 +18,30 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "input/keyevent.h"
-
-#include "debug.h"
-
-KeyEvent::KeyEvent(gcn::Widget *const source,
- const bool shiftPressed,
- const bool controlPressed,
- const bool altPressed,
- const bool metaPressed,
- const unsigned int type,
- const bool numericPad,
- const int actionId,
- const gcn::Key& key) :
- gcn::KeyEvent(source, shiftPressed, controlPressed, altPressed,
- metaPressed, type, numericPad, key),
-#ifdef USE_SDL2
- mActionId(actionId),
- mText()
-#else
- mActionId(actionId)
-#endif
-{
-}
+#ifndef GUI_MODELS_TOUCHACTIONMODEL_H
+#define GUI_MODELS_TOUCHACTIONMODEL_H
+
+#include "gui/models/namesmodel.h"
+
+#include "gui/widgets/setupitem.h"
-KeyEvent::~KeyEvent()
+class TouchActionsModel final : public NamesModel
{
-}
+ public:
+ TouchActionsModel();
+
+ A_DELETE_COPY(TouchActionsModel)
+
+ ~TouchActionsModel()
+ { }
+
+ int getActionFromSelection(const int sel) const;
+
+ int getSelectionFromAction(const int action) const;
+
+ private:
+ std::vector<int> mActionId;
+ std::map<int, int> mActionToSelection;
+};
+
+#endif // GUI_MODELS_TOUCHACTIONMODEL_H
diff --git a/src/gui/models/typelistmodel.h b/src/gui/models/typelistmodel.h
new file mode 100644
index 000000000..f9c005f8f
--- /dev/null
+++ b/src/gui/models/typelistmodel.h
@@ -0,0 +1,65 @@
+/*
+ * The Mana Client
+ * Copyright (C) 2011-2012 The Mana Developers
+ * Copyright (C) 2012-2014 The ManaPlus 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 GUI_MODELS_TYPELISTMODEL_H
+#define GUI_MODELS_TYPELISTMODEL_H
+
+#include "gui/models/listmodel.h"
+
+/**
+ * Server Type List Model
+ */
+class TypeListModel : public ListModel
+{
+ public:
+ TypeListModel()
+ { }
+
+ /**
+ * Used to get number of line in the list
+ */
+ int getNumberOfElements() override final A_WARN_UNUSED
+#ifdef EATHENA_SUPPORT
+ { return 3; }
+#else
+ { return 2; }
+#endif
+
+ /**
+ * Used to get an element from the list
+ */
+ std::string getElementAt(int elementIndex)
+ override final A_WARN_UNUSED
+ {
+ if (elementIndex == 0)
+ return "TmwAthena";
+ else if (elementIndex == 1)
+ return "Evol";
+#ifdef EATHENA_SUPPORT
+ else if (elementIndex == 2)
+ return "eAthena";
+#endif
+ else
+ return "Unknown";
+ }
+};
+
+#endif // GUI_MODELS_TYPELISTMODEL_H
diff --git a/src/gui/models/updatelistmodel.h b/src/gui/models/updatelistmodel.h
new file mode 100644
index 000000000..2e1d2a7d5
--- /dev/null
+++ b/src/gui/models/updatelistmodel.h
@@ -0,0 +1,66 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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 GUI_MODELS_UPDATELISTMODEL_H
+#define GUI_MODELS_UPDATELISTMODEL_H
+
+#include "gui/models/listmodel.h"
+
+#include "net/logindata.h"
+
+#include "utils/gettext.h"
+
+#include "localconsts.h"
+
+class UpdateListModel final : public ListModel
+{
+ public:
+ explicit UpdateListModel(LoginData *const data) :
+ ListModel(),
+ mLoginData(data)
+ {
+ }
+
+ A_DELETE_COPY(UpdateListModel)
+
+ ~UpdateListModel()
+ { }
+
+ int getNumberOfElements() override final
+ {
+ if (!mLoginData)
+ return 0;
+ return static_cast<int>(mLoginData->updateHosts.size());
+ }
+
+ std::string getElementAt(int i) override final
+ {
+ if (!mLoginData || i >= getNumberOfElements() || i < 0)
+ return "???";
+ return mLoginData->updateHosts[i];
+ }
+
+ protected:
+ LoginData *mLoginData;
+};
+
+#endif // GUI_MODELS_UPDATELISTMODEL_H
diff --git a/src/gui/models/updatetypemodel.h b/src/gui/models/updatetypemodel.h
new file mode 100644
index 000000000..f96c11e87
--- /dev/null
+++ b/src/gui/models/updatetypemodel.h
@@ -0,0 +1,63 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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 GUI_MODELS_UPDATETYPEMODEL_H
+#define GUI_MODELS_UPDATETYPEMODEL_H
+
+#include "utils/gettext.h"
+
+#include "gui/models/listmodel.h"
+
+const char *UPDATE_TYPE_TEXT[3] =
+{
+ // TRANSLATORS: update type
+ N_("Normal"),
+ // TRANSLATORS: update type
+ N_("Auto Close"),
+ // TRANSLATORS: update type
+ N_("Skip"),
+};
+
+class UpdateTypeModel final : public ListModel
+{
+ public:
+ UpdateTypeModel()
+ { }
+
+ A_DELETE_COPY(UpdateTypeModel)
+
+ ~UpdateTypeModel()
+ { }
+
+ int getNumberOfElements() override final
+ {
+ return 3;
+ }
+
+ std::string getElementAt(int i) override final
+ {
+ if (i >= getNumberOfElements() || i < 0)
+ return "???";
+ return gettext(UPDATE_TYPE_TEXT[i]);
+ }
+};
+
+#endif // GUI_MODELS_UPDATETYPEMODEL_H
diff --git a/src/gui/models/worldlistmodel.h b/src/gui/models/worldlistmodel.h
new file mode 100644
index 000000000..7d9dc322c
--- /dev/null
+++ b/src/gui/models/worldlistmodel.h
@@ -0,0 +1,68 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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 GUI_MODELS_WORLDLISTMODEL_H
+#define GUI_MODELS_WORLDLISTMODEL_H
+
+#include "gui/models/listmodel.h"
+
+#include "net/worldinfo.h"
+
+/**
+ * The list model for the server list.
+ */
+class WorldListModel final : public ListModel
+{
+ public:
+ explicit WorldListModel(Worlds worlds) :
+ mWorlds(worlds)
+ {
+ }
+
+ A_DELETE_COPY(WorldListModel)
+
+ ~WorldListModel()
+ { }
+
+ int getNumberOfElements() override final
+ {
+ return static_cast<int>(mWorlds.size());
+ }
+
+ std::string getElementAt(int i) override final
+ {
+ const WorldInfo *const si = mWorlds[i];
+ if (si)
+ {
+ return std::string(si->name).append(" (").append(
+ toString(si->online_users)).append(")");
+ }
+ else
+ {
+ return "???";
+ }
+ }
+ private:
+ Worlds mWorlds;
+};
+
+#endif // GUI_MODELS_WORLDLISTMODEL_H
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp
index 9d6c19095..21e027d82 100644
--- a/src/gui/palette.cpp
+++ b/src/gui/palette.cpp
@@ -29,18 +29,18 @@
#include "debug.h"
-const gcn::Color Palette::BLACK = gcn::Color(0, 0, 0);
+const Color Palette::BLACK = Color(0, 0, 0);
Palette::Palettes Palette::mInstances;
-const gcn::Color Palette::RAINBOW_COLORS[7] =
+const Color Palette::RAINBOW_COLORS[7] =
{
- gcn::Color(255, 0, 0),
- gcn::Color(255, 153, 0),
- gcn::Color(255, 255, 0),
- gcn::Color(0, 153, 0),
- gcn::Color(0, 204, 204),
- gcn::Color(51, 0, 153),
- gcn::Color(153, 0, 153)
+ Color(255, 0, 0),
+ Color(255, 153, 0),
+ Color(255, 255, 0),
+ Color(0, 153, 0),
+ Color(0, 204, 204),
+ Color(51, 0, 153),
+ Color(153, 0, 153)
};
const int Palette::RAINBOW_COLOR_COUNT = 7;
@@ -59,7 +59,7 @@ Palette::~Palette()
mInstances.erase(this);
}
-const gcn::Color& Palette::getCharColor(const signed char c, bool &valid) const
+const Color& Palette::getCharColor(const signed char c, bool &valid) const
{
const CharColors::const_iterator it = mCharColors.find(c);
if (it != mCharColors.end())
@@ -128,7 +128,7 @@ void Palette::advanceGradient()
else
colIndex = gradIndex;
- gcn::Color &color = elem->color;
+ Color &color = elem->color;
int colVal;
if (grad == PULSE)
@@ -136,7 +136,7 @@ void Palette::advanceGradient()
colVal = static_cast<int>(255.0 *
sin(M_PI * colIndex / numOfColors));
- const gcn::Color &col = elem->testColor;
+ const Color &col = elem->testColor;
color.r = ((colVal * col.r) / 255) % (col.r + 1);
color.g = ((colVal * col.g) / 255) % (col.g + 1);
@@ -180,9 +180,9 @@ void Palette::advanceGradient()
}
else if (elem->grad == RAINBOW)
{
- const gcn::Color &startCol = RAINBOW_COLORS[colIndex];
- const gcn::Color &destCol =
- RAINBOW_COLORS[(colIndex + 1) % numOfColors];
+ const Color &startCol = RAINBOW_COLORS[colIndex];
+ const Color &destCol
+ = RAINBOW_COLORS[(colIndex + 1) % numOfColors];
double startColVal;
double destColVal;
diff --git a/src/gui/palette.h b/src/gui/palette.h
index 26ea6817c..0dbb5d3ad 100644
--- a/src/gui/palette.h
+++ b/src/gui/palette.h
@@ -26,7 +26,7 @@
#include "logger.h"
-#include <guichan/color.hpp>
+#include "gui/color.h"
#if defined __native_client__
#include <stdlib.h>
@@ -49,7 +49,7 @@ class Palette
{
public:
/** Black Color Constant */
- static const gcn::Color BLACK;
+ static const Color BLACK;
/** Colors can be static or can alter over time. */
enum GradientType
@@ -71,8 +71,8 @@ class Palette
*
* @return the requested color or Palette::BLACK
*/
- const gcn::Color &getCharColor(const signed char c,
- bool &valid) const A_WARN_UNUSED;
+ const Color &getCharColor(const signed char c,
+ bool &valid) const A_WARN_UNUSED;
int getIdByChar(const signed char c, bool &valid) const A_WARN_UNUSED;
@@ -85,8 +85,8 @@ class Palette
*
* @return the requested color
*/
- inline const gcn::Color &getColor(int type,
- const int alpha = 255) A_WARN_UNUSED
+ inline const Color &getColor(int type,
+ const int alpha = 255) A_WARN_UNUSED
{
if (type >= static_cast<signed>(mColors.size()) || type < 0)
{
@@ -94,15 +94,14 @@ class Palette
type, static_cast<unsigned int>(mColors.size()));
type = 0;
}
- gcn::Color* col = &mColors[type].color;
+ Color* col = &mColors[type].color;
col->a = alpha;
return *col;
}
- inline const gcn::Color &getColorWithAlpha(const int type)
- A_WARN_UNUSED
+ inline const Color &getColorWithAlpha(const int type) A_WARN_UNUSED
{
- gcn::Color* col = &mColors[type].color;
+ Color* col = &mColors[type].color;
col->a = mColors[type].delay;
return *col;
}
@@ -144,7 +143,7 @@ class Palette
protected:
/** Colors used for the rainbow gradient */
- static const gcn::Color RAINBOW_COLORS[7];
+ static const Color RAINBOW_COLORS[7];
static const int RAINBOW_COLOR_COUNT;
/** Time tick, that gradient-type colors were updated the last time. */
@@ -183,9 +182,9 @@ class Palette
}
int type;
- gcn::Color color;
- gcn::Color testColor;
- gcn::Color committedColor;
+ Color color;
+ Color testColor;
+ Color committedColor;
std::string text;
signed char ch;
GradientType grad;
@@ -194,7 +193,7 @@ class Palette
int delay;
int committedDelay;
- void set(const int type0, const gcn::Color &color0,
+ void set(const int type0, const Color &color0,
const GradientType grad0, const int delay0)
{
type = type0;
diff --git a/src/gui/popups/beingpopup.cpp b/src/gui/popups/beingpopup.cpp
index 6d3077130..07d4b064a 100644
--- a/src/gui/popups/beingpopup.cpp
+++ b/src/gui/popups/beingpopup.cpp
@@ -24,15 +24,14 @@
#include "being/being.h"
#include "being/playerrelations.h"
-#include "gui/sdlfont.h"
+#include "gui/font.h"
+#include "gui/gui.h"
#include "gui/widgets/label.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
-#include <guichan/font.hpp>
-
#include "debug.h"
BeingPopup::BeingPopup() :
diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp
index 1fd496dec..0a65ce3bc 100644
--- a/src/gui/popups/itempopup.cpp
+++ b/src/gui/popups/itempopup.cpp
@@ -27,7 +27,8 @@
#include "item.h"
#include "units.h"
-#include "gui/sdlfont.h"
+#include "gui/font.h"
+#include "gui/gui.h"
#include "gui/widgets/icon.h"
#include "gui/widgets/label.h"
@@ -38,8 +39,6 @@
#include "resources/image.h"
#include "resources/resourcemanager.h"
-#include <guichan/font.hpp>
-
#include "debug.h"
extern int serverVersion;
@@ -265,7 +264,7 @@ void ItemPopup::setLabelColor(Label *label, const ItemType type) const
}
#undef caseSetColor
-void ItemPopup::mouseMoved(gcn::MouseEvent &event)
+void ItemPopup::mouseMoved(MouseEvent &event)
{
Popup::mouseMoved(event);
diff --git a/src/gui/popups/itempopup.h b/src/gui/popups/itempopup.h
index ac4683938..f1cedf046 100644
--- a/src/gui/popups/itempopup.h
+++ b/src/gui/popups/itempopup.h
@@ -29,6 +29,7 @@
#include "resources/iteminfo.h"
class Icon;
+class Item;
class Label;
class TextBox;
@@ -60,7 +61,7 @@ class ItemPopup final : public Popup
void setItem(const Item *const item, const bool showImage = false);
- void mouseMoved(gcn::MouseEvent &mouseEvent) override final;
+ void mouseMoved(MouseEvent &mouseEvent) override final;
private:
Label *mItemName;
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index 52cf1d5d6..3905d91e6 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -23,6 +23,7 @@
#include "gui/popups/popupmenu.h"
#include "actormanager.h"
+#include "commands.h"
#include "commandhandler.h"
#include "configuration.h"
#include "dropshortcut.h"
@@ -56,6 +57,7 @@
#include "gui/viewport.h"
+#include "gui/widgets/button.h"
#include "gui/widgets/browserbox.h"
#include "gui/widgets/tabs/chattab.h"
#include "gui/widgets/progressbar.h"
@@ -79,7 +81,7 @@
#include "utils/gettext.h"
#include "utils/process.h"
-#include <guichan/listmodel.hpp>
+#include "gui/models/listmodel.h"
#include "debug.h"
@@ -118,7 +120,7 @@ PopupMenu::PopupMenu() :
mPlayerListener.setNick("");
mPlayerListener.setDialog(nullptr);
mPlayerListener.setType(static_cast<int>(Being::UNKNOWN));
- mScrollArea = new ScrollArea(mBrowserBox, false);
+ mScrollArea = new ScrollArea(this, mBrowserBox, false);
mScrollArea->setVerticalScrollPolicy(ScrollArea::SHOW_AUTO);
}
@@ -839,7 +841,7 @@ void PopupMenu::showChangePos(const int x, const int y)
}
void PopupMenu::handleLink(const std::string &link,
- gcn::MouseEvent *event A_UNUSED)
+ MouseEvent *event A_UNUSED)
{
Being *being = nullptr;
if (actorManager)
@@ -2683,7 +2685,7 @@ void PopupMenu::addPickupFilter(const std::string &name)
}
void PopupMenu::showPopup(const int x, const int y,
- gcn::ListModel *const model)
+ ListModel *const model)
{
if (!model)
return;
@@ -2838,7 +2840,7 @@ void PopupMenu::showGMPopup()
}
RenameListener::RenameListener() :
- gcn::ActionListener(),
+ ActionListener(),
mMapItemX(0),
mMapItemY(0),
mDialog(nullptr)
@@ -2859,7 +2861,7 @@ void RenameListener::setMapItem(MapItem *const mapItem)
}
}
-void RenameListener::action(const gcn::ActionEvent &event)
+void RenameListener::action(const ActionEvent &event)
{
if (event.getId() == "ok" && viewport && mDialog)
{
@@ -2893,7 +2895,7 @@ PlayerListener::PlayerListener() :
{
}
-void PlayerListener::action(const gcn::ActionEvent &event)
+void PlayerListener::action(const ActionEvent &event)
{
if (event.getId() == "ok" && !mNick.empty() && mDialog)
{
diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h
index 0970f34b6..7eb38dc15 100644
--- a/src/gui/popups/popupmenu.h
+++ b/src/gui/popups/popupmenu.h
@@ -26,19 +26,18 @@
#include "gui/widgets/linkhandler.h"
#include "gui/widgets/popup.h"
-#include "being/actorsprite.h"
-
-#include <guichan/actionlistener.hpp>
-#include <guichan/listmodel.hpp>
+#include "listeners/actionlistener.h"
#include "localconsts.h"
+class ActorSprite;
class Being;
class BrowserBox;
class Button;
class ChatTab;
class FloorItem;
class Item;
+class ListModel;
class MapItem;
class ScrollArea;
class TextCommand;
@@ -47,14 +46,14 @@ class TextField;
class ProgressBar;
class Window;
-class RenameListener final : public gcn::ActionListener
+class RenameListener final : public ActionListener
{
public:
RenameListener();
A_DELETE_COPY(RenameListener)
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void setMapItem(MapItem *const mapItem);
@@ -67,14 +66,14 @@ class RenameListener final : public gcn::ActionListener
TextDialog *mDialog;
};
-class PlayerListener : public gcn::ActionListener
+class PlayerListener : public ActionListener
{
public:
PlayerListener();
A_DELETE_COPY(PlayerListener)
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void setNick(std::string name)
{ mNick = name; }
@@ -173,7 +172,7 @@ class PopupMenu final : public Popup, public LinkHandler
void showChangePos(const int x, const int y);
- void showPopup(const int x, const int y, gcn::ListModel *const model);
+ void showPopup(const int x, const int y, ListModel *const model);
void showTextFieldPopup(int x, int y, TextField *const input);
@@ -187,7 +186,7 @@ class PopupMenu final : public Popup, public LinkHandler
* Handles link action.
*/
void handleLink(const std::string &link,
- gcn::MouseEvent *event A_UNUSED) override final;
+ MouseEvent *event A_UNUSED) override final;
void clear();
diff --git a/src/gui/popups/speechbubble.cpp b/src/gui/popups/speechbubble.cpp
index e32a6bb4d..3d0250a78 100644
--- a/src/gui/popups/speechbubble.cpp
+++ b/src/gui/popups/speechbubble.cpp
@@ -23,14 +23,12 @@
#include "gui/popups/speechbubble.h"
-#include "gui/sdlfont.h"
+#include "gui/font.h"
+#include "gui/gui.h"
#include "gui/viewport.h"
#include "gui/widgets/browserbox.h"
#include "gui/widgets/label.h"
-#include "gui/widgets/textbox.h"
-
-#include <guichan/font.hpp>
#include "debug.h"
@@ -59,8 +57,8 @@ void SpeechBubble::postInit()
}
void SpeechBubble::setCaption(const std::string &name,
- const gcn::Color *const color1,
- const gcn::Color *const color2)
+ const Color *const color1,
+ const Color *const color2)
{
mCaption->setCaption(name);
mCaption->adjustSize();
diff --git a/src/gui/popups/speechbubble.h b/src/gui/popups/speechbubble.h
index 62da9b146..1bc5385a4 100644
--- a/src/gui/popups/speechbubble.h
+++ b/src/gui/popups/speechbubble.h
@@ -47,9 +47,9 @@ class SpeechBubble final : public Popup
* Sets the name displayed for the speech bubble, and in what color.
*/
void setCaption(const std::string &name,
- const gcn::Color *const color1 =
+ const Color *const color1 =
&Theme::getThemeColor(Theme::BUBBLE_NAME),
- const gcn::Color *const color2 =
+ const Color *const color2 =
&Theme::getThemeColor(Theme::BUBBLE_NAME_OUTLINE));
/**
diff --git a/src/gui/popups/spellpopup.cpp b/src/gui/popups/spellpopup.cpp
index df25739f2..bf6ea1799 100644
--- a/src/gui/popups/spellpopup.cpp
+++ b/src/gui/popups/spellpopup.cpp
@@ -23,7 +23,9 @@
#include "gui/popups/spellpopup.h"
-#include "gui/sdlfont.h"
+#include "textcommand.h"
+
+#include "gui/gui.h"
#include "gui/widgets/label.h"
@@ -88,7 +90,7 @@ void SpellPopup::view(const int x, const int y)
int posX = std::max(0, x - getWidth() / 2);
int posY = y + distance;
- const gcn::Rectangle &rect = mDimension;
+ const Rect &rect = mDimension;
const int w = rect.width;
const int h = rect.height;
if (posX + w > mainGraphics->mWidth)
@@ -109,7 +111,7 @@ void SpellPopup::view(const int x, const int y)
requestMoveToTop();
}
-void SpellPopup::mouseMoved(gcn::MouseEvent &event)
+void SpellPopup::mouseMoved(MouseEvent &event)
{
Popup::mouseMoved(event);
diff --git a/src/gui/popups/spellpopup.h b/src/gui/popups/spellpopup.h
index c8123a4ce..cbbd53703 100644
--- a/src/gui/popups/spellpopup.h
+++ b/src/gui/popups/spellpopup.h
@@ -26,9 +26,8 @@
#include "gui/widgets/popup.h"
-#include "textcommand.h"
-
class Label;
+class TextCommand;
/**
* A popup that displays information about an item.
@@ -60,7 +59,7 @@ class SpellPopup final : public Popup
*/
void view(const int x, const int y);
- void mouseMoved(gcn::MouseEvent &mouseEvent) override final;
+ void mouseMoved(MouseEvent &mouseEvent) override final;
private:
Label *mItemName;
diff --git a/src/gui/popups/statuspopup.cpp b/src/gui/popups/statuspopup.cpp
index 1d696fe82..7dd3c3634 100644
--- a/src/gui/popups/statuspopup.cpp
+++ b/src/gui/popups/statuspopup.cpp
@@ -33,7 +33,7 @@
#include "utils/stringutils.h"
-#include <guichan/font.hpp>
+#include "gui/font.h"
#include "debug.h"
diff --git a/src/gui/popups/textpopup.cpp b/src/gui/popups/textpopup.cpp
index 9a7f1d3e4..d5cc918d3 100644
--- a/src/gui/popups/textpopup.cpp
+++ b/src/gui/popups/textpopup.cpp
@@ -25,7 +25,7 @@
#include "gui/widgets/label.h"
-#include <guichan/font.hpp>
+#include "gui/font.h"
#include "debug.h"
@@ -86,7 +86,7 @@ void TextPopup::show(const int x, const int y, const std::string &str1,
setHeight(pad2 + mText[0]->getFont()->getHeight() * cnt);
const int distance = 20;
- const gcn::Rectangle &rect = mDimension;
+ const Rect &rect = mDimension;
int posX = std::max(0, x - rect.width / 2);
int posY = y + distance;
@@ -100,7 +100,7 @@ void TextPopup::show(const int x, const int y, const std::string &str1,
requestMoveToTop();
}
-void TextPopup::mouseMoved(gcn::MouseEvent &event)
+void TextPopup::mouseMoved(MouseEvent &event)
{
Popup::mouseMoved(event);
diff --git a/src/gui/popups/textpopup.h b/src/gui/popups/textpopup.h
index 131921b7b..eb29cba61 100644
--- a/src/gui/popups/textpopup.h
+++ b/src/gui/popups/textpopup.h
@@ -72,7 +72,7 @@ class TextPopup final : public Popup
void show(const int x, const int y, const std::string &str1,
const std::string &str2, const std::string &str3);
- void mouseMoved(gcn::MouseEvent &mouseEvent) override final;
+ void mouseMoved(MouseEvent &mouseEvent) override final;
private:
Label *mText[TEXTPOPUPCOUNT];
diff --git a/src/guichan/mouseinput.cpp b/src/gui/rect.cpp
index b13708bb7..5f9d2bf0f 100644
--- a/src/guichan/mouseinput.cpp
+++ b/src/gui/rect.cpp
@@ -65,72 +65,92 @@
* For comments regarding functions please see the header file.
*/
-#include "guichan/mouseinput.hpp"
+#include "gui/rect.h"
#include "debug.h"
-namespace gcn
+Rect::Rect() :
+ x(0),
+ y(0),
+ width(0),
+ height(0)
{
- MouseInput::MouseInput(const unsigned int button,
- const unsigned int type,
- const int x,
- const int y,
- const int timeStamp) :
- mType(type),
- mButton(button),
- mTimeStamp(timeStamp),
- mX(x),
- mY(y)
- {
- }
+}
- void MouseInput::setType(unsigned int type)
- {
- mType = type;
- }
+Rect::Rect(const int x_, const int y_,
+ const int width_, const int height_) :
+ x(x_),
+ y(y_),
+ width(width_),
+ height(height_)
+{
+}
- unsigned int MouseInput::getType() const
- {
- return mType;
- }
+void Rect::setAll(const int x0,
+ const int y0,
+ const int width0,
+ const int height0)
+{
+ x = x0;
+ y = y0;
+ width = width0;
+ height = height0;
+}
- void MouseInput::setButton(unsigned int button)
- {
- mButton = button;
- }
+bool Rect::isIntersecting(const Rect& rectangle) const
+{
+ int x_ = x;
+ int y_ = y;
+ int width_ = width;
+ int height_ = height;
- unsigned int MouseInput::getButton() const
- {
- return mButton;
- }
+ x_ -= rectangle.x;
+ y_ -= rectangle.y;
- int MouseInput::getTimeStamp() const
+ if (x_ < 0)
{
- return mTimeStamp;
+ width_ += x_;
+// x_ = 0;
}
-
- void MouseInput::setTimeStamp(int timeStamp)
+ else if (x_ + width_ > rectangle.width)
{
- mTimeStamp = timeStamp;
+ width_ = rectangle.width - x_;
}
- void MouseInput::setX(int x)
+ if (y_ < 0)
{
- mX = x;
+ height_ += y_;
+// y_ = 0;
}
-
- int MouseInput::getX() const
+ else if (y_ + height_ > rectangle.height)
{
- return mX;
+ height_ = rectangle.height - y_;
}
- void MouseInput::setY(int y)
+ if (width_ <= 0 || height_ <= 0)
{
- mY = y;
+ return false;
}
- int MouseInput::getY() const
- {
- return mY;
- }
-} // namespace gcn
+ return true;
+}
+
+bool Rect::isPointInRect(int x_, int y_) const
+{
+ return x_ >= x
+ && y_ >= y
+ && x_ < x + width
+ && y_ < y + height;
+}
+
+std::ostream& operator<<(std::ostream& out,
+ const Rect& rectangle)
+{
+ out << "Rect [x = " << rectangle.x
+ << ", y = " << rectangle.y
+ << ", width = " << rectangle.width
+ << ", height = " << rectangle.height
+ << "]";
+
+ return out;
+}
diff --git a/src/guichan/include/guichan/rectangle.hpp b/src/gui/rect.h
index b8503db98..69c0120ca 100644
--- a/src/guichan/include/guichan/rectangle.hpp
+++ b/src/gui/rect.h
@@ -61,99 +61,102 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef GCN_RECTANGLE_HPP
-#define GCN_RECTANGLE_HPP
+#ifndef GUI_RECT_H
+#define GUI_RECT_H
#include <iostream>
#include "localconsts.h"
-namespace gcn
+/**
+ * Represents a rectangle.
+ *
+ * @since 0.1.0
+ */
+class Rect
{
- /**
- * Represents a rectangle.
- *
- * @since 0.1.0
- */
- class Rectangle
- {
public:
/**
- * Constructor. The default rectangle is an empty rectangle
- * at the coordinates (0,0).
- */
- Rectangle();
+ * Constructor. The default rectangle is an empty rectangle
+ * at the coordinates (0,0).
+ */
+ Rect();
/**
- * Constructor.
- *
- * @param x The x coordinate of the rectangle.
- * @param y The y coordinate of the rectangle.
- * @param width The width of the rectangle.
- * @param height The height of the rectangle.
- * @since 0.1.0
- */
- Rectangle(const int x, const int y, const int width, const int height);
+ * Constructor.
+ *
+ * @param x The x coordinate of the rectangle.
+ * @param y The y coordinate of the rectangle.
+ * @param width The width of the rectangle.
+ * @param height The height of the rectangle.
+ * @since 0.1.0
+ */
+ Rect(const int x, const int y, const int width, const int height);
+
+ virtual ~Rect()
+ { }
/**
- * Sets the dimension of a rectangle.
- *
- * @param x The x coordinate of the rectangle.
- * @param y The y coordinate of the rectangle.
- * @param width The width of the rectangle.
- * @param height The height of the rectangle.
- * @since 0.1.0
- */
- void setAll(int x, int y, int width, int height);
+ * Sets the dimension of a rectangle.
+ *
+ * @param x The x coordinate of the rectangle.
+ * @param y The y coordinate of the rectangle.
+ * @param width The width of the rectangle.
+ * @param height The height of the rectangle.
+ * @since 0.1.0
+ */
+ void setAll(const int x,
+ const int y,
+ const int width0,
+ const int height0);
/**
- * Checks if another rectangle intersects with the rectangle.
- *
- * @param rectangle Another rectangle to check for intersection.
- * @return True if the rectangles intersect, false otherwise.
- * @since 0.1.0
- */
- bool isIntersecting(const Rectangle& rectangle) const A_WARN_UNUSED;
+ * Checks if another rectangle intersects with the rectangle.
+ *
+ * @param rectangle Another rectangle to check for intersection.
+ * @return True if the rectangles intersect, false otherwise.
+ * @since 0.1.0
+ */
+ bool isIntersecting(const Rect& rectangle) const A_WARN_UNUSED;
/**
- * Checks if a point is inside the rectangle
- *
- * @param x The x coordinate of the point.
- * @param y The y coordinate of the point.
- * @return True if the point is inside the rectangle.
- * @since 0.1.0
- */
+ * Checks if a point is inside the rectangle
+ *
+ * @param x The x coordinate of the point.
+ * @param y The y coordinate of the point.
+ * @return True if the point is inside the rectangle.
+ * @since 0.1.0
+ */
bool isPointInRect(int x, int y) const A_WARN_UNUSED;
/**
- * Output operator for output.
- *
- * @param out The stream to output to.
- * @param rectangle The rectangle to output.
- */
+ * Output operator for output.
+ *
+ * @param out The stream to output to.
+ * @param rectangle The rectangle to output.
+ */
friend std::ostream& operator<<(std::ostream& out,
- const Rectangle& rectangle);
+ const Rect& rectangle);
/**
- * Holds the x coordinate of the rectangle.
- */
+ * Holds the x coordinate of the rectangle.
+ */
int x;
/**
- * Holds the x coordinate of the rectangle.
- */
+ * Holds the x coordinate of the rectangle.
+ */
int y;
/**
- * Holds the width of the rectangle.
- */
+ * Holds the width of the rectangle.
+ */
int width;
/**
- * Holds the height of the rectangle.
- */
+ * Holds the height of the rectangle.
+ */
int height;
- };
-} // namespace gcn
+};
-#endif // end GCN_RECTANGEL_HPP
+#endif // GUI_RECT_H
diff --git a/src/gui/sdlfont_unittest.cc b/src/gui/sdlfont_unittest.cc
index eab4d2994..e0f536c01 100644
--- a/src/gui/sdlfont_unittest.cc
+++ b/src/gui/sdlfont_unittest.cc
@@ -20,7 +20,7 @@
#include "logger.h"
-#include "gui/sdlfont.h"
+#include "gui/font.h"
#include "gui/theme.h"
#include "gtest/gtest.h"
@@ -43,7 +43,7 @@ TEST(TextChunkList, add1)
TextChunkList list;
SDLTextChunk *chunk = new SDLTextChunk("test",
- gcn::Color(1, 2, 3), gcn::Color(2, 3, 4));
+ Color(1, 2, 3), Color(2, 3, 4));
list.insertFirst(chunk);
@@ -66,9 +66,9 @@ TEST(TextChunkList, add2)
TextChunkList list;
SDLTextChunk *chunk1 = new SDLTextChunk("test",
- gcn::Color(1, 2, 3), gcn::Color(3, 4, 5));
+ Color(1, 2, 3), Color(3, 4, 5));
SDLTextChunk *chunk2 = new SDLTextChunk("test",
- gcn::Color(2, 3, 4), gcn::Color(4, 5, 6));
+ Color(2, 3, 4), Color(4, 5, 6));
list.insertFirst(chunk2);
list.insertFirst(chunk1);
@@ -96,7 +96,7 @@ TEST(TextChunkList, addRemoveBack1)
TextChunkList list;
SDLTextChunk *chunk = new SDLTextChunk("test",
- gcn::Color(1, 2, 3), gcn::Color(1, 2, 3));
+ Color(1, 2, 3), Color(1, 2, 3));
list.insertFirst(chunk);
list.removeBack();
@@ -113,9 +113,9 @@ TEST(TextChunkList, addRemoveBack2)
TextChunkList list;
SDLTextChunk *chunk1 = new SDLTextChunk("test",
- gcn::Color(1, 2, 3), gcn::Color(1, 2, 3));
+ Color(1, 2, 3), Color(1, 2, 3));
SDLTextChunk *chunk2 = new SDLTextChunk("test2",
- gcn::Color(1, 2, 4), gcn::Color(1, 2, 5));
+ Color(1, 2, 4), Color(1, 2, 5));
list.insertFirst(chunk2);
list.insertFirst(chunk1);
@@ -140,9 +140,9 @@ TEST(TextChunkList, addRemoveBack3)
TextChunkList list;
SDLTextChunk *chunk1 = new SDLTextChunk("test",
- gcn::Color(1, 2, 3), gcn::Color(1, 2, 3));
+ Color(1, 2, 3), Color(1, 2, 3));
SDLTextChunk *chunk2 = new SDLTextChunk("test2",
- gcn::Color(2, 3, 4), gcn::Color(2, 3, 4));
+ Color(2, 3, 4), Color(2, 3, 4));
list.insertFirst(chunk2);
list.insertFirst(chunk1);
@@ -161,11 +161,11 @@ TEST(TextChunkList, addRemoveBack4)
TextChunkList list;
SDLTextChunk *chunk1 = new SDLTextChunk("test",
- gcn::Color(1, 2, 3), gcn::Color(1, 2, 3));
+ Color(1, 2, 3), Color(1, 2, 3));
SDLTextChunk *chunk2 = new SDLTextChunk("test2",
- gcn::Color(2, 3, 4), gcn::Color(2, 3, 4));
+ Color(2, 3, 4), Color(2, 3, 4));
SDLTextChunk *chunk3 = new SDLTextChunk("test",
- gcn::Color(3, 4, 5), gcn::Color(3, 4, 5));
+ Color(3, 4, 5), Color(3, 4, 5));
list.insertFirst(chunk3);
list.insertFirst(chunk2);
@@ -191,7 +191,7 @@ TEST(TextChunkList, moveToFirst1)
TextChunkList list;
SDLTextChunk *chunk = new SDLTextChunk("test",
- gcn::Color(1, 2, 3), gcn::Color(2, 3, 4));
+ Color(1, 2, 3), Color(2, 3, 4));
list.insertFirst(chunk);
list.moveToFirst(chunk);
@@ -208,9 +208,9 @@ TEST(TextChunkList, moveToFirst2)
TextChunkList list;
SDLTextChunk *chunk1 = new SDLTextChunk("test",
- gcn::Color(1, 2, 3), gcn::Color(1, 2, 3));
+ Color(1, 2, 3), Color(1, 2, 3));
SDLTextChunk *chunk2 = new SDLTextChunk("test",
- gcn::Color(2, 3, 4), gcn::Color(1, 2, 3));
+ Color(2, 3, 4), Color(1, 2, 3));
list.insertFirst(chunk1);
list.insertFirst(chunk2);
@@ -230,11 +230,11 @@ TEST(TextChunkList, moveToFirst3)
TextChunkList list;
SDLTextChunk *chunk1 = new SDLTextChunk("test",
- gcn::Color(1, 2, 3), gcn::Color(1, 2, 3));
+ Color(1, 2, 3), Color(1, 2, 3));
SDLTextChunk *chunk2 = new SDLTextChunk("test",
- gcn::Color(1, 2, 4), gcn::Color(1, 2, 3));
+ Color(1, 2, 4), Color(1, 2, 3));
SDLTextChunk *chunk3 = new SDLTextChunk("test",
- gcn::Color(1, 2, 5), gcn::Color(1, 2, 3));
+ Color(1, 2, 5), Color(1, 2, 3));
list.insertFirst(chunk3);
list.insertFirst(chunk1);
@@ -257,11 +257,11 @@ TEST(TextChunkList, moveToFirst4)
TextChunkList list;
SDLTextChunk *chunk1 = new SDLTextChunk("test",
- gcn::Color(), gcn::Color());
+ Color(), Color());
SDLTextChunk *chunk2 = new SDLTextChunk("test2",
- gcn::Color(), gcn::Color());
+ Color(), Color());
SDLTextChunk *chunk3 = new SDLTextChunk("test3",
- gcn::Color(), gcn::Color());
+ Color(), Color());
list.insertFirst(chunk1);
list.insertFirst(chunk3);
@@ -284,7 +284,7 @@ TEST(TextChunkList, clear1)
TextChunkList list;
int chunksLeft = sdlTextChunkCnt;
- SDLTextChunk *chunk = new SDLTextChunk("test", gcn::Color(), gcn::Color());
+ SDLTextChunk *chunk = new SDLTextChunk("test", Color(), Color());
list.insertFirst(chunk);
list.clear();
@@ -303,11 +303,11 @@ TEST(TextChunkList, clear2)
int chunksLeft = sdlTextChunkCnt;
SDLTextChunk *chunk1 = new SDLTextChunk("test",
- gcn::Color(1, 2, 3), gcn::Color(2, 0, 0));
+ Color(1, 2, 3), Color(2, 0, 0));
SDLTextChunk *chunk2 = new SDLTextChunk("test",
- gcn::Color(1, 2, 3), gcn::Color(2, 0, 1));
+ Color(1, 2, 3), Color(2, 0, 1));
SDLTextChunk *chunk3 = new SDLTextChunk("test",
- gcn::Color(1, 2, 3), gcn::Color(2, 0, 2));
+ Color(1, 2, 3), Color(2, 0, 2));
list.insertFirst(chunk1);
list.insertFirst(chunk2);
@@ -328,11 +328,11 @@ TEST(TextChunkList, clear3)
int chunksLeft = sdlTextChunkCnt;
SDLTextChunk *chunk1 = new SDLTextChunk("test",
- gcn::Color(1, 2, 3), gcn::Color(2, 0, 0));
+ Color(1, 2, 3), Color(2, 0, 0));
SDLTextChunk *chunk2 = new SDLTextChunk("test",
- gcn::Color(1, 2, 3), gcn::Color(2, 0, 1));
+ Color(1, 2, 3), Color(2, 0, 1));
SDLTextChunk *chunk3 = new SDLTextChunk("test",
- gcn::Color(1, 2, 3), gcn::Color(2, 0, 2));
+ Color(1, 2, 3), Color(2, 0, 2));
list.insertFirst(chunk1);
list.insertFirst(chunk2);
@@ -359,11 +359,11 @@ TEST(TextChunkList, clear4)
int chunksLeft = sdlTextChunkCnt;
SDLTextChunk *chunk1 = new SDLTextChunk("test",
- gcn::Color(1, 2, 3), gcn::Color(2, 0, 0));
+ Color(1, 2, 3), Color(2, 0, 0));
SDLTextChunk *chunk2 = new SDLTextChunk("test",
- gcn::Color(1, 2, 3), gcn::Color(2, 0, 1));
+ Color(1, 2, 3), Color(2, 0, 1));
SDLTextChunk *chunk3 = new SDLTextChunk("test3",
- gcn::Color(1, 2, 3), gcn::Color(2, 0, 2));
+ Color(1, 2, 3), Color(2, 0, 2));
list.insertFirst(chunk1);
list.insertFirst(chunk2);
@@ -387,11 +387,11 @@ TEST(TextChunkList, clear4)
TEST(TextChunkList, sort1)
{
SDLTextChunkSmall item1("test line1",
- gcn::Color(1, 2, 3), gcn::Color(1, 2, 3));
+ Color(1, 2, 3), Color(1, 2, 3));
SDLTextChunkSmall item2("test line1",
- gcn::Color(1, 2, 3), gcn::Color(1, 2, 3));
+ Color(1, 2, 3), Color(1, 2, 3));
SDLTextChunkSmall item3("test line2",
- gcn::Color(1, 2, 3), gcn::Color(1, 2, 3));
+ Color(1, 2, 3), Color(1, 2, 3));
EXPECT_EQ(false, item1 < item2);
EXPECT_EQ(false, item2 < item1);
EXPECT_EQ(true, item1 < item3);
@@ -401,9 +401,9 @@ TEST(TextChunkList, sort1)
TEST(TextChunkList, sort2)
{
SDLTextChunkSmall item1("test line1",
- gcn::Color(1, 2, 3), gcn::Color(1, 2, 3));
+ Color(1, 2, 3), Color(1, 2, 3));
SDLTextChunkSmall item2("test line1",
- gcn::Color(2, 3, 4), gcn::Color(1, 2, 3));
+ Color(2, 3, 4), Color(1, 2, 3));
EXPECT_EQ(true, item1 < item2);
EXPECT_EQ(false, item2 < item1);
}
@@ -411,9 +411,9 @@ TEST(TextChunkList, sort2)
TEST(TextChunkList, sort3)
{
SDLTextChunkSmall item1("test line1",
- gcn::Color(1, 2, 3), gcn::Color(1, 2, 3));
+ Color(1, 2, 3), Color(1, 2, 3));
SDLTextChunkSmall item2("test line1",
- gcn::Color(1, 3, 4), gcn::Color(1, 2, 3));
+ Color(1, 3, 4), Color(1, 2, 3));
EXPECT_EQ(true, item1 < item2);
EXPECT_EQ(false, item2 < item1);
}
@@ -421,9 +421,9 @@ TEST(TextChunkList, sort3)
TEST(TextChunkList, sort4)
{
SDLTextChunkSmall item1("test line1",
- gcn::Color(1, 2, 3), gcn::Color(1, 2, 3));
+ Color(1, 2, 3), Color(1, 2, 3));
SDLTextChunkSmall item2("test line1",
- gcn::Color(1, 2, 4), gcn::Color(1, 2, 3));
+ Color(1, 2, 4), Color(1, 2, 3));
EXPECT_EQ(true, item1 < item2);
EXPECT_EQ(false, item2 < item1);
}
@@ -431,9 +431,9 @@ TEST(TextChunkList, sort4)
TEST(TextChunkList, sort5)
{
SDLTextChunkSmall item1("test line1",
- gcn::Color(1, 2, 3), gcn::Color(1, 2, 3));
+ Color(1, 2, 3), Color(1, 2, 3));
SDLTextChunkSmall item2("test line1",
- gcn::Color(1, 2, 3), gcn::Color(2, 2, 3));
+ Color(1, 2, 3), Color(2, 2, 3));
EXPECT_EQ(true, item1 < item2);
EXPECT_EQ(false, item2 < item1);
}
@@ -441,9 +441,9 @@ TEST(TextChunkList, sort5)
TEST(TextChunkList, sort6)
{
SDLTextChunkSmall item1("test line1",
- gcn::Color(1, 2, 3), gcn::Color(1, 2, 3));
+ Color(1, 2, 3), Color(1, 2, 3));
SDLTextChunkSmall item2("test line1",
- gcn::Color(1, 2, 3), gcn::Color(1, 3, 3));
+ Color(1, 2, 3), Color(1, 3, 3));
EXPECT_EQ(true, item1 < item2);
EXPECT_EQ(false, item2 < item1);
}
@@ -451,9 +451,9 @@ TEST(TextChunkList, sort6)
TEST(TextChunkList, sort7)
{
SDLTextChunkSmall item1("test line1",
- gcn::Color(1, 2, 3), gcn::Color(1, 2, 3));
+ Color(1, 2, 3), Color(1, 2, 3));
SDLTextChunkSmall item2("test line1",
- gcn::Color(1, 2, 3), gcn::Color(1, 2, 4));
+ Color(1, 2, 3), Color(1, 2, 4));
EXPECT_EQ(true, item1 < item2);
EXPECT_EQ(false, item2 < item1);
}
diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp
index 193a35dfe..ffb90a883 100644
--- a/src/gui/sdlinput.cpp
+++ b/src/gui/sdlinput.cpp
@@ -75,12 +75,12 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "gui/sdlinput.h"
-
#include "sdlshared.h"
#include "input/inputmanager.h"
+#include "gui/sdlinput.h"
+
#include "render/graphics.h"
#ifdef USE_SDL2
@@ -90,8 +90,6 @@
#include <SDL_keyboard.h>
#include <SDL_timer.h>
-#include <guichan/exception.hpp>
-
SDLInput::SDLInput() :
mKeyInputQueue(),
mMouseInputQueue(),
@@ -100,7 +98,7 @@ SDLInput::SDLInput() :
{
}
-bool SDLInput::isKeyQueueEmpty()
+bool SDLInput::isKeyQueueEmpty() const
{
return mKeyInputQueue.empty();
}
@@ -108,9 +106,7 @@ bool SDLInput::isKeyQueueEmpty()
KeyInput SDLInput::dequeueKeyInput2()
{
if (mKeyInputQueue.empty())
- {
- throw GCN_EXCEPTION("The queue is empty.");
- }
+ return KeyInput();
KeyInput keyInput = mKeyInputQueue.front();
mKeyInputQueue.pop();
@@ -118,17 +114,17 @@ KeyInput SDLInput::dequeueKeyInput2()
return keyInput;
}
-bool SDLInput::isMouseQueueEmpty()
+bool SDLInput::isMouseQueueEmpty() const
{
return mMouseInputQueue.empty();
}
-gcn::MouseInput SDLInput::dequeueMouseInput()
+MouseInput SDLInput::dequeueMouseInput()
{
- gcn::MouseInput mouseInput;
+ MouseInput mouseInput;
if (mMouseInputQueue.empty())
- throw GCN_EXCEPTION("The queue is empty.");
+ return MouseInput();
mouseInput = mMouseInputQueue.front();
mMouseInputQueue.pop();
@@ -141,7 +137,7 @@ MouseInput SDLInput::dequeueMouseInput2()
MouseInput mouseInput;
if (mMouseInputQueue.empty())
- throw GCN_EXCEPTION("The queue is empty.");
+ return MouseInput();
mouseInput = mMouseInputQueue.front();
mMouseInputQueue.pop();
@@ -158,7 +154,7 @@ void SDLInput::pushInput(const SDL_Event &event)
{
case SDL_KEYDOWN:
{
- keyInput.setType(gcn::KeyInput::PRESSED);
+ keyInput.setType(KeyInput::PRESSED);
convertKeyEventToKey(event, keyInput);
mKeyInputQueue.push(keyInput);
break;
@@ -166,7 +162,7 @@ void SDLInput::pushInput(const SDL_Event &event)
case SDL_KEYUP:
{
- keyInput.setType(gcn::KeyInput::RELEASED);
+ keyInput.setType(KeyInput::RELEASED);
convertKeyEventToKey(event, keyInput);
mKeyInputQueue.push(keyInput);
break;
@@ -174,8 +170,8 @@ void SDLInput::pushInput(const SDL_Event &event)
#ifdef USE_SDL2
case SDL_TEXTINPUT:
- keyInput.setType(gcn::KeyInput::PRESSED);
- keyInput.setKey(gcn::Key(Key::TEXTINPUT));
+ keyInput.setType(KeyInput::PRESSED);
+ keyInput.setKey(Key(Key::TEXTINPUT));
keyInput.setText(event.text.text);
mKeyInputQueue.push(keyInput);
break;
@@ -193,9 +189,9 @@ void SDLInput::pushInput(const SDL_Event &event)
#endif
mouseInput.setButton(-1);
if (y > 0)
- mouseInput.setType(gcn::MouseInput::WHEEL_MOVED_UP);
+ mouseInput.setType(MouseInput::WHEEL_MOVED_UP);
else
- mouseInput.setType(gcn::MouseInput::WHEEL_MOVED_DOWN);
+ mouseInput.setType(MouseInput::WHEEL_MOVED_DOWN);
mouseInput.setTimeStamp(SDL_GetTicks());
mMouseInputQueue.push(mouseInput);
}
@@ -231,12 +227,12 @@ void SDLInput::pushInput(const SDL_Event &event)
#ifndef USE_SDL2
if (event.button.button == SDL_BUTTON_WHEELDOWN)
- mouseInput.setType(gcn::MouseInput::WHEEL_MOVED_DOWN);
+ mouseInput.setType(MouseInput::WHEEL_MOVED_DOWN);
else if (event.button.button == SDL_BUTTON_WHEELUP)
- mouseInput.setType(gcn::MouseInput::WHEEL_MOVED_UP);
+ mouseInput.setType(MouseInput::WHEEL_MOVED_UP);
else
#endif
- mouseInput.setType(gcn::MouseInput::PRESSED);
+ mouseInput.setType(MouseInput::PRESSED);
mouseInput.setTimeStamp(SDL_GetTicks());
mMouseInputQueue.push(mouseInput);
break;
@@ -258,7 +254,7 @@ void SDLInput::pushInput(const SDL_Event &event)
#endif
#endif
mouseInput.setButton(convertMouseButton(event.button.button));
- mouseInput.setType(gcn::MouseInput::RELEASED);
+ mouseInput.setType(MouseInput::RELEASED);
mouseInput.setTimeStamp(SDL_GetTicks());
mMouseInputQueue.push(mouseInput);
break;
@@ -278,8 +274,8 @@ void SDLInput::pushInput(const SDL_Event &event)
event.motion.realy / scale);
#endif
#endif
- mouseInput.setButton(gcn::MouseInput::EMPTY);
- mouseInput.setType(gcn::MouseInput::MOVED);
+ mouseInput.setButton(MouseInput::EMPTY);
+ mouseInput.setType(MouseInput::MOVED);
mouseInput.setTimeStamp(SDL_GetTicks());
mMouseInputQueue.push(mouseInput);
break;
@@ -299,8 +295,8 @@ void SDLInput::pushInput(const SDL_Event &event)
{
mouseInput.setX(-1);
mouseInput.setY(-1);
- mouseInput.setButton(gcn::MouseInput::EMPTY);
- mouseInput.setType(gcn::MouseInput::MOVED);
+ mouseInput.setButton(MouseInput::EMPTY);
+ mouseInput.setType(MouseInput::MOVED);
mMouseInputQueue.push(mouseInput);
}
}
@@ -319,7 +315,7 @@ void SDLInput::pushInput(const SDL_Event &event)
void SDLInput::convertKeyEventToKey(const SDL_Event &event, KeyInput &keyInput)
{
- keyInput.setKey(gcn::Key(convertKeyCharacter(event)));
+ keyInput.setKey(Key(convertKeyCharacter(event)));
keyInput.setShiftPressed(event.key.keysym.mod & KMOD_SHIFT);
keyInput.setControlPressed(event.key.keysym.mod & KMOD_CTRL);
keyInput.setAltPressed(event.key.keysym.mod & KMOD_ALT);
@@ -342,11 +338,11 @@ int SDLInput::convertMouseButton(const int button)
switch (button)
{
case SDL_BUTTON_LEFT:
- return gcn::MouseInput::LEFT;
+ return MouseInput::LEFT;
case SDL_BUTTON_RIGHT:
- return gcn::MouseInput::RIGHT;
+ return MouseInput::RIGHT;
case SDL_BUTTON_MIDDLE:
- return gcn::MouseInput::MIDDLE;
+ return MouseInput::MIDDLE;
default:
// We have an unknown mouse type which is ignored.
return button;
@@ -573,10 +569,10 @@ void SDLInput::simulateMouseClick(const int x, const int y,
mouseInput.setY(y);
mouseInput.setReal(x, y);
mouseInput.setButton(button);
- mouseInput.setType(gcn::MouseInput::PRESSED);
+ mouseInput.setType(MouseInput::PRESSED);
mouseInput.setTimeStamp(SDL_GetTicks());
mMouseInputQueue.push(mouseInput);
- mouseInput.setType(gcn::MouseInput::RELEASED);
+ mouseInput.setType(MouseInput::RELEASED);
mouseInput.setTimeStamp(SDL_GetTicks());
mMouseInputQueue.push(mouseInput);
}
diff --git a/src/gui/sdlinput.h b/src/gui/sdlinput.h
index b07a57a00..8197aa110 100644
--- a/src/gui/sdlinput.h
+++ b/src/gui/sdlinput.h
@@ -80,75 +80,16 @@
#include "input/keyinput.h"
-#include "mouseinput.h"
-
#include <SDL_events.h>
-#include <guichan/input.hpp>
-#include <guichan/keyinput.hpp>
-#include <guichan/mouseinput.hpp>
+#include "input/mouseinput.h"
#include <queue>
-namespace Key
-{
- enum
- {
- SPACE = ' ',
- TAB = '\t',
- ENTER = '\n',
- // Negative values, to avoid conflicts with higher character codes.
- LEFT_ALT = -1000,
- RIGHT_ALT,
- LEFT_SHIFT,
- RIGHT_SHIFT,
- LEFT_CONTROL,
- RIGHT_CONTROL,
- LEFT_META,
- RIGHT_META,
- LEFT_SUPER,
- RIGHT_SUPER,
- INSERT,
- HOME,
- PAGE_UP,
- DELETE_,
- END,
- PAGE_DOWN,
- ESCAPE,
- CAPS_LOCK,
- BACKSPACE,
- F1,
- F2,
- F3,
- F4,
- F5,
- F6,
- F7,
- F8,
- F9,
- F10,
- F11,
- F12,
- F13,
- F14,
- F15,
- PRINT_SCREEN,
- SCROLL_LOCK,
- PAUSE,
- NUM_LOCK,
- ALT_GR,
- LEFT,
- RIGHT,
- UP,
- DOWN,
- TEXTINPUT
- };
-} // namespace Key
-
/**
- * SDL implementation of Input.
+ * SDL implementation of SDLInput.
*/
-class SDLInput final : public gcn::Input
+class SDLInput final
{
public:
/**
@@ -166,26 +107,18 @@ public:
*/
void pushInput(const SDL_Event &event);
- /**
- * Polls all input. It exists for input driver compatibility. If you
- * only use SDL and plan sticking with SDL you can safely ignore this
- * function as it in the SDL case does nothing.
- */
- void _pollInput() override final
- { }
-
KeyInput dequeueKeyInput2() A_WARN_UNUSED;
- gcn::KeyInput dequeueKeyInput() override final A_WARN_UNUSED
- { return gcn::KeyInput(); }
+ KeyInput dequeueKeyInput() A_WARN_UNUSED
+ { return KeyInput(); }
- // Inherited from Input
+ // Inherited from SDLInput
- bool isKeyQueueEmpty() override final A_WARN_UNUSED;
+ bool isKeyQueueEmpty() const A_WARN_UNUSED;
- bool isMouseQueueEmpty() override final A_WARN_UNUSED;
+ bool isMouseQueueEmpty() const A_WARN_UNUSED;
- gcn::MouseInput dequeueMouseInput() override final A_WARN_UNUSED;
+ MouseInput dequeueMouseInput() A_WARN_UNUSED;
MouseInput dequeueMouseInput2() A_WARN_UNUSED;
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 4218aff7c..1a504f680 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -259,7 +259,7 @@ void Theme::deleteInstance()
mInstance = nullptr;
}
-gcn::Color Theme::getProgressColor(const int type, const float progress)
+Color Theme::getProgressColor(const int type, const float progress)
{
int color[3] = {0, 0, 0};
@@ -273,7 +273,7 @@ gcn::Color Theme::getProgressColor(const int type, const float progress)
logger->log("color not found: " + toString(type));
}
- return gcn::Color(color[0], color[1], color[2]);
+ return Color(color[0], color[1], color[2]);
}
Skin *Theme::load(const std::string &filename, const std::string &filename2,
@@ -972,7 +972,7 @@ static int readColorType(const std::string &type)
return -1;
}
-static gcn::Color readColor(const std::string &description)
+static Color readColor(const std::string &description)
{
const int size = static_cast<const int>(description.length());
if (size < 7 || description[0] != '#')
@@ -982,7 +982,7 @@ static gcn::Color readColor(const std::string &description)
return Palette::BLACK;
}
- int v = 0;
+ unsigned int v = 0;
for (int i = 1; i < 7; ++i)
{
signed const char c = description[i];
@@ -1010,7 +1010,7 @@ static gcn::Color readColor(const std::string &description)
v = (v << 4) | n;
}
- return gcn::Color(v);
+ return Color(v);
}
static Palette::GradientType readColorGradient(const std::string &grad)
@@ -1084,7 +1084,7 @@ void Theme::loadColors(std::string file)
int type;
std::string temp;
- gcn::Color color;
+ Color color;
GradientType grad;
for_each_xml_child_node(paletteNode, root)
diff --git a/src/gui/theme.h b/src/gui/theme.h
index b40be2881..86543ea64 100644
--- a/src/gui/theme.h
+++ b/src/gui/theme.h
@@ -25,7 +25,7 @@
#ifndef GUI_THEME_H
#define GUI_THEME_H
-#include "configlistener.h"
+#include "listeners/configlistener.h"
#include "render/graphics.h"
@@ -450,21 +450,21 @@ class Theme final : public Palette, public ConfigListener
*
* @return the requested color
*/
- inline static const gcn::Color &getThemeColor(const int type,
- const int alpha = 255)
- A_WARN_UNUSED
+ inline static const Color &getThemeColor(const int type,
+ const int alpha = 255)
+ A_WARN_UNUSED
{ return mInstance->getColor(type, alpha); }
- static const gcn::Color &getThemeCharColor(const signed char c,
- bool &valid) A_WARN_UNUSED
+ static const Color &getThemeCharColor(const signed char c,
+ bool &valid) A_WARN_UNUSED
{ return mInstance->getCharColor(c, valid); }
static int getThemeIdByChar(const signed char c,
bool &valid) A_WARN_UNUSED
{ return mInstance->getIdByChar(c, valid); }
- static gcn::Color getProgressColor(const int type,
- const float progress) A_WARN_UNUSED;
+ static Color getProgressColor(const int type,
+ const float progress) A_WARN_UNUSED;
/**
* Loads a skin.
diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp
index 69125f8e2..74d47203f 100644
--- a/src/gui/userpalette.cpp
+++ b/src/gui/userpalette.cpp
@@ -237,7 +237,7 @@ UserPalette::~UserPalette()
void UserPalette::setColor(const int type, const int r,
const int g, const int b)
{
- gcn::Color &color = mColors[type].color;
+ Color &color = mColors[type].color;
color.r = r;
color.g = g;
color.b = b;
@@ -296,14 +296,14 @@ void UserPalette::rollback()
if (i->grad != i->committedGrad)
setGradient(i->type, i->committedGrad);
- const gcn::Color &committedColor = i->committedColor;
+ const Color &committedColor = i->committedColor;
setGradientDelay(i->type, i->committedDelay);
setColor(i->type, committedColor.r,
committedColor.g, committedColor.b);
if (i->grad == PULSE)
{
- gcn::Color &testColor = i->testColor;
+ Color &testColor = i->testColor;
testColor.r = committedColor.r;
testColor.g = committedColor.g;
testColor.b = committedColor.b;
@@ -342,7 +342,7 @@ void UserPalette::addColor(const unsigned type, const unsigned rgb,
rgbValue = atox(rgbString);
else
rgbValue = atoi(rgbString.c_str());
- const gcn::Color &trueCol = gcn::Color(rgbValue);
+ const Color &trueCol = Color(rgbValue);
grad = static_cast<GradientType>(config.getValue(configName + "Gradient",
static_cast<int>(grad)));
delay = config.getValueInt(configName + "Delay", delay);
diff --git a/src/gui/userpalette.h b/src/gui/userpalette.h
index 18fe1cbe2..7bab5bed9 100644
--- a/src/gui/userpalette.h
+++ b/src/gui/userpalette.h
@@ -26,12 +26,12 @@
#include "gui/palette.h"
-#include <guichan/listmodel.hpp>
+#include "gui/models/listmodel.h"
/**
* Class controlling the game's color palette.
*/
-class UserPalette final : public Palette, public gcn::ListModel
+class UserPalette final : public Palette, public ListModel
{
public:
/** List of all colors that are configurable. */
@@ -100,8 +100,8 @@ class UserPalette final : public Palette, public gcn::ListModel
*
* @return the requested committed color
*/
- inline const gcn::Color &getCommittedColor(const int type)
- const A_WARN_UNUSED
+ inline const Color &getCommittedColor(const int type)
+ const A_WARN_UNUSED
{
return mColors[type].committedColor;
}
@@ -113,8 +113,7 @@ class UserPalette final : public Palette, public gcn::ListModel
*
* @return the requested test color
*/
- inline const gcn::Color &getTestColor(const int type)
- const A_WARN_UNUSED
+ inline const Color &getTestColor(const int type) const A_WARN_UNUSED
{ return mColors[type].testColor; }
/**
@@ -123,7 +122,7 @@ class UserPalette final : public Palette, public gcn::ListModel
* @param type the color type requested
* @param color the color that should be tested
*/
- inline void setTestColor(const int type, const gcn::Color &color)
+ inline void setTestColor(const int type, const Color &color)
{ mColors[type].testColor = color; }
/**
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 341af1f0b..96760f8c7 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -42,7 +42,7 @@
#include "gui/windows/ministatuswindow.h"
-#include <guichan/font.hpp>
+#include "gui/font.h"
#include "debug.h"
@@ -51,7 +51,7 @@ extern MiniStatusWindow *miniStatusWindow;
Viewport::Viewport() :
WindowContainer(nullptr),
- gcn::MouseListener(),
+ MouseListener(),
mMap(nullptr),
mScrollRadius(config.getIntValue("ScrollRadius")),
mScrollLaziness(config.getIntValue("ScrollLaziness")),
@@ -114,22 +114,20 @@ void Viewport::setMap(Map *const map)
mMap = map;
}
-void Viewport::draw(gcn::Graphics *gcnGraphics)
+void Viewport::draw(Graphics *graphics)
{
BLOCK_START("Viewport::draw 1")
static int lastTick = tick_time;
if (!mMap || !player_node)
{
- gcnGraphics->setColor(gcn::Color(64, 64, 64));
- gcnGraphics->fillRectangle(
- gcn::Rectangle(0, 0, getWidth(), getHeight()));
+ graphics->setColor(Color(64, 64, 64));
+ graphics->fillRectangle(
+ Rect(0, 0, getWidth(), getHeight()));
BLOCK_END("Viewport::draw 1")
return;
}
- Graphics *const graphics = static_cast<Graphics* const>(gcnGraphics);
-
// Avoid freaking out when tick_time overflows
if (tick_time < lastTick)
lastTick = tick_time;
@@ -260,7 +258,7 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
miniStatusWindow->drawIcons(graphics);
// Draw contained widgets
- WindowContainer::draw(gcnGraphics);
+ WindowContainer::draw(graphics);
BLOCK_END("Viewport::draw 1")
}
@@ -282,13 +280,13 @@ void Viewport::_followMouse()
if (mPlayerFollowMouse && (button & SDL_BUTTON(1)))
{
// We create a mouse event and send it to mouseDragged.
- gcn::MouseEvent mouseEvent(nullptr,
+ MouseEvent mouseEvent(nullptr,
0,
false,
false,
false,
- gcn::MouseEvent::DRAGGED,
- gcn::MouseEvent::LEFT,
+ MouseEvent::DRAGGED,
+ MouseEvent::LEFT,
mMouseX,
mMouseY,
0);
@@ -340,54 +338,29 @@ void Viewport::_drawDebugPath(Graphics *const graphics)
}
void Viewport::_drawPath(Graphics *const graphics, const Path &path,
- const gcn::Color &color) const
+ const Color &color) const
{
graphics->setColor(color);
- gcn::Font *const font = getFont();
+ Font *const font = getFont();
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() != ServerInfo::MANASERV)
-#endif
+ int cnt = 1;
+ FOR_EACH (Path::const_iterator, i, path)
{
- int cnt = 1;
- FOR_EACH (Path::const_iterator, i, path)
- {
- const int squareX = i->x * mapTileSize - mPixelViewX + 12;
- const int squareY = i->y * mapTileSize - mPixelViewY + 12;
+ const int squareX = i->x * mapTileSize - mPixelViewX + 12;
+ const int squareY = i->y * mapTileSize - mPixelViewY + 12;
- graphics->fillRectangle(gcn::Rectangle(squareX, squareY, 8, 8));
- if (mMap)
- {
- const std::string str = toString(cnt);
- font->drawString(graphics, str, squareX + 4
- - font->getWidth(str) / 2, squareY + 12);
- }
- cnt ++;
- }
- }
-#ifdef MANASERV_SUPPORT
- else if (Net::getNetworkType() == ServerInfo::MANASERV)
- {
- FOR_EACH (Path::const_iterator, i, path)
+ graphics->fillRectangle(Rect(squareX, squareY, 8, 8));
+ if (mMap)
{
- const int squareX = i->x - mPixelViewX;
- const int squareY = i->y - mPixelViewY;
-
- graphics->fillRectangle(gcn::Rectangle(squareX - 4, squareY - 4,
- 8, 8));
- if (mMap)
- {
- const std::string str = toString(mMap->getMetaTile(
- i->x / mapTileSize, i->y / mapTileSize)->Gcost);
- font->drawString(graphics, str,
- squareX + 4 - font->getWidth(text) / 2, squareY + 12);
- }
+ const std::string str = toString(cnt);
+ font->drawString(graphics, str, squareX + 4
+ - font->getWidth(str) / 2, squareY + 12);
}
+ cnt ++;
}
-#endif
}
-void Viewport::mousePressed(gcn::MouseEvent &event)
+void Viewport::mousePressed(MouseEvent &event)
{
if (event.getSource() != this)
return;
@@ -408,7 +381,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
const int pixelY = eventY + mPixelViewY;
// Right click might open a popup
- if (eventButton == gcn::MouseEvent::RIGHT)
+ if (eventButton == MouseEvent::RIGHT)
{
mPlayerFollowMouse = false;
if (mHoverBeing)
@@ -462,7 +435,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
}
// Left click can cause different actions
- if (eventButton == gcn::MouseEvent::LEFT)
+ if (eventButton == MouseEvent::LEFT)
{
// Interact with some being
if (mHoverBeing)
@@ -534,7 +507,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
_followMouse();
}
}
- else if (eventButton == gcn::MouseEvent::MIDDLE)
+ else if (eventButton == MouseEvent::MIDDLE)
{
mPlayerFollowMouse = false;
validateSpeed();
@@ -550,7 +523,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
}
}
-void Viewport::mouseDragged(gcn::MouseEvent &event)
+void Viewport::mouseDragged(MouseEvent &event)
{
if (!mMap || !player_node)
return;
@@ -559,127 +532,111 @@ void Viewport::mouseDragged(gcn::MouseEvent &event)
Input::KEY_STOP_ATTACK) && !inputManager.isActionActive(
Input::KEY_UNTARGET))
{
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() == ServerInfo::MANASERV)
+ if (mLocalWalkTime != player_node->getActionTime())
{
- if (get_elapsed_time(mLocalWalkTime) >= walkingMouseDelay)
+ mLocalWalkTime = cur_time;
+ player_node->unSetPickUpTarget();
+ int playerX = player_node->getTileX();
+ int playerY = player_node->getTileY();
+ if (mMouseDirectionMove)
{
- mLocalWalkTime = tick_time;
- player_node->unSetPickUpTarget();
- player_node->setDestination(event.getX() + mPixelViewX,
- event.getY() + mPixelViewY);
- player_node->pathSetByMouse();
- }
- }
- else
-#endif
- {
- if (mLocalWalkTime != player_node->getActionTime())
- {
- mLocalWalkTime = cur_time;
- player_node->unSetPickUpTarget();
- int playerX = player_node->getTileX();
- int playerY = player_node->getTileY();
- if (mMouseDirectionMove)
+ const int width = mainGraphics->mWidth / 2;
+ const int height = mainGraphics->mHeight / 2;
+ const float wh = static_cast<float>(width)
+ / static_cast<float>(height);
+ int x = event.getX() - width;
+ int y = event.getY() - height;
+ if (!x && !y)
+ return;
+ const int x2 = abs(x);
+ const int y2 = abs(y);
+ const float diff = 2;
+ int dx = 0;
+ int dy = 0;
+ if (x2 > y2)
{
- const int width = mainGraphics->mWidth / 2;
- const int height = mainGraphics->mHeight / 2;
- const float wh = static_cast<float>(width)
- / static_cast<float>(height);
- int x = event.getX() - width;
- int y = event.getY() - height;
- if (!x && !y)
- return;
- const int x2 = abs(x);
- const int y2 = abs(y);
- const float diff = 2;
- int dx = 0;
- int dy = 0;
- if (x2 > y2)
- {
- if (y2 && x2 / y2 / wh > diff)
- y = 0;
- }
- else
- {
- if (x2 && y2 * wh / x2 > diff)
- x = 0;
- }
- if (x > 0)
- dx = 1;
- else if (x < 0)
- dx = -1;
- if (y > 0)
- dy = 1;
- else if (y < 0)
- dy = -1;
-
- if (mMap->getWalk(playerX + dx, playerY + dy))
+ if (y2 && x2 / y2 / wh > diff)
+ y = 0;
+ }
+ else
+ {
+ if (x2 && y2 * wh / x2 > diff)
+ x = 0;
+ }
+ if (x > 0)
+ dx = 1;
+ else if (x < 0)
+ dx = -1;
+ if (y > 0)
+ dy = 1;
+ else if (y < 0)
+ dy = -1;
+
+ if (mMap->getWalk(playerX + dx, playerY + dy))
+ {
+ player_node->navigateTo(playerX + dx, playerY + dy);
+ }
+ else
+ {
+ if (dx && dy)
{
- player_node->navigateTo(playerX + dx, playerY + dy);
+ // try avoid diagonal collision
+ if (x2 > y2)
+ {
+ if (mMap->getWalk(playerX + dx, playerY))
+ dy = 0;
+ else
+ dx = 0;
+ }
+ else
+ {
+ if (mMap->getWalk(playerX, playerY + dy))
+ dx = 0;
+ else
+ dy = 0;
+ }
}
else
{
- if (dx && dy)
+ // try avoid vertical or horisontal collision
+ if (!dx)
{
- // try avoid diagonal collision
- if (x2 > y2)
- {
- if (mMap->getWalk(playerX + dx, playerY))
- dy = 0;
- else
- dx = 0;
- }
- else
- {
- if (mMap->getWalk(playerX, playerY + dy))
- dx = 0;
- else
- dy = 0;
- }
+ if (mMap->getWalk(playerX + 1, playerY + dy))
+ dx = 1;
+ if (mMap->getWalk(playerX - 1, playerY + dy))
+ dx = -1;
}
- else
+ if (!dy)
{
- // try avoid vertical or horisontal collision
- if (!dx)
- {
- if (mMap->getWalk(playerX + 1, playerY + dy))
- dx = 1;
- if (mMap->getWalk(playerX - 1, playerY + dy))
- dx = -1;
- }
- if (!dy)
- {
- if (mMap->getWalk(playerX + dx, playerY + 1))
- dy = 1;
- if (mMap->getWalk(playerX + dx, playerY - 1))
- dy = -1;
- }
+ if (mMap->getWalk(playerX + dx, playerY + 1))
+ dy = 1;
+ if (mMap->getWalk(playerX + dx, playerY - 1))
+ dy = -1;
}
- player_node->navigateTo(playerX + dx, playerY + dy);
}
+ player_node->navigateTo(playerX + dx, playerY + dy);
}
- else
+ }
+ else
+ {
+ const int destX = (event.getX() + mPixelViewX)
+ / static_cast<float>(mMap->getTileWidth());
+ const int destY = (event.getY() + mPixelViewY)
+ / static_cast<float>(mMap->getTileHeight());
+ if (playerX != destX || playerY != destY)
{
- const int destX = (event.getX() + mPixelViewX)
- / static_cast<float>(mMap->getTileWidth());
- const int destY = (event.getY() + mPixelViewY)
- / static_cast<float>(mMap->getTileHeight());
- if (playerX != destX || playerY != destY)
+ if (!player_node->navigateTo(destX, destY))
{
- if (!player_node->navigateTo(destX, destY))
- {
- if (playerX > destX)
- playerX --;
- else if (playerX < destX)
- playerX ++;
- if (playerY > destY)
- playerY --;
- else if (playerY < destY)
- playerY ++;
- if (mMap->getWalk(playerX, playerY, 0))
- player_node->navigateTo(playerX, playerY);
- }
+ if (playerX > destX)
+ playerX --;
+ else if (playerX < destX)
+ playerX ++;
+ if (playerY > destY)
+ playerY --;
+ else if (playerY < destY)
+ playerY ++;
+ if (mMap->getWalk(playerX, playerY, 0))
+ player_node->navigateTo(playerX, playerY);
}
}
}
@@ -687,10 +644,9 @@ void Viewport::mouseDragged(gcn::MouseEvent &event)
}
}
-void Viewport::mouseReleased(gcn::MouseEvent &event A_UNUSED)
+void Viewport::mouseReleased(MouseEvent &event A_UNUSED)
{
mPlayerFollowMouse = false;
- // Only useful for eAthena but doesn't hurt under ManaServ
mLocalWalkTime = -1;
}
@@ -840,7 +796,7 @@ void Viewport::optionChanged(const std::string &name)
mMouseDirectionMove = config.getBoolValue("mouseDirectionMove");
}
-void Viewport::mouseMoved(gcn::MouseEvent &event A_UNUSED)
+void Viewport::mouseMoved(MouseEvent &event A_UNUSED)
{
// Check if we are on the map
if (!mMap || !player_node || !actorManager)
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index dcddc003c..16d0e4e34 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -23,12 +23,13 @@
#ifndef GUI_VIEWPORT_H
#define GUI_VIEWPORT_H
-#include "configlistener.h"
#include "position.h"
+#include "listeners/configlistener.h"
+
#include "gui/widgets/windowcontainer.h"
-#include <guichan/mouselistener.hpp>
+#include "listeners/mouselistener.h"
class ActorSprite;
class Button;
@@ -59,7 +60,7 @@ const int walkingMouseDelay = 500;
* coordinates.
*/
class Viewport final : public WindowContainer,
- public gcn::MouseListener,
+ public MouseListener,
public ConfigListener
{
public:
@@ -83,7 +84,7 @@ class Viewport final : public WindowContainer,
/**
* Draws the viewport.
*/
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
/**
* Implements player to keep following mouse.
@@ -102,22 +103,22 @@ class Viewport final : public WindowContainer,
/**
* Handles mouse press on map.
*/
- void mousePressed(gcn::MouseEvent &event) override final;
+ void mousePressed(MouseEvent &event) override final;
/**
* Handles mouse move on map
*/
- void mouseDragged(gcn::MouseEvent &event) override final;
+ void mouseDragged(MouseEvent &event) override final;
/**
* Handles mouse button release on map.
*/
- void mouseReleased(gcn::MouseEvent &event) override final;
+ void mouseReleased(MouseEvent &event) override final;
/**
* Handles mouse move on map.
*/
- void mouseMoved(gcn::MouseEvent &event) override final;
+ void mouseMoved(MouseEvent &event) override final;
/**
* Shows a popup for an item.
@@ -297,7 +298,7 @@ class Viewport final : public WindowContainer,
* Draws the given path.
*/
void _drawPath(Graphics *const graphics, const Path &path,
- const gcn::Color &color = gcn::Color(255, 0, 0)) const;
+ const Color &color = Color(255, 0, 0)) const;
/**
* Make the player go to the mouse position.
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index b676a7e94..01126f8ac 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -28,16 +28,16 @@
#include "being/localplayer.h"
+#include "gui/font.h"
#include "gui/gui.h"
-#include "gui/sdlfont.h"
#include "gui/viewport.h"
+#include "gui/models/avatarlistmodel.h"
+
#include "gui/windows/chatwindow.h"
#include "resources/image.h"
-#include <guichan/font.hpp>
-
#include "debug.h"
int AvatarListBox::instances = 0;
@@ -90,7 +90,7 @@ AvatarListBox::~AvatarListBox()
}
}
-void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
+void AvatarListBox::draw(Graphics *graphics)
{
BLOCK_START("AvatarListBox::draw")
if (!mListModel || !player_node)
@@ -102,12 +102,10 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
AvatarListModel *const model = static_cast<AvatarListModel *const>(
mListModel);
updateAlpha();
- Graphics *const graphics = static_cast<Graphics *const>(gcnGraphics);
-
- gcn::Font *const font = getFont();
+ Font *const font = getFont();
const int fontHeight = getFont()->getHeight();
- const gcn::Widget *const parent = mParent;
+ const Widget *const parent = mParent;
const std::string name = player_node->getName();
// Draw the list elements
@@ -137,7 +135,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
}
else
{
- graphics->drawImage2(icon, mImagePadding, y + mPadding);
+ graphics->drawImage(icon, mImagePadding, y + mPadding);
}
}
}
@@ -158,13 +156,13 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
}
if (parent && a->getMaxHp())
{
- gcn::Color color = Theme::getProgressColor(
+ Color color = Theme::getProgressColor(
Theme::PROG_HP, static_cast<float>(a->getHp())
/ static_cast<float>(a->getMaxHp()));
color.a = 80;
graphics->setColor(color);
- graphics->fillRectangle(gcn::Rectangle(mPadding, y + mPadding,
+ graphics->fillRectangle(Rect(mPadding, y + mPadding,
parent->getWidth() * a->getHp() / a->getMaxHp()
- 2 * mPadding, fontHeight));
}
@@ -184,12 +182,11 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
if (parent)
{
- gcn::Color color = Theme::getProgressColor(Theme::PROG_HP,
- 1);
+ Color color = Theme::getProgressColor(Theme::PROG_HP, 1);
color.a = 80;
graphics->setColor(color);
- graphics->fillRectangle(gcn::Rectangle(mPadding, y + mPadding,
+ graphics->fillRectangle(Rect(mPadding, y + mPadding,
parent->getWidth() * a->getDamageHp() / 1024
- 2 * mPadding, fontHeight));
@@ -312,7 +309,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
BLOCK_END("AvatarListBox::draw")
}
-void AvatarListBox::mousePressed(gcn::MouseEvent &event)
+void AvatarListBox::mousePressed(MouseEvent &event)
{
if (!actorManager || !player_node || !viewport
|| !getFont()->getHeight())
@@ -336,7 +333,7 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event)
return;
const unsigned int eventButton = event.getButton();
- if (eventButton == gcn::MouseEvent::LEFT)
+ if (eventButton == MouseEvent::LEFT)
{
if (ava->getType() == AVATAR_PLAYER)
{
@@ -350,7 +347,7 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event)
player_node->navigateTo(ava->getX(), ava->getY());
}
}
- else if (eventButton == gcn::MouseEvent::RIGHT)
+ else if (eventButton == MouseEvent::RIGHT)
{
switch (ava->getType())
{
@@ -409,7 +406,7 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event)
}
}
}
- else if (eventButton == gcn::MouseEvent::MIDDLE)
+ else if (eventButton == MouseEvent::MIDDLE)
{
if (ava->getType() == AVATAR_PLAYER && chatWindow)
{
@@ -421,7 +418,7 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event)
}
}
-void AvatarListBox::mouseReleased(gcn::MouseEvent &event A_UNUSED)
+void AvatarListBox::mouseReleased(MouseEvent &event A_UNUSED)
{
}
diff --git a/src/gui/widgets/avatarlistbox.h b/src/gui/widgets/avatarlistbox.h
index 99c1132b2..e0711a7b7 100644
--- a/src/gui/widgets/avatarlistbox.h
+++ b/src/gui/widgets/avatarlistbox.h
@@ -22,29 +22,21 @@
#ifndef GUI_WIDGETS_AVATARLISTBOX_H
#define GUI_WIDGETS_AVATARLISTBOX_H
-#include "avatar.h"
-
-#include "configlistener.h"
+#include "listeners/configlistener.h"
#include "gui/widgets/listbox.h"
#include <string>
+class AvatarListModel;
class Image;
-class AvatarListModel : public gcn::ListModel
-{
-public:
- virtual Avatar *getAvatarAt(const int i) A_WARN_UNUSED = 0;
-
- std::string getElementAt(int i) override final A_WARN_UNUSED
- { return getAvatarAt(i)->getName(); }
-};
-
-class AvatarListBox final : public ListBox, public ConfigListener
+class AvatarListBox final : public ListBox,
+ public ConfigListener
{
public:
- AvatarListBox(const Widget2 *const widget, AvatarListModel *const model);
+ AvatarListBox(const Widget2 *const widget,
+ AvatarListModel *const model);
A_DELETE_COPY(AvatarListBox)
@@ -53,11 +45,11 @@ public:
/**
* Draws the list box.
*/
- void draw(gcn::Graphics *gcnGraphics) override final;
+ void draw(Graphics *gcnGraphics) override final;
- void mousePressed(gcn::MouseEvent &event) override final;
+ void mousePressed(MouseEvent &event) override final;
- void mouseReleased(gcn::MouseEvent &event A_UNUSED) override final;
+ void mouseReleased(MouseEvent &event A_UNUSED) override final;
void optionChanged(const std::string &value) override final;
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index b91c095b7..100281d94 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -25,8 +25,8 @@
#include "input/inputmanager.h"
+#include "gui/font.h"
#include "gui/gui.h"
-#include "gui/sdlfont.h"
#include "gui/widgets/linkhandler.h"
@@ -37,9 +37,9 @@
#include "utils/stringutils.h"
#include "utils/timer.h"
-#include <guichan/graphics.hpp>
-#include <guichan/font.hpp>
-#include <guichan/cliprectangle.hpp>
+#include "gui/cliprect.h"
+
+#include "render/graphics.h"
#include <algorithm>
@@ -52,9 +52,8 @@ BrowserBox::BrowserBox(const Widget2 *const widget,
const unsigned int mode,
const bool opaque,
const std::string &skin) :
- gcn::Widget(),
- Widget2(widget),
- gcn::MouseListener(),
+ Widget(widget),
+ MouseListener(),
mTextRows(),
mTextRowLinksCount(),
mLineParts(),
@@ -174,7 +173,7 @@ void BrowserBox::addRow(const std::string &row, const bool atTop)
std::string tmp = row;
std::string newRow;
size_t idx1;
- const gcn::Font *const font = getFont();
+ const Font *const font = getFont();
int linksCount = 0;
if (getWidth() < 0)
@@ -422,7 +421,7 @@ struct MouseOverLink
int mX, mY;
};
-void BrowserBox::mousePressed(gcn::MouseEvent &event)
+void BrowserBox::mousePressed(MouseEvent &event)
{
if (!mLinkHandler)
return;
@@ -437,7 +436,7 @@ void BrowserBox::mousePressed(gcn::MouseEvent &event)
}
}
-void BrowserBox::mouseMoved(gcn::MouseEvent &event)
+void BrowserBox::mouseMoved(MouseEvent &event)
{
const LinkIterator i = std::find_if(mLinks.begin(), mLinks.end(),
MouseOverLink(event.getX(), event.getY()));
@@ -446,13 +445,14 @@ void BrowserBox::mouseMoved(gcn::MouseEvent &event)
? static_cast<int>(i - mLinks.begin()) : -1;
}
-void BrowserBox::draw(gcn::Graphics *graphics)
+void BrowserBox::draw(Graphics *graphics)
{
BLOCK_START("BrowserBox::draw")
- const gcn::ClipRectangle &cr = graphics->getCurrentClipArea();
- Graphics *const graphics2 = static_cast<Graphics *const>(graphics);
- mYStart = cr.y - cr.yOffset;
- const int yEnd = mYStart + cr.height;
+ const ClipRect *const cr = graphics->getCurrentClipArea();
+ if (!cr)
+ return;
+ mYStart = cr->y - cr->yOffset;
+ const int yEnd = mYStart + cr->height;
if (mYStart < 0)
mYStart = 0;
@@ -462,7 +462,7 @@ void BrowserBox::draw(gcn::Graphics *graphics)
if (mOpaque)
{
graphics->setColor(mBackgroundColor);
- graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
+ graphics->fillRectangle(Rect(0, 0, getWidth(), getHeight()));
}
if (mSelectedLink >= 0 && mSelectedLink
@@ -471,7 +471,7 @@ void BrowserBox::draw(gcn::Graphics *graphics)
if ((mHighMode & BACKGROUND))
{
graphics->setColor(mHighlightColor);
- graphics->fillRectangle(gcn::Rectangle(
+ graphics->fillRectangle(Rect(
mLinks[mSelectedLink].x1,
mLinks[mSelectedLink].y1,
mLinks[mSelectedLink].x2 - mLinks[mSelectedLink].x1,
@@ -489,7 +489,7 @@ void BrowserBox::draw(gcn::Graphics *graphics)
}
}
- gcn::Font *const font = getFont();
+ Font *const font = getFont();
FOR_EACH (LinePartCIter, i, mLineParts)
{
@@ -500,7 +500,7 @@ void BrowserBox::draw(gcn::Graphics *graphics)
break;
if (!part.mType)
{
- graphics2->setColorAll(part.mColor, part.mColor2);
+ graphics->setColorAll(part.mColor, part.mColor2);
if (part.mBold)
boldFont->drawString(graphics, part.mText, part.mX, part.mY);
else
@@ -508,7 +508,7 @@ void BrowserBox::draw(gcn::Graphics *graphics)
}
else if (part.mImage)
{
- graphics2->drawImage2(part.mImage, part.mX, part.mY);
+ graphics->drawImage(part.mImage, part.mX, part.mY);
}
}
@@ -528,14 +528,14 @@ int BrowserBox::calcHeight()
if (maxWidth < 0)
return 1;
- const gcn::Font *const font = getFont();
+ const Font *const font = getFont();
const int fontHeight = font->getHeight() + 2 * mItemPadding;
const int fontWidthMinus = font->getWidth("-");
const char *const hyphen = "~";
const int hyphenWidth = font->getWidth(hyphen);
- gcn::Color selColor[2] = {mForegroundColor, mForegroundColor2};
- const gcn::Color textColor[2] = {mForegroundColor, mForegroundColor2};
+ Color selColor[2] = {mForegroundColor, mForegroundColor2};
+ const Color textColor[2] = {mForegroundColor, mForegroundColor2};
ResourceManager *const resman = ResourceManager::getInstance();
mLineParts.clear();
@@ -581,7 +581,7 @@ int BrowserBox::calcHeight()
continue;
}
- gcn::Color prevColor[2];
+ Color prevColor[2];
prevColor[0] = selColor[0];
prevColor[1] = selColor[1];
bold = false;
@@ -621,7 +621,7 @@ int BrowserBox::calcHeight()
const signed char c = row.at(start + 2);
bool valid(false);
- const gcn::Color col[2] =
+ const Color col[2] =
{
getThemeCharColor(c, valid),
getThemeCharColor(c | 0x80, valid)
@@ -897,8 +897,8 @@ std::string BrowserBox::getTextAtPos(const int x, const int y) const
return str;
}
-void BrowserBox::setForegroundColorAll(const gcn::Color &color1,
- const gcn::Color &color2)
+void BrowserBox::setForegroundColorAll(const Color &color1,
+ const Color &color2)
{
mForegroundColor = color1;
mForegroundColor2 = color2;
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
index 09f06bc39..8202fa548 100644
--- a/src/gui/widgets/browserbox.h
+++ b/src/gui/widgets/browserbox.h
@@ -24,10 +24,9 @@
#ifndef GUI_WIDGETS_BROWSERBOX_H
#define GUI_WIDGETS_BROWSERBOX_H
-#include "gui/widgets/widget2.h"
+#include "listeners/mouselistener.h"
-#include <guichan/mouselistener.hpp>
-#include <guichan/widget.hpp>
+#include "gui/widgets/widget.h"
#include <list>
#include <vector>
@@ -60,8 +59,8 @@ struct BrowserLink final
class LinePart final
{
public:
- LinePart(const int x, const int y, const gcn::Color &color,
- const gcn::Color &color2, const std::string &text,
+ LinePart(const int x, const int y, const Color &color,
+ const Color &color2, const std::string &text,
const bool bold) :
mX(x),
mY(y),
@@ -74,8 +73,8 @@ class LinePart final
{
}
- LinePart(const int x, const int y, const gcn::Color &color,
- const gcn::Color &color2, Image *const image) :
+ LinePart(const int x, const int y, const Color &color,
+ const Color &color2, Image *const image) :
mX(x),
mY(y),
mColor(color),
@@ -90,8 +89,8 @@ class LinePart final
~LinePart();
int mX, mY;
- gcn::Color mColor;
- gcn::Color mColor2;
+ Color mColor;
+ Color mColor2;
std::string mText;
unsigned char mType;
Image *mImage;
@@ -102,9 +101,8 @@ class LinePart final
* A simple browser box able to handle links and forward events to the
* parent conteiner.
*/
-class BrowserBox final : public gcn::Widget,
- public Widget2,
- public gcn::MouseListener
+class BrowserBox final : public Widget,
+ public MouseListener
{
public:
/**
@@ -158,14 +156,14 @@ class BrowserBox final : public gcn::Widget,
/**
* Handles mouse actions.
*/
- void mousePressed(gcn::MouseEvent &event) override final;
+ void mousePressed(MouseEvent &event) override final;
- void mouseMoved(gcn::MouseEvent &event) override final;
+ void mouseMoved(MouseEvent &event) override final;
/**
* Draws the browser box.
*/
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
void updateHeight();
@@ -231,8 +229,8 @@ class BrowserBox final : public gcn::Widget,
int getPadding() const A_WARN_UNUSED
{ return mPadding; }
- void setForegroundColorAll(const gcn::Color &color1,
- const gcn::Color &color2);
+ void setForegroundColorAll(const Color &color1,
+ const Color &color2);
int getDataWidth() const
{ return mDataWidth; }
@@ -269,9 +267,9 @@ class BrowserBox final : public gcn::Widget,
int mItemPadding;
unsigned int mDataWidth;
- gcn::Color mHighlightColor;
- gcn::Color mHyperLinkColor;
- gcn::Color mColors[2][COLORS_MAX];
+ Color mHighlightColor;
+ Color mHyperLinkColor;
+ Color mColors[2][COLORS_MAX];
bool mOpaque;
bool mUseLinksAndUserColors;
diff --git a/src/gui/widgets/browserbox_unittest.cc b/src/gui/widgets/browserbox_unittest.cc
index 87d31e900..2acc5f5d3 100644
--- a/src/gui/widgets/browserbox_unittest.cc
+++ b/src/gui/widgets/browserbox_unittest.cc
@@ -22,7 +22,7 @@
#include "client.h"
-#include "gui/sdlfont.h"
+#include "gui/font.h"
#include "gui/theme.h"
#include "gui/widgets/browserbox.h"
@@ -51,7 +51,7 @@ TEST(browserbox, test1)
logger = new Logger();
imageHelper = new SDLImageHelper();
Theme *theme = Theme::instance();
- gcn::Widget::setGlobalFont(new SDLFont("/usr/share/fonts/truetype/"
+ Widget::setGlobalFont(new Font("/usr/share/fonts/truetype/"
"ttf-dejavu/DejaVuSans-Oblique.ttf", 18));
BrowserBox *box = new BrowserBox(nullptr, BrowserBox::AUTO_WRAP, true, "");
box->setWidth(100);
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index 0042b07e3..3cb6d823d 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -25,12 +25,17 @@
#include "client.h"
#include "graphicsvertexes.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
+#include "resources/image.h"
#include "resources/imageset.h"
-#include <guichan/font.hpp>
+#include "gui/font.h"
+#include "gui/gui.h"
+
+#include "gui/rect.h"
#include "debug.h"
@@ -48,9 +53,8 @@ static std::string const data[Button::BUTTON_COUNT] =
Skin *Button::button[BUTTON_COUNT];
Button::Button(const Widget2 *const widget) :
- gcn::Button(),
- Widget2(widget),
- gcn::WidgetListener(),
+ gcn::Button(widget),
+ WidgetListener(),
mDescription(),
mVertexes2(new ImageCollection),
mEnabledColor(getThemeColor(Theme::BUTTON)),
@@ -81,10 +85,9 @@ Button::Button(const Widget2 *const widget) :
Button::Button(const Widget2 *const widget,
const std::string &restrict caption,
const std::string &restrict actionEventId,
- gcn::ActionListener *const listener) :
- gcn::Button(caption),
- Widget2(widget),
- gcn::WidgetListener(),
+ ActionListener *const listener) :
+ gcn::Button(widget, caption),
+ WidgetListener(),
mDescription(),
mVertexes2(new ImageCollection),
mEnabledColor(getThemeColor(Theme::BUTTON)),
@@ -121,10 +124,9 @@ Button::Button(const Widget2 *const widget,
const std::string &restrict imageName,
const int imageWidth, const int imageHeight,
const std::string &restrict actionEventId,
- gcn::ActionListener *const listener) :
- gcn::Button(caption),
- Widget2(widget),
- gcn::WidgetListener(),
+ ActionListener *const listener) :
+ gcn::Button(widget, caption),
+ WidgetListener(),
mDescription(),
mVertexes2(new ImageCollection),
mEnabledColor(getThemeColor(Theme::BUTTON)),
@@ -161,10 +163,9 @@ Button::Button(const Widget2 *const widget,
const std::string &restrict imageName,
const int imageWidth, const int imageHeight,
const std::string &restrict actionEventId,
- gcn::ActionListener *const listener) :
- gcn::Button(),
- Widget2(widget),
- gcn::WidgetListener(),
+ ActionListener *const listener) :
+ gcn::Button(widget),
+ WidgetListener(),
mDescription(),
mVertexes2(new ImageCollection),
mEnabledColor(getThemeColor(Theme::BUTTON)),
@@ -201,10 +202,9 @@ Button::Button(const Widget2 *const widget,
const std::string &restrict caption,
const std::string &restrict imageName,
const std::string &restrict actionEventId,
- gcn::ActionListener *const listener) :
- gcn::Button(caption),
- Widget2(widget),
- gcn::WidgetListener(),
+ ActionListener *const listener) :
+ gcn::Button(widget, caption),
+ WidgetListener(),
mDescription(),
mVertexes2(new ImageCollection),
mEnabledColor(getThemeColor(Theme::BUTTON)),
@@ -350,7 +350,7 @@ void Button::updateAlpha()
}
}
-void Button::draw(gcn::Graphics *graphics)
+void Button::draw(Graphics *graphics)
{
BLOCK_START("Button::draw")
int mode;
@@ -373,8 +373,6 @@ void Button::draw(gcn::Graphics *graphics)
updateAlpha();
- Graphics *const g2 = static_cast<Graphics *const>(graphics);
-
bool recalc = false;
if (mRedraw)
{
@@ -384,7 +382,7 @@ void Button::draw(gcn::Graphics *graphics)
{
// because we don't know where parent windows was moved,
// need recalc vertexes
- gcn::ClipRectangle &rect = g2->getTopClip();
+ ClipRect &rect = graphics->getTopClip();
if (rect.xOffset != mXOffset || rect.yOffset != mYOffset)
{
recalc = true;
@@ -396,7 +394,7 @@ void Button::draw(gcn::Graphics *graphics)
recalc = true;
mMode = mode;
}
- else if (g2->getRedraw())
+ else if (graphics->getRedraw())
{
recalc = true;
}
@@ -408,26 +406,26 @@ void Button::draw(gcn::Graphics *graphics)
switch (mode)
{
case BUTTON_DISABLED:
- g2->setColorAll(mDisabledColor, mDisabledColor2);
+ graphics->setColorAll(mDisabledColor, mDisabledColor2);
break;
case BUTTON_PRESSED:
- g2->setColorAll(mPressedColor, mPressedColor2);
+ graphics->setColorAll(mPressedColor, mPressedColor2);
break;
case BUTTON_HIGHLIGHTED:
- g2->setColorAll(mHighlightedColor, mHighlightedColor2);
+ graphics->setColorAll(mHighlightedColor, mHighlightedColor2);
break;
default:
- g2->setColorAll(mEnabledColor, mEnabledColor2);
+ graphics->setColorAll(mEnabledColor, mEnabledColor2);
break;
}
int imageX = 0;
int imageY = 0;
int textX = 0;
- const gcn::Rectangle &rect = mDimension;
+ const Rect &rect = mDimension;
const int width = rect.width;
const int height = rect.height;
- gcn::Font *const font = getFont();
+ Font *const font = getFont();
int textY = height / 2 - font->getHeight() / 2;
if (mImages)
imageY = height / 2 - mImageHeight / 2;
@@ -437,7 +435,7 @@ void Button::draw(gcn::Graphics *graphics)
switch (mAlignment)
{
default:
- case gcn::Graphics::LEFT:
+ case Graphics::LEFT:
{
if (mImages)
{
@@ -450,7 +448,7 @@ void Button::draw(gcn::Graphics *graphics)
}
break;
}
- case gcn::Graphics::CENTER:
+ case Graphics::CENTER:
{
const int width1 = font->getWidth(mCaption);
if (mImages)
@@ -465,7 +463,7 @@ void Button::draw(gcn::Graphics *graphics)
}
break;
}
- case gcn::Graphics::RIGHT:
+ case Graphics::RIGHT:
{
const int width1 = font->getWidth(mCaption);
textX = width - width1 - padding;
@@ -481,39 +479,39 @@ void Button::draw(gcn::Graphics *graphics)
mRedraw = false;
mMode = mode;
mVertexes2->clear();
- g2->calcWindow(mVertexes2, 0, 0, width, height,
+ graphics->calcWindow(mVertexes2,
+ 0, 0,
+ width, height,
skin->getBorder());
if (mImages)
{
if (isPressed())
{
- g2->calcTileCollection(mVertexes2, mImages[mode],
+ graphics->calcTileCollection(mVertexes2,
+ mImages[mode],
imageX + 1, imageY + 1);
}
else
{
- g2->calcTileCollection(mVertexes2,
- mImages[mode], imageX, imageY);
+ graphics->calcTileCollection(mVertexes2,
+ mImages[mode],
+ imageX, imageY);
}
}
}
- g2->drawTileCollection(mVertexes2);
+ graphics->drawTileCollection(mVertexes2);
}
else
{
- g2->drawImageRect(0, 0, width, height, skin->getBorder());
+ graphics->drawImageRect(0, 0, width, height, skin->getBorder());
if (mImages)
{
if (isPressed())
- {
- g2->drawImage2(mImages[mode], imageX + 1, imageY + 1);
- }
+ graphics->drawImage(mImages[mode], imageX + 1, imageY + 1);
else
- {
- g2->drawImage2(mImages[mode], imageX, imageY);
- }
+ graphics->drawImage(mImages[mode], imageX, imageY);
}
}
@@ -522,13 +520,13 @@ void Button::draw(gcn::Graphics *graphics)
textX ++;
textY ++;
}
- font->drawString(g2, mCaption, textX, textY);
+ font->drawString(graphics, mCaption, textX, textY);
BLOCK_END("Button::draw")
}
-void Button::mouseReleased(gcn::MouseEvent& mouseEvent)
+void Button::mouseReleased(MouseEvent& mouseEvent)
{
- if (mouseEvent.getButton() == gcn::MouseEvent::LEFT)
+ if (mouseEvent.getButton() == MouseEvent::LEFT)
{
if (mStick)
mPressed = !mPressed;
@@ -548,19 +546,19 @@ void Button::mouseReleased(gcn::MouseEvent& mouseEvent)
}
}
-void Button::widgetResized(const gcn::Event &event A_UNUSED)
+void Button::widgetResized(const Event &event A_UNUSED)
{
mRedraw = true;
}
-void Button::widgetMoved(const gcn::Event &event A_UNUSED)
+void Button::widgetMoved(const Event &event A_UNUSED)
{
mRedraw = true;
}
void Button::adjustSize()
{
- const gcn::Font *const font = getFont();
+ const Font *const font = getFont();
const Skin *const skin = button[BUTTON_STANDARD];
if (!skin)
return;
@@ -591,9 +589,9 @@ void Button::setCaption(const std::string& caption)
mCaption = caption;
}
-void Button::keyPressed(gcn::KeyEvent& keyEvent)
+void Button::keyPressed(KeyEvent& keyEvent)
{
- const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int action = keyEvent.getActionId();
if (action == Input::KEY_GUI_SELECT)
{
@@ -602,9 +600,9 @@ void Button::keyPressed(gcn::KeyEvent& keyEvent)
}
}
-void Button::keyReleased(gcn::KeyEvent& keyEvent)
+void Button::keyReleased(KeyEvent& keyEvent)
{
- const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int action = keyEvent.getActionId();
if (action == Input::KEY_GUI_SELECT && mKeyPressed)
{
diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h
index 3dd783e52..039475150 100644
--- a/src/gui/widgets/button.h
+++ b/src/gui/widgets/button.h
@@ -23,10 +23,8 @@
#ifndef GUI_WIDGETS_BUTTON_H
#define GUI_WIDGETS_BUTTON_H
-#include "gui/widgets/widget2.h"
-
-#include <guichan/widgets/button.hpp>
-#include <guichan/widgetlistener.hpp>
+#include "gui/base/widgets/button.hpp"
+#include "listeners/widgetlistener.h"
#include "localconsts.h"
@@ -43,8 +41,7 @@ const std::string BUTTON_PLAY = "buttonplay.png";
* \ingroup GUI
*/
class Button final : public gcn::Button,
- public Widget2,
- public gcn::WidgetListener
+ public WidgetListener
{
public:
/**
@@ -59,7 +56,7 @@ class Button final : public gcn::Button,
Button(const Widget2 *const widget,
const std::string &restrict caption,
const std::string &restrict actionEventId,
- gcn::ActionListener *const listener);
+ ActionListener *const listener);
/**
* Constructor, sets the caption of the button to the given string and
@@ -70,7 +67,7 @@ class Button final : public gcn::Button,
const std::string &restrict imageName,
const int imageWidth, const int imageHeight,
const std::string &actionEventId,
- gcn::ActionListener *const listener);
+ ActionListener *const listener);
/**
* Constructor, sets the caption of the button to the given string and
@@ -80,7 +77,7 @@ class Button final : public gcn::Button,
const std::string &restrict imageName,
const int imageWidth, const int imageHeight,
const std::string &restrict actionEventId,
- gcn::ActionListener *const listener);
+ ActionListener *const listener);
/**
* Constructor, sets the caption of the button to the given string and
@@ -90,7 +87,7 @@ class Button final : public gcn::Button,
const std::string &restrict imageName,
const std::string &restrict caption,
const std::string &restrict actionEventId,
- gcn::ActionListener *const listener);
+ ActionListener *const listener);
A_DELETE_COPY(Button)
@@ -102,14 +99,14 @@ class Button final : public gcn::Button,
/**
* Draws the button.
*/
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
/**
* Update the alpha value to the button components.
*/
static void updateAlpha();
- void mouseReleased(gcn::MouseEvent& mouseEvent) override final;
+ void mouseReleased(MouseEvent& mouseEvent) override final;
void setDescription(std::string text)
{ mDescription = text; }
@@ -132,9 +129,9 @@ class Button final : public gcn::Button,
void setPressed(bool b)
{ mPressed = b; }
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
- void widgetMoved(const gcn::Event &event) override final;
+ void widgetMoved(const Event &event) override final;
void loadImage(const std::string &imageName);
@@ -144,9 +141,9 @@ class Button final : public gcn::Button,
void setCaption(const std::string& caption);
- void keyPressed(gcn::KeyEvent &keyEvent) override final;
+ void keyPressed(KeyEvent &keyEvent) override final;
- void keyReleased(gcn::KeyEvent &keyEvent) override final;
+ void keyReleased(KeyEvent &keyEvent) override final;
bool isPressed2() const A_WARN_UNUSED;
@@ -168,14 +165,14 @@ class Button final : public gcn::Button,
std::string mDescription;
ImageCollection *mVertexes2;
- gcn::Color mEnabledColor;
- gcn::Color mEnabledColor2;
- gcn::Color mDisabledColor;
- gcn::Color mDisabledColor2;
- gcn::Color mHighlightedColor;
- gcn::Color mHighlightedColor2;
- gcn::Color mPressedColor;
- gcn::Color mPressedColor2;
+ Color mEnabledColor;
+ Color mEnabledColor2;
+ Color mDisabledColor;
+ Color mDisabledColor2;
+ Color mHighlightedColor;
+ Color mHighlightedColor2;
+ Color mPressedColor;
+ Color mPressedColor2;
Image **mImages;
ImageSet *mImageSet;
unsigned mClickCount;
diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp
index 5ae4e2f5b..7bfc938de 100644
--- a/src/gui/widgets/characterdisplay.cpp
+++ b/src/gui/widgets/characterdisplay.cpp
@@ -24,6 +24,8 @@
#include "units.h"
+#include "gui/gui.h"
+
#include "gui/windows/charselectdialog.h"
#include "gui/popups/textpopup.h"
@@ -32,16 +34,15 @@
#include "gui/widgets/layouthelper.h"
#include "utils/gettext.h"
-
-#include <SDL_mouse.h>
+#include "utils/stringutils.h"
#include "debug.h"
CharacterDisplay::CharacterDisplay(const Widget2 *const widget,
CharSelectDialog *const charSelectDialog) :
Container(widget),
- gcn::MouseListener(),
- gcn::WidgetListener(),
+ MouseListener(),
+ WidgetListener(),
mCharacter(nullptr),
mPlayerBox(new PlayerBox(nullptr)),
mName(new Label(this, "wwwwwwwwwwwwwwwwwwwwwwww")),
@@ -110,17 +111,17 @@ void CharacterDisplay::update()
distributeResizedEvent();
}
-void CharacterDisplay::widgetHidden(const gcn::Event &event A_UNUSED)
+void CharacterDisplay::widgetHidden(const Event &event A_UNUSED)
{
mPopup->setVisible(false);
}
-void CharacterDisplay::mouseExited(gcn::MouseEvent &event A_UNUSED)
+void CharacterDisplay::mouseExited(MouseEvent &event A_UNUSED)
{
mPopup->setVisible(false);
}
-void CharacterDisplay::mouseMoved(gcn::MouseEvent &event A_UNUSED)
+void CharacterDisplay::mouseMoved(MouseEvent &event A_UNUSED)
{
if (!gui)
return;
@@ -142,7 +143,7 @@ void CharacterDisplay::mouseMoved(gcn::MouseEvent &event A_UNUSED)
}
}
-void CharacterDisplay::mousePressed(gcn::MouseEvent &event)
+void CharacterDisplay::mousePressed(MouseEvent &event)
{
if (event.getClickCount() == 2)
distributeActionEvent();
diff --git a/src/gui/widgets/characterdisplay.h b/src/gui/widgets/characterdisplay.h
index eb5ec6dfc..8f9acf462 100644
--- a/src/gui/widgets/characterdisplay.h
+++ b/src/gui/widgets/characterdisplay.h
@@ -26,10 +26,7 @@
#include "gui/widgets/container.h"
#include "gui/widgets/playerbox.h"
-#include "net/charserverhandler.h"
-#include "net/net.h"
-
-#include <guichan/widgetlistener.hpp>
+#include "listeners/widgetlistener.h"
#include "localconsts.h"
@@ -37,9 +34,14 @@ class CharSelectDialog;
class Label;
class TextPopup;
+namespace Net
+{
+ struct Character;
+}
+
class CharacterDisplay final : public Container,
- public gcn::MouseListener,
- public gcn::WidgetListener
+ public MouseListener,
+ public WidgetListener
{
public:
CharacterDisplay(const Widget2 *const widget,
@@ -73,13 +75,13 @@ class CharacterDisplay final : public Container,
void setSelect(bool b)
{ mPlayerBox->setSelected(b); }
- void widgetHidden(const gcn::Event &event) override final;
+ void widgetHidden(const Event &event) override final;
- void mouseExited(gcn::MouseEvent &event) override final;
+ void mouseExited(MouseEvent &event) override final;
- void mouseMoved(gcn::MouseEvent &event) override final;
+ void mouseMoved(MouseEvent &event) override final;
- void mousePressed(gcn::MouseEvent &event) override final;
+ void mousePressed(MouseEvent &event) override final;
private:
void update();
diff --git a/src/gui/widgets/characterviewbase.h b/src/gui/widgets/characterviewbase.h
index a7c9d2240..16b6c3e0d 100644
--- a/src/gui/widgets/characterviewbase.h
+++ b/src/gui/widgets/characterviewbase.h
@@ -25,12 +25,12 @@
#include "gui/widgets/container.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
#include "localconsts.h"
class CharacterViewBase : public Container,
- public gcn::ActionListener
+ public ActionListener
{
public:
A_DELETE_COPY(CharacterViewBase)
@@ -50,7 +50,7 @@ class CharacterViewBase : public Container,
protected:
CharacterViewBase(CharSelectDialog *const widget, const int padding) :
Container(widget),
- gcn::ActionListener(),
+ ActionListener(),
mParent(widget),
mPadding(padding),
mSelected(0)
diff --git a/src/gui/widgets/characterviewnormal.cpp b/src/gui/widgets/characterviewnormal.cpp
index 78c538b8c..1df98d85e 100644
--- a/src/gui/widgets/characterviewnormal.cpp
+++ b/src/gui/widgets/characterviewnormal.cpp
@@ -23,7 +23,6 @@
#include "configuration.h"
#include "gui/widgets/characterdisplay.h"
-#include "gui/widgets/characterviewsmall.h"
#include "debug.h"
@@ -87,6 +86,6 @@ void CharacterViewNormal::resize()
(*mCharacterEntries)[f]->setPosition((f - 5) * width, y);
}
-void CharacterViewNormal::action(const gcn::ActionEvent &event A_UNUSED)
+void CharacterViewNormal::action(const ActionEvent &event A_UNUSED)
{
}
diff --git a/src/gui/widgets/characterviewnormal.h b/src/gui/widgets/characterviewnormal.h
index 50001a61d..4ef1500b0 100644
--- a/src/gui/widgets/characterviewnormal.h
+++ b/src/gui/widgets/characterviewnormal.h
@@ -40,7 +40,7 @@ class CharacterViewNormal final : public CharacterViewBase
void resize() override;
- void action(const gcn::ActionEvent &event A_UNUSED) override final;
+ void action(const ActionEvent &event A_UNUSED) override final;
private:
std::vector<CharacterDisplay*> *mCharacterEntries;
diff --git a/src/gui/widgets/characterviewsmall.cpp b/src/gui/widgets/characterviewsmall.cpp
index ce218646b..4d2c93b48 100644
--- a/src/gui/widgets/characterviewsmall.cpp
+++ b/src/gui/widgets/characterviewsmall.cpp
@@ -24,6 +24,8 @@
#include "gui/widgets/characterdisplay.h"
#include "gui/widgets/label.h"
+#include "utils/stringutils.h"
+
#include "debug.h"
CharacterViewSmall::CharacterViewSmall(CharSelectDialog *const widget,
@@ -98,7 +100,7 @@ void CharacterViewSmall::resize()
mNumber->setPosition(10, y2);
}
-void CharacterViewSmall::action(const gcn::ActionEvent &event)
+void CharacterViewSmall::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "next")
diff --git a/src/gui/widgets/characterviewsmall.h b/src/gui/widgets/characterviewsmall.h
index 3a326134b..a9f6d7f9b 100644
--- a/src/gui/widgets/characterviewsmall.h
+++ b/src/gui/widgets/characterviewsmall.h
@@ -25,6 +25,8 @@
#include "localconsts.h"
+class Label;
+
class CharacterViewSmall final : public CharacterViewBase
{
public:
@@ -39,7 +41,7 @@ class CharacterViewSmall final : public CharacterViewBase
void resize() override final;
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
private:
CharacterDisplay *mSelectedEntry;
diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp
index 47d9f2b57..9fb63b2e8 100644
--- a/src/gui/widgets/checkbox.cpp
+++ b/src/gui/widgets/checkbox.cpp
@@ -24,12 +24,14 @@
#include "client.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
#include "resources/image.h"
-#include <guichan/font.hpp>
+#include "gui/font.h"
+#include "gui/gui.h"
#include "debug.h"
@@ -38,11 +40,11 @@ Skin *CheckBox::mSkin = nullptr;
float CheckBox::mAlpha = 1.0;
CheckBox::CheckBox(const Widget2 *const widget,
- const std::string &restrict caption, const bool selected,
- gcn::ActionListener *const listener,
+ const std::string &restrict caption,
+ const bool selected,
+ ActionListener *const listener,
const std::string &restrict eventId) :
- gcn::CheckBox(caption, selected),
- Widget2(widget),
+ gcn::CheckBox(widget, caption, selected),
mPadding(0),
mImagePadding(0),
mImageSize(9),
@@ -94,15 +96,13 @@ CheckBox::~CheckBox()
}
}
-void CheckBox::draw(gcn::Graphics *const graphics)
+void CheckBox::draw(Graphics *const graphics)
{
BLOCK_START("CheckBox::draw")
drawBox(graphics);
- gcn::Font *const font = getFont();
- static_cast<Graphics *const>(graphics)->setColorAll(
- mForegroundColor, mForegroundColor2);
-
+ Font *const font = getFont();
+ graphics->setColorAll(mForegroundColor, mForegroundColor2);
font->drawString(graphics, mCaption, mPadding + mImageSize + mSpacing,
mPadding);
BLOCK_END("CheckBox::draw")
@@ -129,7 +129,7 @@ void CheckBox::updateAlpha()
}
}
-void CheckBox::drawBox(gcn::Graphics *const graphics)
+void CheckBox::drawBox(Graphics *const graphics)
{
if (!mSkin || !mDrawBox)
return;
@@ -167,24 +167,25 @@ void CheckBox::drawBox(gcn::Graphics *const graphics)
if (box)
{
- static_cast<Graphics*>(graphics)->drawImage2(
- box, mImagePadding, (getHeight() - mImageSize) / 2);
+ graphics->drawImage(box,
+ mImagePadding,
+ (getHeight() - mImageSize) / 2);
}
}
-void CheckBox::mouseEntered(gcn::MouseEvent& event A_UNUSED)
+void CheckBox::mouseEntered(MouseEvent& event A_UNUSED)
{
mHasMouse = true;
}
-void CheckBox::mouseExited(gcn::MouseEvent& event A_UNUSED)
+void CheckBox::mouseExited(MouseEvent& event A_UNUSED)
{
mHasMouse = false;
}
-void CheckBox::keyPressed(gcn::KeyEvent& keyEvent)
+void CheckBox::keyPressed(KeyEvent& keyEvent)
{
- const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int action = keyEvent.getActionId();
if (action == Input::KEY_GUI_SELECT)
{
diff --git a/src/gui/widgets/checkbox.h b/src/gui/widgets/checkbox.h
index 2d4581327..28eadb75c 100644
--- a/src/gui/widgets/checkbox.h
+++ b/src/gui/widgets/checkbox.h
@@ -23,9 +23,7 @@
#ifndef GUI_WIDGETS_CHECKBOX_H
#define GUI_WIDGETS_CHECKBOX_H
-#include "gui/widgets/widget2.h"
-
-#include <guichan/widgets/checkbox.hpp>
+#include "gui/base/widgets/checkbox.hpp"
#include "localconsts.h"
@@ -36,8 +34,7 @@ class Skin;
*
* \ingroup GUI
*/
-class CheckBox final : public gcn::CheckBox,
- public Widget2
+class CheckBox final : public gcn::CheckBox
{
public:
/**
@@ -46,7 +43,7 @@ class CheckBox final : public gcn::CheckBox,
CheckBox(const Widget2 *const widget,
const std::string &restrict caption,
const bool selected = false,
- gcn::ActionListener *const listener = nullptr,
+ ActionListener *const listener = nullptr,
const std::string &restrict eventId = "");
A_DELETE_COPY(CheckBox)
@@ -59,7 +56,7 @@ class CheckBox final : public gcn::CheckBox,
/**
* Draws the caption, then calls drawBox to draw the check box.
*/
- void draw(gcn::Graphics *const graphics) override final;
+ void draw(Graphics *const graphics) override final;
/**
* Update the alpha value to the checkbox components.
@@ -69,19 +66,19 @@ class CheckBox final : public gcn::CheckBox,
/**
* Draws the check box, not the caption.
*/
- void drawBox(gcn::Graphics *const graphics);
+ void drawBox(Graphics *const graphics);
/**
* Called when the mouse enteres the widget area.
*/
- void mouseEntered(gcn::MouseEvent& event) override final;
+ void mouseEntered(MouseEvent& event) override final;
/**
* Called when the mouse leaves the widget area.
*/
- void mouseExited(gcn::MouseEvent& event) override final;
+ void mouseExited(MouseEvent& event) override final;
- void keyPressed(gcn::KeyEvent& keyEvent) override final;
+ void keyPressed(KeyEvent& keyEvent) override final;
void adjustSize();
diff --git a/src/gui/widgets/colorpage.cpp b/src/gui/widgets/colorpage.cpp
index 11dd1f07e..501b3dea7 100644
--- a/src/gui/widgets/colorpage.cpp
+++ b/src/gui/widgets/colorpage.cpp
@@ -20,20 +20,20 @@
#include "gui/widgets/colorpage.h"
-#include "gui/widgets/colormodel.h"
+#include "gui/models/colormodel.h"
-#include <guichan/font.hpp>
+#include "gui/font.h"
#include "debug.h"
ColorPage::ColorPage(const Widget2 *const widget,
- gcn::ListModel *const listModel,
+ ListModel *const listModel,
const std::string &skin) :
ListBox(widget, listModel, skin)
{
mItemPadding = mSkin ? mSkin->getOption("itemPadding") : 1;
mRowHeight = 13;
- const gcn::Font *const font = getFont();
+ const Font *const font = getFont();
if (font)
mRowHeight = font->getHeight() + 2 * mItemPadding;
if (mListModel)
@@ -47,43 +47,42 @@ ColorPage::~ColorPage()
{
}
-void ColorPage::draw(gcn::Graphics *graphics)
+void ColorPage::draw(Graphics *graphics)
{
BLOCK_START("ColorPage::draw")
const ColorModel *const model = static_cast<ColorModel* const>(
mListModel);
- Graphics *const g = static_cast<Graphics *const>(graphics);
mHighlightColor.a = static_cast<int>(mAlpha * 255.0F);
graphics->setColor(mHighlightColor);
updateAlpha();
- gcn::Font *const font = getFont();
+ Font *const font = getFont();
const int rowHeight = getRowHeight();
const int width = mDimension.width;
if (mSelected >= 0)
{
- graphics->fillRectangle(gcn::Rectangle(mPadding,
+ graphics->fillRectangle(Rect(mPadding,
rowHeight * mSelected + mPadding,
mDimension.width - 2 * mPadding, rowHeight));
const ColorPair *const colors = model->getColorAt(mSelected);
- g->setColorAll(*colors->color1, *colors->color2);
+ graphics->setColorAll(*colors->color1, *colors->color2);
const std::string str = mListModel->getElementAt(mSelected);
font->drawString(graphics, str, (width - font->getWidth(str)) / 2,
mSelected * rowHeight + mPadding);
}
- g->setColorAll(mForegroundColor, mForegroundColor2);
+ graphics->setColorAll(mForegroundColor, mForegroundColor2);
const int sz = mListModel->getNumberOfElements();
for (int i = 0, y = mPadding; i < sz; ++i, y += rowHeight)
{
if (i != mSelected)
{
const ColorPair *const colors = model->getColorAt(i);
- g->setColorAll(*colors->color1, *colors->color2);
+ graphics->setColorAll(*colors->color1, *colors->color2);
const std::string str = mListModel->getElementAt(i);
font->drawString(graphics, str, (width - font->getWidth(str)) / 2,
y);
diff --git a/src/gui/widgets/colorpage.h b/src/gui/widgets/colorpage.h
index c1c90eddf..88182e4f2 100644
--- a/src/gui/widgets/colorpage.h
+++ b/src/gui/widgets/colorpage.h
@@ -29,14 +29,14 @@ class ColorPage final : public ListBox
{
public:
ColorPage(const Widget2 *const widget,
- gcn::ListModel *const listModel,
+ ListModel *const listModel,
const std::string &skin);
A_DELETE_COPY(ColorPage)
~ColorPage();
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
void resetAction();
diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp
index e37bd5103..93d74dc8d 100644
--- a/src/gui/widgets/container.cpp
+++ b/src/gui/widgets/container.cpp
@@ -22,11 +22,12 @@
#include "gui/widgets/container.h"
+#include "gui/gui.h"
+
#include "debug.h"
Container::Container(const Widget2 *const widget) :
- gcn::Container(),
- Widget2(widget)
+ gcn::Container(widget)
{
setOpaque(false);
}
@@ -44,7 +45,7 @@ void Container::removeControls()
delete mWidgets.front();
}
-bool Container::safeRemove(gcn::Widget *const widget)
+bool Container::safeRemove(Widget *const widget)
{
for (WidgetListConstIterator iter = mWidgets.begin();
iter != mWidgets.end(); ++iter)
diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h
index 2983a7433..17d6b2af4 100644
--- a/src/gui/widgets/container.h
+++ b/src/gui/widgets/container.h
@@ -23,13 +23,7 @@
#ifndef GUI_WIDGETS_CONTAINER_H
#define GUI_WIDGETS_CONTAINER_H
-#include "gui/widgets/widget2.h"
-
-#include <guichan/widgets/container.hpp>
-
-#if !defined USE_INTERNALGUICHAN
-typedef std::list<gcn::Widget *>::const_iterator WidgetListConstIterator;
-#endif
+#include "gui/base/widgets/container.hpp"
/**
* A widget container.
@@ -40,15 +34,14 @@ typedef std::list<gcn::Widget *>::const_iterator WidgetListConstIterator;
*
* This container is also non-opaque by default.
*/
-class Container : public gcn::Container,
- public Widget2
+class Container : public gcn::Container
{
public:
explicit Container(const Widget2 *const widget);
virtual ~Container();
- bool safeRemove(gcn::Widget *const widget);
+ bool safeRemove(Widget *const widget);
void removeControls();
};
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp
index 32c8a4988..a77516c62 100644
--- a/src/gui/widgets/desktop.cpp
+++ b/src/gui/widgets/desktop.cpp
@@ -35,7 +35,7 @@
Desktop::Desktop(const Widget2 *const widget) :
Container(widget),
- gcn::WidgetListener(),
+ WidgetListener(),
mWallpaper(nullptr),
mVersionLabel(nullptr),
mSkin(nullptr),
@@ -98,17 +98,16 @@ void Desktop::reloadWallpaper()
setBestFittingWallpaper();
}
-void Desktop::widgetResized(const gcn::Event &event A_UNUSED)
+void Desktop::widgetResized(const Event &event A_UNUSED)
{
setBestFittingWallpaper();
}
-void Desktop::draw(gcn::Graphics *graphics)
+void Desktop::draw(Graphics *graphics)
{
BLOCK_START("Desktop::draw")
- Graphics *const g = static_cast<Graphics *const>(graphics);
- const gcn::Rectangle &rect = mDimension;
+ const Rect &rect = mDimension;
const int width = rect.width;
const int height = rect.height;
if (mWallpaper)
@@ -118,30 +117,30 @@ void Desktop::draw(gcn::Graphics *graphics)
if (width > wallpWidth || height > wallpHeight)
{
- g->setColor(mBackgroundGrayColor);
- g->fillRectangle(gcn::Rectangle(0, 0, width, height));
+ graphics->setColor(mBackgroundGrayColor);
+ graphics->fillRectangle(Rect(0, 0, width, height));
}
if (imageHelper->useOpenGL() == RENDER_SOFTWARE)
{
- g->drawImage2(mWallpaper,
+ graphics->drawImage(mWallpaper,
(width - wallpWidth) / 2,
(height - wallpHeight) / 2);
}
else
{
- g->drawRescaledImage(mWallpaper, 0, 0, width, height);
+ graphics->drawRescaledImage(mWallpaper, 0, 0, width, height);
}
}
else
{
- g->setColor(mBackgroundGrayColor);
- g->fillRectangle(gcn::Rectangle(0, 0, width, height));
+ graphics->setColor(mBackgroundGrayColor);
+ graphics->fillRectangle(Rect(0, 0, width, height));
}
// Draw a thin border under the application version...
- g->setColor(mBackgroundColor);
- g->fillRectangle(gcn::Rectangle(mVersionLabel->getDimension()));
+ graphics->setColor(mBackgroundColor);
+ graphics->fillRectangle(Rect(mVersionLabel->getDimension()));
Container::draw(graphics);
BLOCK_END("Desktop::draw")
@@ -166,7 +165,7 @@ void Desktop::setBestFittingWallpaper()
mWallpaper = nullptr;
}
- const gcn::Rectangle &rect = mDimension;
+ const Rect &rect = mDimension;
const int width = rect.width;
const int height = rect.height;
diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h
index b62ae96ef..f0fd500ea 100644
--- a/src/gui/widgets/desktop.h
+++ b/src/gui/widgets/desktop.h
@@ -24,7 +24,7 @@
#include "gui/widgets/container.h"
-#include <guichan/widgetlistener.hpp>
+#include "listeners/widgetlistener.h"
#include "localconsts.h"
@@ -45,7 +45,8 @@ class Skin;
*
* \ingroup GUI
*/
-class Desktop final : public Container, private gcn::WidgetListener
+class Desktop final : public Container,
+ private WidgetListener
{
public:
explicit Desktop(const Widget2 *const widget);
@@ -59,9 +60,9 @@ class Desktop final : public Container, private gcn::WidgetListener
*/
void reloadWallpaper();
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
void postInit();
@@ -71,8 +72,8 @@ class Desktop final : public Container, private gcn::WidgetListener
Image *mWallpaper;
Label *mVersionLabel;
Skin *mSkin;
- gcn::Color mBackgroundColor;
- gcn::Color mBackgroundGrayColor;
+ Color mBackgroundColor;
+ Color mBackgroundGrayColor;
bool mShowBackground;
};
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 59cdec6fb..dfc17e17b 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -24,15 +24,18 @@
#include "client.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
-#include "gui/widgets/extendedlistmodel.h"
+#include "gui/models/extendedlistmodel.h"
+
#include "gui/widgets/popuplist.h"
#include "resources/image.h"
-#include <guichan/font.hpp>
+#include "gui/font.h"
+#include "gui/gui.h"
#include <algorithm>
@@ -51,18 +54,17 @@ static std::string const dropdownFiles[2] =
};
DropDown::DropDown(const Widget2 *const widget,
- gcn::ListModel *const listModel,
+ ListModel *const listModel,
const bool extended,
const bool modal,
- gcn::ActionListener *const listener,
+ ActionListener *const listener,
const std::string &eventId):
- gcn::ActionListener(),
- gcn::BasicContainer(),
- gcn::KeyListener(),
- gcn::MouseListener(),
- gcn::FocusListener(),
- gcn::SelectionListener(),
- Widget2(widget),
+ ActionListener(),
+ gcn::BasicContainer(widget),
+ KeyListener(),
+ MouseListener(),
+ FocusListener(),
+ SelectionListener(),
mPopup(new PopupList(this, listModel, extended, modal)),
mShadowColor(getThemeColor(Theme::DROPDOWN_SHADOW)),
mHighlightColor(getThemeColor(Theme::HIGHLIGHT)),
@@ -214,7 +216,7 @@ void DropDown::updateAlpha()
}
}
-void DropDown::draw(gcn::Graphics* graphics)
+void DropDown::draw(Graphics* graphics)
{
BLOCK_START("DropDown::draw")
int h;
@@ -231,12 +233,11 @@ void DropDown::draw(gcn::Graphics* graphics)
mHighlightColor.a = alpha;
mShadowColor.a = alpha;
- gcn::ListModel *const model = mPopup->getListModel();
+ ListModel *const model = mPopup->getListModel();
if (model && mPopup->getSelected() >= 0)
{
- gcn::Font *const font = getFont();
- static_cast<Graphics *const>(graphics)->setColorAll(
- mForegroundColor, mForegroundColor2);
+ Font *const font = getFont();
+ graphics->setColorAll(mForegroundColor, mForegroundColor2);
if (mExtended)
{
const int sel = mPopup->getSelected();
@@ -250,9 +251,9 @@ void DropDown::draw(gcn::Graphics* graphics)
}
else
{
- static_cast<Graphics*>(graphics)->drawImage2(
- image, mImagePadding, (mDimension.height
- - image->getHeight()) / 2 + mPadding);
+ graphics->drawImage(image,
+ mImagePadding,
+ (mDimension.height - image->getHeight()) / 2 + mPadding);
font->drawString(graphics, model->getElementAt(sel),
image->getWidth() + mImagePadding + mSpacing, mPadding);
}
@@ -267,7 +268,7 @@ void DropDown::draw(gcn::Graphics* graphics)
if (isFocused())
{
graphics->setColor(mHighlightColor);
- graphics->drawRectangle(gcn::Rectangle(mPadding, mPadding,
+ graphics->drawRectangle(Rect(mPadding, mPadding,
mDimension.width - h - pad, h - pad));
}
@@ -286,35 +287,36 @@ void DropDown::draw(gcn::Graphics* graphics)
BLOCK_END("DropDown::draw")
}
-void DropDown::drawFrame(gcn::Graphics *graphics)
+void DropDown::drawFrame(Graphics *graphics)
{
BLOCK_START("DropDown::drawFrame")
const int bs2 = getFrameSize();
- const gcn::Rectangle &rect = mDimension;
- static_cast<Graphics*>(graphics)->drawImageRect(
- 0, 0, rect.width + bs2, rect.height + bs2, skinRect);
+ const Rect &rect = mDimension;
+ graphics->drawImageRect(0, 0,
+ rect.width + bs2, rect.height + bs2,
+ skinRect);
BLOCK_END("DropDown::drawFrame")
}
-void DropDown::drawButton(gcn::Graphics *graphics)
+void DropDown::drawButton(Graphics *graphics)
{
const int height = mDroppedDown ? mFoldedUpHeight : mDimension.height;
Image *image = buttons[mDroppedDown][mPushed];
if (image)
{
- static_cast<Graphics*>(graphics)->drawImage2(image,
+ graphics->drawImage(image,
mDimension.width - image->getWidth() - mImagePadding,
(height - image->getHeight()) / 2);
}
}
-void DropDown::keyPressed(gcn::KeyEvent& keyEvent)
+void DropDown::keyPressed(KeyEvent& keyEvent)
{
if (keyEvent.isConsumed())
return;
- const int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int actionId = keyEvent.getActionId();
switch (actionId)
{
case Input::KEY_GUI_SELECT:
@@ -356,10 +358,10 @@ void DropDown::hideDrop(bool event)
mPopup->setVisible(false);
}
-void DropDown::mousePressed(gcn::MouseEvent& mouseEvent)
+void DropDown::mousePressed(MouseEvent& mouseEvent)
{
// If we have a mouse press on the widget.
- if (mouseEvent.getButton() == gcn::MouseEvent::LEFT
+ if (mouseEvent.getButton() == MouseEvent::LEFT
&& !mDroppedDown && mouseEvent.getSource() == this)
{
mPushed = true;
@@ -373,7 +375,7 @@ void DropDown::mousePressed(gcn::MouseEvent& mouseEvent)
}
}
-void DropDown::mouseReleased(gcn::MouseEvent &mouseEvent)
+void DropDown::mouseReleased(MouseEvent &mouseEvent)
{
if (mIsDragged)
mPushed = false;
@@ -384,12 +386,12 @@ void DropDown::mouseReleased(gcn::MouseEvent &mouseEvent)
// Released outside of widget. Can happen when we have modal
// input focus.
if ((0 > y || y >= mDimension.height || x < 0 || x >= mDimension.width)
- && button == gcn::MouseEvent::LEFT)
+ && button == MouseEvent::LEFT)
{
if (mIsDragged)
foldUp();
}
- else if (button == gcn::MouseEvent::LEFT)
+ else if (button == MouseEvent::LEFT)
{
mPushed = false;
}
@@ -397,19 +399,19 @@ void DropDown::mouseReleased(gcn::MouseEvent &mouseEvent)
mIsDragged = false;
}
-void DropDown::mouseDragged(gcn::MouseEvent &mouseEvent)
+void DropDown::mouseDragged(MouseEvent &mouseEvent)
{
mIsDragged = true;
mouseEvent.consume();
}
-void DropDown::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent)
+void DropDown::mouseWheelMovedUp(MouseEvent& mouseEvent)
{
setSelected(getSelected() - 1);
mouseEvent.consume();
}
-void DropDown::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent)
+void DropDown::mouseWheelMovedDown(MouseEvent& mouseEvent)
{
setSelected(getSelected() + 1);
mouseEvent.consume();
@@ -417,7 +419,7 @@ void DropDown::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent)
void DropDown::setSelectedString(const std::string &str)
{
- gcn::ListModel *const listModel = mPopup->getListModel();
+ ListModel *const listModel = mPopup->getListModel();
if (!listModel)
return;
@@ -433,7 +435,7 @@ void DropDown::setSelectedString(const std::string &str)
std::string DropDown::getSelectedString() const
{
- gcn::ListModel *const listModel = mPopup->getListModel();
+ ListModel *const listModel = mPopup->getListModel();
if (!listModel)
return "";
@@ -490,7 +492,7 @@ void DropDown::setSelected(int selected)
mPopup->setSelected(selected);
}
-void DropDown::setListModel(gcn::ListModel *const listModel)
+void DropDown::setListModel(ListModel *const listModel)
{
mPopup->setListModel(listModel);
@@ -500,30 +502,30 @@ void DropDown::setListModel(gcn::ListModel *const listModel)
adjustHeight();
}
-gcn::ListModel *DropDown::getListModel()
+ListModel *DropDown::getListModel()
{
return mPopup->getListModel();
}
-void DropDown::action(const gcn::ActionEvent &actionEvent A_UNUSED)
+void DropDown::action(const ActionEvent &actionEvent A_UNUSED)
{
foldUp();
distributeActionEvent();
}
-gcn::Rectangle DropDown::getChildrenArea()
+Rect DropDown::getChildrenArea()
{
if (mDroppedDown)
{
// Calculate the children area (with the one pixel border in mind)
- return gcn::Rectangle(1, mFoldedUpHeight + 1,
+ return Rect(1, mFoldedUpHeight + 1,
mDimension.width - 2, mDimension.height - mFoldedUpHeight - 2);
}
- return gcn::Rectangle();
+ return Rect();
}
-void DropDown::valueChanged(const gcn::SelectionEvent& event A_UNUSED)
+void DropDown::valueChanged(const SelectionEvent& event A_UNUSED)
{
}
@@ -551,7 +553,7 @@ void DropDown::distributeValueChangedEvent()
iter != mSelectionListeners.end();
++iter)
{
- gcn::SelectionEvent event(this);
+ SelectionEvent event(this);
(*iter)->valueChanged(event);
}
}
diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h
index ed93dc358..8e463a2c1 100644
--- a/src/gui/widgets/dropdown.h
+++ b/src/gui/widgets/dropdown.h
@@ -23,23 +23,19 @@
#ifndef GUI_WIDGETS_DROPDOWN_H
#define GUI_WIDGETS_DROPDOWN_H
-#include "gui/widgets/widget2.h"
+#include "gui/base/basiccontainer.hpp"
-#include <guichan/actionlistener.hpp>
-#include <guichan/basiccontainer.hpp>
-#include <guichan/focuslistener.hpp>
-#include <guichan/keylistener.hpp>
-#include <guichan/listmodel.hpp>
-#include <guichan/mouselistener.hpp>
-#include <guichan/selectionlistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/focuslistener.h"
+#include "listeners/keylistener.h"
+#include "listeners/mouselistener.h"
+#include "listeners/selectionlistener.h"
#include "localconsts.h"
class Image;
-class ImageRect;
-class ListBox;
+class ListModel;
class PopupList;
-class ScrollArea;
class Skin;
/**
@@ -49,13 +45,12 @@ class Skin;
* DropDown you must give DropDown an implemented ListModel which represents
* your list.
*/
-class DropDown final : public gcn::ActionListener,
+class DropDown final : public ActionListener,
public gcn::BasicContainer,
- public gcn::KeyListener,
- public gcn::MouseListener,
- public gcn::FocusListener,
- public gcn::SelectionListener,
- public Widget2
+ public KeyListener,
+ public MouseListener,
+ public FocusListener,
+ public SelectionListener
{
public:
/**
@@ -67,10 +62,10 @@ class DropDown final : public gcn::ActionListener,
* @see ListModel, ScrollArea, ListBox.
*/
DropDown(const Widget2 *const widget,
- gcn::ListModel *const listModel,
+ ListModel *const listModel,
const bool extended = false,
const bool modal = false,
- gcn::ActionListener *const listener = nullptr,
+ ActionListener *const listener = nullptr,
const std::string &eventId = "");
A_DELETE_COPY(DropDown)
@@ -82,31 +77,31 @@ class DropDown final : public gcn::ActionListener,
*/
void updateAlpha();
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
- void drawFrame(gcn::Graphics *graphics) override final;
+ void drawFrame(Graphics *graphics) override final;
// Inherited from KeyListener
- void keyPressed(gcn::KeyEvent& keyEvent) override final;
+ void keyPressed(KeyEvent& keyEvent) override final;
// Inherited from MouseListener
- void mousePressed(gcn::MouseEvent& mouseEvent) override final;
+ void mousePressed(MouseEvent& mouseEvent) override final;
- void mouseReleased(gcn::MouseEvent& mouseEvent) override final;
+ void mouseReleased(MouseEvent& mouseEvent) override final;
- void mouseDragged(gcn::MouseEvent& mouseEvent) override final;
+ void mouseDragged(MouseEvent& mouseEvent) override final;
- void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) override final;
+ void mouseWheelMovedUp(MouseEvent& mouseEvent) override final;
- void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) override final;
+ void mouseWheelMovedDown(MouseEvent& mouseEvent) override final;
void setSelectedString(const std::string &str);
std::string getSelectedString() const A_WARN_UNUSED;
- void valueChanged(const gcn::SelectionEvent& event) override final;
+ void valueChanged(const SelectionEvent& event) override final;
void updateSelection();
@@ -122,17 +117,17 @@ class DropDown final : public gcn::ActionListener,
void setSelected(int selected);
- void setListModel(gcn::ListModel *const listModel);
+ void setListModel(ListModel *const listModel);
- gcn::ListModel *getListModel();
+ ListModel *getListModel();
void addSelectionListener(SelectionListener* listener);
void removeSelectionListener(SelectionListener* selectionListener);
- gcn::Rectangle getChildrenArea() override;
+ Rect getChildrenArea() override;
- void action(const gcn::ActionEvent &actionEvent) override;
+ void action(const ActionEvent &actionEvent) override;
void distributeValueChangedEvent();
@@ -142,11 +137,11 @@ class DropDown final : public gcn::ActionListener,
*
* @param graphics a Graphics object to draw with.
*/
- void drawButton(gcn::Graphics *graphics);
+ void drawButton(Graphics *graphics);
PopupList *mPopup;
- gcn::Color mShadowColor;
- gcn::Color mHighlightColor;
+ Color mShadowColor;
+ Color mHighlightColor;
int mPadding;
int mImagePadding;
int mSpacing;
diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp
index 73547b770..c8e4bc2d9 100644
--- a/src/gui/widgets/dropshortcutcontainer.cpp
+++ b/src/gui/widgets/dropshortcutcontainer.cpp
@@ -36,12 +36,12 @@
#include "resources/image.h"
-#include <guichan/font.hpp>
+#include "gui/font.h"
#include "debug.h"
-DropShortcutContainer::DropShortcutContainer():
- ShortcutContainer(),
+DropShortcutContainer::DropShortcutContainer(Widget2 *const widget):
+ ShortcutContainer(widget),
mItemClicked(false),
mItemPopup(new ItemPopup),
mEquipedColor(getThemeColor(Theme::ITEM_EQUIPPED)),
@@ -94,7 +94,7 @@ void DropShortcutContainer::setWidget2(const Widget2 *const widget)
mUnEquipedColor2 = getThemeColor(Theme::ITEM_NOT_EQUIPPED_OUTLINE);
}
-void DropShortcutContainer::draw(gcn::Graphics *graphics)
+void DropShortcutContainer::draw(Graphics *graphics)
{
if (!dropShortcut)
return;
@@ -107,8 +107,7 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics)
mBackgroundImg->setAlpha(mAlpha);
}
- Graphics *const g = static_cast<Graphics*>(graphics);
- drawBackground(g);
+ drawBackground(graphics);
const Inventory *const inv = PlayerInfo::getInventory();
if (!inv)
@@ -117,7 +116,7 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics)
return;
}
- gcn::Font *const font = getFont();
+ Font *const font = getFont();
for (unsigned i = 0; i < mMaxItems; i++)
{
@@ -144,12 +143,12 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics)
caption = "Eq.";
image->setAlpha(1.0F);
- g->drawImage2(image, itemX, itemY);
+ graphics->drawImage(image, itemX, itemY);
if (item->isEquipped())
- g->setColorAll(mEquipedColor, mEquipedColor2);
+ graphics->setColorAll(mEquipedColor, mEquipedColor2);
else
- g->setColorAll(mUnEquipedColor, mUnEquipedColor2);
- font->drawString(g, caption,
+ graphics->setColorAll(mUnEquipedColor, mUnEquipedColor2);
+ font->drawString(graphics, caption,
itemX + (mBoxWidth - font->getWidth(caption)) / 2,
itemY + mBoxHeight - 14);
}
@@ -158,12 +157,12 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics)
BLOCK_END("DropShortcutContainer::draw")
}
-void DropShortcutContainer::mouseDragged(gcn::MouseEvent &event)
+void DropShortcutContainer::mouseDragged(MouseEvent &event)
{
if (!dropShortcut)
return;
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ if (event.getButton() == MouseEvent::LEFT)
{
if (dragDrop.isEmpty() && mItemClicked)
{
@@ -197,7 +196,7 @@ void DropShortcutContainer::mouseDragged(gcn::MouseEvent &event)
}
}
-void DropShortcutContainer::mousePressed(gcn::MouseEvent &event)
+void DropShortcutContainer::mousePressed(MouseEvent &event)
{
if (!dropShortcut || !inventoryWindow)
return;
@@ -208,7 +207,7 @@ void DropShortcutContainer::mousePressed(gcn::MouseEvent &event)
return;
const int eventButton = event.getButton();
- if (eventButton == gcn::MouseEvent::LEFT)
+ if (eventButton == MouseEvent::LEFT)
{
if (dropShortcut->getItem(index) > 0)
{
@@ -224,7 +223,7 @@ void DropShortcutContainer::mousePressed(gcn::MouseEvent &event)
}
}
}
- else if (eventButton == gcn::MouseEvent::RIGHT)
+ else if (eventButton == MouseEvent::RIGHT)
{
const Inventory *const inv = PlayerInfo::getInventory();
if (!inv)
@@ -238,12 +237,12 @@ void DropShortcutContainer::mousePressed(gcn::MouseEvent &event)
}
}
-void DropShortcutContainer::mouseReleased(gcn::MouseEvent &event)
+void DropShortcutContainer::mouseReleased(MouseEvent &event)
{
if (!dropShortcut)
return;
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ if (event.getButton() == MouseEvent::LEFT)
{
if (dropShortcut->isItemSelected())
dropShortcut->setItemSelected(-1);
@@ -270,7 +269,7 @@ void DropShortcutContainer::mouseReleased(gcn::MouseEvent &event)
}
// Show ItemTooltip
-void DropShortcutContainer::mouseMoved(gcn::MouseEvent &event)
+void DropShortcutContainer::mouseMoved(MouseEvent &event)
{
if (!dropShortcut)
return;
@@ -303,13 +302,13 @@ void DropShortcutContainer::mouseMoved(gcn::MouseEvent &event)
}
}
-void DropShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED)
+void DropShortcutContainer::mouseExited(MouseEvent &event A_UNUSED)
{
if (mItemPopup)
mItemPopup->setVisible(false);
}
-void DropShortcutContainer::widgetHidden(const gcn::Event &event A_UNUSED)
+void DropShortcutContainer::widgetHidden(const Event &event A_UNUSED)
{
if (mItemPopup)
mItemPopup->setVisible(false);
diff --git a/src/gui/widgets/dropshortcutcontainer.h b/src/gui/widgets/dropshortcutcontainer.h
index b5a144cba..1888292de 100644
--- a/src/gui/widgets/dropshortcutcontainer.h
+++ b/src/gui/widgets/dropshortcutcontainer.h
@@ -38,7 +38,7 @@ class DropShortcutContainer final : public ShortcutContainer
/**
* Constructor. Initializes the graphic.
*/
- DropShortcutContainer();
+ explicit DropShortcutContainer(Widget2 *const widget);
A_DELETE_COPY(DropShortcutContainer)
@@ -50,28 +50,28 @@ class DropShortcutContainer final : public ShortcutContainer
/**
* Draws the items.
*/
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
/**
* Handles mouse when dragged.
*/
- void mouseDragged(gcn::MouseEvent &event) override final;
+ void mouseDragged(MouseEvent &event) override final;
/**
* Handles mouse when pressed.
*/
- void mousePressed(gcn::MouseEvent &event) override final;
+ void mousePressed(MouseEvent &event) override final;
/**
* Handles mouse release.
*/
- void mouseReleased(gcn::MouseEvent &event) override final;
+ void mouseReleased(MouseEvent &event) override final;
- void widgetHidden(const gcn::Event &event) override final;
+ void widgetHidden(const Event &event) override final;
- void mouseExited(gcn::MouseEvent &event) override final;
+ void mouseExited(MouseEvent &event) override final;
- void mouseMoved(gcn::MouseEvent &event) override final;
+ void mouseMoved(MouseEvent &event) override final;
void setWidget2(const Widget2 *const widget) override final;
@@ -79,10 +79,10 @@ class DropShortcutContainer final : public ShortcutContainer
bool mItemClicked;
ItemPopup *mItemPopup;
- gcn::Color mEquipedColor;
- gcn::Color mEquipedColor2;
- gcn::Color mUnEquipedColor;
- gcn::Color mUnEquipedColor2;
+ Color mEquipedColor;
+ Color mEquipedColor2;
+ Color mUnEquipedColor;
+ Color mUnEquipedColor2;
};
#endif // GUI_WIDGETS_DROPSHORTCUTCONTAINER_H
diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp
index f2f84ed56..139082815 100644
--- a/src/gui/widgets/emotepage.cpp
+++ b/src/gui/widgets/emotepage.cpp
@@ -34,10 +34,9 @@ namespace
} // namespace
EmotePage::EmotePage(const Widget2 *const widget) :
- gcn::Widget(),
- Widget2(widget),
- gcn::MouseListener(),
- gcn::WidgetListener(),
+ Widget(widget),
+ MouseListener(),
+ WidgetListener(),
mEmotes(ResourceManager::getInstance()->getImageSet(
"graphics/sprites/chatemotes.png", emoteWidth, emoteHeight)),
mVertexes(new ImageCollection),
@@ -59,7 +58,7 @@ EmotePage::~EmotePage()
mVertexes = nullptr;
}
-void EmotePage::draw(gcn::Graphics *graphics)
+void EmotePage::draw(Graphics *graphics)
{
BLOCK_START("EmotePage::draw")
@@ -68,7 +67,6 @@ void EmotePage::draw(gcn::Graphics *graphics)
const std::vector<Image*> &images = mEmotes->getImages();
- Graphics *const g = static_cast<Graphics*>(graphics);
const unsigned int width = mDimension.width;
unsigned int x = 0;
unsigned int y = 0;
@@ -84,7 +82,7 @@ void EmotePage::draw(gcn::Graphics *graphics)
const Image *const image = *it;
if (image)
{
- g->calcTileCollection(mVertexes, image, x, y);
+ graphics->calcTileCollection(mVertexes, image, x, y);
x += emoteWidth;
if (x + emoteWidth > width)
{
@@ -94,7 +92,7 @@ void EmotePage::draw(gcn::Graphics *graphics)
}
}
}
- g->drawTileCollection(mVertexes);
+ graphics->drawTileCollection(mVertexes);
}
else
{
@@ -103,7 +101,7 @@ void EmotePage::draw(gcn::Graphics *graphics)
const Image *const image = *it;
if (image)
{
- g->drawImage2(image, x, y);
+ graphics->drawImage(image, x, y);
x += emoteWidth;
if (x + emoteWidth > width)
{
@@ -117,7 +115,7 @@ void EmotePage::draw(gcn::Graphics *graphics)
BLOCK_END("EmotePage::draw")
}
-void EmotePage::mousePressed(gcn::MouseEvent &mouseEvent)
+void EmotePage::mousePressed(MouseEvent &mouseEvent)
{
mSelectedIndex = getIndexFromGrid(mouseEvent.getX(), mouseEvent.getY());
distributeActionEvent();
@@ -140,12 +138,12 @@ void EmotePage::resetAction()
mSelectedIndex = -1;
}
-void EmotePage::widgetResized(const gcn::Event &event A_UNUSED)
+void EmotePage::widgetResized(const Event &event A_UNUSED)
{
mRedraw = true;
}
-void EmotePage::widgetMoved(const gcn::Event &event A_UNUSED)
+void EmotePage::widgetMoved(const Event &event A_UNUSED)
{
mRedraw = true;
}
diff --git a/src/gui/widgets/emotepage.h b/src/gui/widgets/emotepage.h
index 132cfb8e9..2ce50f1fc 100644
--- a/src/gui/widgets/emotepage.h
+++ b/src/gui/widgets/emotepage.h
@@ -21,18 +21,16 @@
#ifndef GUI_WIDGETS_EMOTEPAGE_H
#define GUI_WIDGETS_EMOTEPAGE_H
-#include "gui/widgets/widget2.h"
+#include "listeners/mouselistener.h"
+#include "listeners/widgetlistener.h"
-#include <guichan/mouselistener.hpp>
-#include <guichan/widget.hpp>
-#include <guichan/widgetlistener.hpp>
+#include "gui/widgets/widget.h"
#include "localconsts.h"
-class EmotePage final : public gcn::Widget,
- public Widget2,
- public gcn::MouseListener,
- public gcn::WidgetListener
+class EmotePage final : public Widget,
+ public MouseListener,
+ public WidgetListener
{
public:
explicit EmotePage(const Widget2 *const widget);
@@ -41,15 +39,15 @@ class EmotePage final : public gcn::Widget,
~EmotePage();
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
- void mousePressed(gcn::MouseEvent &mouseEvent) override final;
+ void mousePressed(MouseEvent &mouseEvent) override final;
int getIndexFromGrid(const int x, const int y) const;
- void widgetResized(const gcn::Event &event A_UNUSED) override final;
+ void widgetResized(const Event &event A_UNUSED) override final;
- void widgetMoved(const gcn::Event &event A_UNUSED) override final;
+ void widgetMoved(const Event &event A_UNUSED) override final;
void resetAction();
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index d080a6072..296f21126 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -27,20 +27,21 @@
#include "input/inputmanager.h"
+#include "gui/font.h"
#include "gui/viewport.h"
#include "gui/popups/textpopup.h"
#include "resources/image.h"
-#include <guichan/font.hpp>
+#include "resources/db/emotedb.h"
#include "debug.h"
static const int MAX_ITEMS = 48;
-EmoteShortcutContainer::EmoteShortcutContainer():
- ShortcutContainer(),
+EmoteShortcutContainer::EmoteShortcutContainer(Widget2 *const widget) :
+ ShortcutContainer(widget),
mEmoteImg(),
mEmotePopup(new TextPopup),
mEmoteClicked(false),
@@ -99,7 +100,7 @@ void EmoteShortcutContainer::setWidget2(const Widget2 *const widget)
mForegroundColor2 = getThemeColor(Theme::TEXT_OUTLINE);
}
-void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
+void EmoteShortcutContainer::draw(Graphics *graphics)
{
if (!emoteShortcut)
return;
@@ -112,11 +113,10 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
mAlpha = client->getGuiAlpha();
}
- Graphics *const g = static_cast<Graphics *const>(graphics);
- gcn::Font *const font = getFont();
- drawBackground(g);
+ Font *const font = getFont();
+ drawBackground(graphics);
- g->setColorAll(mForegroundColor, mForegroundColor2);
+ graphics->setColorAll(mForegroundColor, mForegroundColor2);
for (unsigned i = 0; i < mMaxItems; i++)
{
const int emoteX = (i % mGridWidth) * mBoxWidth;
@@ -126,7 +126,7 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
const std::string key = inputManager.getKeyValueString(
Input::KEY_EMOTE_1 + i);
- font->drawString(g, key, emoteX + 2, emoteY + 2);
+ font->drawString(graphics, key, emoteX + 2, emoteY + 2);
}
unsigned sz = static_cast<unsigned>(mEmoteImg.size());
if (sz > mMaxItems)
@@ -139,7 +139,8 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
const AnimatedSprite *const sprite = emoteImg->sprite;
if (sprite)
{
- sprite->draw(g, (i % mGridWidth) * mBoxWidth + 2,
+ sprite->draw(graphics,
+ (i % mGridWidth) * mBoxWidth + 2,
(i / mGridWidth) * mBoxHeight + 10);
}
}
@@ -148,11 +149,11 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
BLOCK_END("EmoteShortcutContainer::draw")
}
-void EmoteShortcutContainer::mouseDragged(gcn::MouseEvent &event A_UNUSED)
+void EmoteShortcutContainer::mouseDragged(MouseEvent &event A_UNUSED)
{
}
-void EmoteShortcutContainer::mousePressed(gcn::MouseEvent &event)
+void EmoteShortcutContainer::mousePressed(MouseEvent &event)
{
if (!emoteShortcut)
return;
@@ -174,12 +175,12 @@ void EmoteShortcutContainer::mousePressed(gcn::MouseEvent &event)
}
}
-void EmoteShortcutContainer::mouseReleased(gcn::MouseEvent &event)
+void EmoteShortcutContainer::mouseReleased(MouseEvent &event)
{
if (!emoteShortcut)
return;
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ if (event.getButton() == MouseEvent::LEFT)
{
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -206,7 +207,7 @@ void EmoteShortcutContainer::mouseReleased(gcn::MouseEvent &event)
}
}
-void EmoteShortcutContainer::mouseMoved(gcn::MouseEvent &event)
+void EmoteShortcutContainer::mouseMoved(MouseEvent &event)
{
if (!emoteShortcut || !mEmotePopup)
return;
@@ -226,13 +227,13 @@ void EmoteShortcutContainer::mouseMoved(gcn::MouseEvent &event)
}
}
-void EmoteShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED)
+void EmoteShortcutContainer::mouseExited(MouseEvent &event A_UNUSED)
{
if (mEmotePopup)
mEmotePopup->setVisible(false);
}
-void EmoteShortcutContainer::widgetHidden(const gcn::Event &event A_UNUSED)
+void EmoteShortcutContainer::widgetHidden(const Event &event A_UNUSED)
{
if (mEmotePopup)
mEmotePopup->setVisible(false);
diff --git a/src/gui/widgets/emoteshortcutcontainer.h b/src/gui/widgets/emoteshortcutcontainer.h
index 2c99aaf87..a3061441f 100644
--- a/src/gui/widgets/emoteshortcutcontainer.h
+++ b/src/gui/widgets/emoteshortcutcontainer.h
@@ -24,12 +24,12 @@
#include "gui/widgets/shortcutcontainer.h"
-#include "resources/db/emotedb.h"
-
#include <vector>
class TextPopup;
+struct EmoteSprite;
+
/**
* An emote shortcut container. Used to quickly use emoticons.
*
@@ -41,7 +41,7 @@ class EmoteShortcutContainer final : public ShortcutContainer
/**
* Constructor. Initializes the graphic.
*/
- EmoteShortcutContainer();
+ explicit EmoteShortcutContainer(Widget2 *const widget);
A_DELETE_COPY(EmoteShortcutContainer)
@@ -53,28 +53,28 @@ class EmoteShortcutContainer final : public ShortcutContainer
/**
* Draws the items.
*/
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
/**
* Handles mouse when dragged.
*/
- void mouseDragged(gcn::MouseEvent &event) override final;
+ void mouseDragged(MouseEvent &event) override final;
/**
* Handles mouse when pressed.
*/
- void mousePressed(gcn::MouseEvent &event) override final;
+ void mousePressed(MouseEvent &event) override final;
/**
* Handles mouse release.
*/
- void mouseReleased(gcn::MouseEvent &event) override final;
+ void mouseReleased(MouseEvent &event) override final;
- void mouseMoved(gcn::MouseEvent &event) override final;
+ void mouseMoved(MouseEvent &event) override final;
- void mouseExited(gcn::MouseEvent &event) override final;
+ void mouseExited(MouseEvent &event) override final;
- void widgetHidden(const gcn::Event &event) override final;
+ void widgetHidden(const Event &event) override final;
void setWidget2(const Widget2 *const widget) override final;
diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp
index bd3a35964..7245ddd19 100644
--- a/src/gui/widgets/extendedlistbox.cpp
+++ b/src/gui/widgets/extendedlistbox.cpp
@@ -20,16 +20,18 @@
#include "gui/widgets/extendedlistbox.h"
-#include "gui/widgets/extendedlistmodel.h"
+#include "gui/models/extendedlistmodel.h"
-#include <guichan/font.hpp>
-#include <guichan/graphics.hpp>
-#include <guichan/listmodel.hpp>
+#include "gui/font.h"
+
+#include "gui/models/listmodel.h"
+
+#include "render/graphics.h"
#include "debug.h"
ExtendedListBox::ExtendedListBox(const Widget2 *const widget,
- gcn::ListModel *const listModel,
+ ListModel *const listModel,
const std::string &skin,
const int rowHeight) :
ListBox(widget, listModel, skin),
@@ -47,7 +49,7 @@ ExtendedListBox::~ExtendedListBox()
{
}
-void ExtendedListBox::draw(gcn::Graphics *graphics)
+void ExtendedListBox::draw(Graphics *graphics)
{
if (!mListModel)
return;
@@ -55,10 +57,9 @@ void ExtendedListBox::draw(gcn::Graphics *graphics)
BLOCK_START("ExtendedListBox::draw")
ExtendedListModel *const model = static_cast<ExtendedListModel* const>(
mListModel);
- Graphics *const g = static_cast<Graphics *const>(graphics);
updateAlpha();
- gcn::Font *const font = getFont();
+ Font *const font = getFont();
const int height = mRowHeight;
const int pad2 = 2 + mPadding;
@@ -133,7 +134,7 @@ void ExtendedListBox::draw(gcn::Graphics *graphics)
{
mHighlightColor.a = static_cast<int>(mAlpha * 255.0F);
graphics->setColor(mHighlightColor);
- graphics->fillRectangle(gcn::Rectangle(mPadding, minY + mPadding,
+ graphics->fillRectangle(Rect(mPadding, minY + mPadding,
width - pad2, maxY - minY + height));
}
@@ -146,13 +147,14 @@ void ExtendedListBox::draw(gcn::Graphics *graphics)
const Image *const image = model->getImageAt(row1);
if (image)
{
- g->drawImage2(image, mImagePadding, item.y + (height
- - image->getHeight()) / 2 + mPadding);
+ graphics->drawImage(image,
+ mImagePadding,
+ item.y + (height - image->getHeight()) / 2 + mPadding);
}
}
}
- g->setColorAll(mForegroundColor, mForegroundColor2);
+ graphics->setColorAll(mForegroundColor, mForegroundColor2);
for (int f = 0; f < itemsSz; ++f)
{
@@ -180,13 +182,14 @@ void ExtendedListBox::draw(gcn::Graphics *graphics)
const Image *const image = model->getImageAt(row1);
if (image)
{
- g->drawImage2(image, mImagePadding, item.y + (height
- - image->getHeight()) / 2 + mPadding);
+ graphics->drawImage(image,
+ mImagePadding,
+ item.y + (height - image->getHeight()) / 2 + mPadding);
}
}
}
- g->setColorAll(mForegroundSelectedColor, mForegroundSelectedColor2);
+ graphics->setColorAll(mForegroundSelectedColor, mForegroundSelectedColor2);
for (int f = 0; f < selSz; ++f)
{
diff --git a/src/gui/widgets/extendedlistbox.h b/src/gui/widgets/extendedlistbox.h
index 30e7a32fb..ae94cde02 100644
--- a/src/gui/widgets/extendedlistbox.h
+++ b/src/gui/widgets/extendedlistbox.h
@@ -48,7 +48,7 @@ class ExtendedListBox final : public ListBox
* Constructor.
*/
ExtendedListBox(const Widget2 *const widget,
- gcn::ListModel *const listModel,
+ ListModel *const listModel,
const std::string &skin,
const int rowHeight = 13);
@@ -59,7 +59,7 @@ class ExtendedListBox final : public ListBox
/**
* Draws the list box.
*/
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
void adjustSize() override;
diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp
index d39a7124a..e9b5c1e0c 100644
--- a/src/gui/widgets/flowcontainer.cpp
+++ b/src/gui/widgets/flowcontainer.cpp
@@ -24,9 +24,10 @@
#include "debug.h"
FlowContainer::FlowContainer(const Widget2 *const widget,
- const int boxWidth, const int boxHeight) :
+ const int boxWidth,
+ const int boxHeight) :
Container(widget),
- gcn::WidgetListener(),
+ WidgetListener(),
mBoxWidth(boxWidth),
mBoxHeight(boxHeight),
mGridWidth(1),
@@ -39,7 +40,7 @@ FlowContainer::FlowContainer(const Widget2 *const widget,
mBoxHeight = 1;
}
-void FlowContainer::widgetResized(const gcn::Event &event A_UNUSED)
+void FlowContainer::widgetResized(const Event &event A_UNUSED)
{
if (getWidth() < mBoxWidth)
{
@@ -85,12 +86,12 @@ void FlowContainer::widgetResized(const gcn::Event &event A_UNUSED)
}
}
-void FlowContainer::add(gcn::Widget *widget)
+void FlowContainer::add(Widget *widget)
{
if (!widget)
return;
Container::add(widget);
widget->setSize(mBoxWidth, mBoxHeight);
- widgetResized(gcn::Event(nullptr));
+ widgetResized(Event(nullptr));
}
diff --git a/src/gui/widgets/flowcontainer.h b/src/gui/widgets/flowcontainer.h
index 81043b450..7266bb06a 100644
--- a/src/gui/widgets/flowcontainer.h
+++ b/src/gui/widgets/flowcontainer.h
@@ -24,7 +24,7 @@
#include "gui/widgets/container.h"
-#include <guichan/widgetlistener.hpp>
+#include "listeners/widgetlistener.h"
#include "localconsts.h"
@@ -34,14 +34,15 @@
* \ingroup GUI
*/
class FlowContainer final : public Container,
- public gcn::WidgetListener
+ public WidgetListener
{
public:
/**
* Constructor. Initializes the shortcut container.
*/
FlowContainer(const Widget2 *const widget,
- const int boxWidth, const int boxHeight);
+ const int boxWidth,
+ const int boxHeight);
A_DELETE_COPY(FlowContainer)
@@ -55,7 +56,7 @@ class FlowContainer final : public Container,
* Invoked when a widget changes its size. This is used to determine
* the new height of the container.
*/
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
int getBoxWidth() const A_WARN_UNUSED
{ return mBoxWidth; }
@@ -63,7 +64,7 @@ class FlowContainer final : public Container,
int getBoxHeight() const A_WARN_UNUSED
{ return mBoxHeight; }
- void add(gcn::Widget *widget) override final;
+ void add(Widget *widget) override final;
private:
int mBoxWidth;
diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp
index ae0dd14c5..70ebb77d6 100644
--- a/src/gui/widgets/guitable.cpp
+++ b/src/gui/widgets/guitable.cpp
@@ -24,44 +24,47 @@
#include "client.h"
-#include "input/keyevent.h"
+#include "gui/gui.h"
+
+#include "events/keyevent.h"
+
#include "input/keydata.h"
#include "utils/dtor.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/graphics.hpp>
-#include <guichan/key.hpp>
+#include "listeners/actionlistener.h"
+
+#include "render/graphics.h"
#include "debug.h"
float GuiTable::mAlpha = 1.0;
-class GuiTableActionListener final : public gcn::ActionListener
+class GuiTableActionListener final : public ActionListener
{
public:
GuiTableActionListener(GuiTable *restrict _table,
- gcn::Widget *restrict _widget,
+ Widget *restrict _widget,
int _row, int _column);
A_DELETE_COPY(GuiTableActionListener)
~GuiTableActionListener();
- void action(const gcn::ActionEvent& actionEvent) override final;
+ void action(const ActionEvent& actionEvent) override final;
protected:
GuiTable *mTable;
int mRow;
int mColumn;
- gcn::Widget *mWidget;
+ Widget *mWidget;
};
GuiTableActionListener::GuiTableActionListener(GuiTable *restrict table,
- gcn::Widget *restrict widget,
+ Widget *restrict widget,
int row, int column) :
- gcn::ActionListener(),
+ ActionListener(),
mTable(table),
mRow(row),
mColumn(column),
@@ -83,8 +86,7 @@ GuiTableActionListener::~GuiTableActionListener()
}
}
-void GuiTableActionListener::action(const gcn::ActionEvent
- &actionEvent A_UNUSED)
+void GuiTableActionListener::action(const ActionEvent &actionEvent A_UNUSED)
{
mTable->setSelected(mRow, mColumn);
mTable->distributeActionEvent();
@@ -92,11 +94,11 @@ void GuiTableActionListener::action(const gcn::ActionEvent
GuiTable::GuiTable(const Widget2 *const widget,
- TableModel *const initial_model, const bool opacity) :
- gcn::Widget(),
- Widget2(widget),
- gcn::MouseListener(),
- gcn::KeyListener(),
+ TableModel *const initial_model,
+ const bool opacity) :
+ Widget(widget),
+ MouseListener(),
+ KeyListener(),
mModel(nullptr),
mTopWidget(nullptr),
mActionListeners(),
@@ -280,7 +282,7 @@ void GuiTable::installActionListeners()
{
for (int column = 0; column < columns; ++column)
{
- gcn::Widget *const widget = mModel->getElementAt(row, column);
+ Widget *const widget = mModel->getElementAt(row, column);
if (widget)
{
mActionListeners.push_back(new GuiTableActionListener(
@@ -293,7 +295,7 @@ void GuiTable::installActionListeners()
}
// -- widget ops
-void GuiTable::draw(gcn::Graphics* graphics)
+void GuiTable::draw(Graphics* graphics)
{
if (!mModel || !getRowHeight())
return;
@@ -302,7 +304,7 @@ void GuiTable::draw(gcn::Graphics* graphics)
if (client->getGuiAlpha() != mAlpha)
mAlpha = client->getGuiAlpha();
- const gcn::Rectangle &rect = mDimension;
+ const Rect &rect = mDimension;
const int width = rect.width;
const int height = rect.height;
const int y = rect.y;
@@ -310,7 +312,7 @@ void GuiTable::draw(gcn::Graphics* graphics)
{
mBackgroundColor.a = static_cast<int>(mAlpha * 255.0F);
graphics->setColor(mBackgroundColor);
- graphics->fillRectangle(gcn::Rectangle(0, 0, width, height));
+ graphics->fillRectangle(Rect(0, 0, width, height));
}
// First, determine how many rows we need to draw,
@@ -345,11 +347,11 @@ void GuiTable::draw(gcn::Graphics* graphics)
for (unsigned c = first_column; c + 1 <= last_column1; ++c)
{
- gcn::Widget *const widget = mModel->getElementAt(r, c);
+ Widget *const widget = mModel->getElementAt(r, c);
const int cWidth = getColumnWidth(c);
if (widget)
{
- gcn::Rectangle bounds(x_offset, y_offset, cWidth, rHeight);
+ Rect bounds(x_offset, y_offset, cWidth, rHeight);
if (widget == mTopWidget)
{
@@ -367,14 +369,14 @@ void GuiTable::draw(gcn::Graphics* graphics)
if (mLinewiseMode && r == static_cast<unsigned>(
mSelectedRow) && c == 0)
{
- graphics->fillRectangle(gcn::Rectangle(0, y_offset,
+ graphics->fillRectangle(Rect(0, y_offset,
width, rHeight));
}
else if (!mLinewiseMode && mSelectedColumn > 0
&& c == static_cast<unsigned>(mSelectedColumn)
&& r == static_cast<unsigned>(mSelectedRow))
{
- graphics->fillRectangle(gcn::Rectangle(
+ graphics->fillRectangle(Rect(
x_offset, y_offset, cWidth, rHeight));
}
}
@@ -391,7 +393,7 @@ void GuiTable::draw(gcn::Graphics* graphics)
if (mTopWidget)
{
- const gcn::Rectangle &bounds = mTopWidget->getDimension();
+ const Rect &bounds = mTopWidget->getDimension();
graphics->pushClipArea(bounds);
mTopWidget->draw(graphics);
graphics->popClipArea();
@@ -399,28 +401,28 @@ void GuiTable::draw(gcn::Graphics* graphics)
BLOCK_END("GuiTable::draw")
}
-void GuiTable::moveToTop(gcn::Widget *widget)
+void GuiTable::moveToTop(Widget *widget)
{
- gcn::Widget::moveToTop(widget);
+ Widget::moveToTop(widget);
mTopWidget = widget;
}
-void GuiTable::moveToBottom(gcn::Widget *widget)
+void GuiTable::moveToBottom(Widget *widget)
{
- gcn::Widget::moveToBottom(widget);
+ Widget::moveToBottom(widget);
if (widget == mTopWidget)
mTopWidget = nullptr;
}
-gcn::Rectangle GuiTable::getChildrenArea()
+Rect GuiTable::getChildrenArea()
{
- return gcn::Rectangle(0, 0, mDimension.width, mDimension.height);
+ return Rect(0, 0, mDimension.width, mDimension.height);
}
// -- KeyListener notifications
-void GuiTable::keyPressed(gcn::KeyEvent& keyEvent)
+void GuiTable::keyPressed(KeyEvent& keyEvent)
{
- const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int action = keyEvent.getActionId();
if (action == Input::KEY_GUI_SELECT)
{
@@ -462,12 +464,12 @@ void GuiTable::keyPressed(gcn::KeyEvent& keyEvent)
}
// -- MouseListener notifications
-void GuiTable::mousePressed(gcn::MouseEvent& mouseEvent)
+void GuiTable::mousePressed(MouseEvent& mouseEvent)
{
if (!mModel || !mSelectable)
return;
- if (mouseEvent.getButton() == gcn::MouseEvent::LEFT)
+ if (mouseEvent.getButton() == MouseEvent::LEFT)
{
const int row = getRowForY(mouseEvent.getY());
const int column = getColumnForX(mouseEvent.getX());
@@ -483,7 +485,7 @@ void GuiTable::mousePressed(gcn::MouseEvent& mouseEvent)
}
}
-void GuiTable::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent)
+void GuiTable::mouseWheelMovedUp(MouseEvent& mouseEvent)
{
if (isFocused())
{
@@ -494,7 +496,7 @@ void GuiTable::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent)
}
}
-void GuiTable::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent)
+void GuiTable::mouseWheelMovedDown(MouseEvent& mouseEvent)
{
if (isFocused())
{
@@ -503,9 +505,9 @@ void GuiTable::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent)
}
}
-void GuiTable::mouseDragged(gcn::MouseEvent& mouseEvent)
+void GuiTable::mouseDragged(MouseEvent& mouseEvent)
{
- if (mouseEvent.getButton() != gcn::MouseEvent::LEFT)
+ if (mouseEvent.getButton() != MouseEvent::LEFT)
return;
// Make table selection update on drag
@@ -530,7 +532,7 @@ void GuiTable::modelUpdated(const bool completed)
}
}
-gcn::Widget *GuiTable::getWidgetAt(int x, int y)
+Widget *GuiTable::getWidgetAt(int x, int y)
{
const int row = getRowForY(y);
const int column = getColumnForX(x);
@@ -540,7 +542,7 @@ gcn::Widget *GuiTable::getWidgetAt(int x, int y)
if (mModel && row > -1 && column > -1)
{
- gcn::Widget *const w = mModel->getElementAt(row, column);
+ Widget *const w = mModel->getElementAt(row, column);
if (w && w->isFocusable())
return w;
else
@@ -586,14 +588,14 @@ int GuiTable::getColumnForX(int x) const
return column;
}
-void GuiTable::_setFocusHandler(gcn::FocusHandler* focusHandler)
+void GuiTable::_setFocusHandler(FocusHandler* focusHandler)
{
// add check for focusHandler. may be need remove it?
if (!mModel || !focusHandler)
return;
- gcn::Widget::_setFocusHandler(focusHandler);
+ Widget::_setFocusHandler(focusHandler);
const int rows = mModel->getRows();
const int cols = mModel->getColumns();
@@ -601,7 +603,7 @@ void GuiTable::_setFocusHandler(gcn::FocusHandler* focusHandler)
{
for (int c = 0; c < cols ; ++c)
{
- gcn::Widget *const w = mModel->getElementAt(r, c);
+ Widget *const w = mModel->getElementAt(r, c);
if (w)
w->_setFocusHandler(focusHandler);
}
@@ -612,5 +614,5 @@ void GuiTable::requestFocus()
{
if (!mFocusHandler)
return;
- gcn::Widget::requestFocus();
+ Widget::requestFocus();
}
diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h
index 5529ce842..fb0c34784 100644
--- a/src/gui/widgets/guitable.h
+++ b/src/gui/widgets/guitable.h
@@ -25,12 +25,12 @@
#include "localconsts.h"
-#include "gui/widgets/tablemodel.h"
-#include "gui/widgets/widget2.h"
+#include "gui/models/tablemodel.h"
-#include <guichan/keylistener.hpp>
-#include <guichan/mouselistener.hpp>
-#include <guichan/widget.hpp>
+#include "listeners/keylistener.h"
+#include "listeners/mouselistener.h"
+
+#include "gui/widgets/widget.h"
#include <vector>
@@ -45,10 +45,9 @@ class GuiTableActionListener;
*
* \ingroup GUI
*/
-class GuiTable final : public gcn::Widget,
- public Widget2,
- public gcn::MouseListener,
- public gcn::KeyListener,
+class GuiTable final : public Widget,
+ public MouseListener,
+ public KeyListener,
public TableModelListener
{
// so that the action listener can call distributeActionEvent
@@ -94,7 +93,7 @@ public:
void setWrappingEnabled(bool wrappingEnabled)
{ mWrappingEnabled = wrappingEnabled; }
- gcn::Rectangle getChildrenArea() override final A_WARN_UNUSED;
+ Rect getChildrenArea() override final A_WARN_UNUSED;
/**
* Toggle whether to use linewise selection mode, in which the table selects
@@ -113,18 +112,18 @@ public:
}
// Inherited from Widget
- void draw(gcn::Graphics* graphics) override final;
+ void draw(Graphics* graphics) override final;
- gcn::Widget *getWidgetAt(int x, int y) override final A_WARN_UNUSED;
+ Widget *getWidgetAt(int x, int y) override final A_WARN_UNUSED;
- void moveToTop(gcn::Widget *child) override final;
+ void moveToTop(Widget *child) override final;
- void moveToBottom(gcn::Widget *child) override final;
+ void moveToBottom(Widget *child) override final;
- void _setFocusHandler(gcn::FocusHandler* focusHandler) override final;
+ void _setFocusHandler(FocusHandler* focusHandler) override final;
// Inherited from KeyListener
- void keyPressed(gcn::KeyEvent& keyEvent) override final;
+ void keyPressed(KeyEvent& keyEvent) override final;
/**
* Sets the table to be opaque, that is sets the table
@@ -145,13 +144,13 @@ public:
{ return mOpaque; }
// Inherited from MouseListener
- void mousePressed(gcn::MouseEvent& mouseEvent) override final;
+ void mousePressed(MouseEvent& mouseEvent) override final;
- void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) override final;
+ void mouseWheelMovedUp(MouseEvent& mouseEvent) override final;
- void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) override final;
+ void mouseWheelMovedDown(MouseEvent& mouseEvent) override final;
- void mouseDragged(gcn::MouseEvent& mouseEvent) override final;
+ void mouseDragged(MouseEvent& mouseEvent) override final;
// Constraints inherited from TableModelListener
void modelUpdated(const bool completed) override final;
@@ -181,7 +180,7 @@ private:
TableModel *mModel;
/** If someone moves a fresh widget to the top, we must display it. */
- gcn::Widget *mTopWidget;
+ Widget *mTopWidget;
/** Vector for compactness; used as a list in practice. */
std::vector<GuiTableActionListener *> mActionListeners;
@@ -189,7 +188,7 @@ private:
/**
* Holds the background color of the table.
*/
- gcn::Color mHighlightColor;
+ Color mHighlightColor;
int mSelectedRow;
int mSelectedColumn;
diff --git a/src/gui/widgets/horizontcontainer.cpp b/src/gui/widgets/horizontcontainer.cpp
index a4c95169a..8e3be9662 100644
--- a/src/gui/widgets/horizontcontainer.cpp
+++ b/src/gui/widgets/horizontcontainer.cpp
@@ -24,9 +24,10 @@
#include "debug.h"
HorizontContainer::HorizontContainer(const Widget2 *const widget,
- const int height, const int spacing) :
+ const int height,
+ const int spacing) :
Container(widget),
- gcn::WidgetListener(),
+ WidgetListener(),
mSpacing(spacing),
mCount(0),
mLastX(spacing)
@@ -35,12 +36,12 @@ HorizontContainer::HorizontContainer(const Widget2 *const widget,
addWidgetListener(this);
}
-void HorizontContainer::add(gcn::Widget *widget)
+void HorizontContainer::add(Widget *widget)
{
add(widget, mSpacing);
}
-void HorizontContainer::add(gcn::Widget *const widget, const int spacing)
+void HorizontContainer::add(Widget *const widget, const int spacing)
{
if (!widget)
return;
@@ -58,6 +59,6 @@ void HorizontContainer::clear()
mCount = 0;
}
-void HorizontContainer::widgetResized(const gcn::Event &event A_UNUSED)
+void HorizontContainer::widgetResized(const Event &event A_UNUSED)
{
}
diff --git a/src/gui/widgets/horizontcontainer.h b/src/gui/widgets/horizontcontainer.h
index be30220e8..bef3d0b00 100644
--- a/src/gui/widgets/horizontcontainer.h
+++ b/src/gui/widgets/horizontcontainer.h
@@ -24,7 +24,7 @@
#include "gui/widgets/container.h"
-#include <guichan/widgetlistener.hpp>
+#include "listeners/widgetlistener.h"
#include "localconsts.h"
@@ -33,21 +33,23 @@
*
* This container places it's contents veritcally.
*/
-class HorizontContainer final : public Container, public gcn::WidgetListener
+class HorizontContainer final : public Container,
+ public WidgetListener
{
public:
HorizontContainer(const Widget2 *const widget,
- const int height, const int spacing);
+ const int height,
+ const int spacing);
A_DELETE_COPY(HorizontContainer)
- void add(gcn::Widget *widget) override final;
+ void add(Widget *widget) override final;
- void add(gcn::Widget *const widget, const int spacing);
+ void add(Widget *const widget, const int spacing);
void clear() override;
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
protected:
int mSpacing;
diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp
index 4fb511c85..9a86fc9bf 100644
--- a/src/gui/widgets/icon.cpp
+++ b/src/gui/widgets/icon.cpp
@@ -22,14 +22,16 @@
#include "gui/widgets/icon.h"
+#include "gui/gui.h"
+
#include "resources/image.h"
#include "resources/resourcemanager.h"
#include "debug.h"
-Icon::Icon(const Widget2 *const widget, const std::string &file) :
- gcn::Widget(),
- Widget2(widget),
+Icon::Icon(const Widget2 *const widget,
+ const std::string &file) :
+ Widget(widget),
mImage(ResourceManager::getInstance()->getImage(file))
{
if (mImage)
@@ -39,9 +41,9 @@ Icon::Icon(const Widget2 *const widget, const std::string &file) :
}
}
-Icon::Icon(const Widget2 *const widget, Image *const image) :
- gcn::Widget(),
- Widget2(widget),
+Icon::Icon(const Widget2 *const widget,
+ Image *const image) :
+ Widget(widget),
mImage(image)
{
if (mImage)
@@ -67,13 +69,12 @@ void Icon::setImage(Image *const image)
}
}
-void Icon::draw(gcn::Graphics *g)
+void Icon::draw(Graphics *graphics)
{
BLOCK_START("Icon::draw")
if (mImage)
{
- Graphics *const graphics = static_cast<Graphics*>(g);
- graphics->drawImage2(mImage,
+ graphics->drawImage(mImage,
(mDimension.width - mImage->mBounds.w) / 2,
(mDimension.height - mImage->mBounds.h) / 2);
}
diff --git a/src/gui/widgets/icon.h b/src/gui/widgets/icon.h
index 1cbd3158c..1e015f8e6 100644
--- a/src/gui/widgets/icon.h
+++ b/src/gui/widgets/icon.h
@@ -23,9 +23,7 @@
#ifndef GUI_WIDGETS_ICON_H
#define GUI_WIDGETS_ICON_H
-#include "gui/widgets/widget2.h"
-
-#include <guichan/widget.hpp>
+#include "gui/widgets/widget.h"
#include "localconsts.h"
@@ -36,19 +34,20 @@ class Image;
*
* \ingroup GUI
*/
-class Icon final : public gcn::Widget,
- public Widget2
+class Icon final : public Widget
{
public:
/**
* Constructor.
*/
- Icon(const Widget2 *const widget, const std::string &filename);
+ Icon(const Widget2 *const widget,
+ const std::string &filename);
/**
* Constructor, uses an existing Image.
*/
- Icon(const Widget2 *const widget, Image *const image);
+ Icon(const Widget2 *const widget,
+ Image *const image);
A_DELETE_COPY(Icon)
@@ -68,7 +67,7 @@ class Icon final : public gcn::Widget,
/**
* Draws the Icon.
*/
- void draw(gcn::Graphics *g) override final;
+ void draw(Graphics *g) override final;
private:
Image *mImage;
diff --git a/src/gui/widgets/inttextfield.cpp b/src/gui/widgets/inttextfield.cpp
index e50bd232b..160cfe5de 100644
--- a/src/gui/widgets/inttextfield.cpp
+++ b/src/gui/widgets/inttextfield.cpp
@@ -26,15 +26,19 @@
#include "gui/sdlinput.h"
#endif
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
#include "utils/stringutils.h"
#include "debug.h"
-IntTextField::IntTextField(const Widget2 *const widget, const int def,
- const int min, const int max,
- const bool enabled, const int width) :
+IntTextField::IntTextField(const Widget2 *const widget,
+ const int def,
+ const int min,
+ const int max,
+ const bool enabled,
+ const int width) :
TextField(widget, toString(def)),
mMin(0),
mMax(0),
@@ -49,9 +53,9 @@ IntTextField::IntTextField(const Widget2 *const widget, const int def,
setWidth(width);
}
-void IntTextField::keyPressed(gcn::KeyEvent &event)
+void IntTextField::keyPressed(KeyEvent &event)
{
- const int action = static_cast<KeyEvent*>(&event)->getActionId();
+ const int action = event.getActionId();
if (action == Input::KEY_GUI_DELETE || action == Input::KEY_GUI_BACKSPACE)
{
@@ -67,7 +71,7 @@ void IntTextField::keyPressed(gcn::KeyEvent &event)
if (val != Key::TEXTINPUT)
return;
- const std::string str = static_cast<KeyEvent*>(&event)->getText();
+ const std::string str = event.getText();
if (str.empty())
return;
const size_t sz = str.size();
diff --git a/src/gui/widgets/inttextfield.h b/src/gui/widgets/inttextfield.h
index 3493cf52b..91b076e30 100644
--- a/src/gui/widgets/inttextfield.h
+++ b/src/gui/widgets/inttextfield.h
@@ -34,9 +34,12 @@ class IntTextField final : public TextField
/**
* Constructor, sets default value.
*/
- explicit IntTextField(const Widget2 *const widget, const int def = 0,
- const int min = 0, const int max = 0,
- const bool enabled = true, const int width = 0);
+ explicit IntTextField(const Widget2 *const widget,
+ const int def = 0,
+ const int min = 0,
+ const int max = 0,
+ const bool enabled = true,
+ const int width = 0);
A_DELETE_COPY(IntTextField)
@@ -68,7 +71,7 @@ class IntTextField final : public TextField
/**
* Responds to key presses.
*/
- void keyPressed(gcn::KeyEvent &event) override final;
+ void keyPressed(KeyEvent &event) override final;
private:
int mMin; /**< Minimum value */
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 2014d3ffe..fe666e6f7 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -46,8 +46,8 @@
#include "resources/image.h"
-#include <guichan/font.hpp>
-#include <guichan/selectionlistener.hpp>
+#include "gui/font.h"
+#include "listeners/selectionlistener.h"
#include <algorithm>
@@ -158,11 +158,10 @@ namespace
ItemContainer::ItemContainer(const Widget2 *const widget,
Inventory *const inventory,
const bool forceQuantity) :
- gcn::Widget(),
- Widget2(widget),
- gcn::KeyListener(),
- gcn::MouseListener(),
- gcn::WidgetListener(),
+ Widget(widget),
+ KeyListener(),
+ MouseListener(),
+ WidgetListener(),
mInventory(inventory),
mSelImg(Theme::getImageFromThemeXml("item_selection.xml", "")),
mProtectedImg(Theme::getImageFromTheme("lock.png")),
@@ -227,7 +226,7 @@ ItemContainer::~ItemContainer()
void ItemContainer::logic()
{
BLOCK_START("ItemContainer::logic")
- gcn::Widget::logic();
+ Widget::logic();
if (!mInventory)
{
@@ -245,14 +244,13 @@ void ItemContainer::logic()
BLOCK_END("ItemContainer::logic")
}
-void ItemContainer::draw(gcn::Graphics *graphics)
+void ItemContainer::draw(Graphics *graphics)
{
if (!mInventory || !mShowMatrix)
return;
BLOCK_START("ItemContainer::draw")
- Graphics *const g = static_cast<Graphics *const>(graphics);
- gcn::Font *const font = getFont();
+ Font *const font = getFont();
for (int j = 0; j < mGridRows; j++)
{
@@ -278,16 +276,18 @@ void ItemContainer::draw(gcn::Graphics *graphics)
if (mShowMatrix[itemIndex] == mSelectedIndex)
{
if (mSelImg)
- g->drawImage2(mSelImg, itemX, itemY);
+ graphics->drawImage(mSelImg, itemX, itemY);
}
image->setAlpha(1.0F); // ensure the image if fully drawn...
- g->drawImage2(image, itemX + mPaddingItemX,
+ graphics->drawImage(image,
+ itemX + mPaddingItemX,
itemY + mPaddingItemY);
if (mProtectedImg && PlayerInfo::isItemProtected(
item->getId()))
{
- g->drawImage2(mProtectedImg,
- itemX + mPaddingItemX, itemY + mPaddingItemY);
+ graphics->drawImage(mProtectedImg,
+ itemX + mPaddingItemX,
+ itemY + mPaddingItemY);
}
}
}
@@ -324,11 +324,11 @@ void ItemContainer::draw(gcn::Graphics *graphics)
}
if (item->isEquipped())
- g->setColorAll(mEquipedColor, mEquipedColor2);
+ graphics->setColorAll(mEquipedColor, mEquipedColor2);
else
- g->setColorAll(mUnEquipedColor, mUnEquipedColor2);
+ graphics->setColorAll(mUnEquipedColor, mUnEquipedColor2);
- font->drawString(g, caption,
+ font->drawString(graphics, caption,
itemX + (mBoxWidth - font->getWidth(caption)) / 2,
itemY + mEquippedTextPadding);
}
@@ -373,7 +373,7 @@ void ItemContainer::distributeValueChangedEvent()
{
if (*i)
{
- gcn::SelectionEvent event(this);
+ SelectionEvent event(this);
(*i)->valueChanged(event);
}
}
@@ -385,15 +385,15 @@ void ItemContainer::hidePopup()
mItemPopup->setVisible(false);
}
-void ItemContainer::keyPressed(gcn::KeyEvent &event A_UNUSED)
+void ItemContainer::keyPressed(KeyEvent &event A_UNUSED)
{
}
-void ItemContainer::keyReleased(gcn::KeyEvent &event A_UNUSED)
+void ItemContainer::keyReleased(KeyEvent &event A_UNUSED)
{
}
-void ItemContainer::mousePressed(gcn::MouseEvent &event)
+void ItemContainer::mousePressed(MouseEvent &event)
{
if (!mInventory)
return;
@@ -401,7 +401,7 @@ void ItemContainer::mousePressed(gcn::MouseEvent &event)
const int button = event.getButton();
mClicks = event.getClickCount();
- if (button == gcn::MouseEvent::LEFT || button == gcn::MouseEvent::RIGHT)
+ if (button == MouseEvent::LEFT || button == MouseEvent::RIGHT)
{
const int index = getSlotIndex(event.getX(), event.getY());
if (index == Inventory::NO_SLOT_INDEX)
@@ -467,13 +467,13 @@ void ItemContainer::mousePressed(gcn::MouseEvent &event)
}
}
-void ItemContainer::mouseDragged(gcn::MouseEvent &event A_UNUSED)
+void ItemContainer::mouseDragged(MouseEvent &event A_UNUSED)
{
if (mSelectionStatus != SEL_NONE)
mSelectionStatus = SEL_DRAGGING;
}
-void ItemContainer::mouseReleased(gcn::MouseEvent &event)
+void ItemContainer::mouseReleased(MouseEvent &event)
{
if (mClicks == 2)
return;
@@ -593,7 +593,7 @@ void ItemContainer::mouseReleased(gcn::MouseEvent &event)
}
}
-void ItemContainer::mouseMoved(gcn::MouseEvent &event)
+void ItemContainer::mouseMoved(MouseEvent &event)
{
if (!mInventory)
return;
@@ -612,12 +612,12 @@ void ItemContainer::mouseMoved(gcn::MouseEvent &event)
}
}
-void ItemContainer::mouseExited(gcn::MouseEvent &event A_UNUSED)
+void ItemContainer::mouseExited(MouseEvent &event A_UNUSED)
{
mItemPopup->setVisible(false);
}
-void ItemContainer::widgetResized(const gcn::Event &event A_UNUSED)
+void ItemContainer::widgetResized(const Event &event A_UNUSED)
{
mGridColumns = std::max(1, mDimension.width / mBoxWidth);
adjustHeight();
diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h
index f4a73af9f..f7bc44849 100644
--- a/src/gui/widgets/itemcontainer.h
+++ b/src/gui/widgets/itemcontainer.h
@@ -23,12 +23,11 @@
#ifndef GUI_WIDGETS_ITEMCONTAINER_H
#define GUI_WIDGETS_ITEMCONTAINER_H
-#include "gui/widgets/widget2.h"
+#include "listeners/keylistener.h"
+#include "listeners/mouselistener.h"
+#include "listeners/widgetlistener.h"
-#include <guichan/keylistener.hpp>
-#include <guichan/mouselistener.hpp>
-#include <guichan/widget.hpp>
-#include <guichan/widgetlistener.hpp>
+#include "gui/widgets/widget.h"
#include <list>
@@ -38,22 +37,17 @@ class Image;
class Inventory;
class Item;
class ItemPopup;
-
-namespace gcn
-{
- class SelectionListener;
-}
+class SelectionListener;
/**
* An item container. Used to show items in inventory and trade dialog.
*
* \ingroup GUI
*/
-class ItemContainer final : public gcn::Widget,
- public Widget2,
- public gcn::KeyListener,
- public gcn::MouseListener,
- public gcn::WidgetListener
+class ItemContainer final : public Widget,
+ public KeyListener,
+ public MouseListener,
+ public WidgetListener
{
public:
/**
@@ -85,21 +79,21 @@ class ItemContainer final : public gcn::Widget,
/**
* Draws the items.
*/
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
// KeyListener
- void keyPressed(gcn::KeyEvent &event) override final;
- void keyReleased(gcn::KeyEvent &event) override final;
+ void keyPressed(KeyEvent &event) override final;
+ void keyReleased(KeyEvent &event) override final;
// MouseListener
- void mousePressed(gcn::MouseEvent &event) override final;
- void mouseDragged(gcn::MouseEvent &event) override final;
- void mouseReleased(gcn::MouseEvent &event) override final;
- void mouseMoved(gcn::MouseEvent &event) override final;
- void mouseExited(gcn::MouseEvent &event) override final;
+ void mousePressed(MouseEvent &event) override final;
+ void mouseDragged(MouseEvent &event) override final;
+ void mouseReleased(MouseEvent &event) override final;
+ void mouseMoved(MouseEvent &event) override final;
+ void mouseExited(MouseEvent &event) override final;
// WidgetListener
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
/**
* Returns the selected item.
@@ -115,14 +109,14 @@ class ItemContainer final : public gcn::Widget,
* Adds a listener to the list that's notified each time a change to
* the selection occurs.
*/
- void addSelectionListener(gcn::SelectionListener *listener)
+ void addSelectionListener(SelectionListener *listener)
{ mSelectionListeners.push_back(listener); }
/**
* Removes a listener from the list that's notified each time a change
* to the selection occurs.
*/
- void removeSelectionListener(gcn::SelectionListener *listener)
+ void removeSelectionListener(SelectionListener *listener)
{ mSelectionListeners.remove(listener); }
void setFilter(const int tag);
@@ -187,11 +181,11 @@ class ItemContainer final : public gcn::Widget,
ItemPopup *mItemPopup;
int *mShowMatrix;
Skin *mSkin;
- gcn::Color mEquipedColor;
- gcn::Color mEquipedColor2;
- gcn::Color mUnEquipedColor;
- gcn::Color mUnEquipedColor2;
- typedef std::list<gcn::SelectionListener*> SelectionListenerList;
+ Color mEquipedColor;
+ Color mEquipedColor2;
+ Color mUnEquipedColor;
+ Color mUnEquipedColor2;
+ typedef std::list<SelectionListener*> SelectionListenerList;
typedef SelectionListenerList::iterator SelectionListenerIterator;
SelectionListenerList mSelectionListeners;
int mGridColumns;
diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp
index cb74a658b..2cf27ae30 100644
--- a/src/gui/widgets/itemlinkhandler.cpp
+++ b/src/gui/widgets/itemlinkhandler.cpp
@@ -35,25 +35,27 @@
#include "resources/db/itemdb.h"
-#include <string>
+#include "listeners/actionlistener.h"
+
+#include "input/mouseinput.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/mouseinput.hpp>
+#include <string>
#include "debug.h"
namespace
{
- struct OpenUrlListener : public gcn::ActionListener
+ struct OpenUrlListener : public ActionListener
{
OpenUrlListener() :
+ ActionListener(),
url()
{
}
A_DELETE_COPY(OpenUrlListener)
- void action(const gcn::ActionEvent &event) override final
+ void action(const ActionEvent &event) override final
{
if (event.getId() == "yes")
openBrowser(url);
@@ -64,6 +66,7 @@ namespace
} // namespace
ItemLinkHandler::ItemLinkHandler() :
+ LinkHandler(),
mItemPopup(new ItemPopup)
{
mItemPopup->postInit();
@@ -75,8 +78,7 @@ ItemLinkHandler::~ItemLinkHandler()
mItemPopup = nullptr;
}
-void ItemLinkHandler::handleLink(const std::string &link,
- gcn::MouseEvent *event)
+void ItemLinkHandler::handleLink(const std::string &link, MouseEvent *event)
{
if (strStartWith(link, "http://") || strStartWith(link, "https://"))
{
@@ -86,7 +88,7 @@ void ItemLinkHandler::handleLink(const std::string &link,
replaceAll(url, " ", "");
listener.url = url;
const int button = event->getButton();
- if (button == gcn::MouseInput::LEFT)
+ if (button == MouseInput::LEFT)
{
ConfirmDialog *const confirmDlg = new ConfirmDialog(
// TRANSLATORS: dialog message
@@ -94,7 +96,7 @@ void ItemLinkHandler::handleLink(const std::string &link,
confirmDlg->postInit();
confirmDlg->addActionListener(&listener);
}
- else if (button == gcn::MouseInput::RIGHT)
+ else if (button == MouseInput::RIGHT)
{
if (viewport)
viewport->showLinkPopup(url);
diff --git a/src/gui/widgets/itemlinkhandler.h b/src/gui/widgets/itemlinkhandler.h
index 4e55a8f72..39e811721 100644
--- a/src/gui/widgets/itemlinkhandler.h
+++ b/src/gui/widgets/itemlinkhandler.h
@@ -39,7 +39,7 @@ class ItemLinkHandler final : public LinkHandler
~ItemLinkHandler();
void handleLink(const std::string &link,
- gcn::MouseEvent *event) override final;
+ MouseEvent *event) override final;
private:
ItemPopup *mItemPopup;
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index cdeb83af7..b9dc3bec8 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -33,6 +33,7 @@
#include "input/inputmanager.h"
+#include "gui/font.h"
#include "gui/viewport.h"
#include "gui/popups/itempopup.h"
@@ -45,12 +46,11 @@
#include "resources/image.h"
-#include <guichan/font.hpp>
-
#include "debug.h"
-ItemShortcutContainer::ItemShortcutContainer(const unsigned number) :
- ShortcutContainer(),
+ItemShortcutContainer::ItemShortcutContainer(Widget2 *const widget,
+ const unsigned number) :
+ ShortcutContainer(widget),
mItemClicked(false),
mNumber(number),
mItemPopup(new ItemPopup),
@@ -112,7 +112,7 @@ void ItemShortcutContainer::setWidget2(const Widget2 *const widget)
mForegroundColor2 = getThemeColor(Theme::TEXT_OUTLINE);
}
-void ItemShortcutContainer::draw(gcn::Graphics *graphics)
+void ItemShortcutContainer::draw(Graphics *graphics)
{
BLOCK_START("ItemShortcutContainer::draw")
const ItemShortcut *const selShortcut = itemShortcut[mNumber];
@@ -129,9 +129,8 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
mAlpha = client->getGuiAlpha();
}
- Graphics *const g = static_cast<Graphics*>(graphics);
- gcn::Font *const font = getFont();
- drawBackground(g);
+ Font *const font = getFont();
+ drawBackground(graphics);
const Inventory *const inv = PlayerInfo::getInventory();
if (!inv)
@@ -149,8 +148,8 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
// Draw item keyboard shortcut.
const std::string key = inputManager.getKeyValueString(
Input::KEY_SHORTCUT_1 + i);
- g->setColorAll(mForegroundColor, mForegroundColor);
- font->drawString(g, key, itemX + 2, itemY + 2);
+ graphics->setColorAll(mForegroundColor, mForegroundColor);
+ font->drawString(graphics, key, itemX + 2, itemY + 2);
const int itemId = selShortcut->getItem(i);
const unsigned char itemColor = selShortcut->getItemColor(i);
@@ -175,12 +174,17 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
caption = "Eq.";
image->setAlpha(1.0F);
- g->drawImage2(image, itemX, itemY);
+ graphics->drawImage(image, itemX, itemY);
if (item->isEquipped())
- g->setColorAll(mEquipedColor, mEquipedColor2);
+ {
+ graphics->setColorAll(mEquipedColor, mEquipedColor2);
+ }
else
- g->setColorAll(mUnEquipedColor, mUnEquipedColor2);
- font->drawString(g, caption,
+ {
+ graphics->setColorAll(mUnEquipedColor,
+ mUnEquipedColor2);
+ }
+ font->drawString(graphics, caption,
itemX + (mBoxWidth - font->getWidth(caption)) / 2,
itemY + mBoxHeight - 14);
}
@@ -199,11 +203,11 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
if (image)
{
image->setAlpha(1.0F);
- g->drawImage2(image, itemX, itemY);
+ graphics->drawImage(image, itemX, itemY);
}
}
- font->drawString(g, spell->getSymbol(),
+ font->drawString(graphics, spell->getSymbol(),
itemX + 2, itemY + mBoxHeight / 2);
}
}
@@ -218,10 +222,10 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
if (image)
{
image->setAlpha(1.0F);
- g->drawImage2(image, itemX, itemY);
+ graphics->drawImage(image, itemX, itemY);
}
- font->drawString(g, skill->data->shortName, itemX + 2,
+ font->drawString(graphics, skill->data->shortName, itemX + 2,
itemY + mBoxHeight / 2);
}
}
@@ -229,13 +233,13 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
BLOCK_END("ItemShortcutContainer::draw")
}
-void ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event)
+void ItemShortcutContainer::mouseDragged(MouseEvent &event)
{
ItemShortcut *const selShortcut = itemShortcut[mNumber];
if (!selShortcut)
return;
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ if (event.getButton() == MouseEvent::LEFT)
{
if (dragDrop.isEmpty() && mItemClicked)
{
@@ -317,7 +321,7 @@ void ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event)
}
}
-void ItemShortcutContainer::mousePressed(gcn::MouseEvent &event)
+void ItemShortcutContainer::mousePressed(MouseEvent &event)
{
ItemShortcut *const selShortcut = itemShortcut[mNumber];
if (!selShortcut)
@@ -328,7 +332,7 @@ void ItemShortcutContainer::mousePressed(gcn::MouseEvent &event)
if (index == -1)
return;
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ if (event.getButton() == MouseEvent::LEFT)
{
// Stores the selected item if theirs one.
if (selShortcut->isItemSelected() && inventoryWindow &&
@@ -346,7 +350,7 @@ void ItemShortcutContainer::mousePressed(gcn::MouseEvent &event)
mItemClicked = true;
}
}
- else if (event.getButton() == gcn::MouseEvent::RIGHT)
+ else if (event.getButton() == MouseEvent::RIGHT)
{
if (viewport && selShortcut)
{
@@ -356,13 +360,13 @@ void ItemShortcutContainer::mousePressed(gcn::MouseEvent &event)
}
}
-void ItemShortcutContainer::mouseReleased(gcn::MouseEvent &event)
+void ItemShortcutContainer::mouseReleased(MouseEvent &event)
{
ItemShortcut *const selShortcut = itemShortcut[mNumber];
if (!selShortcut)
return;
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ if (event.getButton() == MouseEvent::LEFT)
{
if (selShortcut->isItemSelected())
selShortcut->setItemSelected(-1);
@@ -398,7 +402,7 @@ void ItemShortcutContainer::mouseReleased(gcn::MouseEvent &event)
}
}
-void ItemShortcutContainer::mouseMoved(gcn::MouseEvent &event)
+void ItemShortcutContainer::mouseMoved(MouseEvent &event)
{
const ItemShortcut *const selShortcut = itemShortcut[mNumber];
if (!selShortcut)
@@ -455,7 +459,7 @@ void ItemShortcutContainer::mouseMoved(gcn::MouseEvent &event)
}
// Hide ItemTooltip
-void ItemShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED)
+void ItemShortcutContainer::mouseExited(MouseEvent &event A_UNUSED)
{
if (mItemPopup)
mItemPopup->setVisible(false);
@@ -463,7 +467,7 @@ void ItemShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED)
mSpellPopup->setVisible(false);
}
-void ItemShortcutContainer::widgetHidden(const gcn::Event &event A_UNUSED)
+void ItemShortcutContainer::widgetHidden(const Event &event A_UNUSED)
{
if (mItemPopup)
mItemPopup->setVisible(false);
diff --git a/src/gui/widgets/itemshortcutcontainer.h b/src/gui/widgets/itemshortcutcontainer.h
index f9ec24589..07c3ef822 100644
--- a/src/gui/widgets/itemshortcutcontainer.h
+++ b/src/gui/widgets/itemshortcutcontainer.h
@@ -39,7 +39,8 @@ class ItemShortcutContainer final : public ShortcutContainer
/**
* Constructor. Initializes the graphic.
*/
- explicit ItemShortcutContainer(const unsigned number);
+ ItemShortcutContainer(Widget2 *const widget,
+ const unsigned number);
A_DELETE_COPY(ItemShortcutContainer)
@@ -51,28 +52,28 @@ class ItemShortcutContainer final : public ShortcutContainer
/**
* Draws the items.
*/
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
/**
* Handles mouse when dragged.
*/
- void mouseDragged(gcn::MouseEvent &event) override final;
+ void mouseDragged(MouseEvent &event) override final;
/**
* Handles mouse when pressed.
*/
- void mousePressed(gcn::MouseEvent &event) override final;
+ void mousePressed(MouseEvent &event) override final;
/**
* Handles mouse release.
*/
- void mouseReleased(gcn::MouseEvent &event) override final;
+ void mouseReleased(MouseEvent &event) override final;
- void widgetHidden(const gcn::Event &event) override final;
+ void widgetHidden(const Event &event) override final;
- void mouseExited(gcn::MouseEvent &event) override final;
+ void mouseExited(MouseEvent &event) override final;
- void mouseMoved(gcn::MouseEvent &event) override final;
+ void mouseMoved(MouseEvent &event) override final;
void setWidget2(const Widget2 *const widget);
@@ -82,10 +83,10 @@ class ItemShortcutContainer final : public ShortcutContainer
ItemPopup *mItemPopup;
SpellPopup *mSpellPopup;
- gcn::Color mEquipedColor;
- gcn::Color mEquipedColor2;
- gcn::Color mUnEquipedColor;
- gcn::Color mUnEquipedColor2;
+ Color mEquipedColor;
+ Color mEquipedColor2;
+ Color mUnEquipedColor;
+ Color mUnEquipedColor2;
};
#endif // GUI_WIDGETS_ITEMSHORTCUTCONTAINER_H
diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp
index 7a16b800c..56c949964 100644
--- a/src/gui/widgets/label.cpp
+++ b/src/gui/widgets/label.cpp
@@ -21,7 +21,8 @@
#include "gui/widgets/label.h"
-#include <guichan/font.hpp>
+#include "gui/font.h"
+#include "gui/gui.h"
#include "debug.h"
@@ -29,16 +30,15 @@ Skin *Label::mSkin = nullptr;
int Label::mInstances = 0;
Label::Label(const Widget2 *const widget) :
- gcn::Label(),
- Widget2(widget),
+ gcn::Label(widget),
mPadding(0)
{
init();
}
-Label::Label(const Widget2 *const widget, const std::string &caption) :
- gcn::Label(caption),
- Widget2(widget),
+Label::Label(const Widget2 *const widget,
+ const std::string &caption) :
+ gcn::Label(widget, caption),
mPadding(0)
{
init();
@@ -76,13 +76,13 @@ void Label::init()
mPadding = 0;
}
-void Label::draw(gcn::Graphics* graphics)
+void Label::draw(Graphics* graphics)
{
BLOCK_START("Label::draw")
int textX;
- const gcn::Rectangle &rect = mDimension;
+ const Rect &rect = mDimension;
const int textY = rect.height / 2 - getFont()->getHeight() / 2;
- gcn::Font *const font = getFont();
+ Font *const font = getFont();
switch (mAlignment)
{
@@ -101,28 +101,27 @@ void Label::draw(gcn::Graphics* graphics)
break;
}
- static_cast<Graphics*>(graphics)->setColorAll(
- mForegroundColor, mForegroundColor2);
+ graphics->setColorAll(mForegroundColor, mForegroundColor2);
font->drawString(graphics, mCaption, textX, textY);
BLOCK_END("Label::draw")
}
void Label::adjustSize()
{
- const gcn::Font *const font = getFont();
+ const Font *const font = getFont();
const int pad2 = 2 * mPadding;
setWidth(font->getWidth(mCaption) + pad2);
setHeight(font->getHeight() + pad2);
}
-void Label::setForegroundColor(const gcn::Color &color)
+void Label::setForegroundColor(const Color &color)
{
mForegroundColor = color;
mForegroundColor2 = color;
}
-void Label::setForegroundColorAll(const gcn::Color &color1,
- const gcn::Color &color2)
+void Label::setForegroundColorAll(const Color &color1,
+ const Color &color2)
{
mForegroundColor = color1;
mForegroundColor2 = color2;
@@ -130,7 +129,7 @@ void Label::setForegroundColorAll(const gcn::Color &color1,
void Label::resizeTo(const int maxSize, const int minSize)
{
- const gcn::Font *const font = getFont();
+ const Font *const font = getFont();
const int pad2 = 2 * mPadding;
setHeight(font->getHeight() + pad2);
diff --git a/src/gui/widgets/label.h b/src/gui/widgets/label.h
index 3546f17b4..616f6cc79 100644
--- a/src/gui/widgets/label.h
+++ b/src/gui/widgets/label.h
@@ -22,9 +22,7 @@
#ifndef GUI_WIDGETS_LABEL_H
#define GUI_WIDGETS_LABEL_H
-#include "gui/widgets/widget2.h"
-
-#include <guichan/widgets/label.hpp>
+#include "gui/base/widgets/label.hpp"
#include "localconsts.h"
@@ -36,7 +34,7 @@ class Skin;
*
* \ingroup GUI
*/
-class Label final : public gcn::Label, public Widget2
+class Label final : public gcn::Label
{
public:
/**
@@ -48,7 +46,8 @@ class Label final : public gcn::Label, public Widget2
* Constructor. This version of the constructor sets the label with an
* inintialization string.
*/
- Label(const Widget2 *const widget, const std::string &caption);
+ Label(const Widget2 *const widget,
+ const std::string &caption);
A_DELETE_COPY(Label)
@@ -59,14 +58,14 @@ class Label final : public gcn::Label, public Widget2
/**
* Draws the label.
*/
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
void adjustSize();
- void setForegroundColor(const gcn::Color &color);
+ void setForegroundColor(const Color &color);
- void setForegroundColorAll(const gcn::Color &color1,
- const gcn::Color &color2);
+ void setForegroundColorAll(const Color &color1,
+ const Color &color2);
void resizeTo(const int maxSize, const int minSize);
diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp
index d9a818e0f..24722510b 100644
--- a/src/gui/widgets/layout.cpp
+++ b/src/gui/widgets/layout.cpp
@@ -24,6 +24,8 @@
#include "logger.h"
+#include "gui/base/widgets/container.hpp"
+
#include <cassert>
#include "debug.h"
@@ -34,7 +36,7 @@ ContainerPlacer ContainerPlacer::at(const int x, const int y)
}
LayoutCell &ContainerPlacer::operator()
- (const int x, const int y, gcn::Widget *const wg, const int w, const int h)
+ (const int x, const int y, Widget *const wg, const int w, const int h)
{
mContainer->add(wg);
return mCell->place(wg, x, y, w, h);
@@ -78,7 +80,7 @@ void LayoutCell::reflow(int nx, int ny, int nw, int nh)
if (mType == ARRAY)
mArray->reflow(nx, ny, nw, nh);
else
- mWidget->setDimension(gcn::Rectangle(nx, ny, nw, nh));
+ mWidget->setDimension(Rect(nx, ny, nw, nh));
}
void LayoutCell::computeSizes()
@@ -201,7 +203,7 @@ void LayoutArray::extend(const int x, const int y, const int w, const int h)
cell.mExtent[1] = h;
}
-LayoutCell &LayoutArray::place(gcn::Widget *const widget, const int x,
+LayoutCell &LayoutArray::place(Widget *const widget, const int x,
const int y, const int w, const int h)
{
LayoutCell &cell = at(x, y, w, h);
diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h
index b03c10c1f..288c282a0 100644
--- a/src/gui/widgets/layout.h
+++ b/src/gui/widgets/layout.h
@@ -25,12 +25,17 @@
#include "localconsts.h"
-#include <guichan/widgets/container.hpp>
-
#include <vector>
class LayoutCell;
+namespace gcn
+{
+ class Container;
+}
+
+class Widget;
+
/**
* This class is a helper for adding widgets to nested tables in a window.
*/
@@ -57,7 +62,7 @@ class ContainerPlacer final
* Adds the given widget to the container and places it in the layout.
* @see LayoutArray::place
*/
- LayoutCell &operator()(const int x, const int y, gcn::Widget *const wg,
+ LayoutCell &operator()(const int x, const int y, Widget *const wg,
const int w = 1, const int h = 1);
private:
@@ -90,7 +95,7 @@ class LayoutArray final
* @note When @a w is 1, the width of column @a x is reset to zero if
* it was AUTO_DEF. Similarly for @a h.
*/
- LayoutCell &place(gcn::Widget *const widget, const int x, const int y,
+ LayoutCell &place(Widget *const widget, const int x, const int y,
const int w = 1, const int h = 1);
/**
@@ -216,7 +221,7 @@ class LayoutCell
/**
* @see LayoutArray::place
*/
- LayoutCell &place(gcn::Widget *wg, int x, int y, int w = 1, int h = 1)
+ LayoutCell &place(Widget *wg, int x, int y, int w = 1, int h = 1)
{ return getArray().place(wg, x, y, w, h); }
/**
@@ -294,7 +299,7 @@ class LayoutCell
union
{
- gcn::Widget *mWidget;
+ Widget *mWidget;
LayoutArray *mArray;
};
diff --git a/src/gui/widgets/layouthelper.cpp b/src/gui/widgets/layouthelper.cpp
index b0fb75adc..c225c7543 100644
--- a/src/gui/widgets/layouthelper.cpp
+++ b/src/gui/widgets/layouthelper.cpp
@@ -22,10 +22,12 @@
#include "gui/widgets/layouthelper.h"
+#include "gui/base/widgets/container.hpp"
+
#include "debug.h"
LayoutHelper::LayoutHelper(gcn::Container *const container) :
- gcn::WidgetListener(),
+ WidgetListener(),
mLayout(),
mContainer(container)
{
@@ -43,7 +45,7 @@ const Layout &LayoutHelper::getLayout() const
}
LayoutCell &LayoutHelper::place(const int x, const int y,
- gcn::Widget *const wg,
+ Widget *const wg,
const int w, const int h)
{
mContainer->add(wg);
@@ -61,9 +63,9 @@ void LayoutHelper::reflowLayout(int w, int h)
mContainer->setSize(w, h);
}
-void LayoutHelper::widgetResized(const gcn::Event &event A_UNUSED)
+void LayoutHelper::widgetResized(const Event &event A_UNUSED)
{
- const gcn::Rectangle area = mContainer->getChildrenArea();
+ const Rect area = mContainer->getChildrenArea();
int w = area.width;
int h = area.height;
mLayout.reflow(w, h);
diff --git a/src/gui/widgets/layouthelper.h b/src/gui/widgets/layouthelper.h
index 4f8ed8708..32e3d9e34 100644
--- a/src/gui/widgets/layouthelper.h
+++ b/src/gui/widgets/layouthelper.h
@@ -25,14 +25,14 @@
#include "gui/widgets/layout.h"
-#include <guichan/widgetlistener.hpp>
+#include "listeners/widgetlistener.h"
/**
* A helper class for adding a layout to a Guichan container widget. The layout
* will register itself as a widget listener and relayout the widgets in the
* container dynamically on resize.
*/
-class LayoutHelper final : public gcn::WidgetListener
+class LayoutHelper final : public WidgetListener
{
public:
/**
@@ -67,7 +67,7 @@ class LayoutHelper final : public gcn::WidgetListener
/**
* Adds a widget to the container and sets it at given cell.
*/
- LayoutCell &place(const int x, const int y, gcn::Widget *const wg,
+ LayoutCell &place(const int x, const int y, Widget *const wg,
const int w = 1, const int h = 1);
/**
@@ -78,7 +78,7 @@ class LayoutHelper final : public gcn::WidgetListener
/**
* Called whenever the managed container changes size.
*/
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
private:
Layout mLayout; /**< Layout handler */
diff --git a/src/gui/widgets/linkhandler.h b/src/gui/widgets/linkhandler.h
index 744ff0b29..b373162a3 100644
--- a/src/gui/widgets/linkhandler.h
+++ b/src/gui/widgets/linkhandler.h
@@ -25,7 +25,7 @@
#include <string>
-#include <guichan/mouselistener.hpp>
+#include "listeners/mouselistener.h"
/**
* A simple interface to windows that need to handle links from BrowserBox
@@ -38,7 +38,7 @@ class LinkHandler
{ }
virtual void handleLink(const std::string &link,
- gcn::MouseEvent *event) = 0;
+ MouseEvent *event) = 0;
};
#endif // GUI_WIDGETS_LINKHANDLER_H
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index 9a1a074b3..c6e431634 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -24,25 +24,26 @@
#include "client.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
+#include "gui/focushandler.h"
+#include "gui/font.h"
#include "gui/gui.h"
-#include <guichan/focushandler.hpp>
-#include <guichan/font.hpp>
-#include <guichan/graphics.hpp>
-#include <guichan/listmodel.hpp>
+#include "gui/models/listmodel.h"
+
+#include "render/graphics.h"
#include "debug.h"
float ListBox::mAlpha = 1.0;
ListBox::ListBox(const Widget2 *const widget,
- gcn::ListModel *const listModel,
+ ListModel *const listModel,
const std::string &skin) :
- gcn::ListBox(listModel),
- Widget2(widget),
+ gcn::ListBox(widget, listModel),
mHighlightColor(getThemeColor(Theme::HIGHLIGHT)),
mForegroundSelectedColor(getThemeColor(Theme::LISTBOX_SELECTED)),
mForegroundSelectedColor2(getThemeColor(Theme::LISTBOX_SELECTED_OUTLINE)),
@@ -68,7 +69,7 @@ ListBox::ListBox(const Widget2 *const widget,
mItemPadding = mSkin->getOption("itemPadding");
}
- const gcn::Font *const font = getFont();
+ const Font *const font = getFont();
if (font)
mRowHeight = font->getHeight() + 2 * mItemPadding;
else
@@ -98,18 +99,17 @@ void ListBox::updateAlpha()
mAlpha = alpha;
}
-void ListBox::draw(gcn::Graphics *graphics)
+void ListBox::draw(Graphics *graphics)
{
if (!mListModel)
return;
BLOCK_START("ListBox::draw")
updateAlpha();
- Graphics *const g = static_cast<Graphics*>(graphics);
mHighlightColor.a = static_cast<int>(mAlpha * 255.0F);
graphics->setColor(mHighlightColor);
- gcn::Font *const font = getFont();
+ Font *const font = getFont();
const int rowHeight = getRowHeight();
const int width = mDimension.width;
@@ -118,11 +118,11 @@ void ListBox::draw(gcn::Graphics *graphics)
// Draw filled rectangle around the selected list element
if (mSelected >= 0)
{
- graphics->fillRectangle(gcn::Rectangle(mPadding,
+ graphics->fillRectangle(Rect(mPadding,
rowHeight * mSelected + mPadding,
mDimension.width - 2 * mPadding, rowHeight));
- g->setColorAll(mForegroundSelectedColor,
+ graphics->setColorAll(mForegroundSelectedColor,
mForegroundSelectedColor2);
const std::string str = mListModel->getElementAt(mSelected);
font->drawString(graphics, str,
@@ -130,7 +130,7 @@ void ListBox::draw(gcn::Graphics *graphics)
mSelected * rowHeight + mPadding + mItemPadding);
}
// Draw the list elements
- g->setColorAll(mForegroundColor, mForegroundColor2);
+ graphics->setColorAll(mForegroundColor, mForegroundColor2);
const int sz = mListModel->getNumberOfElements();
for (int i = 0, y = mPadding + mItemPadding;
i < sz; ++i, y += rowHeight)
@@ -148,18 +148,18 @@ void ListBox::draw(gcn::Graphics *graphics)
// Draw filled rectangle around the selected list element
if (mSelected >= 0)
{
- graphics->fillRectangle(gcn::Rectangle(mPadding,
+ graphics->fillRectangle(Rect(mPadding,
rowHeight * mSelected + mPadding,
mDimension.width - 2 * mPadding, rowHeight));
- g->setColorAll(mForegroundSelectedColor,
+ graphics->setColorAll(mForegroundSelectedColor,
mForegroundSelectedColor2);
const std::string str = mListModel->getElementAt(mSelected);
font->drawString(graphics, str, mPadding,
mSelected * rowHeight + mPadding + mItemPadding);
}
// Draw the list elements
- g->setColorAll(mForegroundColor, mForegroundColor2);
+ graphics->setColorAll(mForegroundColor, mForegroundColor2);
const int sz = mListModel->getNumberOfElements();
for (int i = 0, y = mPadding + mItemPadding; i < sz;
++i, y += rowHeight)
@@ -174,9 +174,9 @@ void ListBox::draw(gcn::Graphics *graphics)
BLOCK_END("ListBox::draw")
}
-void ListBox::keyPressed(gcn::KeyEvent &keyEvent)
+void ListBox::keyPressed(KeyEvent &keyEvent)
{
- const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int action = keyEvent.getActionId();
if (action == Input::KEY_GUI_SELECT)
{
distributeActionEvent();
@@ -213,20 +213,20 @@ void ListBox::keyPressed(gcn::KeyEvent &keyEvent)
// Don't do anything on scrollwheel. ScrollArea will deal with that.
-void ListBox::mouseWheelMovedUp(gcn::MouseEvent &mouseEvent A_UNUSED)
+void ListBox::mouseWheelMovedUp(MouseEvent &mouseEvent A_UNUSED)
{
}
-void ListBox::mouseWheelMovedDown(gcn::MouseEvent &mouseEvent A_UNUSED)
+void ListBox::mouseWheelMovedDown(MouseEvent &mouseEvent A_UNUSED)
{
}
-void ListBox::mousePressed(gcn::MouseEvent &event)
+void ListBox::mousePressed(MouseEvent &event)
{
mPressedIndex = getSelectionByMouse(event.getY());
}
-void ListBox::mouseReleased(gcn::MouseEvent &event)
+void ListBox::mouseReleased(MouseEvent &event)
{
if (mPressedIndex != getSelectionByMouse(event.getY()))
return;
@@ -261,18 +261,18 @@ void ListBox::mouseReleased(gcn::MouseEvent &event)
mPressedIndex = -2;
}
-void ListBox::mouseReleased1(const gcn::MouseEvent &mouseEvent)
+void ListBox::mouseReleased1(const MouseEvent &mouseEvent)
{
- if (mouseEvent.getButton() == gcn::MouseEvent::LEFT)
+ if (mouseEvent.getButton() == MouseEvent::LEFT)
{
setSelected(std::max(0, getSelectionByMouse(mouseEvent.getY())));
distributeActionEvent();
}
}
-void ListBox::mouseDragged(gcn::MouseEvent &event)
+void ListBox::mouseDragged(MouseEvent &event)
{
- if (event.getButton() != gcn::MouseEvent::LEFT || getRowHeight() == 0)
+ if (event.getButton() != MouseEvent::LEFT || getRowHeight() == 0)
return;
// Make list selection update on drag, but guard against negative y
diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h
index b1a2f0da5..64faa6eb5 100644
--- a/src/gui/widgets/listbox.h
+++ b/src/gui/widgets/listbox.h
@@ -23,13 +23,17 @@
#ifndef GUI_WIDGETS_LISTBOX_H
#define GUI_WIDGETS_LISTBOX_H
-#include "gui/widgets/widget2.h"
+#include "gui/color.h"
-#include <guichan/widgets/listbox.hpp>
+#include "gui/base/widgets/listbox.hpp"
#include "localconsts.h"
class Skin;
+class KeyEvent;
+class ListModel;
+class MouseEvent;
+class Widget2;
/**
* A list box, meant to be used inside a scroll area. Same as the Guichan list
@@ -38,15 +42,14 @@ class Skin;
*
* \ingroup GUI
*/
-class ListBox : public gcn::ListBox,
- public Widget2
+class ListBox : public gcn::ListBox
{
public:
/**
* Constructor.
*/
ListBox(const Widget2 *const widget,
- gcn::ListModel *const listModel,
+ ListModel *const listModel,
const std::string &skin);
A_DELETE_COPY(ListBox)
@@ -58,7 +61,7 @@ class ListBox : public gcn::ListBox,
/**
* Draws the list box.
*/
- void draw(gcn::Graphics *graphics) override;
+ void draw(Graphics *graphics) override;
/**
* Update the alpha value to the graphic components.
@@ -67,21 +70,21 @@ class ListBox : public gcn::ListBox,
// Inherited from KeyListener
- void keyPressed(gcn::KeyEvent& keyEvent) override final;
+ void keyPressed(KeyEvent& keyEvent) override final;
// Inherited from MouseListener
- void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) override final;
+ void mouseWheelMovedUp(MouseEvent& mouseEvent) override final;
- void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) override final;
+ void mouseWheelMovedDown(MouseEvent& mouseEvent) override final;
- void mousePressed(gcn::MouseEvent &event) override;
+ void mousePressed(MouseEvent &event) override;
- void mouseReleased(gcn::MouseEvent &event) override;
+ void mouseReleased(MouseEvent &event) override;
- void mouseReleased1(const gcn::MouseEvent &event);
+ void mouseReleased1(const MouseEvent &event);
- void mouseDragged(gcn::MouseEvent &event) override;
+ void mouseDragged(MouseEvent &event) override;
void refocus();
@@ -107,9 +110,9 @@ class ListBox : public gcn::ListBox,
{ mRowHeight = n; }
protected:
- gcn::Color mHighlightColor;
- gcn::Color mForegroundSelectedColor;
- gcn::Color mForegroundSelectedColor2;
+ Color mHighlightColor;
+ Color mForegroundSelectedColor;
+ Color mForegroundSelectedColor2;
int mOldSelected;
int mPadding;
int mPressedIndex;
diff --git a/src/gui/widgets/passwordfield.cpp b/src/gui/widgets/passwordfield.cpp
index b2ee6ccad..1b562b7f0 100644
--- a/src/gui/widgets/passwordfield.cpp
+++ b/src/gui/widgets/passwordfield.cpp
@@ -31,7 +31,7 @@ PasswordField::PasswordField(const Widget2 *const widget,
{
}
-void PasswordField::draw(gcn::Graphics *graphics)
+void PasswordField::draw(Graphics *graphics)
{
BLOCK_START("PasswordField::draw")
// std::string uses cow, thus cheap copy
diff --git a/src/gui/widgets/passwordfield.h b/src/gui/widgets/passwordfield.h
index 322d71b8b..f72350763 100644
--- a/src/gui/widgets/passwordfield.h
+++ b/src/gui/widgets/passwordfield.h
@@ -44,7 +44,7 @@ class PasswordField final : public TextField
/**
* Draws the password field.
*/
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
protected:
int mPasswordChar;
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
index 6fda932bf..7ef543511 100644
--- a/src/gui/widgets/playerbox.cpp
+++ b/src/gui/widgets/playerbox.cpp
@@ -26,14 +26,17 @@
#include "being/being.h"
+#include "gui/gui.h"
+
#include "resources/image.h"
#include "debug.h"
-PlayerBox::PlayerBox(Being *const being, const std::string &skin,
+PlayerBox::PlayerBox(Widget2 *const widget,
+ Being *const being,
+ const std::string &skin,
const std::string &selectedSkin) :
- Widget2(),
- ScrollArea(),
+ ScrollArea(widget),
mBeing(being),
mAlpha(1.0),
mBackground(),
@@ -48,9 +51,10 @@ PlayerBox::PlayerBox(Being *const being, const std::string &skin,
init(skin, selectedSkin);
}
-PlayerBox::PlayerBox(const std::string &skin,
+PlayerBox::PlayerBox(Widget2 *const widget,
+ const std::string &skin,
const std::string &selectedSkin) :
- ScrollArea(),
+ ScrollArea(widget),
mBeing(nullptr),
mAlpha(1.0),
mBackground(),
@@ -107,7 +111,7 @@ void PlayerBox::init(std::string name, std::string selectedName)
}
}
-void PlayerBox::draw(gcn::Graphics *graphics)
+void PlayerBox::draw(Graphics *graphics)
{
BLOCK_START("PlayerBox::draw")
if (mBeing)
@@ -115,7 +119,7 @@ void PlayerBox::draw(gcn::Graphics *graphics)
const int bs = mFrameSize;
const int x = mDimension.width / 2 + bs + mOffsetX;
const int y = mDimension.height - bs + mOffsetY;
- mBeing->drawSpriteAt(static_cast<Graphics*>(graphics), x, y);
+ mBeing->drawSpriteAt(graphics, x, y);
}
if (client->getGuiAlpha() != mAlpha)
@@ -130,7 +134,7 @@ void PlayerBox::draw(gcn::Graphics *graphics)
BLOCK_END("PlayerBox::draw")
}
-void PlayerBox::drawFrame(gcn::Graphics *graphics)
+void PlayerBox::drawFrame(Graphics *graphics)
{
BLOCK_START("PlayerBox::drawFrame")
if (mDrawBackground)
@@ -140,23 +144,17 @@ void PlayerBox::drawFrame(gcn::Graphics *graphics)
const int h = mDimension.height + bs;
if (!mSelected)
- {
- static_cast<Graphics*>(graphics)->drawImageRect(
- 0, 0, w, h, mBackground);
- }
+ graphics->drawImageRect(0, 0, w, h, mBackground);
else
- {
- static_cast<Graphics*>(graphics)->drawImageRect(
- 0, 0, w, h, mSelectedBackground);
- }
+ graphics->drawImageRect(0, 0, w, h, mSelectedBackground);
}
BLOCK_END("PlayerBox::drawFrame")
}
-void PlayerBox::mouseReleased(gcn::MouseEvent& event)
+void PlayerBox::mouseReleased(MouseEvent& event)
{
ScrollArea::mouseReleased(event);
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ if (event.getButton() == MouseEvent::LEFT)
{
if (!mActionEventId.empty())
distributeActionEvent();
diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h
index 3ebae9be4..7481dc9db 100644
--- a/src/gui/widgets/playerbox.h
+++ b/src/gui/widgets/playerbox.h
@@ -23,9 +23,7 @@
#ifndef GUI_WIDGETS_PLAYERBOX_H
#define GUI_WIDGETS_PLAYERBOX_H
-#include "gui/widgets/widget2.h"
-
-#include <guichan/widgets/scrollarea.hpp>
+#include "gui/base/widgets/scrollarea.hpp"
#include "localconsts.h"
@@ -37,18 +35,20 @@ class Skin;
*
* \ingroup GUI
*/
-class PlayerBox final : public Widget2,
- public gcn::ScrollArea
+class PlayerBox final : public gcn::ScrollArea
{
public:
/**
* Constructor. Takes the initial player character that this box should
* display, which defaults to <code>NULL</code>.
*/
- explicit PlayerBox(Being *const being, const std::string &skin = "",
+ explicit PlayerBox(Widget2 *const widget,
+ Being *const being,
+ const std::string &skin = "",
const std::string &selectedSkin = "");
- explicit PlayerBox(const std::string &skin = "",
+ explicit PlayerBox(Widget2 *const widget,
+ const std::string &skin = "",
const std::string &selectedSkin = "");
A_DELETE_COPY(PlayerBox)
@@ -71,12 +71,12 @@ class PlayerBox final : public Widget2,
/**
* Draws the scroll area.
*/
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
/**
* Draws the background and border of the scroll area.
*/
- void drawFrame(gcn::Graphics *graphics) override final;
+ void drawFrame(Graphics *graphics) override final;
Being *getBeing() A_WARN_UNUSED
{ return mBeing; }
@@ -84,7 +84,7 @@ class PlayerBox final : public Widget2,
void setSelected(bool b)
{ mSelected = b; }
- void mouseReleased(gcn::MouseEvent& event) override final;
+ void mouseReleased(MouseEvent& event) override final;
private:
Being *mBeing;
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index 1ba4083cd..1114b4a5e 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -27,15 +27,13 @@
#include "gui/viewport.h"
-#include <guichan/exception.hpp>
-
#include "debug.h"
Popup::Popup(const std::string &name,
std::string skin) :
Container(nullptr),
- gcn::MouseListener(),
- gcn::WidgetListener(),
+ MouseListener(),
+ WidgetListener(),
mPadding(3),
mSkin(nullptr),
mPopupName(name),
@@ -48,9 +46,6 @@ Popup::Popup(const std::string &name,
{
logger->log("Popup::Popup(\"%s\")", name.c_str());
- if (!windowContainer)
- throw GCN_EXCEPTION("Popup::Popup(): no windowContainer set");
-
addWidgetListener(this);
if (skin == "")
@@ -67,7 +62,8 @@ Popup::Popup(const std::string &name,
}
}
- windowContainer->add(this);
+ if (windowContainer)
+ windowContainer->add(this);
// Popups are invisible by default
setVisible(false);
@@ -94,10 +90,9 @@ void Popup::setWindowContainer(WindowContainer *const wc)
windowContainer = wc;
}
-void Popup::draw(gcn::Graphics *graphics)
+void Popup::draw(Graphics *graphics)
{
BLOCK_START("Popup::draw")
- Graphics *const g = static_cast<Graphics*>(graphics);
if (mSkin)
{
@@ -107,16 +102,18 @@ void Popup::draw(gcn::Graphics *graphics)
{
mRedraw = false;
mVertexes->clear();
- g->calcWindow(mVertexes, 0, 0,
+ graphics->calcWindow(mVertexes,
+ 0, 0,
mDimension.width, mDimension.height,
mSkin->getBorder());
}
- g->drawTileCollection(mVertexes);
+ graphics->drawTileCollection(mVertexes);
}
else
{
- g->drawImageRect(0, 0, mDimension.width, mDimension.height,
+ graphics->drawImageRect(0, 0,
+ mDimension.width, mDimension.height,
mSkin->getBorder());
}
}
@@ -125,10 +122,10 @@ void Popup::draw(gcn::Graphics *graphics)
BLOCK_END("Popup::draw")
}
-gcn::Rectangle Popup::getChildrenArea()
+Rect Popup::getChildrenArea()
{
const int pad2 = mPadding * 2;
- return gcn::Rectangle(mPadding, mPadding,
+ return Rect(mPadding, mPadding,
mDimension.width - pad2, mDimension.height - pad2);
}
@@ -151,7 +148,7 @@ void Popup::setContentSize(int width, int height)
mRedraw = true;
}
-void Popup::setLocationRelativeTo(const gcn::Widget *const widget)
+void Popup::setLocationRelativeTo(const Widget *const widget)
{
if (!widget)
return;
@@ -230,7 +227,7 @@ void Popup::position(const int x, const int y)
mRedraw = true;
}
-void Popup::mouseMoved(gcn::MouseEvent &event A_UNUSED)
+void Popup::mouseMoved(MouseEvent &event A_UNUSED)
{
if (viewport)
viewport->hideBeingPopup();
@@ -243,12 +240,12 @@ void Popup::hide()
mRedraw = true;
}
-void Popup::widgetResized(const gcn::Event &event A_UNUSED)
+void Popup::widgetResized(const Event &event A_UNUSED)
{
mRedraw = true;
}
-void Popup::widgetMoved(const gcn::Event &event A_UNUSED)
+void Popup::widgetMoved(const Event &event A_UNUSED)
{
mRedraw = true;
}
diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h
index 711ac97b7..01247cf61 100644
--- a/src/gui/widgets/popup.h
+++ b/src/gui/widgets/popup.h
@@ -26,8 +26,8 @@
#include "gui/widgets/container.h"
-#include <guichan/mouselistener.hpp>
-#include <guichan/widgetlistener.hpp>
+#include "listeners/mouselistener.h"
+#include "listeners/widgetlistener.h"
class ImageCollection;
class Skin;
@@ -45,8 +45,9 @@ class WindowContainer;
*
* \ingroup GUI
*/
-class Popup : public Container, public gcn::MouseListener,
- public gcn::WidgetListener
+class Popup : public Container,
+ public MouseListener,
+ public WidgetListener
{
public:
/**
@@ -75,7 +76,7 @@ class Popup : public Container, public gcn::MouseListener,
/**
* Draws the popup.
*/
- void draw(gcn::Graphics *graphics) override;
+ void draw(Graphics *graphics) override;
/**
* Sets the size of this popup.
@@ -85,9 +86,9 @@ class Popup : public Container, public gcn::MouseListener,
/**
* Sets the location relative to the given widget.
*/
- void setLocationRelativeTo(const gcn::Widget *const widget);
+ void setLocationRelativeTo(const Widget *const widget);
- void mouseMoved(gcn::MouseEvent &event) override;
+ void mouseMoved(MouseEvent &event) override;
/**
* Sets the minimum width of the popup.
@@ -151,7 +152,7 @@ class Popup : public Container, public gcn::MouseListener,
// Inherited from BasicContainer
- virtual gcn::Rectangle getChildrenArea() override;
+ virtual Rect getChildrenArea() override;
/**
* Sets the location to display the popup. Tries to horizontally center
@@ -163,9 +164,9 @@ class Popup : public Container, public gcn::MouseListener,
void hide();
- void widgetResized(const gcn::Event &event) override;
+ void widgetResized(const Event &event) override;
- void widgetMoved(const gcn::Event &event) override final;
+ void widgetMoved(const Event &event) override final;
bool isPopupVisible() const
{ return mVisible; }
diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp
index f7f8afc66..cfb973384 100644
--- a/src/gui/widgets/popuplist.cpp
+++ b/src/gui/widgets/popuplist.cpp
@@ -29,15 +29,15 @@
#include "debug.h"
PopupList::PopupList(DropDown *const widget,
- gcn::ListModel *const listModel,
+ ListModel *const listModel,
bool extended, bool modal):
Popup("PopupList", "popuplist.xml"),
- gcn::FocusListener(),
+ FocusListener(),
mListModel(listModel),
mListBox(extended ? new ExtendedListBox(
widget, listModel, "extendedlistbox.xml", 0) :
new ListBox(widget, listModel, "popuplistbox.xml")),
- mScrollArea(new ScrollArea(mListBox, false)),
+ mScrollArea(new ScrollArea(this, mListBox, false)),
mDropDown(widget),
mPressedIndex(-2),
mModal(modal)
@@ -90,7 +90,7 @@ void PopupList::show(int x, int y)
requestModalFocus();
}
-void PopupList::widgetResized(const gcn::Event &event)
+void PopupList::widgetResized(const Event &event)
{
Popup::widgetResized(event);
adjustSize();
@@ -112,7 +112,7 @@ int PopupList::getSelected() const
return mListBox->getSelected();
}
-void PopupList::setListModel(gcn::ListModel *const model)
+void PopupList::setListModel(ListModel *const model)
{
if (mListBox)
mListBox->setListModel(model);
@@ -129,13 +129,13 @@ void PopupList::adjustSize()
mListBox->setWidth(width);
}
-void PopupList::mousePressed(gcn::MouseEvent& mouseEvent)
+void PopupList::mousePressed(MouseEvent& mouseEvent)
{
mPressedIndex = mListBox->getSelectionByMouse(
mouseEvent.getY() + mPadding);
}
-void PopupList::mouseReleased(gcn::MouseEvent& mouseEvent)
+void PopupList::mouseReleased(MouseEvent& mouseEvent)
{
if (mPressedIndex != mListBox->getSelectionByMouse(
mouseEvent.getY() + mPadding))
@@ -154,9 +154,9 @@ void PopupList::mouseReleased(gcn::MouseEvent& mouseEvent)
releaseModalFocus();
}
-void PopupList::focusGained(const gcn::Event& event)
+void PopupList::focusGained(const Event& event)
{
- const gcn::Widget *const source = event.getSource();
+ const Widget *const source = event.getSource();
if (!mVisible || source == this || source == mListBox
|| source == mScrollArea || source == mDropDown)
{
@@ -170,7 +170,7 @@ void PopupList::focusGained(const gcn::Event& event)
releaseModalFocus();
}
-void PopupList::focusLost(const gcn::Event& event A_UNUSED)
+void PopupList::focusLost(const Event& event A_UNUSED)
{
if (mDropDown)
mDropDown->updateSelection();
diff --git a/src/gui/widgets/popuplist.h b/src/gui/widgets/popuplist.h
index f41b9f631..32a9dfc47 100644
--- a/src/gui/widgets/popuplist.h
+++ b/src/gui/widgets/popuplist.h
@@ -23,21 +23,21 @@
#include "gui/widgets/popup.h"
-#include <guichan/focuslistener.hpp>
-#include <guichan/listmodel.hpp>
+#include "listeners/focuslistener.h"
#include "localconsts.h"
class DropDown;
class ListBox;
+class ListModel;
class ScrollArea;
class PopupList final : public Popup,
- public gcn::FocusListener
+ public FocusListener
{
public:
PopupList(DropDown *const widget,
- gcn::ListModel *const listModel, bool extended,
+ ListModel *const listModel, bool extended,
bool modal = false);
~PopupList();
@@ -48,29 +48,29 @@ class PopupList final : public Popup,
void show(int x, int y);
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
void setSelected(int selected);
int getSelected() const;
- void setListModel(gcn::ListModel *const model);
+ void setListModel(ListModel *const model);
- gcn::ListModel *getListModel() const
+ ListModel *getListModel() const
{ return mListModel; }
void adjustSize();
- void focusGained(const gcn::Event& event A_UNUSED) override final;
+ void focusGained(const Event& event A_UNUSED) override final;
- void focusLost(const gcn::Event& event A_UNUSED) override final;
+ void focusLost(const Event& event A_UNUSED) override final;
- void mousePressed(gcn::MouseEvent& mouseEvent) override final;
+ void mousePressed(MouseEvent& mouseEvent) override final;
- void mouseReleased(gcn::MouseEvent& mouseEvent) override final;
+ void mouseReleased(MouseEvent& mouseEvent) override final;
private:
- gcn::ListModel *mListModel;
+ ListModel *mListModel;
ListBox *mListBox;
ScrollArea *mScrollArea;
DropDown *mDropDown;
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index 38257e0a8..5bccd61ca 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -25,23 +25,23 @@
#include "client.h"
#include "graphicsvertexes.h"
+#include "gui/font.h"
#include "gui/gui.h"
-#include "gui/sdlfont.h"
-
-#include <guichan/font.hpp>
#include "debug.h"
int ProgressBar::mInstances = 0;
float ProgressBar::mAlpha = 1.0;
-ProgressBar::ProgressBar(const Widget2 *const widget, float progress,
- const int width, const int height,
+ProgressBar::ProgressBar(const Widget2 *const widget,
+ float progress,
+ const int width,
+ const int height,
const int backColor,
- const std::string &skin, const std::string &skinFill):
- gcn::Widget(),
- Widget2(widget),
- gcn::WidgetListener(),
+ const std::string &skin,
+ const std::string &skinFill):
+ Widget(widget),
+ WidgetListener(),
mFillRect(),
mSkin(nullptr),
mProgress(progress),
@@ -146,12 +146,12 @@ void ProgressBar::updateAlpha()
mAlpha = alpha;
}
-void ProgressBar::draw(gcn::Graphics *graphics)
+void ProgressBar::draw(Graphics *graphics)
{
BLOCK_START("ProgressBar::draw")
updateAlpha();
mBackgroundColor.a = static_cast<int>(mAlpha * 255);
- render(static_cast<Graphics*>(graphics));
+ render(graphics);
BLOCK_END("ProgressBar::draw")
}
@@ -184,7 +184,7 @@ void ProgressBar::setProgressPalette(const int progressPalette)
}
}
-void ProgressBar::setBackgroundColor(const gcn::Color &color)
+void ProgressBar::setBackgroundColor(const Color &color)
{
mRedraw = true;
mBackgroundColorToGo = color;
@@ -193,7 +193,7 @@ void ProgressBar::setBackgroundColor(const gcn::Color &color)
mBackgroundColor = color;
}
-void ProgressBar::setColor(const gcn::Color &color1, const gcn::Color &color2)
+void ProgressBar::setColor(const Color &color1, const Color &color2)
{
mForegroundColor = color1;
mForegroundColor2 = color2;
@@ -261,7 +261,7 @@ void ProgressBar::render(Graphics *graphics)
{
if (width > maxWidth)
width = maxWidth;
- graphics->fillRectangle(gcn::Rectangle(mFillPadding, mFillPadding,
+ graphics->fillRectangle(Rect(mFillPadding, mFillPadding,
width, mDimension.height - pad));
}
}
@@ -269,9 +269,9 @@ void ProgressBar::render(Graphics *graphics)
// The label
if (!mText.empty())
{
- const gcn::Color oldColor = graphics->getColor();
+ const Color oldColor = graphics->getColor();
- gcn::Font *const font = gui->getFont();
+ Font *const font = gui->getFont();
const int textX = mDimension.width / 2;
const int textY = (mDimension.height - font->getHeight()) / 2;
@@ -283,12 +283,12 @@ void ProgressBar::render(Graphics *graphics)
}
}
-void ProgressBar::widgetResized(const gcn::Event &event A_UNUSED)
+void ProgressBar::widgetResized(const Event &event A_UNUSED)
{
mRedraw = true;
}
-void ProgressBar::widgetMoved(const gcn::Event &event A_UNUSED)
+void ProgressBar::widgetMoved(const Event &event A_UNUSED)
{
mRedraw = true;
}
diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h
index eefabe83a..fef9bf11d 100644
--- a/src/gui/widgets/progressbar.h
+++ b/src/gui/widgets/progressbar.h
@@ -23,10 +23,9 @@
#ifndef GUI_WIDGETS_PROGRESSBAR_H
#define GUI_WIDGETS_PROGRESSBAR_H
-#include "gui/widgets/widget2.h"
+#include "gui/widgets/widget.h"
-#include <guichan/widget.hpp>
-#include <guichan/widgetlistener.hpp>
+#include "listeners/widgetlistener.h"
#include <string>
@@ -40,18 +39,20 @@ class Skin;
*
* \ingroup GUI
*/
-class ProgressBar final : public gcn::Widget,
- public Widget2,
- public gcn::WidgetListener
+class ProgressBar final : public Widget,
+ public WidgetListener
{
public:
/**
* Constructor, initializes the progress with the given value.
*/
- ProgressBar(const Widget2 *const widget, float progress,
- const int width, const int height,
+ ProgressBar(const Widget2 *const widget,
+ float progress,
+ const int width,
+ const int height,
const int backColor,
- const std::string &skin, const std::string &skinFill);
+ const std::string &skin,
+ const std::string &skinFill);
A_DELETE_COPY(ProgressBar)
@@ -70,7 +71,7 @@ class ProgressBar final : public gcn::Widget,
/**
* Draws the progress bar.
*/
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
/**
* Sets the current progress.
@@ -92,14 +93,14 @@ class ProgressBar final : public gcn::Widget,
/**
* Change the color of the progress bar.
*/
- void setBackgroundColor(const gcn::Color &color);
+ void setBackgroundColor(const Color &color);
- void setColor(const gcn::Color &color1, const gcn::Color &color2);
+ void setColor(const Color &color1, const Color &color2);
/**
* Returns the color of the progress bar.
*/
- const gcn::Color &getBackgroundColor() const A_WARN_UNUSED
+ const Color &getBackgroundColor() const A_WARN_UNUSED
{ return mBackgroundColor; }
/**
@@ -131,9 +132,9 @@ class ProgressBar final : public gcn::Widget,
*/
void render(Graphics *graphics);
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
- void widgetMoved(const gcn::Event &event) override final;
+ void widgetMoved(const Event &event) override final;
void setPadding(unsigned int padding)
{ mPadding = padding; }
@@ -144,7 +145,7 @@ class ProgressBar final : public gcn::Widget,
float mProgress;
float mProgressToGo;
- gcn::Color mBackgroundColorToGo;
+ Color mBackgroundColorToGo;
std::string mText;
ImageCollection *mVertexes;
diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp
index d89ff7f2a..8e86417bd 100644
--- a/src/gui/widgets/progressindicator.cpp
+++ b/src/gui/widgets/progressindicator.cpp
@@ -23,14 +23,15 @@
#include "simpleanimation.h"
+#include "gui/gui.h"
+
#include "resources/animation.h"
#include "resources/imageset.h"
#include "debug.h"
-ProgressIndicator::ProgressIndicator() :
- gcn::Widget(),
- Widget2(),
+ProgressIndicator::ProgressIndicator(Widget2 *const widget) :
+ Widget(widget),
mIndicator(nullptr)
{
ImageSet *const images = Theme::getImageSetFromTheme(
@@ -65,7 +66,7 @@ void ProgressIndicator::logic()
BLOCK_END("ProgressIndicator::logic")
}
-void ProgressIndicator::draw(gcn::Graphics *graphics)
+void ProgressIndicator::draw(Graphics *graphics)
{
BLOCK_START("ProgressIndicator::draw")
if (mIndicator)
@@ -73,7 +74,7 @@ void ProgressIndicator::draw(gcn::Graphics *graphics)
// Draw the indicator centered on the widget
const int x = (mDimension.width - 32) / 2;
const int y = (mDimension.height - 32) / 2;
- mIndicator->draw(static_cast<Graphics*>(graphics), x, y);
+ mIndicator->draw(graphics, x, y);
}
BLOCK_END("ProgressIndicator::draw")
}
diff --git a/src/gui/widgets/progressindicator.h b/src/gui/widgets/progressindicator.h
index 61a72dd67..447c3d4e4 100644
--- a/src/gui/widgets/progressindicator.h
+++ b/src/gui/widgets/progressindicator.h
@@ -22,9 +22,7 @@
#ifndef GUI_WIDGETS_PROGRESSINDICATOR_H
#define GUI_WIDGETS_PROGRESSINDICATOR_H
-#include "gui/widgets/widget2.h"
-
-#include <guichan/widget.hpp>
+#include "gui/widgets/widget.h"
#include "localconsts.h"
@@ -34,11 +32,10 @@ class SimpleAnimation;
* A widget that indicates progress. Suitable to use instead of a progress bar
* in cases where it is unknown how long something is going to take.
*/
-class ProgressIndicator final : public gcn::Widget,
- public Widget2
+class ProgressIndicator final : public Widget
{
public:
- ProgressIndicator();
+ explicit ProgressIndicator(Widget2 *const widget);
A_DELETE_COPY(ProgressIndicator)
@@ -46,7 +43,7 @@ class ProgressIndicator final : public gcn::Widget,
void logic() override final;
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
private:
SimpleAnimation *mIndicator;
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp
index e0643a8ac..bb9ae46f9 100644
--- a/src/gui/widgets/radiobutton.cpp
+++ b/src/gui/widgets/radiobutton.cpp
@@ -24,12 +24,14 @@
#include "client.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
#include "resources/image.h"
-#include <guichan/font.hpp>
+#include "gui/font.h"
+#include "gui/gui.h"
#include "debug.h"
@@ -41,8 +43,7 @@ RadioButton::RadioButton(const Widget2 *const widget,
const std::string &restrict caption,
const std::string &restrict group,
const bool marked):
- gcn::RadioButton(caption, group, marked),
- Widget2(widget),
+ gcn::RadioButton(widget, caption, group, marked),
mPadding(0),
mImagePadding(0),
mImageSize(9),
@@ -110,7 +111,7 @@ void RadioButton::updateAlpha()
}
}
-void RadioButton::drawBox(gcn::Graphics* graphics)
+void RadioButton::drawBox(Graphics* graphics)
{
if (!mSkin)
return;
@@ -149,38 +150,37 @@ void RadioButton::drawBox(gcn::Graphics* graphics)
if (box)
{
- static_cast<Graphics*>(graphics)->drawImage2(
- box, mImagePadding, (getHeight() - mImageSize) / 2);
+ graphics->drawImage(box,
+ mImagePadding,
+ (getHeight() - mImageSize) / 2);
}
}
-void RadioButton::draw(gcn::Graphics* graphics)
+void RadioButton::draw(Graphics* graphics)
{
BLOCK_START("RadioButton::draw")
drawBox(graphics);
- gcn::Font *const font = getFont();
- static_cast<Graphics *const>(graphics)->setColorAll(
- mForegroundColor, mForegroundColor2);
-
+ Font *const font = getFont();
+ graphics->setColorAll(mForegroundColor, mForegroundColor2);
font->drawString(graphics, mCaption, mPadding + mImageSize + mSpacing,
mPadding);
BLOCK_END("RadioButton::draw")
}
-void RadioButton::mouseEntered(gcn::MouseEvent& event A_UNUSED)
+void RadioButton::mouseEntered(MouseEvent& event A_UNUSED)
{
mHasMouse = true;
}
-void RadioButton::mouseExited(gcn::MouseEvent& event A_UNUSED)
+void RadioButton::mouseExited(MouseEvent& event A_UNUSED)
{
mHasMouse = false;
}
-void RadioButton::keyPressed(gcn::KeyEvent& keyEvent)
+void RadioButton::keyPressed(KeyEvent& keyEvent)
{
- const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int action = keyEvent.getActionId();
if (action == Input::KEY_GUI_SELECT)
{
setSelected(true);
@@ -191,7 +191,7 @@ void RadioButton::keyPressed(gcn::KeyEvent& keyEvent)
void RadioButton::adjustSize()
{
- gcn::Font *const font = getFont();
+ Font *const font = getFont();
setHeight(font->getHeight() + 2 * mPadding);
setWidth(mImagePadding + mImageSize + mSpacing
+ font->getWidth(mCaption) + mPadding);
diff --git a/src/gui/widgets/radiobutton.h b/src/gui/widgets/radiobutton.h
index f5ff43f4c..2deb9a772 100644
--- a/src/gui/widgets/radiobutton.h
+++ b/src/gui/widgets/radiobutton.h
@@ -23,9 +23,7 @@
#ifndef GUI_WIDGETS_RADIOBUTTON_H
#define GUI_WIDGETS_RADIOBUTTON_H
-#include "gui/widgets/widget2.h"
-
-#include <guichan/widgets/radiobutton.hpp>
+#include "gui/base/widgets/radiobutton.hpp"
#include "localconsts.h"
@@ -34,8 +32,7 @@ class Skin;
/**
* Guichan based RadioButton with custom look
*/
-class RadioButton final : public gcn::RadioButton,
- public Widget2
+class RadioButton final : public gcn::RadioButton
{
public:
/**
@@ -56,25 +53,25 @@ class RadioButton final : public gcn::RadioButton,
/**
* Draws the radiobutton, not the caption.
*/
- void drawBox(gcn::Graphics* graphics) override final;
+ void drawBox(Graphics* graphics) override final;
/**
* Implementation of the draw methods.
* Thus, avoiding the rhomb around the radio button.
*/
- void draw(gcn::Graphics* graphics) override final;
+ void draw(Graphics* graphics) override final;
/**
* Called when the mouse enteres the widget area.
*/
- void mouseEntered(gcn::MouseEvent& event) override final;
+ void mouseEntered(MouseEvent& event) override final;
/**
* Called when the mouse leaves the widget area.
*/
- void mouseExited(gcn::MouseEvent& event) override final;
+ void mouseExited(MouseEvent& event) override final;
- void keyPressed(gcn::KeyEvent& keyEvent) override final;
+ void keyPressed(KeyEvent& keyEvent) override final;
void updateAlpha();
diff --git a/src/gui/widgets/radiogroup.cpp b/src/gui/widgets/radiogroup.cpp
index d2f130c1b..9bb4f40c5 100644
--- a/src/gui/widgets/radiogroup.cpp
+++ b/src/gui/widgets/radiogroup.cpp
@@ -31,7 +31,7 @@ RadioGroup::RadioGroup(const Widget2 *const widget,
{
}
-gcn::Widget *RadioGroup::createWidget(const std::string &text) const
+Widget *RadioGroup::createWidget(const std::string &text) const
{
RadioButton *const widget = new RadioButton(
this, text, mGroup, mCount == 0);
diff --git a/src/gui/widgets/radiogroup.h b/src/gui/widgets/radiogroup.h
index 1863a348c..41193b3d6 100644
--- a/src/gui/widgets/radiogroup.h
+++ b/src/gui/widgets/radiogroup.h
@@ -23,19 +23,18 @@
#include "gui/widgets/widgetgroup.h"
-#include <guichan/widget.hpp>
-
class RadioGroup final : public WidgetGroup
{
public:
RadioGroup(const Widget2 *const widget,
- const std::string &group, const int height,
+ const std::string &group,
+ const int height,
const int spacing);
A_DELETE_COPY(RadioGroup)
- gcn::Widget *createWidget(const std::string &name)
- const override final A_WARN_UNUSED;
+ Widget *createWidget(const std::string &name)
+ const override final A_WARN_UNUSED;
};
#endif // GUI_WIDGETS_RADIOGROUP_H
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index a260142a1..dcc3a871b 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -25,6 +25,10 @@
#include "client.h"
#include "graphicsvertexes.h"
+#include "gui/gui.h"
+
+#include "resources/image.h"
+
#include "debug.h"
int ScrollArea::instances = 0;
@@ -45,31 +49,12 @@ static std::string const buttonFiles[2] =
"scrollbuttons_pressed.xml"
};
-ScrollArea::ScrollArea(const bool opaque, const std::string &skin) :
- gcn::ScrollArea(),
- gcn::WidgetListener(),
- mX(0),
- mY(0),
- mClickX(0),
- mClickY(0),
- mVertexes(new ImageCollection),
- mVertexes2(new ImageCollection),
- mXOffset(0),
- mYOffset(0),
- mDrawWidth(0),
- mDrawHeight(0),
- mHasMouse(false),
- mRedraw(true)
-{
- mOpaque = opaque;
- addWidgetListener(this);
- init(skin);
-}
-
-ScrollArea::ScrollArea(gcn::Widget *const widget, const bool opaque,
+ScrollArea::ScrollArea(Widget2 *const widget2,
+ Widget *const widget,
+ const bool opaque,
const std::string &skin) :
- gcn::ScrollArea(widget),
- gcn::WidgetListener(),
+ gcn::ScrollArea(widget2, widget),
+ WidgetListener(),
mX(0),
mY(0),
mClickX(0),
@@ -194,7 +179,7 @@ void ScrollArea::logic()
}
gcn::ScrollArea::logic();
- gcn::Widget *const content = getContent();
+ Widget *const content = getContent();
// When no scrollbar in a certain direction, adapt content size to match
// the content dimension exactly.
@@ -248,7 +233,7 @@ void ScrollArea::updateAlpha()
}
}
-void ScrollArea::draw(gcn::Graphics *graphics)
+void ScrollArea::draw(Graphics *graphics)
{
BLOCK_START("ScrollArea::draw")
if (mVBarVisible || mHBarVisible)
@@ -282,8 +267,7 @@ void ScrollArea::draw(gcn::Graphics *graphics)
calcHMarker(graphics);
}
}
- static_cast<Graphics *const>(graphics)->drawTileCollection(
- mVertexes);
+ graphics->drawTileCollection(mVertexes);
}
else
{
@@ -315,11 +299,10 @@ void ScrollArea::draw(gcn::Graphics *graphics)
if (mRedraw)
{
- Graphics *g = static_cast<Graphics *const>(graphics);
- const bool redraw = g->getRedraw();
- g->setRedraw(true);
+ const bool redraw = graphics->getRedraw();
+ graphics->setRedraw(true);
drawChildren(graphics);
- g->setRedraw(redraw);
+ graphics->setRedraw(redraw);
}
else
{
@@ -329,14 +312,13 @@ void ScrollArea::draw(gcn::Graphics *graphics)
BLOCK_END("ScrollArea::draw")
}
-void ScrollArea::updateCalcFlag(gcn::Graphics *const graphics)
+void ScrollArea::updateCalcFlag(Graphics *const graphics)
{
if (!mRedraw)
{
// because we don't know where parent windows was moved,
// need recalc vertexes
- const gcn::ClipRectangle &rect = static_cast<Graphics*>(
- graphics)->getTopClip();
+ const ClipRect &rect = graphics->getTopClip();
if (rect.xOffset != mXOffset || rect.yOffset != mYOffset)
{
mRedraw = true;
@@ -349,14 +331,14 @@ void ScrollArea::updateCalcFlag(gcn::Graphics *const graphics)
mDrawWidth = rect.width;
mDrawHeight = rect.height;
}
- else if (static_cast<Graphics*>(graphics)->getRedraw())
+ else if (graphics->getRedraw())
{
mRedraw = true;
}
}
}
-void ScrollArea::drawFrame(gcn::Graphics *graphics)
+void ScrollArea::drawFrame(Graphics *graphics)
{
BLOCK_START("ScrollArea::drawFrame")
if (mOpaque)
@@ -372,15 +354,18 @@ void ScrollArea::drawFrame(gcn::Graphics *graphics)
if (mRedraw)
{
mVertexes2->clear();
- static_cast<Graphics*>(graphics)->calcWindow(
- mVertexes2, 0, 0, w, h, background);
+ graphics->calcWindow(mVertexes2,
+ 0, 0,
+ w, h,
+ background);
}
- static_cast<Graphics*>(graphics)->drawTileCollection(mVertexes2);
+ graphics->drawTileCollection(mVertexes2);
}
else
{
- static_cast<Graphics*>(graphics)->drawImageRect(
- 0, 0, w, h, background);
+ graphics->drawImageRect(0, 0,
+ w, h,
+ background);
}
}
BLOCK_END("ScrollArea::drawFrame")
@@ -392,11 +377,11 @@ void ScrollArea::setOpaque(bool opaque)
setFrameSize(mOpaque ? 2 : 0);
}
-void ScrollArea::drawButton(gcn::Graphics *const graphics,
+void ScrollArea::drawButton(Graphics *const graphics,
const BUTTON_DIR dir)
{
int state = 0;
- gcn::Rectangle dim;
+ Rect dim;
switch (dir)
{
@@ -424,17 +409,14 @@ void ScrollArea::drawButton(gcn::Graphics *const graphics,
}
if (buttons[dir][state])
- {
- static_cast<Graphics*>(graphics)->drawImage2(
- buttons[dir][state], dim.x, dim.y);
- }
+ graphics->drawImage(buttons[dir][state], dim.x, dim.y);
}
-void ScrollArea::calcButton(gcn::Graphics *const graphics,
+void ScrollArea::calcButton(Graphics *const graphics,
const BUTTON_DIR dir)
{
int state = 0;
- gcn::Rectangle dim;
+ Rect dim;
switch (dir)
{
@@ -468,187 +450,213 @@ void ScrollArea::calcButton(gcn::Graphics *const graphics,
}
}
-void ScrollArea::drawVBar(gcn::Graphics *const graphics)
+void ScrollArea::drawVBar(Graphics *const graphics)
{
- const gcn::Rectangle &dim = getVerticalBarDimension();
- Graphics *const g = static_cast<Graphics*>(graphics);
+ const Rect &dim = getVerticalBarDimension();
if (vBackground.grid[4])
{
- g->drawPattern(vBackground.grid[4],
+ graphics->drawPattern(vBackground.grid[4],
dim.x, dim.y, dim.width, dim.height);
}
if (vBackground.grid[1])
{
- g->drawPattern(vBackground.grid[1],
- dim.x, dim.y, dim.width, vBackground.grid[1]->getHeight());
+ graphics->drawPattern(vBackground.grid[1],
+ dim.x, dim.y,
+ dim.width, vBackground.grid[1]->getHeight());
}
if (vBackground.grid[7])
{
- g->drawPattern(vBackground.grid[7],
+ graphics->drawPattern(vBackground.grid[7],
dim.x, dim.height - vBackground.grid[7]->getHeight() + dim.y,
dim.width, vBackground.grid[7]->getHeight());
}
}
-void ScrollArea::calcVBar(gcn::Graphics *const graphics)
+void ScrollArea::calcVBar(Graphics *const graphics)
{
- const gcn::Rectangle &dim = getVerticalBarDimension();
- Graphics *const g = static_cast<Graphics *const>(graphics);
+ const Rect &dim = getVerticalBarDimension();
if (vBackground.grid[4])
{
- g->calcPattern(mVertexes, vBackground.grid[4],
- dim.x, dim.y, dim.width, dim.height);
+ graphics->calcPattern(mVertexes,
+ vBackground.grid[4],
+ dim.x, dim.y,
+ dim.width, dim.height);
}
if (vBackground.grid[1])
{
- g->calcPattern(mVertexes, vBackground.grid[1],
- dim.x, dim.y, dim.width, vBackground.grid[1]->getHeight());
+ graphics->calcPattern(mVertexes,
+ vBackground.grid[1],
+ dim.x, dim.y,
+ dim.width, vBackground.grid[1]->getHeight());
}
if (vBackground.grid[7])
{
- g->calcPattern(mVertexes, vBackground.grid[7],
+ graphics->calcPattern(mVertexes,
+ vBackground.grid[7],
dim.x, dim.height - vBackground.grid[7]->getHeight() + dim.y,
dim.width, vBackground.grid[7]->getHeight());
}
}
-void ScrollArea::drawHBar(gcn::Graphics *const graphics)
+void ScrollArea::drawHBar(Graphics *const graphics)
{
- const gcn::Rectangle &dim = getHorizontalBarDimension();
- Graphics *const g = static_cast<Graphics*>(graphics);
+ const Rect &dim = getHorizontalBarDimension();
if (hBackground.grid[4])
{
- g->drawPattern(hBackground.grid[4],
- dim.x, dim.y, dim.width, dim.height);
+ graphics->drawPattern(hBackground.grid[4],
+ dim.x, dim.y,
+ dim.width, dim.height);
}
if (hBackground.grid[3])
{
- g->drawPattern(hBackground.grid[3],
- dim.x, dim.y, hBackground.grid[3]->getWidth(), dim.height);
+ graphics->drawPattern(hBackground.grid[3],
+ dim.x, dim.y,
+ hBackground.grid[3]->getWidth(), dim.height);
}
if (hBackground.grid[5])
{
- g->drawPattern(hBackground.grid[5],
- dim.x + dim.width - hBackground.grid[5]->getWidth(), dim.y,
- hBackground.grid[5]->getWidth(), dim.height);
+ graphics->drawPattern(hBackground.grid[5],
+ dim.x + dim.width - hBackground.grid[5]->getWidth(),
+ dim.y,
+ hBackground.grid[5]->getWidth(),
+ dim.height);
}
}
-void ScrollArea::calcHBar(gcn::Graphics *const graphics)
+void ScrollArea::calcHBar(Graphics *const graphics)
{
- const gcn::Rectangle &dim = getHorizontalBarDimension();
- Graphics *const g = static_cast<Graphics*>(graphics);
+ const Rect &dim = getHorizontalBarDimension();
if (hBackground.grid[4])
{
- g->calcPattern(mVertexes, hBackground.grid[4],
- dim.x, dim.y, dim.width, dim.height);
+ graphics->calcPattern(mVertexes,
+ hBackground.grid[4],
+ dim.x, dim.y,
+ dim.width, dim.height);
}
if (hBackground.grid[3])
{
- g->calcPattern(mVertexes, hBackground.grid[3],
- dim.x, dim.y, hBackground.grid[3]->getWidth(), dim.height);
+ graphics->calcPattern(mVertexes,
+ hBackground.grid[3],
+ dim.x, dim.y,
+ hBackground.grid[3]->getWidth(), dim.height);
}
if (hBackground.grid[5])
{
- g->calcPattern(mVertexes, hBackground.grid[5],
- dim.x + dim.width - hBackground.grid[5]->getWidth(), dim.y,
- hBackground.grid[5]->getWidth(), dim.height);
+ graphics->calcPattern(mVertexes,
+ hBackground.grid[5],
+ dim.x + dim.width - hBackground.grid[5]->getWidth(),
+ dim.y,
+ hBackground.grid[5]->getWidth(),
+ dim.height);
}
}
-void ScrollArea::drawVMarker(gcn::Graphics *const graphics)
+void ScrollArea::drawVMarker(Graphics *const graphics)
{
- const gcn::Rectangle &dim = getVerticalMarkerDimension();
+ const Rect &dim = getVerticalMarkerDimension();
if ((mHasMouse) && (mX > (mDimension.width - mScrollbarWidth)))
{
- static_cast<Graphics*>(graphics)->
- drawImageRect(dim.x, dim.y, dim.width, dim.height, vMarkerHi);
+ graphics->drawImageRect(dim.x, dim.y,
+ dim.width, dim.height,
+ vMarkerHi);
}
else
{
- static_cast<Graphics*>(graphics)->
- drawImageRect(dim.x, dim.y, dim.width, dim.height, vMarker);
+ graphics->drawImageRect(dim.x, dim.y,
+ dim.width, dim.height,
+ vMarker);
}
}
-void ScrollArea::calcVMarker(gcn::Graphics *const graphics)
+void ScrollArea::calcVMarker(Graphics *const graphics)
{
- const gcn::Rectangle &dim = getVerticalMarkerDimension();
+ const Rect &dim = getVerticalMarkerDimension();
if ((mHasMouse) && (mX > (mDimension.width - mScrollbarWidth)))
{
- static_cast<Graphics*>(graphics)->calcWindow(
- mVertexes, dim.x, dim.y, dim.width, dim.height, vMarkerHi);
+ graphics->calcWindow(mVertexes,
+ dim.x, dim.y,
+ dim.width, dim.height,
+ vMarkerHi);
}
else
{
- static_cast<Graphics*>(graphics)->calcWindow(
- mVertexes, dim.x, dim.y, dim.width, dim.height, vMarker);
+ graphics->calcWindow(mVertexes,
+ dim.x, dim.y,
+ dim.width, dim.height,
+ vMarker);
}
}
-void ScrollArea::drawHMarker(gcn::Graphics *const graphics)
+void ScrollArea::drawHMarker(Graphics *const graphics)
{
- const gcn::Rectangle dim = getHorizontalMarkerDimension();
+ const Rect dim = getHorizontalMarkerDimension();
if ((mHasMouse) && (mY > (mDimension.height - mScrollbarWidth)))
{
- static_cast<Graphics*>(graphics)->
- drawImageRect(dim.x, dim.y, dim.width, dim.height, vMarkerHi);
+ graphics->drawImageRect(dim.x, dim.y,
+ dim.width, dim.height,
+ vMarkerHi);
}
else
{
- static_cast<Graphics*>(graphics)->
- drawImageRect(dim.x, dim.y, dim.width, dim.height, vMarker);
+ graphics->drawImageRect(
+ dim.x, dim.y,
+ dim.width, dim.height,
+ vMarker);
}
}
-void ScrollArea::calcHMarker(gcn::Graphics *const graphics)
+void ScrollArea::calcHMarker(Graphics *const graphics)
{
- const gcn::Rectangle dim = getHorizontalMarkerDimension();
+ const Rect dim = getHorizontalMarkerDimension();
if ((mHasMouse) && (mY > (mDimension.height - mScrollbarWidth)))
{
- static_cast<Graphics*>(graphics)->calcWindow(
- mVertexes, dim.x, dim.y, dim.width, dim.height, vMarkerHi);
+ graphics->calcWindow(mVertexes,
+ dim.x, dim.y,
+ dim.width, dim.height,
+ vMarkerHi);
}
else
{
- static_cast<Graphics*>(graphics)->calcWindow(
- mVertexes, dim.x, dim.y, dim.width, dim.height, vMarker);
+ graphics->calcWindow(mVertexes,
+ dim.x, dim.y,
+ dim.width, dim.height,
+ vMarker);
}
}
-void ScrollArea::mouseMoved(gcn::MouseEvent& event)
+void ScrollArea::mouseMoved(MouseEvent& event)
{
mX = event.getX();
mY = event.getY();
}
-void ScrollArea::mouseEntered(gcn::MouseEvent& event A_UNUSED)
+void ScrollArea::mouseEntered(MouseEvent& event A_UNUSED)
{
mHasMouse = true;
}
-void ScrollArea::mouseExited(gcn::MouseEvent& event A_UNUSED)
+void ScrollArea::mouseExited(MouseEvent& event A_UNUSED)
{
mHasMouse = false;
}
-void ScrollArea::widgetResized(const gcn::Event &event A_UNUSED)
+void ScrollArea::widgetResized(const Event &event A_UNUSED)
{
mRedraw = true;
const unsigned int frameSize = 2 * mFrameSize;
- gcn::Widget *const content = getContent();
+ Widget *const content = getContent();
if (content)
{
content->setSize(mDimension.width - frameSize,
@@ -656,12 +664,12 @@ void ScrollArea::widgetResized(const gcn::Event &event A_UNUSED)
}
}
-void ScrollArea::widgetMoved(const gcn::Event& event A_UNUSED)
+void ScrollArea::widgetMoved(const Event& event A_UNUSED)
{
mRedraw = true;
}
-void ScrollArea::mousePressed(gcn::MouseEvent& event)
+void ScrollArea::mousePressed(MouseEvent& event)
{
const int x = event.getX();
const int y = event.getY();
@@ -731,16 +739,16 @@ void ScrollArea::mousePressed(gcn::MouseEvent& event)
}
}
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ if (event.getButton() == MouseEvent::LEFT)
{
mClickX = event.getX();
mClickY = event.getY();
}
}
-void ScrollArea::mouseReleased(gcn::MouseEvent& event)
+void ScrollArea::mouseReleased(MouseEvent& event)
{
- if (event.getButton() == gcn::MouseEvent::LEFT && mClickX && mClickY)
+ if (event.getButton() == MouseEvent::LEFT && mClickX && mClickY)
{
if (!event.isConsumed())
{
@@ -799,11 +807,11 @@ void ScrollArea::mouseReleased(gcn::MouseEvent& event)
mRedraw = true;
}
-void ScrollArea::mouseDragged(gcn::MouseEvent &event)
+void ScrollArea::mouseDragged(MouseEvent &event)
{
if (mIsVerticalMarkerDragged)
{
- const gcn::Rectangle barDim = getVerticalBarDimension();
+ const Rect barDim = getVerticalBarDimension();
const int pos = event.getY() - barDim.y
- mVerticalMarkerDragOffset;
@@ -822,7 +830,7 @@ void ScrollArea::mouseDragged(gcn::MouseEvent &event)
if (mIsHorizontalMarkerDragged)
{
- const gcn::Rectangle barDim = getHorizontalBarDimension();
+ const Rect barDim = getHorizontalBarDimension();
const int pos = event.getX() - barDim.x
- mHorizontalMarkerDragOffset;
@@ -843,56 +851,56 @@ void ScrollArea::mouseDragged(gcn::MouseEvent &event)
mRedraw = true;
}
-gcn::Rectangle ScrollArea::getVerticalBarDimension() const
+Rect ScrollArea::getVerticalBarDimension() const
{
if (!mVBarVisible)
- return gcn::Rectangle(0, 0, 0, 0);
+ return Rect(0, 0, 0, 0);
const int height = (mVBarVisible && mShowButtons) ? mScrollbarWidth : 0;
if (mHBarVisible)
{
- return gcn::Rectangle(mDimension.width - mScrollbarWidth,
+ return Rect(mDimension.width - mScrollbarWidth,
height,
mScrollbarWidth,
mDimension.height - 2 * height - mScrollbarWidth);
}
- return gcn::Rectangle(mDimension.width - mScrollbarWidth,
+ return Rect(mDimension.width - mScrollbarWidth,
height,
mScrollbarWidth,
mDimension.height - 2 * height);
}
-gcn::Rectangle ScrollArea::getHorizontalBarDimension() const
+Rect ScrollArea::getHorizontalBarDimension() const
{
if (!mHBarVisible)
- return gcn::Rectangle(0, 0, 0, 0);
+ return Rect(0, 0, 0, 0);
const int width = mShowButtons ? mScrollbarWidth : 0;
if (mVBarVisible)
{
- return gcn::Rectangle(width,
+ return Rect(width,
mDimension.height - mScrollbarWidth,
mDimension.width - 2 * width - mScrollbarWidth,
mScrollbarWidth);
}
- return gcn::Rectangle(width,
+ return Rect(width,
mDimension.height - mScrollbarWidth,
mDimension.width - 2 * width,
mScrollbarWidth);
}
-gcn::Rectangle ScrollArea::getVerticalMarkerDimension()
+Rect ScrollArea::getVerticalMarkerDimension()
{
if (!mVBarVisible)
- return gcn::Rectangle(0, 0, 0, 0);
+ return Rect(0, 0, 0, 0);
int length, pos;
int height;
const int h2 = mShowButtons
? mScrollbarWidth : mMarkerSize / 2;
- const gcn::Widget *content;
+ const Widget *content;
if (!mWidgets.empty())
content = *mWidgets.begin();
else
@@ -937,20 +945,20 @@ gcn::Rectangle ScrollArea::getVerticalMarkerDimension()
pos = 0;
}
- return gcn::Rectangle(mDimension.width - mScrollbarWidth, h2 + pos,
+ return Rect(mDimension.width - mScrollbarWidth, h2 + pos,
mScrollbarWidth, length);
}
-gcn::Rectangle ScrollArea::getHorizontalMarkerDimension()
+Rect ScrollArea::getHorizontalMarkerDimension()
{
if (!mHBarVisible)
- return gcn::Rectangle(0, 0, 0, 0);
+ return Rect(0, 0, 0, 0);
int length, pos;
int width;
const int w2 = mShowButtons
? mScrollbarWidth : mMarkerSize / 2;
- const gcn::Widget *content;
+ const Widget *content;
if (!mWidgets.empty())
content = *mWidgets.begin();
else
@@ -999,61 +1007,61 @@ gcn::Rectangle ScrollArea::getHorizontalMarkerDimension()
}
}
- return gcn::Rectangle(w2 + pos, mDimension.height - mScrollbarWidth,
+ return Rect(w2 + pos, mDimension.height - mScrollbarWidth,
length, mScrollbarWidth);
}
-gcn::Rectangle ScrollArea::getUpButtonDimension() const
+Rect ScrollArea::getUpButtonDimension() const
{
if (!mVBarVisible || !mShowButtons)
- return gcn::Rectangle(0, 0, 0, 0);
+ return Rect(0, 0, 0, 0);
- return gcn::Rectangle(mDimension.width - mScrollbarWidth, 0,
+ return Rect(mDimension.width - mScrollbarWidth, 0,
mScrollbarWidth, mScrollbarWidth);
}
-gcn::Rectangle ScrollArea::getDownButtonDimension() const
+Rect ScrollArea::getDownButtonDimension() const
{
if (!mVBarVisible || !mShowButtons)
- return gcn::Rectangle(0, 0, 0, 0);
+ return Rect(0, 0, 0, 0);
if (mVBarVisible && mHBarVisible)
{
- return gcn::Rectangle(mDimension.width - mScrollbarWidth,
+ return Rect(mDimension.width - mScrollbarWidth,
mDimension.height - mScrollbarWidth*2,
mScrollbarWidth,
mScrollbarWidth);
}
- return gcn::Rectangle(mDimension.width - mScrollbarWidth,
+ return Rect(mDimension.width - mScrollbarWidth,
mDimension.height - mScrollbarWidth,
mScrollbarWidth,
mScrollbarWidth);
}
-gcn::Rectangle ScrollArea::getLeftButtonDimension() const
+Rect ScrollArea::getLeftButtonDimension() const
{
if (!mHBarVisible || !mShowButtons)
- return gcn::Rectangle(0, 0, 0, 0);
+ return Rect(0, 0, 0, 0);
- return gcn::Rectangle(0, mDimension.height - mScrollbarWidth,
+ return Rect(0, mDimension.height - mScrollbarWidth,
mScrollbarWidth, mScrollbarWidth);
}
-gcn::Rectangle ScrollArea::getRightButtonDimension() const
+Rect ScrollArea::getRightButtonDimension() const
{
if (!mHBarVisible || !mShowButtons)
- return gcn::Rectangle(0, 0, 0, 0);
+ return Rect(0, 0, 0, 0);
if (mVBarVisible && mHBarVisible)
{
- return gcn::Rectangle(mDimension.width - mScrollbarWidth*2,
+ return Rect(mDimension.width - mScrollbarWidth*2,
mDimension.height - mScrollbarWidth,
mScrollbarWidth,
mScrollbarWidth);
}
- return gcn::Rectangle(mDimension.width - mScrollbarWidth,
+ return Rect(mDimension.width - mScrollbarWidth,
mDimension.height - mScrollbarWidth,
mScrollbarWidth,
mScrollbarWidth);
diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h
index 13e5e3665..7d2b39a96 100644
--- a/src/gui/widgets/scrollarea.h
+++ b/src/gui/widgets/scrollarea.h
@@ -23,10 +23,9 @@
#ifndef GUI_WIDGETS_SCROLLAREA_H
#define GUI_WIDGETS_SCROLLAREA_H
-#include "gui/widgets/widget2.h"
+#include "gui/base/widgets/scrollarea.hpp"
-#include <guichan/widgets/scrollarea.hpp>
-#include <guichan/widgetlistener.hpp>
+#include "listeners/widgetlistener.h"
#include "localconsts.h"
@@ -43,25 +42,18 @@ class ImageCollection;
* \ingroup GUI
*/
class ScrollArea final : public gcn::ScrollArea,
- public Widget2,
- public gcn::WidgetListener
+ public WidgetListener
{
public:
/**
- * Constructor that takes no content. Needed for use with the DropDown
- * class.
- */
- explicit ScrollArea(const bool opaque = true,
- const std::string &skin = "");
-
- /**
* Constructor.
*
* @param content the initial content to show in the scroll area
*/
- explicit ScrollArea(gcn::Widget *const widget,
- const bool opaque = true,
- const std::string &skin = "");
+ ScrollArea(Widget2 *const widget2,
+ Widget *const widget,
+ const bool opaque = true,
+ const std::string &skin = "");
A_DELETE_COPY(ScrollArea)
@@ -84,12 +76,12 @@ class ScrollArea final : public gcn::ScrollArea,
/**
* Draws the scroll area.
*/
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
/**
* Draws the background and border of the scroll area.
*/
- void drawFrame(gcn::Graphics *graphics) override final;
+ void drawFrame(Graphics *graphics) override final;
/**
* Sets whether the widget should draw its background or not.
@@ -105,43 +97,43 @@ class ScrollArea final : public gcn::ScrollArea,
/**
* Called when the mouse moves in the widget area.
*/
- void mouseMoved(gcn::MouseEvent& event) override final;
+ void mouseMoved(MouseEvent& event) override final;
/**
* Called when the mouse enteres the widget area.
*/
- void mouseEntered(gcn::MouseEvent& event) override final;
+ void mouseEntered(MouseEvent& event) override final;
/**
* Called when the mouse leaves the widget area.
*/
- void mouseExited(gcn::MouseEvent& event) override final;
+ void mouseExited(MouseEvent& event) override final;
- void mousePressed(gcn::MouseEvent& event) override final;
+ void mousePressed(MouseEvent& event) override final;
- void mouseReleased(gcn::MouseEvent& event) override final;
+ void mouseReleased(MouseEvent& event) override final;
- void mouseDragged(gcn::MouseEvent &event) override final;
+ void mouseDragged(MouseEvent &event) override final;
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
- void widgetMoved(const gcn::Event &event) override final;
+ void widgetMoved(const Event &event) override final;
- gcn::Rectangle getVerticalBarDimension() const;
+ Rect getVerticalBarDimension() const;
- gcn::Rectangle getHorizontalBarDimension() const;
+ Rect getHorizontalBarDimension() const;
- gcn::Rectangle getVerticalMarkerDimension();
+ Rect getVerticalMarkerDimension();
- gcn::Rectangle getHorizontalMarkerDimension();
+ Rect getHorizontalMarkerDimension();
- gcn::Rectangle getUpButtonDimension() const;
+ Rect getUpButtonDimension() const;
- gcn::Rectangle getDownButtonDimension() const;
+ Rect getDownButtonDimension() const;
- gcn::Rectangle getLeftButtonDimension() const;
+ Rect getLeftButtonDimension() const;
- gcn::Rectangle getRightButtonDimension() const;
+ Rect getRightButtonDimension() const;
protected:
enum BUTTON_DIR
@@ -158,19 +150,19 @@ class ScrollArea final : public gcn::ScrollArea,
*/
void init(std::string skinName);
- void drawButton(gcn::Graphics *const graphics, const BUTTON_DIR dir);
- void calcButton(gcn::Graphics *const graphics, const BUTTON_DIR dir);
- void drawVBar(gcn::Graphics *const graphics) override final;
- void drawHBar(gcn::Graphics *const graphics) override final;
- void drawVMarker(gcn::Graphics *const graphics) override final;
- void drawHMarker(gcn::Graphics *const graphics) override final;
+ void drawButton(Graphics *const graphics, const BUTTON_DIR dir);
+ void calcButton(Graphics *const graphics, const BUTTON_DIR dir);
+ void drawVBar(Graphics *const graphics) override final;
+ void drawHBar(Graphics *const graphics) override final;
+ void drawVMarker(Graphics *const graphics) override final;
+ void drawHMarker(Graphics *const graphics) override final;
- void calcVBar(gcn::Graphics *const graphics);
- void calcHBar(gcn::Graphics *const graphics);
- void calcVMarker(gcn::Graphics *const graphics);
- void calcHMarker(gcn::Graphics *const graphics);
+ void calcVBar(Graphics *const graphics);
+ void calcHBar(Graphics *const graphics);
+ void calcVMarker(Graphics *const graphics);
+ void calcHMarker(Graphics *const graphics);
- void updateCalcFlag(gcn::Graphics *const graphics);
+ void updateCalcFlag(Graphics *const graphics);
static int instances;
static float mAlpha;
diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp
index 2cb7f60d1..218efe8a2 100644
--- a/src/gui/widgets/setupitem.cpp
+++ b/src/gui/widgets/setupitem.cpp
@@ -24,10 +24,12 @@
#include "main.h"
#include "soundmanager.h"
-#include "gui/sdlfont.h"
+#include "gui/font.h"
+#include "gui/gui.h"
#include "gui/windows/editdialog.h"
+#include "gui/widgets/button.h"
#include "gui/widgets/checkbox.h"
#include "gui/widgets/dropdown.h"
#include "gui/widgets/horizontcontainer.h"
@@ -37,12 +39,12 @@
#include "gui/widgets/sliderlist.h"
#include "gui/widgets/vertcontainer.h"
+#include "gui/widgets/tabs/setuptabscroll.h"
+
#include "utils/base64.h"
#include "utils/gettext.h"
#include "utils/mathutils.h"
-#include <guichan/font.hpp>
-
#include "debug.h"
SetupItem::SetupItem(const std::string &restrict text,
@@ -51,8 +53,8 @@ SetupItem::SetupItem(const std::string &restrict text,
SetupTabScroll *restrict const parent,
const std::string &restrict eventName,
const bool mainConfig) :
- gcn::ActionListener(),
- Widget2(),
+ ActionListener(),
+ Widget2(parent),
mText(text),
mDescription(description),
mKeyName(keyName),
@@ -75,8 +77,8 @@ SetupItem::SetupItem(const std::string &restrict text,
const std::string &restrict eventName,
const std::string &restrict def,
const bool mainConfig) :
- gcn::ActionListener(),
- Widget2(),
+ ActionListener(),
+ Widget2(parent),
mText(text),
mDescription(description),
mKeyName(keyName),
@@ -154,7 +156,7 @@ std::string SetupItem::getActionEventId() const
return mWidget->getActionEventId();
}
-void SetupItem::action(const gcn::ActionEvent &event)
+void SetupItem::action(const ActionEvent &event)
{
if (!mWidget)
return;
@@ -189,7 +191,7 @@ void SetupItem::externalUnloaded(const std::string &eventName A_UNUSED)
{
}
-void SetupItem::fixFirstItemSize(gcn::Widget *const widget)
+void SetupItem::fixFirstItemSize(Widget *const widget)
{
const int maxSize = mParent->getPreferredFirstItemSize();
if (widget->getWidth() < maxSize)
@@ -393,7 +395,7 @@ void SetupItemTextField::toWidget()
mTextField->setText(mValue);
}
-void SetupItemTextField::action(const gcn::ActionEvent &event)
+void SetupItemTextField::action(const ActionEvent &event)
{
if (!mTextField)
return;
@@ -529,7 +531,7 @@ void SetupItemIntTextField::toWidget()
mTextField->setText(mValue);
}
-void SetupItemIntTextField::action(const gcn::ActionEvent &event)
+void SetupItemIntTextField::action(const ActionEvent &event)
{
if (!mTextField)
return;
@@ -609,7 +611,7 @@ void SetupItemLabel::toWidget()
{
}
-void SetupItemLabel::action(const gcn::ActionEvent &event A_UNUSED)
+void SetupItemLabel::action(const ActionEvent &event A_UNUSED)
{
}
@@ -623,7 +625,7 @@ SetupItemDropDown::SetupItemDropDown(const std::string &restrict text,
const std::string &restrict keyName,
SetupTabScroll *restrict const parent,
const std::string &restrict eventName,
- gcn::ListModel *restrict const model,
+ ListModel *restrict const model,
const int width,
const bool mainConfig) :
SetupItem(text, description, keyName, parent, eventName, mainConfig),
@@ -642,7 +644,7 @@ SetupItemDropDown::SetupItemDropDown(const std::string &restrict text,
const std::string &restrict keyName,
SetupTabScroll *restrict const parent,
const std::string &restrict eventName,
- gcn::ListModel *restrict const model,
+ ListModel *restrict const model,
const int width,
const std::string &restrict def,
const bool mainConfig) :
@@ -764,7 +766,7 @@ void SetupItemSlider::createControls()
mHorizont = new HorizontContainer(this, 32, 2);
mLabel = new Label(this, mText);
- mSlider = new Slider(mMin, mMax);
+ mSlider = new Slider(this, mMin, mMax);
mSlider->setActionEventId(mEventName);
mSlider->addActionListener(mParent);
mSlider->setValue2(atof(mValue.c_str()));
@@ -799,7 +801,7 @@ void SetupItemSlider::toWidget()
mSlider->setValue2(atof(mValue.c_str()));
}
-void SetupItemSlider::action(const gcn::ActionEvent &event A_UNUSED)
+void SetupItemSlider::action(const ActionEvent &event A_UNUSED)
{
fromWidget();
if (mOnTheFly)
@@ -888,7 +890,7 @@ void SetupItemSlider2::createControls()
mLabel = new Label(this, mText);
mLabel2 = new Label(this, "");
mLabel2->setWidth(width);
- mSlider = new Slider(mMin, mMax);
+ mSlider = new Slider(this, mMin, mMax);
mSlider->setActionEventId(mEventName);
mSlider->addActionListener(mParent);
mSlider->setValue2(atof(mValue.c_str()));
@@ -918,7 +920,7 @@ int SetupItemSlider2::getMaxWidth()
int maxWidth = 0;
SetupItemNamesConstIter it = mValues->begin();
const SetupItemNamesConstIter it_end = mValues->end();
- const gcn::Font *const font = gui->getFont();
+ const Font *const font = gui->getFont();
while (it != it_end)
{
@@ -954,7 +956,7 @@ void SetupItemSlider2::toWidget()
updateLabel();
}
-void SetupItemSlider2::action(const gcn::ActionEvent &event A_UNUSED)
+void SetupItemSlider2::action(const ActionEvent &event A_UNUSED)
{
fromWidget();
updateLabel();
@@ -1002,7 +1004,7 @@ SetupItemSliderList::SetupItemSliderList(const std::string &restrict text,
const std::string &restrict keyName,
SetupTabScroll *restrict const parent,
const std::string &restrict eventName,
- gcn::ListModel *restrict const model,
+ ListModel *restrict const model,
const int width, const bool onTheFly,
const bool mainConfig) :
SetupItem(text, description, keyName, parent, eventName, mainConfig),
@@ -1022,7 +1024,7 @@ SetupItemSliderList::SetupItemSliderList(const std::string &restrict text,
const std::string &restrict keyName,
SetupTabScroll *restrict const parent,
const std::string &restrict eventName,
- gcn::ListModel *restrict const model,
+ ListModel *restrict const model,
const std::string &restrict def,
const int width,
const bool onTheFly,
@@ -1086,7 +1088,7 @@ void SetupItemSliderList::toWidget()
mSlider->setSelectedString(mValue);
}
-void SetupItemSliderList::action(const gcn::ActionEvent &event A_UNUSED)
+void SetupItemSliderList::action(const ActionEvent &event A_UNUSED)
{
fromWidget();
if (mOnTheFly)
@@ -1107,7 +1109,7 @@ SetupItemSound::SetupItemSound(const std::string &restrict text,
const std::string &restrict keyName,
SetupTabScroll *restrict const parent,
const std::string &restrict eventName,
- gcn::ListModel *restrict const model,
+ ListModel *restrict const model,
const int width, const bool onTheFly,
const bool mainConfig) :
SetupItemSliderList(text, description, keyName, parent, eventName,
@@ -1124,7 +1126,7 @@ void SetupItemSound::addMoreControls()
mHorizont->add(mButton);
}
-void SetupItemSound::action(const gcn::ActionEvent &event)
+void SetupItemSound::action(const ActionEvent &event)
{
if (event.getId() == mEventName + "_PLAY")
{
@@ -1145,7 +1147,7 @@ SetupItemSliderInt::SetupItemSliderInt(const std::string &restrict text,
const std::string &restrict keyName,
SetupTabScroll *restrict const parent,
const std::string &restrict eventName,
- gcn::ListModel *restrict const model,
+ ListModel *restrict const model,
const int min,
const int width,
const bool onTheFly,
diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h
index c72bb39ef..7dee860be 100644
--- a/src/gui/widgets/setupitem.h
+++ b/src/gui/widgets/setupitem.h
@@ -21,14 +21,14 @@
#ifndef GUI_WIDGETS_SETUPITEM_H
#define GUI_WIDGETS_SETUPITEM_H
-#include "gui/widgets/button.h"
-#include "gui/widgets/tabs/setuptabscroll.h"
+#include "gui/widgets/widget2.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
#include <list>
#include <vector>
+class Button;
class CheckBox;
class Configuration;
class DropDown;
@@ -36,16 +36,13 @@ class EditDialog;
class HorizontContainer;
class IntTextField;
class Label;
+class ListModel;
+class SetupTabScroll;
class Slider;
class SliderList;
class TextField;
-namespace gcn
-{
- class ListModel;
-}
-
-class SetupItem : public gcn::ActionListener,
+class SetupItem : public ActionListener,
public Widget2
{
public:
@@ -69,17 +66,17 @@ class SetupItem : public gcn::ActionListener,
virtual void toWidget() = 0;
- void setWidget(gcn::Widget *widget)
+ void setWidget(Widget *widget)
{ mWidget = widget; }
- gcn::Widget *getWidget() const A_WARN_UNUSED
+ Widget *getWidget() const A_WARN_UNUSED
{ return mWidget; }
Configuration *getConfig() const A_WARN_UNUSED;
virtual std::string getActionEventId() const A_WARN_UNUSED;
- virtual void action(const gcn::ActionEvent &event) override;
+ virtual void action(const ActionEvent &event) override;
virtual void action();
@@ -94,11 +91,11 @@ class SetupItem : public gcn::ActionListener,
bool isMainConfig() const A_WARN_UNUSED
{ return mMainConfig; }
- void fixFirstItemSize(gcn::Widget *const widget);
+ void fixFirstItemSize(Widget *const widget);
virtual void rereadValue();
- void setValue(const std::string str)
+ void setValue(const std::string &str)
{ mValue = str; }
std::string getValue() const
@@ -137,9 +134,9 @@ class SetupItem : public gcn::ActionListener,
std::string mDefault;
- gcn::Widget *mWidget;
+ Widget *mWidget;
- std::list<gcn::Widget*> mTempWidgets;
+ std::list<Widget*> mTempWidgets;
int mValueType;
@@ -210,7 +207,7 @@ class SetupItemTextField final : public SetupItem
void toWidget() override final;
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void apply(const std::string &eventName) override final;
@@ -265,7 +262,7 @@ class SetupItemIntTextField final : public SetupItem
void toWidget() override final;
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void apply(const std::string &eventName) override final;
@@ -297,7 +294,7 @@ class SetupItemLabel final : public SetupItem
void toWidget() override final;
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void apply(const std::string &eventName) override final;
@@ -314,7 +311,7 @@ class SetupItemDropDown final : public SetupItem
const std::string &restrict keyName,
SetupTabScroll *restrict const parent,
const std::string &restrict eventName,
- gcn::ListModel *restrict const model,
+ ListModel *restrict const model,
const int width, const bool mainConfig = true);
SetupItemDropDown(const std::string &restrict text,
@@ -322,7 +319,7 @@ class SetupItemDropDown final : public SetupItem
const std::string &restrict keyName,
SetupTabScroll *restrict const parent,
const std::string &restrict eventName,
- gcn::ListModel *restrict const model,
+ ListModel *restrict const model,
const int width,
const std::string &restrict def,
const bool mainConfig = true);
@@ -340,7 +337,7 @@ class SetupItemDropDown final : public SetupItem
protected:
HorizontContainer *mHorizont;
Label *mLabel;
- gcn::ListModel *mModel;
+ ListModel *mModel;
DropDown *mDropDown;
int mWidth;
};
@@ -377,7 +374,7 @@ class SetupItemSlider final : public SetupItem
void toWidget() override final;
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void apply(const std::string &eventName) override final;
@@ -433,7 +430,7 @@ class SetupItemSlider2 final : public SetupItem
void toWidget() override final;
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void apply(const std::string &eventName) override final;
@@ -470,7 +467,7 @@ class SetupItemSliderList : public SetupItem
void toWidget() override;
- virtual void action(const gcn::ActionEvent &event) override;
+ virtual void action(const ActionEvent &event) override;
void apply(const std::string &eventName) override final;
@@ -482,7 +479,7 @@ class SetupItemSliderList : public SetupItem
const std::string &restrict keyName,
SetupTabScroll *restrict const parent,
const std::string &restrict eventName,
- gcn::ListModel *restrict const model,
+ ListModel *restrict const model,
const int width = 150, const bool onTheFly = false,
const bool mainConfig = true);
@@ -491,7 +488,7 @@ class SetupItemSliderList : public SetupItem
const std::string &restrict keyName,
SetupTabScroll *restrict const parent,
const std::string &restrict eventName,
- gcn::ListModel *restrict const model,
+ ListModel *restrict const model,
const std::string &restrict def,
const int width = 150,
const bool onTheFly = false,
@@ -500,7 +497,7 @@ class SetupItemSliderList : public SetupItem
HorizontContainer *mHorizont;
Label *mLabel;
SliderList *mSlider;
- gcn::ListModel *mModel;
+ ListModel *mModel;
int mWidth;
bool mOnTheFly;
};
@@ -513,14 +510,14 @@ class SetupItemSound final : public SetupItemSliderList
const std::string &restrict keyName,
SetupTabScroll *restrict const parent,
const std::string &restrict eventName,
- gcn::ListModel *restrict const model,
+ ListModel *restrict const model,
const int width = 150,
const bool onTheFly = false,
const bool mainConfig = true);
A_DELETE_COPY(SetupItemSound)
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void addMoreControls() override final;
@@ -536,7 +533,7 @@ class SetupItemSliderInt final : public SetupItemSliderList
const std::string &restrict keyName,
SetupTabScroll *restrict const parent,
const std::string &restrict eventName,
- gcn::ListModel *restrict const model,
+ ListModel *restrict const model,
const int min,
const int width = 150,
const bool onTheFly = false,
diff --git a/src/gui/widgets/setuptouchitem.cpp b/src/gui/widgets/setuptouchitem.cpp
index b080de428..3c8238fd0 100644
--- a/src/gui/widgets/setuptouchitem.cpp
+++ b/src/gui/widgets/setuptouchitem.cpp
@@ -20,74 +20,18 @@
#include "gui/widgets/setuptouchitem.h"
-#include "gui/setupactiondata.h"
+#include "gui/models/touchactionmodel.h"
#include "gui/widgets/dropdown.h"
#include "gui/widgets/horizontcontainer.h"
#include "gui/widgets/label.h"
#include "gui/widgets/vertcontainer.h"
-#include <algorithm>
+#include "gui/widgets/tabs/setuptabscroll.h"
-#include "debug.h"
-
-static class SortTouchActionFunctor final
-{
- public:
- bool operator() (const SetupActionData *const data1,
- const SetupActionData *const data2) const
- {
- if (!data1 || !data2)
- return false;
- return data1->name < data2->name;
- }
-} touchActionSorter;
-
-TouchActionsModel::TouchActionsModel() :
- NamesModel(),
- mActionId(),
- mActionToSelection()
-{
- std::vector<SetupActionData*> data;
-
- for (int f = 0, sz = touchActionDataSize; f < sz; f ++)
- {
- int k = 0;
- while (!touchActionData[f][k].name.empty())
- {
- data.push_back(&touchActionData[f][k]);
- k ++;
- }
- }
-
- std::sort(data.begin(), data.end(), touchActionSorter);
- int cnt = 0;
- FOR_EACH (std::vector<SetupActionData*>::iterator, it, data)
- {
- const SetupActionData *const data1 = *it;
- mNames.push_back(data1->name);
- mActionId.push_back(data1->actionId);
- mActionToSelection[data1->actionId] = cnt;
- cnt ++;
- }
-}
-
-int TouchActionsModel::getActionFromSelection(const int sel) const
-{
- if (sel < 0 || sel > static_cast<signed int>(mActionId.size()))
- return -1;
- return mActionId[sel];
-}
-
-int TouchActionsModel::getSelectionFromAction(const int action) const
-{
- const std::map<int, int>::const_iterator it
- = mActionToSelection.find(action);
- if (it == mActionToSelection.end())
- return 0;
- return (*it).second;
-}
+#include "utils/stringutils.h"
+#include "debug.h"
SetupActionDropDown::SetupActionDropDown(const std::string &restrict text,
const std::string &restrict
diff --git a/src/gui/widgets/setuptouchitem.h b/src/gui/widgets/setuptouchitem.h
index f15c0d43d..f7bbf2691 100644
--- a/src/gui/widgets/setuptouchitem.h
+++ b/src/gui/widgets/setuptouchitem.h
@@ -21,27 +21,9 @@
#ifndef GUI_WIDGETS_SETUPTOUCHITEM_H
#define GUI_WIDGETS_SETUPTOUCHITEM_H
-#include "gui/widgets/namesmodel.h"
#include "gui/widgets/setupitem.h"
-class TouchActionsModel final : public NamesModel
-{
- public:
- TouchActionsModel();
-
- A_DELETE_COPY(TouchActionsModel)
-
- ~TouchActionsModel()
- { }
-
- int getActionFromSelection(const int sel) const;
-
- int getSelectionFromAction(const int action) const;
-
- private:
- std::vector<int> mActionId;
- std::map<int, int> mActionToSelection;
-};
+class TouchActionsModel;
class SetupActionDropDown final : public SetupItem
{
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index 58f9ec8eb..007dc6442 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -27,23 +27,23 @@
#include "being/playerinfo.h"
+#include "gui/font.h"
#include "gui/viewport.h"
#include "gui/popups/itempopup.h"
-#include "gui/widgets/shopitems.h"
+#include "gui/models/shopitems.h"
#include "resources/image.h"
-#include <guichan/font.hpp>
-#include <guichan/listmodel.hpp>
+#include "gui/models/listmodel.h"
#include "debug.h"
const int ITEM_ICON_SIZE = 32;
ShopListBox::ShopListBox(const Widget2 *const widget,
- gcn::ListModel *const listModel) :
+ ListModel *const listModel) :
ListBox(widget, listModel, "shoplistbox.xml"),
mPlayerMoney(0),
mShopItems(nullptr),
@@ -60,7 +60,7 @@ ShopListBox::ShopListBox(const Widget2 *const widget,
}
ShopListBox::ShopListBox(const Widget2 *const widget,
- gcn::ListModel *const listModel,
+ ListModel *const listModel,
ShopItems *const shopListModel) :
ListBox(widget, listModel, "shoplistbox.xml"),
mPlayerMoney(0),
@@ -82,7 +82,7 @@ void ShopListBox::setPlayersMoney(const int money)
mPlayerMoney = money;
}
-void ShopListBox::draw(gcn::Graphics *gcnGraphics)
+void ShopListBox::draw(Graphics *graphics)
{
BLOCK_START("ShopListBox::draw")
if (!mListModel || !mShopItems)
@@ -95,8 +95,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
mAlpha = client->getGuiAlpha();
const int alpha = static_cast<int>(mAlpha * 255.0F);
- Graphics *graphics = static_cast<Graphics*>(gcnGraphics);
- gcn::Font *const font = getFont();
+ Font *const font = getFont();
const int sz = mListModel->getNumberOfElements();
const int fontHeigh = getFont()->getHeight();
@@ -107,8 +106,8 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
++i, y += mRowHeight)
{
bool needDraw(false);
- gcn::Color temp;
- gcn::Color* backgroundColor = &mBackgroundColor;
+ Color temp;
+ Color* backgroundColor = &mBackgroundColor;
ShopItem *const item = mShopItems->at(i);
if (item && ((mShopItems && mPlayerMoney < item->getPrice()
@@ -145,7 +144,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
if (needDraw)
{
graphics->setColor(*backgroundColor);
- graphics->fillRectangle(gcn::Rectangle(mPadding, y + mPadding,
+ graphics->fillRectangle(Rect(mPadding, y + mPadding,
width, mRowHeight));
}
@@ -155,7 +154,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
if (icon)
{
icon->setAlpha(1.0F);
- graphics->drawImage2(icon, mPadding, y + mPadding);
+ graphics->drawImage(icon, mPadding, y + mPadding);
}
}
if (mSelected == i)
@@ -190,7 +189,7 @@ void ShopListBox::setPriceCheck(const bool check)
mPriceCheck = check;
}
-void ShopListBox::mouseMoved(gcn::MouseEvent &event)
+void ShopListBox::mouseMoved(MouseEvent &event)
{
if (!mItemPopup || !mRowHeight)
return;
@@ -222,10 +221,10 @@ void ShopListBox::mouseMoved(gcn::MouseEvent &event)
}
}
-void ShopListBox::mouseReleased(gcn::MouseEvent& mouseEvent)
+void ShopListBox::mouseReleased(MouseEvent& mouseEvent)
{
ListBox::mouseReleased(mouseEvent);
- if (mouseEvent.getButton() == gcn::MouseEvent::RIGHT)
+ if (mouseEvent.getButton() == MouseEvent::RIGHT)
{
setSelected(std::max(0, getSelectionByMouse(mouseEvent.getY())));
@@ -237,7 +236,7 @@ void ShopListBox::mouseReleased(gcn::MouseEvent& mouseEvent)
}
}
-void ShopListBox::mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED)
+void ShopListBox::mouseExited(MouseEvent& mouseEvent A_UNUSED)
{
if (!mItemPopup)
return;
diff --git a/src/gui/widgets/shoplistbox.h b/src/gui/widgets/shoplistbox.h
index 095d187eb..17c1ed4d5 100644
--- a/src/gui/widgets/shoplistbox.h
+++ b/src/gui/widgets/shoplistbox.h
@@ -42,13 +42,13 @@ class ShopListBox final : public ListBox
* Constructor.
*/
ShopListBox(const Widget2 *const widget,
- gcn::ListModel *const listModel);
+ ListModel *const listModel);
/**
* Constructor with shopitems
*/
ShopListBox(const Widget2 *const widget,
- gcn::ListModel *const listModel,
+ ListModel *const listModel,
ShopItems *const shopListModel);
A_DELETE_COPY(ShopListBox)
@@ -56,7 +56,7 @@ class ShopListBox final : public ListBox
/**
* Draws the list box.
*/
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
/**
* gives information about the current player's money
@@ -74,11 +74,11 @@ class ShopListBox final : public ListBox
*/
void setPriceCheck(const bool check);
- void mouseMoved(gcn::MouseEvent &event) override final;
+ void mouseMoved(MouseEvent &event) override final;
- void mouseReleased(gcn::MouseEvent& mouseEvent) override final;
+ void mouseReleased(MouseEvent& mouseEvent) override final;
- void mouseExited(gcn::MouseEvent& mouseEvent) override final;
+ void mouseExited(MouseEvent& mouseEvent) override final;
void setProtectItems(bool p)
{ mProtectItems = p; }
@@ -94,8 +94,8 @@ class ShopListBox final : public ListBox
ItemPopup *mItemPopup;
- gcn::Color mBackgroundColor;
- gcn::Color mWarningColor;
+ Color mBackgroundColor;
+ Color mWarningColor;
bool mPriceCheck;
bool mProtectItems;
diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp
index a3030b035..0d9aa64a6 100644
--- a/src/gui/widgets/shortcutcontainer.cpp
+++ b/src/gui/widgets/shortcutcontainer.cpp
@@ -24,15 +24,16 @@
#include "graphicsvertexes.h"
+#include "gui/gui.h"
+
#include "debug.h"
float ShortcutContainer::mAlpha = 1.0;
-ShortcutContainer::ShortcutContainer() :
- gcn::Widget(),
- Widget2(),
- gcn::WidgetListener(),
- gcn::MouseListener(),
+ShortcutContainer::ShortcutContainer(Widget2 *const widget) :
+ Widget(widget),
+ WidgetListener(),
+ MouseListener(),
mBackgroundImg(nullptr),
mMaxItems(0),
mBoxWidth(1),
@@ -53,14 +54,14 @@ ShortcutContainer::~ShortcutContainer()
mVertexes = nullptr;
}
-void ShortcutContainer::widgetResized(const gcn::Event &event A_UNUSED)
+void ShortcutContainer::widgetResized(const Event &event A_UNUSED)
{
mGridWidth = mDimension.width / mBoxWidth;
if (mGridWidth < 1)
mGridWidth = 1;
- mGridHeight = mMaxItems / mGridWidth;
+ mGridHeight = mMaxItems / static_cast<unsigned int>(mGridWidth);
if (mMaxItems % mGridWidth != 0 || mGridHeight < 1)
++mGridHeight;
@@ -72,7 +73,7 @@ void ShortcutContainer::widgetResized(const gcn::Event &event A_UNUSED)
int ShortcutContainer::getIndexFromGrid(const int pointX,
const int pointY) const
{
- const gcn::Rectangle tRect = gcn::Rectangle(0, 0,
+ const Rect tRect = Rect(0, 0,
mGridWidth * mBoxWidth, mGridHeight * mBoxHeight);
int index = ((pointY / mBoxHeight) * mGridWidth) + pointX / mBoxWidth;
@@ -109,14 +110,14 @@ void ShortcutContainer::drawBackground(Graphics *g)
{
for (unsigned i = 0; i < mMaxItems; i ++)
{
- g->drawImage2(mBackgroundImg, (i % mGridWidth) * mBoxWidth,
+ g->drawImage(mBackgroundImg, (i % mGridWidth) * mBoxWidth,
(i / mGridWidth) * mBoxHeight);
}
}
}
}
-void ShortcutContainer::widgetMoved(const gcn::Event& event A_UNUSED)
+void ShortcutContainer::widgetMoved(const Event& event A_UNUSED)
{
mRedraw = true;
}
diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h
index 8bd84758d..81392097b 100644
--- a/src/gui/widgets/shortcutcontainer.h
+++ b/src/gui/widgets/shortcutcontainer.h
@@ -23,11 +23,10 @@
#ifndef GUI_WIDGETS_SHORTCUTCONTAINER_H
#define GUI_WIDGETS_SHORTCUTCONTAINER_H
-#include "gui/widgets/widget2.h"
+#include "gui/widgets/widget.h"
-#include <guichan/mouselistener.hpp>
-#include <guichan/widget.hpp>
-#include <guichan/widgetlistener.hpp>
+#include "listeners/mouselistener.h"
+#include "listeners/widgetlistener.h"
class Image;
class ImageCollection;
@@ -37,10 +36,9 @@ class ImageCollection;
*
* \ingroup GUI
*/
-class ShortcutContainer : public gcn::Widget,
- public Widget2,
- public gcn::WidgetListener,
- public gcn::MouseListener
+class ShortcutContainer : public Widget,
+ public WidgetListener,
+ public MouseListener
{
public:
A_DELETE_COPY(ShortcutContainer)
@@ -53,34 +51,34 @@ class ShortcutContainer : public gcn::Widget,
/**
* Draws the shortcuts
*/
- virtual void draw(gcn::Graphics *graphics) override = 0;
+ virtual void draw(Graphics *graphics) override = 0;
/**
* Invoked when a widget changes its size. This is used to determine
* the new height of the container.
*/
- virtual void widgetResized(const gcn::Event &event) override final;
+ virtual void widgetResized(const Event &event) override final;
- virtual void widgetMoved(const gcn::Event& event) override final;
+ virtual void widgetMoved(const Event& event) override final;
/**
* Handles mouse when dragged.
*/
- virtual void mouseDragged(gcn::MouseEvent &event A_UNUSED) override
+ virtual void mouseDragged(MouseEvent &event A_UNUSED) override
{
}
/**
* Handles mouse when pressed.
*/
- virtual void mousePressed(gcn::MouseEvent &event A_UNUSED) override
+ virtual void mousePressed(MouseEvent &event A_UNUSED) override
{
}
/**
* Handles mouse release.
*/
- virtual void mouseReleased(gcn::MouseEvent &event A_UNUSED) override
+ virtual void mouseReleased(MouseEvent &event A_UNUSED) override
{
}
@@ -102,7 +100,7 @@ class ShortcutContainer : public gcn::Widget,
/**
* Constructor. Initializes the shortcut container.
*/
- explicit ShortcutContainer();
+ explicit ShortcutContainer(Widget2 *const widget);
/**
* Gets the index from the grid provided the point is in an item box.
diff --git a/src/gui/widgets/skillinfo.cpp b/src/gui/widgets/skillinfo.cpp
index 46a3f425f..a009d623a 100644
--- a/src/gui/widgets/skillinfo.cpp
+++ b/src/gui/widgets/skillinfo.cpp
@@ -27,7 +27,8 @@
#include "gui/theme.h"
#include "gui/widgets/skilldata.h"
-#include "gui/widgets/skillmodel.h"
+
+#include "gui/models/skillmodel.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
diff --git a/src/gui/widgets/skillinfo.h b/src/gui/widgets/skillinfo.h
index d268b3438..f9baec6cc 100644
--- a/src/gui/widgets/skillinfo.h
+++ b/src/gui/widgets/skillinfo.h
@@ -23,7 +23,7 @@
#ifndef GUI_WIDGETS_SKILLINFO_H
#define GUI_WIDGETS_SKILLINFO_H
-#include <guichan/color.hpp>
+#include "gui/color.h"
#include <vector>
#include <map>
@@ -43,7 +43,7 @@ struct SkillInfo final
std::string skillLevel;
std::string skillExp;
float progress;
- gcn::Color color;
+ Color color;
SkillDataMap dataMap;
SkillModel *model;
SkillData *data;
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index 750b58528..7a9b38050 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -25,8 +25,11 @@
#include "client.h"
#include "graphicsvertexes.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
+
+#include "gui/gui.h"
#include "resources/image.h"
@@ -42,9 +45,9 @@ static std::string const data[2] =
"slider_highlighted.xml"
};
-Slider::Slider(const double scaleEnd) :
- gcn::Slider(scaleEnd),
- Widget2(),
+Slider::Slider(Widget2 *const widget,
+ const double scaleEnd) :
+ gcn::Slider(widget, scaleEnd),
mVertexes(new ImageCollection),
mHasMouse(false),
mRedraw(true)
@@ -52,9 +55,10 @@ Slider::Slider(const double scaleEnd) :
init();
}
-Slider::Slider(const double scaleStart, const double scaleEnd) :
- gcn::Slider(scaleStart, scaleEnd),
- Widget2(),
+Slider::Slider(Widget2 *const widget,
+ const double scaleStart,
+ const double scaleEnd) :
+ gcn::Slider(widget, scaleStart, scaleEnd),
mVertexes(new ImageCollection),
mHasMouse(false),
mRedraw(true)
@@ -118,7 +122,7 @@ void Slider::updateAlpha()
}
}
-void Slider::draw(gcn::Graphics *graphics)
+void Slider::draw(Graphics *graphics)
{
BLOCK_START("Slider::draw")
if (!buttons[0].grid[HSTART] || !buttons[1].grid[HSTART]
@@ -133,19 +137,18 @@ void Slider::draw(gcn::Graphics *graphics)
int x = 0;
const int y = mHasMouse ? (h - buttons[1].grid[HSTART]->getHeight()) / 2 :
(h - buttons[0].grid[HSTART]->getHeight()) / 2;
- Graphics *const g = static_cast<Graphics*>(graphics);
updateAlpha();
if (isBatchDrawRenders(openGLMode))
{
- if (mRedraw || g->getRedraw())
+ if (mRedraw || graphics->getRedraw())
{
mRedraw = false;
mVertexes->clear();
if (!mHasMouse)
{
- g->calcTileCollection(mVertexes,
+ graphics->calcTileCollection(mVertexes,
buttons[0].grid[HSTART], x, y);
const int width = buttons[0].grid[HSTART]->getWidth();
@@ -155,24 +158,31 @@ void Slider::draw(gcn::Graphics *graphics)
if (buttons[0].grid[HMID])
{
const Image *const hMid = buttons[0].grid[HMID];
- g->calcPattern(mVertexes, hMid, x, y,
+ graphics->calcPattern(mVertexes,
+ hMid,
+ x, y,
w, hMid->getHeight());
}
x += w;
- g->calcTileCollection(mVertexes, buttons[0].grid[HEND], x, y);
+ graphics->calcTileCollection(mVertexes,
+ buttons[0].grid[HEND],
+ x, y);
const Image *const img = buttons[0].grid[HGRIP];
if (img)
{
- g->calcTileCollection(mVertexes, img, getMarkerPosition(),
+ graphics->calcTileCollection(mVertexes,
+ img,
+ getMarkerPosition(),
(mDimension.height - img->getHeight()) / 2);
}
}
else
{
- g->calcTileCollection(mVertexes,
- buttons[1].grid[HSTART], x, y);
+ graphics->calcTileCollection(mVertexes,
+ buttons[1].grid[HSTART],
+ x, y);
const int width = buttons[1].grid[HSTART]->getWidth();
w -= width;
@@ -183,32 +193,36 @@ void Slider::draw(gcn::Graphics *graphics)
if (buttons[1].grid[HMID])
{
const Image *const hMid = buttons[1].grid[HMID];
- g->calcPattern(mVertexes, hMid, x, y,
+ graphics->calcPattern(mVertexes,
+ hMid,
+ x, y,
w, hMid->getHeight());
}
x += w;
if (buttons[1].grid[HEND])
{
- g->calcTileCollection(mVertexes,
+ graphics->calcTileCollection(mVertexes,
buttons[1].grid[HEND], x, y);
}
const Image *const img = buttons[1].grid[HGRIP];
if (img)
{
- g->calcTileCollection(mVertexes, img, getMarkerPosition(),
+ graphics->calcTileCollection(mVertexes,
+ img,
+ getMarkerPosition(),
(mDimension.height - img->getHeight()) / 2);
}
}
}
- g->drawTileCollection(mVertexes);
+ graphics->drawTileCollection(mVertexes);
}
else
{
if (!mHasMouse)
{
- g->drawImage2(buttons[0].grid[HSTART], x, y);
+ graphics->drawImage(buttons[0].grid[HSTART], x, y);
const int width = buttons[0].grid[HSTART]->getWidth();
w -= width + buttons[0].grid[HEND]->getWidth();
x += width;
@@ -216,22 +230,22 @@ void Slider::draw(gcn::Graphics *graphics)
if (buttons[0].grid[HMID])
{
const Image *const hMid = buttons[0].grid[HMID];
- g->drawPattern(hMid, x, y, w, hMid->getHeight());
+ graphics->drawPattern(hMid, x, y, w, hMid->getHeight());
}
x += w;
- g->drawImage2(buttons[0].grid[HEND], x, y);
+ graphics->drawImage(buttons[0].grid[HEND], x, y);
const Image *const img = buttons[0].grid[HGRIP];
if (img)
{
- g->drawImage2(img, getMarkerPosition(),
+ graphics->drawImage(img, getMarkerPosition(),
(mDimension.height - img->getHeight()) / 2);
}
}
else
{
- g->drawImage2(buttons[1].grid[HSTART], x, y);
+ graphics->drawImage(buttons[1].grid[HSTART], x, y);
const int width = buttons[1].grid[HSTART]->getWidth();
w -= width;
@@ -242,17 +256,17 @@ void Slider::draw(gcn::Graphics *graphics)
if (buttons[1].grid[HMID])
{
const Image *const hMid = buttons[1].grid[HMID];
- g->drawPattern(hMid, x, y, w, hMid->getHeight());
+ graphics->drawPattern(hMid, x, y, w, hMid->getHeight());
}
x += w;
if (buttons[1].grid[HEND])
- g->drawImage2(buttons[1].grid[HEND], x, y);
+ graphics->drawImage(buttons[1].grid[HEND], x, y);
const Image *const img = buttons[1].grid[HGRIP];
if (img)
{
- g->drawImage2(img, getMarkerPosition(),
+ graphics->drawImage(img, getMarkerPosition(),
(mDimension.height - img->getHeight()) / 2);
}
}
@@ -261,21 +275,21 @@ void Slider::draw(gcn::Graphics *graphics)
BLOCK_END("Slider::draw")
}
-void Slider::mouseEntered(gcn::MouseEvent& event A_UNUSED)
+void Slider::mouseEntered(MouseEvent& event A_UNUSED)
{
mHasMouse = true;
mRedraw = true;
}
-void Slider::mouseExited(gcn::MouseEvent& event A_UNUSED)
+void Slider::mouseExited(MouseEvent& event A_UNUSED)
{
mHasMouse = false;
mRedraw = true;
}
-void Slider::mousePressed(gcn::MouseEvent &mouseEvent)
+void Slider::mousePressed(MouseEvent &mouseEvent)
{
- if (mouseEvent.getButton() == gcn::MouseEvent::LEFT
+ if (mouseEvent.getButton() == MouseEvent::LEFT
&& mouseEvent.getX() >= 0
&& mouseEvent.getX() <= getWidth()
&& mouseEvent.getY() >= 0
@@ -296,7 +310,7 @@ void Slider::mousePressed(gcn::MouseEvent &mouseEvent)
}
}
-void Slider::mouseDragged(gcn::MouseEvent &mouseEvent)
+void Slider::mouseDragged(MouseEvent &mouseEvent)
{
if (getOrientation() == HORIZONTAL)
{
@@ -314,7 +328,7 @@ void Slider::mouseDragged(gcn::MouseEvent &mouseEvent)
mouseEvent.consume();
}
-void Slider::mouseWheelMovedUp(gcn::MouseEvent &mouseEvent)
+void Slider::mouseWheelMovedUp(MouseEvent &mouseEvent)
{
setValue2(getValue() + getStepLength());
distributeActionEvent();
@@ -322,7 +336,7 @@ void Slider::mouseWheelMovedUp(gcn::MouseEvent &mouseEvent)
mouseEvent.consume();
}
-void Slider::mouseWheelMovedDown(gcn::MouseEvent &mouseEvent)
+void Slider::mouseWheelMovedDown(MouseEvent &mouseEvent)
{
setValue2(getValue() - getStepLength());
distributeActionEvent();
@@ -330,9 +344,9 @@ void Slider::mouseWheelMovedDown(gcn::MouseEvent &mouseEvent)
mouseEvent.consume();
}
-void Slider::keyPressed(gcn::KeyEvent& keyEvent)
+void Slider::keyPressed(KeyEvent& keyEvent)
{
- const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int action = keyEvent.getActionId();
if (getOrientation() == HORIZONTAL)
{
diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h
index a0f7829ac..2f21127d1 100644
--- a/src/gui/widgets/slider.h
+++ b/src/gui/widgets/slider.h
@@ -23,9 +23,7 @@
#ifndef GUI_WIDGETS_SLIDER_H
#define GUI_WIDGETS_SLIDER_H
-#include "gui/widgets/widget2.h"
-
-#include <guichan/widgets/slider.hpp>
+#include "gui/base/widgets/slider.hpp"
#include "localconsts.h"
@@ -36,19 +34,21 @@ class ImageCollection;
*
* \ingroup GUI
*/
-class Slider final : public gcn::Slider,
- public Widget2
+class Slider final : public gcn::Slider
{
public:
/**
* Constructor with scale start equal to 0.
*/
- explicit Slider(const double scaleEnd = 1.0);
+ explicit Slider(Widget2 *const widget,
+ const double scaleEnd = 1.0);
/**
* Constructor.
*/
- Slider(const double scaleStart, const double scaleEnd);
+ Slider(Widget2 *const widget,
+ const double scaleStart,
+ const double scaleEnd);
A_DELETE_COPY(Slider)
@@ -65,27 +65,27 @@ class Slider final : public gcn::Slider,
/**
* Draws the slider.
*/
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
/**
* Called when the mouse enteres the widget area.
*/
- void mouseEntered(gcn::MouseEvent& event) override final;
+ void mouseEntered(MouseEvent& event) override final;
/**
* Called when the mouse leaves the widget area.
*/
- void mouseExited(gcn::MouseEvent& event) override final;
+ void mouseExited(MouseEvent& event) override final;
- void mousePressed(gcn::MouseEvent &mouseEvent) override final;
+ void mousePressed(MouseEvent &mouseEvent) override final;
- void mouseDragged(gcn::MouseEvent &mouseEvent) override final;
+ void mouseDragged(MouseEvent &mouseEvent) override final;
- void mouseWheelMovedUp(gcn::MouseEvent &mouseEvent) override final;
+ void mouseWheelMovedUp(MouseEvent &mouseEvent) override final;
- void mouseWheelMovedDown(gcn::MouseEvent &mouseEvent) override final;
+ void mouseWheelMovedDown(MouseEvent &mouseEvent) override final;
- void keyPressed(gcn::KeyEvent& keyEvent) override final;
+ void keyPressed(KeyEvent& keyEvent) override final;
void setValue2(const double value);
diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp
index 60d7926d1..03f0c4ed2 100644
--- a/src/gui/widgets/sliderlist.cpp
+++ b/src/gui/widgets/sliderlist.cpp
@@ -20,13 +20,14 @@
#include "gui/widgets/sliderlist.h"
+#include "gui/font.h"
#include "gui/gui.h"
+#include "gui/models/listmodel.h"
+
#include "gui/widgets/button.h"
#include "gui/widgets/label.h"
-#include <guichan/font.hpp>
-
#include "debug.h"
static const int buttonWidth = 27;
@@ -34,10 +35,10 @@ static const int buttonSpace = 30;
static const int sliderHeight = 30;
SliderList::SliderList(const Widget2 *const widget,
- gcn::ListModel *const listModel) :
+ ListModel *const listModel) :
Container(widget),
- gcn::ActionListener(),
- gcn::MouseListener(),
+ ActionListener(),
+ MouseListener(),
mLabel(new Label(this)),
mListModel(listModel),
mPrevEventId(),
@@ -48,7 +49,7 @@ SliderList::SliderList(const Widget2 *const widget,
setHeight(sliderHeight);
}
-void SliderList::postInit(gcn::ActionListener *const listener,
+void SliderList::postInit(ActionListener *const listener,
const std::string &eventId)
{
mPrevEventId = eventId + "_prev";
@@ -80,13 +81,13 @@ void SliderList::updateAlpha()
Button::updateAlpha();
}
-void SliderList::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent)
+void SliderList::mouseWheelMovedUp(MouseEvent& mouseEvent)
{
setSelected(mSelectedIndex - 1);
mouseEvent.consume();
}
-void SliderList::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent)
+void SliderList::mouseWheelMovedDown(MouseEvent& mouseEvent)
{
setSelected(mSelectedIndex + 1);
mouseEvent.consume();
@@ -103,7 +104,7 @@ void SliderList::resize()
updateLabel();
}
-void SliderList::draw(gcn::Graphics *graphics)
+void SliderList::draw(Graphics *graphics)
{
BLOCK_START("SliderList::draw")
const int width = mDimension.width;
@@ -138,7 +139,7 @@ void SliderList::updateLabel()
mLabel->setPosition(buttonSpace + (space - labelWidth) / 2, labelY);
}
-void SliderList::action(const gcn::ActionEvent &event)
+void SliderList::action(const ActionEvent &event)
{
if (!mListModel)
return;
@@ -209,7 +210,7 @@ int SliderList::getMaxLabelWidth() const
return 1;
int maxWidth = 0;
- const gcn::Font *const font = getFont();
+ const Font *const font = getFont();
const int num = mListModel->getNumberOfElements();
for (int f = 0; f < num; f ++)
diff --git a/src/gui/widgets/sliderlist.h b/src/gui/widgets/sliderlist.h
index 73f8c6f5c..84f96ebe4 100644
--- a/src/gui/widgets/sliderlist.h
+++ b/src/gui/widgets/sliderlist.h
@@ -21,9 +21,8 @@
#ifndef GUI_WIDGETS_SLIDERLIST_H
#define GUI_WIDGETS_SLIDERLIST_H
-#include <guichan/actionlistener.hpp>
-#include <guichan/listmodel.hpp>
-#include <guichan/mouselistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/mouselistener.h"
#include "gui/widgets/container.h"
@@ -31,33 +30,34 @@
class Button;
class Label;
+class ListModel;
class SliderList final : public Container,
- public gcn::ActionListener,
- public gcn::MouseListener
+ public ActionListener,
+ public MouseListener
{
public:
SliderList(const Widget2 *const widget,
- gcn::ListModel *const listModel);
+ ListModel *const listModel);
A_DELETE_COPY(SliderList)
~SliderList();
- void postInit(gcn::ActionListener *const listener,
+ void postInit(ActionListener *const listener,
const std::string &eventId);
void updateAlpha();
- void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) override final;
+ void mouseWheelMovedUp(MouseEvent& mouseEvent) override final;
- void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) override final;
+ void mouseWheelMovedDown(MouseEvent& mouseEvent) override final;
void resize();
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void setSelectedString(const std::string &str);
@@ -77,7 +77,7 @@ class SliderList final : public Container,
Button *mButtons[2];
Label *mLabel;
- gcn::ListModel *mListModel;
+ ListModel *mListModel;
std::string mPrevEventId;
std::string mNextEventId;
int mOldWidth;
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index bf14f21fe..ed92b62e1 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -27,21 +27,20 @@
#include "itemshortcut.h"
#include "spellshortcut.h"
+#include "gui/font.h"
#include "gui/viewport.h"
#include "gui/popups/spellpopup.h"
-#include "gui/windows/inventorywindow.h"
#include "gui/windows/shortcutwindow.h"
#include "resources/image.h"
-#include <guichan/font.hpp>
-
#include "debug.h"
-SpellShortcutContainer::SpellShortcutContainer(const unsigned number) :
- ShortcutContainer(),
+SpellShortcutContainer::SpellShortcutContainer(Widget2 *const widget,
+ const unsigned number) :
+ ShortcutContainer(widget),
mSpellPopup(new SpellPopup),
mNumber(number),
mSpellClicked(false)
@@ -90,7 +89,7 @@ void SpellShortcutContainer::setWidget2(const Widget2 *const widget)
mForegroundColor2 = getThemeColor(Theme::TEXT_OUTLINE);
}
-void SpellShortcutContainer::draw(gcn::Graphics *graphics)
+void SpellShortcutContainer::draw(Graphics *graphics)
{
if (!spellShortcut)
return;
@@ -103,12 +102,11 @@ void SpellShortcutContainer::draw(gcn::Graphics *graphics)
mBackgroundImg->setAlpha(mAlpha);
}
- Graphics *const g = static_cast<Graphics *const>(graphics);
- gcn::Font *const font = getFont();
+ Font *const font = getFont();
const int selectedId = spellShortcut->getSelectedItem();
- g->setColorAll(mForegroundColor, mForegroundColor2);
- drawBackground(g);
+ graphics->setColorAll(mForegroundColor, mForegroundColor2);
+ drawBackground(graphics);
for (unsigned i = 0; i < mMaxItems; i++)
{
@@ -118,7 +116,7 @@ void SpellShortcutContainer::draw(gcn::Graphics *graphics)
const int itemId = getItemByIndex(i);
if (selectedId >= 0 && itemId == selectedId)
{
- g->drawRectangle(gcn::Rectangle(itemX + 1, itemY + 1,
+ graphics->drawRectangle(Rect(itemX + 1, itemY + 1,
mBoxWidth - 1, mBoxHeight - 1));
}
@@ -135,11 +133,11 @@ void SpellShortcutContainer::draw(gcn::Graphics *graphics)
if (image)
{
image->setAlpha(1.0F);
- g->drawImage2(image, itemX, itemY);
+ graphics->drawImage(image, itemX, itemY);
}
}
- font->drawString(g, spell->getSymbol(),
+ font->drawString(graphics, spell->getSymbol(),
itemX + 2, itemY + mBoxHeight / 2);
}
}
@@ -147,9 +145,9 @@ void SpellShortcutContainer::draw(gcn::Graphics *graphics)
BLOCK_END("SpellShortcutContainer::draw")
}
-void SpellShortcutContainer::mouseDragged(gcn::MouseEvent &event)
+void SpellShortcutContainer::mouseDragged(MouseEvent &event)
{
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ if (event.getButton() == MouseEvent::LEFT)
{
if (dragDrop.isEmpty() && mSpellClicked)
{
@@ -178,7 +176,7 @@ void SpellShortcutContainer::mouseDragged(gcn::MouseEvent &event)
}
}
-void SpellShortcutContainer::mousePressed(gcn::MouseEvent &event)
+void SpellShortcutContainer::mousePressed(MouseEvent &event)
{
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -186,16 +184,16 @@ void SpellShortcutContainer::mousePressed(gcn::MouseEvent &event)
return;
const unsigned int eventButton = event.getButton();
- if (eventButton == gcn::MouseEvent::LEFT)
+ if (eventButton == MouseEvent::LEFT)
{
const int itemId = getItemByIndex(index);
if (itemId > 0)
mSpellClicked = true;
}
- else if (eventButton == gcn::MouseEvent::RIGHT)
+ else if (eventButton == MouseEvent::RIGHT)
{
}
- else if (eventButton == gcn::MouseEvent::MIDDLE)
+ else if (eventButton == MouseEvent::MIDDLE)
{
if (!spellShortcut || !spellManager)
return;
@@ -205,7 +203,7 @@ void SpellShortcutContainer::mousePressed(gcn::MouseEvent &event)
}
}
-void SpellShortcutContainer::mouseReleased(gcn::MouseEvent &event)
+void SpellShortcutContainer::mouseReleased(MouseEvent &event)
{
if (!spellShortcut || !spellManager)
return;
@@ -221,7 +219,7 @@ void SpellShortcutContainer::mouseReleased(gcn::MouseEvent &event)
const int itemId = getItemByIndex(index);
const unsigned int eventButton = event.getButton();
- if (eventButton == gcn::MouseEvent::LEFT)
+ if (eventButton == MouseEvent::LEFT)
{
mSpellClicked = false;
@@ -273,7 +271,7 @@ void SpellShortcutContainer::mouseReleased(gcn::MouseEvent &event)
}
}
}
- else if (eventButton == gcn::MouseEvent::RIGHT)
+ else if (eventButton == MouseEvent::RIGHT)
{
TextCommand *spell = nullptr;
if (itemId >= 0)
@@ -285,7 +283,7 @@ void SpellShortcutContainer::mouseReleased(gcn::MouseEvent &event)
}
// Show ItemTooltip
-void SpellShortcutContainer::mouseMoved(gcn::MouseEvent &event)
+void SpellShortcutContainer::mouseMoved(MouseEvent &event)
{
if (!mSpellPopup || !spellShortcut || !spellManager)
return;
@@ -309,13 +307,13 @@ void SpellShortcutContainer::mouseMoved(gcn::MouseEvent &event)
}
}
-void SpellShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED)
+void SpellShortcutContainer::mouseExited(MouseEvent &event A_UNUSED)
{
if (mSpellPopup)
mSpellPopup->setVisible(false);
}
-void SpellShortcutContainer::widgetHidden(const gcn::Event &event A_UNUSED)
+void SpellShortcutContainer::widgetHidden(const Event &event A_UNUSED)
{
if (mSpellPopup)
mSpellPopup->setVisible(false);
diff --git a/src/gui/widgets/spellshortcutcontainer.h b/src/gui/widgets/spellshortcutcontainer.h
index 37e7b5660..afff6dcf9 100644
--- a/src/gui/widgets/spellshortcutcontainer.h
+++ b/src/gui/widgets/spellshortcutcontainer.h
@@ -38,7 +38,8 @@ class SpellShortcutContainer final : public ShortcutContainer
/**
* Constructor. Initializes the graphic.
*/
- explicit SpellShortcutContainer(const unsigned number);
+ explicit SpellShortcutContainer(Widget2 *const widget,
+ const unsigned number);
A_DELETE_COPY(SpellShortcutContainer)
@@ -50,28 +51,28 @@ class SpellShortcutContainer final : public ShortcutContainer
/**
* Draws the items.
*/
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
/**
* Handles mouse when dragged.
*/
- void mouseDragged(gcn::MouseEvent &event) override final;
+ void mouseDragged(MouseEvent &event) override final;
/**
* Handles mouse when pressed.
*/
- void mousePressed(gcn::MouseEvent &event) override final;
+ void mousePressed(MouseEvent &event) override final;
/**
* Handles mouse release.
*/
- void mouseReleased(gcn::MouseEvent &event) override final;
+ void mouseReleased(MouseEvent &event) override final;
- void widgetHidden(const gcn::Event &event) override final;
+ void widgetHidden(const Event &event) override final;
- void mouseExited(gcn::MouseEvent &event) override final;
+ void mouseExited(MouseEvent &event) override final;
- void mouseMoved(gcn::MouseEvent &event) override final;
+ void mouseMoved(MouseEvent &event) override final;
void setWidget2(const Widget2 *const widget) override final;
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index 3b0cf1db5..d2bb24720 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -20,29 +20,74 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include "gui/widgets/tabbedarea.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
+
+#include "gui/gui.h"
#include "gui/widgets/button.h"
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/tabs/tab.h"
-#include <guichan/widgets/container.hpp>
+#include "gui/base/widgets/container.hpp"
#include "debug.h"
TabbedArea::TabbedArea(const Widget2 *const widget) :
- Widget2(widget),
- gcn::ActionListener(),
- gcn::BasicContainer(),
- gcn::KeyListener(),
- gcn::MouseListener(),
- gcn::WidgetListener(),
+ ActionListener(),
+ gcn::BasicContainer(widget),
+ KeyListener(),
+ MouseListener(),
+ WidgetListener(),
mSelectedTab(nullptr),
- mTabContainer(new gcn::Container()),
- mWidgetContainer(new gcn::Container()),
+ mTabContainer(new gcn::Container(widget)),
+ mWidgetContainer(new gcn::Container(widget)),
mTabsToDelete(),
mTabs(),
mTabsWidth(0),
@@ -72,7 +117,7 @@ TabbedArea::TabbedArea(const Widget2 *const widget) :
void TabbedArea::postInit()
{
- widgetResized(gcn::Event(nullptr));
+ widgetResized(Event(nullptr));
}
TabbedArea::~TabbedArea()
@@ -139,7 +184,7 @@ Tab *TabbedArea::getTab(const std::string &name) const
return nullptr;
}
-void TabbedArea::draw(gcn::Graphics *graphics)
+void TabbedArea::draw(Graphics *graphics)
{
BLOCK_START("TabbedArea::draw")
if (mTabs.empty())
@@ -152,7 +197,7 @@ void TabbedArea::draw(gcn::Graphics *graphics)
BLOCK_END("TabbedArea::draw")
}
-gcn::Widget *TabbedArea::getWidget(const std::string &name) const
+Widget *TabbedArea::getWidget(const std::string &name) const
{
TabContainer::const_iterator itr = mTabs.begin();
const TabContainer::const_iterator itr_end = mTabs.end();
@@ -167,7 +212,7 @@ gcn::Widget *TabbedArea::getWidget(const std::string &name) const
return nullptr;
}
-gcn::Widget *TabbedArea::getCurrentWidget() const
+Widget *TabbedArea::getCurrentWidget() const
{
const Tab *const tab = getSelectedTab();
@@ -178,7 +223,7 @@ gcn::Widget *TabbedArea::getCurrentWidget() const
}
void TabbedArea::addTab(Tab *const tab,
- gcn::Widget *const widget)
+ Widget *const widget)
{
if (!tab || !widget)
return;
@@ -187,7 +232,7 @@ void TabbedArea::addTab(Tab *const tab,
tab->addActionListener(this);
mTabContainer->add(tab);
- mTabs.push_back(std::pair<Tab*, gcn::Widget*>(tab, widget));
+ mTabs.push_back(std::pair<Tab*, Widget*>(tab, widget));
if (!mSelectedTab)
setSelectedTab(tab);
@@ -203,14 +248,14 @@ void TabbedArea::addTab(Tab *const tab,
updateArrowEnableState();
}
-void TabbedArea::adjustWidget(gcn::Widget *const widget) const
+void TabbedArea::adjustWidget(Widget *const widget) const
{
const int frameSize = 2 * mFrameSize;
widget->setSize(getWidth() - frameSize,
getHeight() - frameSize - mTabContainer->getHeight());
}
-void TabbedArea::addTab(const std::string &caption, gcn::Widget *const widget)
+void TabbedArea::addTab(const std::string &caption, Widget *const widget)
{
Tab *const tab = new Tab(this);
tab->setCaption(caption);
@@ -219,7 +264,7 @@ void TabbedArea::addTab(const std::string &caption, gcn::Widget *const widget)
addTab(tab, widget);
}
-void TabbedArea::addTab(Image *const image, gcn::Widget *const widget)
+void TabbedArea::addTab(Image *const image, Widget *const widget)
{
Tab *const tab = new Tab(this);
tab->setImage(image);
@@ -323,14 +368,14 @@ void TabbedArea::logic()
BLOCK_END("TabbedArea::logic")
}
-void TabbedArea::mousePressed(gcn::MouseEvent &mouseEvent)
+void TabbedArea::mousePressed(MouseEvent &mouseEvent)
{
if (mouseEvent.isConsumed())
return;
- if (mouseEvent.getButton() == gcn::MouseEvent::LEFT)
+ if (mouseEvent.getButton() == MouseEvent::LEFT)
{
- gcn::Widget *const widget = mTabContainer->getWidgetAt(
+ Widget *const widget = mTabContainer->getWidgetAt(
mouseEvent.getX(), mouseEvent.getY());
Tab *const tab = dynamic_cast<Tab *const>(widget);
@@ -365,7 +410,7 @@ void TabbedArea::setSelectedTab(Tab *const tab)
if (newTab)
newTab->setCurrent();
- widgetResized(gcn::Event(nullptr));
+ widgetResized(Event(nullptr));
}
int TabbedArea::getSelectedTabIndex() const
@@ -392,7 +437,7 @@ void TabbedArea::setSelectedTabByName(const std::string &name)
}
}
-void TabbedArea::widgetResized(const gcn::Event &event A_UNUSED)
+void TabbedArea::widgetResized(const Event &event A_UNUSED)
{
adjustSize();
@@ -404,7 +449,7 @@ void TabbedArea::widgetResized(const gcn::Event &event A_UNUSED)
const int height = h1 - frameSize
- mWidgetContainer->getY() - widgetFrameSize;
- gcn::Widget *const w = getCurrentWidget();
+ Widget *const w = getCurrentWidget();
if (w)
{
ScrollArea *const scr = dynamic_cast<ScrollArea *const>(w);
@@ -412,7 +457,7 @@ void TabbedArea::widgetResized(const gcn::Event &event A_UNUSED)
{
if (mFollowDownScroll && height != 0)
{
- const gcn::Rectangle &rect = w->getDimension();
+ const Rect &rect = w->getDimension();
if (rect.height != 0 && rect.height > height + 2)
{
if (scr->getVerticalScrollAmount()
@@ -500,7 +545,7 @@ void TabbedArea::adjustSize()
mWidgetContainer->setPosition(0, maxTabHeight);
mWidgetContainer->setSize(width, height - maxTabHeight);
- gcn::Widget *const w = getCurrentWidget();
+ Widget *const w = getCurrentWidget();
if (w)
{
const int wFrameSize = w->getFrameSize();
@@ -558,9 +603,9 @@ void TabbedArea::adjustTabPositions()
}
}
-void TabbedArea::action(const gcn::ActionEvent& actionEvent)
+void TabbedArea::action(const ActionEvent& actionEvent)
{
- gcn::Widget *const source = actionEvent.getSource();
+ Widget *const source = actionEvent.getSource();
Tab *const tab = dynamic_cast<Tab *const>(source);
if (tab)
@@ -632,7 +677,7 @@ Tab *TabbedArea::getTabByIndex(const int index) const
return static_cast<Tab*>(mTabs[index].first);
}
-gcn::Widget *TabbedArea::getWidgetByIndex(const int index) const
+Widget *TabbedArea::getWidgetByIndex(const int index) const
{
if (index < 0 || index >= static_cast<int>(mTabs.size()))
return nullptr;
@@ -649,7 +694,7 @@ void TabbedArea::removeAll(const bool del)
{
const int idx = getNumberOfTabs() - 1;
Tab *tab = mTabs[idx].first;
- gcn::Widget *widget = mTabs[idx].second;
+ Widget *widget = mTabs[idx].second;
removeTab(tab);
if (del)
{
@@ -661,34 +706,34 @@ void TabbedArea::removeAll(const bool del)
void TabbedArea::setWidth(int width)
{
- gcn::Widget::setWidth(width);
+ Widget::setWidth(width);
adjustSize();
}
void TabbedArea::setHeight(int height)
{
- gcn::Widget::setHeight(height);
+ Widget::setHeight(height);
adjustSize();
}
void TabbedArea::setSize(int width, int height)
{
- gcn::Widget::setSize(width, height);
+ Widget::setSize(width, height);
adjustSize();
}
-void TabbedArea::setDimension(const gcn::Rectangle &dimension)
+void TabbedArea::setDimension(const Rect &dimension)
{
- gcn::Widget::setDimension(dimension);
+ Widget::setDimension(dimension);
adjustSize();
}
-void TabbedArea::keyPressed(gcn::KeyEvent& keyEvent)
+void TabbedArea::keyPressed(KeyEvent& keyEvent)
{
if (mBlockSwitching || keyEvent.isConsumed() || !isFocused())
return;
- const int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int actionId = keyEvent.getActionId();
if (actionId == Input::KEY_GUI_LEFT)
{
@@ -716,7 +761,7 @@ void TabbedArea::keyPressed(gcn::KeyEvent& keyEvent)
}
}
-void TabbedArea::death(const gcn::Event &event)
+void TabbedArea::death(const Event &event)
{
Tab *const tab = dynamic_cast<Tab*>(event.getSource());
diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h
index d0f97b688..dbaa4334b 100644
--- a/src/gui/widgets/tabbedarea.h
+++ b/src/gui/widgets/tabbedarea.h
@@ -20,16 +20,59 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#ifndef GUI_WIDGETS_TABBEDAREA_H
#define GUI_WIDGETS_TABBEDAREA_H
-#include "gui/widgets/widget2.h"
+#include "listeners/keylistener.h"
+#include "listeners/mouselistener.h"
+#include "listeners/widgetlistener.h"
+
+#include "gui/base/widgets/container.hpp"
-#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
-#include <guichan/mouselistener.hpp>
-#include <guichan/widgetlistener.hpp>
-#include <guichan/widgets/container.hpp>
+#include "listeners/actionlistener.h"
class Button;
class Image;
@@ -38,12 +81,11 @@ class Tab;
/**
* A tabbed area, the same as the guichan tabbed area in 0.8, but extended
*/
-class TabbedArea final : public Widget2,
- public gcn::ActionListener,
+class TabbedArea final : public ActionListener,
public gcn::BasicContainer,
- public gcn::KeyListener,
- public gcn::MouseListener,
- public gcn::WidgetListener
+ public KeyListener,
+ public MouseListener,
+ public WidgetListener
{
public:
/**
@@ -60,7 +102,7 @@ class TabbedArea final : public Widget2,
/**
* Draw the tabbed area.
*/
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
/**
* Return how many tabs have been created.
@@ -76,17 +118,17 @@ class TabbedArea final : public Widget2,
Tab *getTabByIndex(const int index) const A_WARN_UNUSED;
- gcn::Widget *getWidgetByIndex(const int index) const A_WARN_UNUSED;
+ Widget *getWidgetByIndex(const int index) const A_WARN_UNUSED;
/**
* Returns the widget with the tab that has specified caption
*/
- gcn::Widget *getWidget(const std::string &name) const A_WARN_UNUSED;
+ Widget *getWidget(const std::string &name) const A_WARN_UNUSED;
/**
* Returns the widget for the current tab
*/
- gcn::Widget *getCurrentWidget() const A_WARN_UNUSED;
+ Widget *getCurrentWidget() const A_WARN_UNUSED;
/**
* Add a tab. Overridden since it needs to size the widget.
@@ -94,11 +136,11 @@ class TabbedArea final : public Widget2,
* @param tab The tab widget for the tab.
* @param widget The widget to view when the tab is selected.
*/
- void addTab(Tab *const tab, gcn::Widget *const widget);
+ void addTab(Tab *const tab, Widget *const widget);
- void addTab(const std::string &caption, gcn::Widget *const widget);
+ void addTab(const std::string &caption, Widget *const widget);
- void addTab(Image *const image, gcn::Widget *const widget);
+ void addTab(Image *const image, Widget *const widget);
bool isTabSelected(const unsigned int index) const A_WARN_UNUSED;
@@ -140,7 +182,7 @@ class TabbedArea final : public Widget2,
void setSelectedTabByName(const std::string &name);
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
/*
void moveLeft(Tab *tab);
@@ -149,11 +191,11 @@ class TabbedArea final : public Widget2,
*/
void adjustTabPositions();
- void action(const gcn::ActionEvent& actionEvent) override final;
+ void action(const ActionEvent& actionEvent) override final;
// Inherited from MouseListener
- void mousePressed(gcn::MouseEvent &mouseEvent) override final;
+ void mousePressed(MouseEvent &mouseEvent) override final;
void enableScrollButtons(const bool enable);
@@ -169,7 +211,7 @@ class TabbedArea final : public Widget2,
bool getFollowDownScroll() const A_WARN_UNUSED
{ return mFollowDownScroll; }
- void keyPressed(gcn::KeyEvent& keyEvent) override final;
+ void keyPressed(KeyEvent& keyEvent) override final;
void setBlockSwitching(const bool b)
{ mBlockSwitching = b; }
@@ -180,21 +222,21 @@ class TabbedArea final : public Widget2,
void setSize(int width, int height);
- void setDimension(const gcn::Rectangle &dimension);
+ void setDimension(const Rect &dimension);
- void death(const gcn::Event &event);
+ void death(const Event &event);
void setResizeHeight(bool b)
{ mResizeHeight = b; }
- void adjustWidget(gcn::Widget *const widget) const;
+ void adjustWidget(Widget *const widget) const;
void selectNextTab();
void selectPrevTab();
private:
- typedef std::vector <std::pair<Tab*, gcn::Widget*> > TabContainer;
+ typedef std::vector <std::pair<Tab*, Widget*> > TabContainer;
/** The tab arrows */
Button *mArrowButton[2];
diff --git a/src/gui/widgets/tabs/chattab.cpp b/src/gui/widgets/tabs/chattab.cpp
index 331101209..fe979ae5a 100644
--- a/src/gui/widgets/tabs/chattab.cpp
+++ b/src/gui/widgets/tabs/chattab.cpp
@@ -24,6 +24,7 @@
#include "chatlogger.h"
#include "client.h"
+#include "commands.h"
#include "commandhandler.h"
#include "configuration.h"
#include "soundconsts.h"
@@ -50,12 +51,13 @@
static const unsigned int MAX_WORD_SIZE = 50;
-ChatTab::ChatTab(const Widget2 *const widget, const std::string &name,
+ChatTab::ChatTab(const Widget2 *const widget,
+ const std::string &name,
const std::string &channel) :
Tab(widget),
mTextOutput(new BrowserBox(this, BrowserBox::AUTO_WRAP, true,
"browserbox.xml")),
- mScrollArea(new ScrollArea(mTextOutput, false)),
+ mScrollArea(new ScrollArea(this, mTextOutput, false)),
mChannelName(channel),
mAllowHightlight(true),
mRemoveNames(false),
@@ -405,7 +407,7 @@ void ChatTab::chatInput(const std::string &message)
void ChatTab::scroll(const int amount)
{
const int range = mScrollArea->getHeight() / 8 * amount;
- gcn::Rectangle scr;
+ Rect scr;
scr.y = mScrollArea->getVerticalScrollAmount() + range;
scr.height = abs(range);
mTextOutput->showPart(scr);
diff --git a/src/gui/widgets/tabs/chattab.h b/src/gui/widgets/tabs/chattab.h
index 651e69d6b..a46279483 100644
--- a/src/gui/widgets/tabs/chattab.h
+++ b/src/gui/widgets/tabs/chattab.h
@@ -58,7 +58,8 @@ class ChatTab : public Tab
/**
* Constructor.
*/
- ChatTab(const Widget2 *const widget, const std::string &name,
+ ChatTab(const Widget2 *const widget,
+ const std::string &name,
const std::string &channel);
A_DELETE_COPY(ChatTab)
diff --git a/src/gui/widgets/tabs/guildchattab.h b/src/gui/widgets/tabs/guildchattab.h
index fbfd3a032..cfcf901ca 100644
--- a/src/gui/widgets/tabs/guildchattab.h
+++ b/src/gui/widgets/tabs/guildchattab.h
@@ -28,7 +28,8 @@
/**
* A tab for a guild chat channel.
*/
-class GuildChatTab final : public ChatTab, public ConfigListener
+class GuildChatTab final : public ChatTab,
+ public ConfigListener
{
public:
explicit GuildChatTab(const Widget2 *const widget);
diff --git a/src/gui/widgets/tabs/langtab.cpp b/src/gui/widgets/tabs/langtab.cpp
index fb6a5e12b..f5064be8c 100644
--- a/src/gui/widgets/tabs/langtab.cpp
+++ b/src/gui/widgets/tabs/langtab.cpp
@@ -26,7 +26,8 @@
#include "debug.h"
-LangTab::LangTab(const Widget2 *const widget, const std::string &lang) :
+LangTab::LangTab(const Widget2 *const widget,
+ const std::string &lang) :
// TRANSLATORS: lang chat tab name
ChatTab(widget, _("Lang"), lang + " ")
{
diff --git a/src/gui/widgets/tabs/langtab.h b/src/gui/widgets/tabs/langtab.h
index 275b69399..e036e4dd8 100644
--- a/src/gui/widgets/tabs/langtab.h
+++ b/src/gui/widgets/tabs/langtab.h
@@ -26,7 +26,8 @@
class LangTab final : public ChatTab
{
public:
- LangTab(const Widget2 *const widget, const std::string &lang);
+ LangTab(const Widget2 *const widget,
+ const std::string &lang);
A_DELETE_COPY(LangTab)
diff --git a/src/gui/widgets/tabs/setup_audio.cpp b/src/gui/widgets/tabs/setup_audio.cpp
index 1bb119ee4..6cf675635 100644
--- a/src/gui/widgets/tabs/setup_audio.cpp
+++ b/src/gui/widgets/tabs/setup_audio.cpp
@@ -30,28 +30,15 @@
#include "gui/viewport.h"
+#include "gui/models/soundsmodel.h"
+
#include "gui/widgets/layouthelper.h"
-#include "gui/widgets/namesmodel.h"
#include "gui/widgets/scrollarea.h"
#include "utils/gettext.h"
#include "debug.h"
-class SoundsModel final : public NamesModel
-{
-public:
- SoundsModel() :
- NamesModel()
- {
- mNames.push_back(gettext("(no sound)"));
- Theme::fillSoundsList(mNames);
- }
-
- ~SoundsModel()
- { }
-};
-
Setup_Audio::Setup_Audio(const Widget2 *const widget) :
SetupTabScroll(widget),
mSoundModel(new SoundsModel),
@@ -168,7 +155,7 @@ Setup_Audio::Setup_Audio(const Widget2 *const widget) :
new SetupItemCheckBox(_("Download music"), "",
"download-music", this, "download-musicEvent");
- setDimension(gcn::Rectangle(0, 0, 550, 350));
+ setDimension(Rect(0, 0, 550, 350));
}
Setup_Audio::~Setup_Audio()
diff --git a/src/gui/widgets/tabs/setup_audio.h b/src/gui/widgets/tabs/setup_audio.h
index 839734b39..b3736e814 100644
--- a/src/gui/widgets/tabs/setup_audio.h
+++ b/src/gui/widgets/tabs/setup_audio.h
@@ -25,6 +25,8 @@
#include "gui/widgets/setupitem.h"
+#include "gui/widgets/tabs/setuptabscroll.h"
+
class Setup_Audio final : public SetupTabScroll
{
public:
@@ -37,7 +39,7 @@ class Setup_Audio final : public SetupTabScroll
void apply() override final;
private:
- gcn::ListModel *mSoundModel;
+ ListModel *mSoundModel;
SetupItemNames *mChannelsList;
};
diff --git a/src/gui/widgets/tabs/setup_chat.cpp b/src/gui/widgets/tabs/setup_chat.cpp
index 3aa6d39d2..7ac88ab0a 100644
--- a/src/gui/widgets/tabs/setup_chat.cpp
+++ b/src/gui/widgets/tabs/setup_chat.cpp
@@ -195,7 +195,7 @@ Setup_Chat::Setup_Chat(const Widget2 *const widget) :
new SetupItemCheckBox(_("Show motd server message on start"), "",
"showmotd", this, "showmotdEvent");
- setDimension(gcn::Rectangle(0, 0, 550, 350));
+ setDimension(Rect(0, 0, 550, 350));
}
void Setup_Chat::apply()
diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp
index 1094f5e29..ac6bf2837 100644
--- a/src/gui/widgets/tabs/setup_colors.cpp
+++ b/src/gui/widgets/tabs/setup_colors.cpp
@@ -21,7 +21,8 @@
#include "gui/widgets/tabs/setup_colors.h"
-#include "gui/sdlfont.h"
+#include "gui/font.h"
+#include "gui/gui.h"
#include "gui/userpalette.h"
#include "gui/widgets/browserbox.h"
@@ -47,34 +48,35 @@ const char *const Setup_Colors::rawmsg =
Setup_Colors::Setup_Colors(const Widget2 *const widget) :
SetupTab(widget),
- gcn::SelectionListener(),
+ SelectionListener(),
mColorBox(new ListBox(this, userPalette, "")),
- mScroll(new ScrollArea(mColorBox, true, "setup_colors_background.xml")),
+ mScroll(new ScrollArea(this, mColorBox,
+ true, "setup_colors_background.xml")),
mPreview(new BrowserBox(this, BrowserBox::AUTO_WRAP, true,
"browserbox.xml")),
mTextPreview(new TextPreview(this, gettext(rawmsg))),
- mPreviewBox(new ScrollArea(mPreview, true,
+ mPreviewBox(new ScrollArea(this, mPreview, true,
"setup_colors_preview_background.xml")),
mSelected(-1),
// TRANSLATORS: colors tab. label.
mGradTypeLabel(new Label(this, _("Type:"))),
- mGradTypeSlider(new Slider(0, 3)),
+ mGradTypeSlider(new Slider(this, 0, 3)),
mGradTypeText(new Label(this)),
// TRANSLATORS: colors tab. label.
mGradDelayLabel(new Label(this, _("Delay:"))),
- mGradDelaySlider(new Slider(20, 100)),
+ mGradDelaySlider(new Slider(this, 20, 100)),
mGradDelayText(new TextField(this)),
// TRANSLATORS: colors tab. label.
mRedLabel(new Label(this, _("Red:"))),
- mRedSlider(new Slider(0, 255)),
+ mRedSlider(new Slider(this, 0, 255)),
mRedText(new TextField(this)),
// TRANSLATORS: colors tab. label.
mGreenLabel(new Label(this, _("Green:"))),
- mGreenSlider(new Slider(0, 255)),
+ mGreenSlider(new Slider(this, 0, 255)),
mGreenText(new TextField(this)),
// TRANSLATORS: colors tab. label.
mBlueLabel(new Label(this, _("Blue:"))),
- mBlueSlider(new Slider(0, 255)),
+ mBlueSlider(new Slider(this, 0, 255)),
mBlueText(new TextField(this))
{
mColorBox->postInit();
@@ -101,7 +103,7 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) :
// TRANSLATORS: color type
std::string longText = _("Static");
- const gcn::Font *const font = getFont();
+ const Font *const font = getFont();
if (getFont()->getWidth(_("Pulse")) > font->getWidth(longText))
{
// TRANSLATORS: color type
@@ -190,7 +192,7 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) :
mGradTypeText->setCaption("");
- setDimension(gcn::Rectangle(0, 0, 365, 350));
+ setDimension(Rect(0, 0, 365, 350));
}
Setup_Colors::~Setup_Colors()
@@ -207,7 +209,7 @@ Setup_Colors::~Setup_Colors()
}
}
-void Setup_Colors::action(const gcn::ActionEvent &event)
+void Setup_Colors::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "slider_grad")
@@ -244,14 +246,14 @@ void Setup_Colors::action(const gcn::ActionEvent &event)
}
}
-void Setup_Colors::valueChanged(const gcn::SelectionEvent &event A_UNUSED)
+void Setup_Colors::valueChanged(const SelectionEvent &event A_UNUSED)
{
if (!userPalette)
return;
mSelected = mColorBox->getSelected();
const int type = userPalette->getColorTypeAt(mSelected);
- const gcn::Color *col = &userPalette->getColor(type);
+ const Color *col = &userPalette->getColor(type);
const Palette::GradientType grad = userPalette->getGradientType(type);
const int delay = userPalette->getGradientDelay(type);
@@ -381,7 +383,7 @@ void Setup_Colors::cancel()
userPalette->rollback();
const int type = userPalette->getColorTypeAt(mSelected);
- const gcn::Color *const col = &userPalette->getColor(type);
+ const Color *const col = &userPalette->getColor(type);
mGradTypeSlider->setValue2(userPalette->getGradientType(type));
const int delay = userPalette->getGradientDelay(type);
setEntry(mGradDelaySlider, mGradDelayText, delay);
@@ -442,7 +444,7 @@ void Setup_Colors::updateColor()
}
else if (grad == Palette::PULSE)
{
- userPalette->setTestColor(type, gcn::Color(
+ userPalette->setTestColor(type, Color(
static_cast<int>(mRedSlider->getValue()),
static_cast<int>(mGreenSlider->getValue()),
static_cast<int>(mBlueSlider->getValue())));
diff --git a/src/gui/widgets/tabs/setup_colors.h b/src/gui/widgets/tabs/setup_colors.h
index b2f860415..ce491706c 100644
--- a/src/gui/widgets/tabs/setup_colors.h
+++ b/src/gui/widgets/tabs/setup_colors.h
@@ -24,9 +24,7 @@
#include "gui/widgets/tabs/setuptab.h"
-#include <guichan/selectionlistener.hpp>
-
-#include <string>
+#include "listeners/selectionlistener.h"
class BrowserBox;
class Label;
@@ -37,7 +35,7 @@ class TextField;
class TextPreview;
class Setup_Colors final : public SetupTab,
- public gcn::SelectionListener
+ public SelectionListener
{
public:
explicit Setup_Colors(const Widget2 *const widget);
@@ -50,9 +48,9 @@ class Setup_Colors final : public SetupTab,
void cancel() override final;
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
- void valueChanged(const gcn::SelectionEvent &event) override final;
+ void valueChanged(const SelectionEvent &event) override final;
private:
static const char *const rawmsg;
diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp
index 9ce6fd616..b04937881 100644
--- a/src/gui/widgets/tabs/setup_input.cpp
+++ b/src/gui/widgets/tabs/setup_input.cpp
@@ -28,6 +28,7 @@
#include "input/inputmanager.h"
#include "input/keyboardconfig.h"
+#include "gui/gui.h"
#include "gui/setupactiondata.h"
#include "gui/windows/okdialog.h"
@@ -38,7 +39,7 @@
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/tabstrip.h"
-#include <guichan/listmodel.hpp>
+#include "gui/models/listmodel.h"
#include "debug.h"
@@ -50,7 +51,7 @@ static const int setupGroups = 9;
*
* \ingroup Interface
*/
-class KeyListModel final : public gcn::ListModel
+class KeyListModel final : public ListModel
{
public:
KeyListModel() :
@@ -103,7 +104,8 @@ Setup_Input::Setup_Input(const Widget2 *const widget) :
// TRANSLATORS: button in input settings tab
mResetKeysButton(new Button(this, _("Reset all keys"), "resetkeys", this)),
mTabs(new TabStrip(this, config.getIntValue("fontSize") + 10)),
- mScrollArea(new ScrollArea(mKeyList, true, "setup_input_background.xml")),
+ mScrollArea(new ScrollArea(this, mKeyList,
+ true, "setup_input_background.xml")),
mKeySetting(false),
mActionDataSize(new int [9])
{
@@ -125,7 +127,7 @@ Setup_Input::Setup_Input(const Widget2 *const widget) :
mKeyListModel->setSize(mActionDataSize[0]);
refreshKeys();
if (gui)
- mKeyList->setFont(reinterpret_cast<gcn::Font*>(gui->getHelpFont()));
+ mKeyList->setFont(gui->getHelpFont());
mKeyList->addActionListener(this);
mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
@@ -162,7 +164,7 @@ Setup_Input::Setup_Input(const Widget2 *const widget) :
if (config.getIntValue("screenwidth") >= 730)
width += 100;
- setDimension(gcn::Rectangle(0, 0, width, 350));
+ setDimension(Rect(0, 0, width, 350));
}
Setup_Input::~Setup_Input()
@@ -213,7 +215,7 @@ void Setup_Input::cancel()
refreshKeys();
}
-void Setup_Input::action(const gcn::ActionEvent &event)
+void Setup_Input::action(const ActionEvent &event)
{
const std::string id = event.getId();
diff --git a/src/gui/widgets/tabs/setup_input.h b/src/gui/widgets/tabs/setup_input.h
index 135cb3339..43ec53b56 100644
--- a/src/gui/widgets/tabs/setup_input.h
+++ b/src/gui/widgets/tabs/setup_input.h
@@ -55,7 +55,7 @@ class Setup_Input final : public SetupTab
void cancel() override final;
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Get an update on the assigned key.
diff --git a/src/gui/widgets/tabs/setup_joystick.cpp b/src/gui/widgets/tabs/setup_joystick.cpp
index 6f023a488..b3d7b78b9 100644
--- a/src/gui/widgets/tabs/setup_joystick.cpp
+++ b/src/gui/widgets/tabs/setup_joystick.cpp
@@ -26,12 +26,13 @@
#include "input/joystick.h"
+#include "gui/models/namesmodel.h"
+
#include "gui/widgets/button.h"
#include "gui/widgets/checkbox.h"
#include "gui/widgets/dropdown.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layouthelper.h"
-#include "gui/widgets/namesmodel.h"
#include "utils/gettext.h"
@@ -93,7 +94,7 @@ Setup_Joystick::Setup_Joystick(const Widget2 *const widget) :
place(0, 4, mCalibrateLabel);
place(0, 5, mCalibrateButton);
- setDimension(gcn::Rectangle(0, 0, 365, 75));
+ setDimension(Rect(0, 0, 365, 75));
}
Setup_Joystick::~Setup_Joystick()
@@ -102,9 +103,9 @@ Setup_Joystick::~Setup_Joystick()
mNamesModel = nullptr;
}
-void Setup_Joystick::action(const gcn::ActionEvent &event)
+void Setup_Joystick::action(const ActionEvent &event)
{
- const gcn::Widget *const source = event.getSource();
+ const Widget *const source = event.getSource();
if (source == mJoystickEnabled)
{
setTempEnabled(mJoystickEnabled->isSelected());
diff --git a/src/gui/widgets/tabs/setup_joystick.h b/src/gui/widgets/tabs/setup_joystick.h
index 5c7b764ec..ac6caef24 100644
--- a/src/gui/widgets/tabs/setup_joystick.h
+++ b/src/gui/widgets/tabs/setup_joystick.h
@@ -44,7 +44,7 @@ class Setup_Joystick final : public SetupTab
void cancel() override final;
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void setTempEnabled(const bool sel);
diff --git a/src/gui/widgets/tabs/setup_mods.cpp b/src/gui/widgets/tabs/setup_mods.cpp
index ada0ef686..b30b84c16 100644
--- a/src/gui/widgets/tabs/setup_mods.cpp
+++ b/src/gui/widgets/tabs/setup_mods.cpp
@@ -44,7 +44,7 @@ Setup_Mods::Setup_Mods(const Widget2 *const widget) :
ContainerPlacer place = h.getPlacer(0, 0);
place(0, 0, mScroll, 10, 10);
- setDimension(gcn::Rectangle(0, 0, 550, 350));
+ setDimension(Rect(0, 0, 550, 350));
}
Setup_Mods::~Setup_Mods()
diff --git a/src/gui/widgets/tabs/setup_other.cpp b/src/gui/widgets/tabs/setup_other.cpp
index 985baa744..e4801506c 100644
--- a/src/gui/widgets/tabs/setup_other.cpp
+++ b/src/gui/widgets/tabs/setup_other.cpp
@@ -22,8 +22,9 @@
#include "gui/widgets/tabs/setup_other.h"
+#include "gui/models/namesmodel.h"
+
#include "gui/widgets/layouthelper.h"
-#include "gui/widgets/namesmodel.h"
#include "gui/widgets/setupitem.h"
#include "gui/widgets/scrollarea.h"
@@ -390,7 +391,7 @@ Setup_Other::Setup_Other(const Widget2 *const widget) :
new SetupItemDropDown(_("Screen density override"), "",
"screenDensity", this, "screenDensityEvent", mDensityList, 100);
- setDimension(gcn::Rectangle(0, 0, 550, 350));
+ setDimension(Rect(0, 0, 550, 350));
}
Setup_Other::~Setup_Other()
diff --git a/src/gui/widgets/tabs/setup_perfomance.cpp b/src/gui/widgets/tabs/setup_perfomance.cpp
index 271501e38..5a0566ec2 100644
--- a/src/gui/widgets/tabs/setup_perfomance.cpp
+++ b/src/gui/widgets/tabs/setup_perfomance.cpp
@@ -22,8 +22,9 @@
#include "gui/widgets/tabs/setup_perfomance.h"
+#include "gui/models/namesmodel.h"
+
#include "gui/widgets/layouthelper.h"
-#include "gui/widgets/namesmodel.h"
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/setupitem.h"
@@ -153,7 +154,7 @@ Setup_Perfomance::Setup_Perfomance(const Widget2 *const widget) :
"", "uselonglivesounds", this,
"uselonglivesoundsEvent");
- setDimension(gcn::Rectangle(0, 0, 550, 350));
+ setDimension(Rect(0, 0, 550, 350));
}
Setup_Perfomance::~Setup_Perfomance()
diff --git a/src/gui/widgets/tabs/setup_players.cpp b/src/gui/widgets/tabs/setup_players.cpp
index d4f29fa2c..01bb60f53 100644
--- a/src/gui/widgets/tabs/setup_players.cpp
+++ b/src/gui/widgets/tabs/setup_players.cpp
@@ -100,5 +100,5 @@ Setup_Players::Setup_Players(const Widget2 *const widget) :
new SetupItemCheckBox(_("Use special diagonal speed in players moving"),
"", "useDiagonalSpeed", this, "useDiagonalSpeedEvent");
- setDimension(gcn::Rectangle(0, 0, 550, 350));
+ setDimension(Rect(0, 0, 550, 350));
}
diff --git a/src/gui/widgets/tabs/setup_relations.cpp b/src/gui/widgets/tabs/setup_relations.cpp
index 89d1f5beb..1458ecd25 100644
--- a/src/gui/widgets/tabs/setup_relations.cpp
+++ b/src/gui/widgets/tabs/setup_relations.cpp
@@ -26,6 +26,9 @@
#include "being/localplayer.h"
+#include "gui/models/ignorechoiceslistmodel.h"
+#include "gui/models/playerrelationlistmodel.h"
+
#include "gui/widgets/button.h"
#include "gui/widgets/checkbox.h"
#include "gui/widgets/dropdown.h"
@@ -60,43 +63,6 @@ static const char *const table_titles[COLUMNS_NR] =
N_("Relation")
};
-static const char *const RELATION_NAMES[PlayerRelation::RELATIONS_NR] =
-{
- // TRANSLATORS: relation type
- N_("Neutral"),
- // TRANSLATORS: relation type
- N_("Friend"),
- // TRANSLATORS: relation type
- N_("Disregarded"),
- // TRANSLATORS: relation type
- N_("Ignored"),
- // TRANSLATORS: relation type
- N_("Erased"),
- // TRANSLATORS: relation type
- N_("Blacklisted"),
- // TRANSLATORS: relation type
- N_("Enemy")
-};
-
-class PlayerRelationListModel final : public gcn::ListModel
-{
-public:
- ~PlayerRelationListModel()
- { }
-
- int getNumberOfElements() override final
- {
- return PlayerRelation::RELATIONS_NR;
- }
-
- std::string getElementAt(int i) override final
- {
- if (i >= getNumberOfElements() || i < 0)
- return "";
- return gettext(RELATION_NAMES[i]);
- }
-};
-
class PlayerTableModel final : public Widget2, public TableModel
{
public:
@@ -165,7 +131,7 @@ public:
player_names->size()); r < sz; ++r)
{
const std::string name = (*player_names)[r];
- gcn::Widget *const widget = new Label(this, name);
+ Widget *const widget = new Label(this, name);
mWidgets.push_back(widget);
DropDown *const choicebox = new DropDown(this, mListModel);
@@ -186,7 +152,7 @@ public:
}
- gcn::Widget *getElementAt(int row, int column) const override final
+ Widget *getElementAt(int row, int column) const override final
{
return mWidgets[WIDGET_AT(row, column)];
}
@@ -209,35 +175,10 @@ public:
protected:
StringVect *mPlayers;
- std::vector<gcn::Widget *> mWidgets;
+ std::vector<Widget *> mWidgets;
PlayerRelationListModel *mListModel;
};
-/**
- * Class for choosing one of the various `what to do when ignoring a player' options
- */
-class IgnoreChoicesListModel final : public gcn::ListModel
-{
-public:
- ~IgnoreChoicesListModel()
- { }
-
- int getNumberOfElements() override final
- {
- return static_cast<int>(player_relations.getPlayerIgnoreStrategies()
- ->size());
- }
-
- std::string getElementAt(int i) override final
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
-
- return (*player_relations.getPlayerIgnoreStrategies())
- [i]->mDescription;
- }
-};
-
static const std::string ACTION_DELETE("delete");
static const std::string ACTION_TABLE("table");
static const std::string ACTION_STRATEGY("strategy");
@@ -249,7 +190,7 @@ Setup_Relations::Setup_Relations(const Widget2 *const widget) :
mPlayerTableModel(new PlayerTableModel(this)),
mPlayerTable(new GuiTable(this, mPlayerTableModel)),
mPlayerTitleTable(new GuiTable(this, mPlayerTableTitleModel)),
- mPlayerScrollArea(new ScrollArea(mPlayerTable)),
+ mPlayerScrollArea(new ScrollArea(this, mPlayerTable)),
// TRANSLATORS: relation dialog button
mDefaultTrading(new CheckBox(this, _("Allow trading"),
player_relations.getDefault() & PlayerRelation::TRADE)),
@@ -319,7 +260,7 @@ Setup_Relations::Setup_Relations(const Widget2 *const widget) :
player_relations.addListener(this);
- setDimension(gcn::Rectangle(0, 0, 500, 350));
+ setDimension(Rect(0, 0, 500, 350));
}
Setup_Relations::~Setup_Relations()
@@ -370,7 +311,7 @@ void Setup_Relations::cancel()
{
}
-void Setup_Relations::action(const gcn::ActionEvent &event)
+void Setup_Relations::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == ACTION_TABLE)
diff --git a/src/gui/widgets/tabs/setup_relations.h b/src/gui/widgets/tabs/setup_relations.h
index c9d8e50a3..9fc197ffc 100644
--- a/src/gui/widgets/tabs/setup_relations.h
+++ b/src/gui/widgets/tabs/setup_relations.h
@@ -27,19 +27,17 @@
#include "gui/widgets/tabs/setuptab.h"
+#include "listeners/playerrelationslistener.h"
+
class Button;
class CheckBox;
class DropDown;
class GuiTable;
+class ListModel;
class PlayerTableModel;
class ScrollArea;
class StaticTableModel;
-namespace gcn
-{
- class ListModel;
-}
-
class Setup_Relations final : public SetupTab,
public PlayerRelationsListener
{
@@ -56,7 +54,7 @@ public:
void reset();
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void updatedPlayer(const std::string &name);
@@ -76,7 +74,7 @@ private:
Button *mDeleteButton;
- gcn::ListModel *mIgnoreActionChoicesModel;
+ ListModel *mIgnoreActionChoicesModel;
DropDown *mIgnoreActionChoicesBox;
};
diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp
index d7cc4b4df..424828694 100644
--- a/src/gui/widgets/tabs/setup_theme.cpp
+++ b/src/gui/widgets/tabs/setup_theme.cpp
@@ -22,14 +22,18 @@
#include "gui/widgets/tabs/setup_theme.h"
+#include "gui/gui.h"
+
#include "gui/windows/okdialog.h"
+#include "gui/models/extendedlistmodel.h"
+#include "gui/models/fontsmodel.h"
+#include "gui/models/themesmodel.h"
+
#include "gui/widgets/button.h"
#include "gui/widgets/dropdown.h"
-#include "gui/widgets/extendedlistmodel.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layouthelper.h"
-#include "gui/widgets/namesmodel.h"
#include "configuration.h"
@@ -51,31 +55,6 @@ const char* ACTION_JAPAN_FONT = "japanese font";
const char* ACTION_CHINA_FONT = "chinese font";
const char* ACTION_INFO = "info";
-class ThemesModel final : public NamesModel
-{
-public:
- ThemesModel() :
- NamesModel()
- {
- mNames.push_back(gettext("(default)"));
- Theme::fillSkinsList(mNames);
- }
-
- ~ThemesModel()
- { }
-};
-
-class FontsModel final : public NamesModel
-{
-public:
- FontsModel() :
- NamesModel()
- { Theme::fillFontsList(mNames); }
-
- ~FontsModel()
- { }
-};
-
const int maxFontSizes = 16;
const char *SIZE_NAME[maxFontSizes] =
@@ -114,7 +93,7 @@ const char *SIZE_NAME[maxFontSizes] =
N_("Huge (23)"),
};
-class FontSizeChoiceListModel final : public gcn::ListModel
+class FontSizeChoiceListModel final : public ListModel
{
public:
~FontSizeChoiceListModel()
@@ -387,7 +366,7 @@ Setup_Theme::Setup_Theme(const Widget2 *const widget) :
else if (size > maxWidth)
size = maxWidth;
- setDimension(gcn::Rectangle(0, 0, size, 500));
+ setDimension(Rect(0, 0, size, 500));
}
Setup_Theme::~Setup_Theme()
@@ -433,7 +412,7 @@ void Setup_Theme::updateInfo()
mInfoButton->setEnabled(!mThemeInfo.empty());
}
-void Setup_Theme::action(const gcn::ActionEvent &event)
+void Setup_Theme::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == ACTION_THEME)
diff --git a/src/gui/widgets/tabs/setup_theme.h b/src/gui/widgets/tabs/setup_theme.h
index a7f3ad101..5e8fe7c2a 100644
--- a/src/gui/widgets/tabs/setup_theme.h
+++ b/src/gui/widgets/tabs/setup_theme.h
@@ -46,7 +46,7 @@ class Setup_Theme final : public SetupTab
void cancel() override final;
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void updateInfo();
diff --git a/src/gui/widgets/tabs/setup_touch.cpp b/src/gui/widgets/tabs/setup_touch.cpp
index 5d995f914..fb50ab4d5 100644
--- a/src/gui/widgets/tabs/setup_touch.cpp
+++ b/src/gui/widgets/tabs/setup_touch.cpp
@@ -20,7 +20,11 @@
#include "gui/widgets/tabs/setup_touch.h"
+#include "gui/models/namesmodel.h"
+#include "gui/models/touchactionmodel.h"
+
#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/setuptouchitem.h"
#include "gui/widgets/scrollarea.h"
#include "utils/gettext.h"
@@ -117,7 +121,7 @@ Setup_Touch::Setup_Touch(const Widget2 *const widget) :
key, this, event, mActionsList, 250);
}
- setDimension(gcn::Rectangle(0, 0, 550, 350));
+ setDimension(Rect(0, 0, 550, 350));
}
Setup_Touch::~Setup_Touch()
diff --git a/src/gui/widgets/tabs/setup_touch.h b/src/gui/widgets/tabs/setup_touch.h
index 9adc2d5cd..ef1afdda3 100644
--- a/src/gui/widgets/tabs/setup_touch.h
+++ b/src/gui/widgets/tabs/setup_touch.h
@@ -21,7 +21,10 @@
#ifndef GUI_WIDGETS_TABS_SETUP_TOUCH_H
#define GUI_WIDGETS_TABS_SETUP_TOUCH_H
-#include "gui/widgets/setuptouchitem.h"
+#include "gui/widgets/tabs/setuptabscroll.h"
+
+class NamesModel;
+class TouchActionsModel;
class Setup_Touch final : public SetupTabScroll
{
diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp
index 45ada01df..f55dceaa4 100644
--- a/src/gui/widgets/tabs/setup_video.cpp
+++ b/src/gui/widgets/tabs/setup_video.cpp
@@ -46,7 +46,7 @@
#include "test/testmain.h"
-#include <guichan/listmodel.hpp>
+#include "gui/models/listmodel.h"
#include <algorithm>
@@ -54,7 +54,7 @@
extern Graphics *mainGraphics;
-class ModeListModel final : public gcn::ListModel
+class ModeListModel final : public ListModel
{
public:
ModeListModel();
@@ -159,7 +159,7 @@ int ModeListModel::getIndexOf(const std::string &widthXHeightMode)
return -1;
}
-class OpenGLListModel final : public gcn::ListModel
+class OpenGLListModel final : public ListModel
{
public:
~OpenGLListModel()
@@ -178,7 +178,7 @@ public:
Setup_Video::Setup_Video(const Widget2 *const widget) :
SetupTab(widget),
- gcn::KeyListener(),
+ KeyListener(),
mFullScreenEnabled(config.getBoolValue("screen")),
mOpenGLEnabled(intToRenderType(config.getIntValue("opengl"))),
mFps(config.getIntValue("fpslimit")),
@@ -191,9 +191,9 @@ Setup_Video::Setup_Video(const Widget2 *const widget) :
mOpenGLDropDown(new DropDown(widget, mOpenGLListModel)),
// TRANSLATORS: video settings checkbox
mFpsCheckBox(new CheckBox(this, _("FPS limit:"))),
- mFpsSlider(new Slider(2, 160)),
+ mFpsSlider(new Slider(this, 2, 160)),
mFpsLabel(new Label(this)),
- mAltFpsSlider(new Slider(2, 160)),
+ mAltFpsSlider(new Slider(this, 2, 160)),
// TRANSLATORS: video settings label
mAltFpsLabel(new Label(this, _("Alt FPS limit: "))),
#if !defined(ANDROID) && !defined(__APPLE__)
@@ -224,7 +224,7 @@ Setup_Video::Setup_Video(const Widget2 *const widget) :
// TRANSLATORS: video settings tab name
setName(_("Video"));
- ScrollArea *const scrollArea = new ScrollArea(mModeList,
+ ScrollArea *const scrollArea = new ScrollArea(this, mModeList,
true, "setup_video_background.xml");
scrollArea->setWidth(150);
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
@@ -304,7 +304,7 @@ Setup_Video::Setup_Video(const Widget2 *const widget) :
if (config.getIntValue("screenwidth") >= 730)
width += 100;
- setDimension(gcn::Rectangle(0, 0, width, 300));
+ setDimension(Rect(0, 0, width, 300));
}
Setup_Video::~Setup_Video()
@@ -445,7 +445,7 @@ void Setup_Video::cancel()
config.setValue("noframe", mNoFrame);
}
-void Setup_Video::action(const gcn::ActionEvent &event)
+void Setup_Video::action(const ActionEvent &event)
{
const std::string &id = event.getId();
diff --git a/src/gui/widgets/tabs/setup_video.h b/src/gui/widgets/tabs/setup_video.h
index 22d55c121..250fac0e0 100644
--- a/src/gui/widgets/tabs/setup_video.h
+++ b/src/gui/widgets/tabs/setup_video.h
@@ -25,7 +25,7 @@
#include "gui/widgets/tabs/setuptab.h"
-#include <guichan/keylistener.hpp>
+#include "listeners/keylistener.h"
class Button;
class CheckBox;
@@ -37,7 +37,8 @@ class OpenGLListModel;
class Slider;
class TextDialog;
-class Setup_Video final : public SetupTab, public gcn::KeyListener
+class Setup_Video final : public SetupTab,
+ public KeyListener
{
public:
explicit Setup_Video(const Widget2 *const widget);
@@ -50,7 +51,7 @@ class Setup_Video final : public SetupTab, public gcn::KeyListener
void cancel() override final;
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
private:
bool mFullScreenEnabled;
diff --git a/src/gui/widgets/tabs/setup_visual.cpp b/src/gui/widgets/tabs/setup_visual.cpp
index ac608f756..9666b224a 100644
--- a/src/gui/widgets/tabs/setup_visual.cpp
+++ b/src/gui/widgets/tabs/setup_visual.cpp
@@ -21,8 +21,9 @@
#include "gui/widgets/tabs/setup_visual.h"
+#include "gui/models/namesmodel.h"
+
#include "gui/widgets/layouthelper.h"
-#include "gui/widgets/namesmodel.h"
#include "gui/widgets/scrollarea.h"
#include "client.h"
@@ -202,7 +203,7 @@ Setup_Visual::Setup_Visual(const Widget2 *const widget) :
new SetupItemCheckBox(_("Allow screensaver to run"),
"", "allowscreensaver", this, "allowscreensaverEvent");
- setDimension(gcn::Rectangle(0, 0, 550, 350));
+ setDimension(Rect(0, 0, 550, 350));
}
Setup_Visual::~Setup_Visual()
diff --git a/src/gui/widgets/tabs/setup_visual.h b/src/gui/widgets/tabs/setup_visual.h
index 2d40d3a08..1229757dd 100644
--- a/src/gui/widgets/tabs/setup_visual.h
+++ b/src/gui/widgets/tabs/setup_visual.h
@@ -24,6 +24,8 @@
#include "gui/widgets/setupitem.h"
+#include "gui/widgets/tabs/setuptabscroll.h"
+
class NamesModel;
class Setup_Visual final : public SetupTabScroll
diff --git a/src/gui/widgets/tabs/setuptab.cpp b/src/gui/widgets/tabs/setuptab.cpp
index c445e2ad7..6de77d7a0 100644
--- a/src/gui/widgets/tabs/setuptab.cpp
+++ b/src/gui/widgets/tabs/setuptab.cpp
@@ -26,8 +26,8 @@
SetupTab::SetupTab(const Widget2 *const widget) :
Container(widget),
- gcn::ActionListener(),
- gcn::WidgetListener(),
+ ActionListener(),
+ WidgetListener(),
mName()
{
setOpaque(false);
diff --git a/src/gui/widgets/tabs/setuptab.h b/src/gui/widgets/tabs/setuptab.h
index 388b0a988..4d6049b6a 100644
--- a/src/gui/widgets/tabs/setuptab.h
+++ b/src/gui/widgets/tabs/setuptab.h
@@ -25,8 +25,8 @@
#include "gui/widgets/container.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/widgetlistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/widgetlistener.h"
#include <string>
@@ -36,8 +36,8 @@
* A container for the contents of a tab in the setup window.
*/
class SetupTab : public Container,
- public gcn::ActionListener,
- public gcn::WidgetListener
+ public ActionListener,
+ public WidgetListener
{
public:
A_DELETE_COPY(SetupTab)
diff --git a/src/gui/widgets/tabs/setuptabscroll.cpp b/src/gui/widgets/tabs/setuptabscroll.cpp
index 659ef5824..9c185b2bb 100644
--- a/src/gui/widgets/tabs/setuptabscroll.cpp
+++ b/src/gui/widgets/tabs/setuptabscroll.cpp
@@ -29,7 +29,7 @@
SetupTabScroll::SetupTabScroll(const Widget2 *const widget) :
SetupTab(widget),
mContainer(new VertContainer(this, 25, false, 8)),
- mScroll(new ScrollArea(mContainer, false)),
+ mScroll(new ScrollArea(this, mContainer, false)),
mItems(),
mAllItems(),
mPreferredFirstItemSize(200)
@@ -146,7 +146,7 @@ void SetupTabScroll::externalUnloaded()
}
}
-void SetupTabScroll::widgetResized(const gcn::Event &event A_UNUSED)
+void SetupTabScroll::widgetResized(const Event &event A_UNUSED)
{
mScroll->setWidth(getWidth() - 12);
mScroll->setHeight(getHeight() - 12 - 12);
diff --git a/src/gui/widgets/tabs/setuptabscroll.h b/src/gui/widgets/tabs/setuptabscroll.h
index fb7de574d..f7aa628c9 100644
--- a/src/gui/widgets/tabs/setuptabscroll.h
+++ b/src/gui/widgets/tabs/setuptabscroll.h
@@ -56,14 +56,14 @@ class SetupTabScroll : public SetupTab
virtual void externalUnloaded() override;
- virtual void action(const gcn::ActionEvent &event A_UNUSED)
+ virtual void action(const ActionEvent &event A_UNUSED)
override final
{ }
int getPreferredFirstItemSize() const A_WARN_UNUSED
{ return mPreferredFirstItemSize; }
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
void reread(const std::string &name);
diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp
index 4f1703d31..96ae76787 100644
--- a/src/gui/widgets/tabs/tab.cpp
+++ b/src/gui/widgets/tabs/tab.cpp
@@ -20,14 +20,61 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include "gui/widgets/tabs/tab.h"
#include "client.h"
#include "graphicsvertexes.h"
+#include "gui/gui.h"
+
#include "gui/widgets/label.h"
#include "gui/widgets/tabbedarea.h"
+#include "resources/image.h"
+
#include "debug.h"
int Tab::mInstances = 0;
@@ -44,10 +91,9 @@ static std::string const data[Tab::TAB_COUNT] =
Skin *Tab::tabImg[Tab::TAB_COUNT];
Tab::Tab(const Widget2 *const widget) :
- gcn::BasicContainer(),
- Widget2(widget),
- gcn::MouseListener(),
- gcn::WidgetListener(),
+ gcn::BasicContainer(widget),
+ MouseListener(),
+ WidgetListener(),
mLabel(new Label(this)),
mTabbedArea(nullptr),
mTabColor(&getThemeColor(Theme::TAB)),
@@ -153,7 +199,7 @@ void Tab::updateAlpha()
}
}
-void Tab::draw(gcn::Graphics *graphics)
+void Tab::draw(Graphics *graphics)
{
BLOCK_START("Tab::draw")
int mode = TAB_STANDARD;
@@ -204,19 +250,19 @@ void Tab::draw(gcn::Graphics *graphics)
updateAlpha();
- Graphics *const g = static_cast<Graphics*>(graphics);
-
// draw tab
if (isBatchDrawRenders(openGLMode))
{
const ImageRect &rect = skin->getBorder();
- if (mRedraw || mode != mMode || g->getRedraw())
+ if (mRedraw || mode != mMode || graphics->getRedraw())
{
mMode = mode;
mRedraw = false;
mVertexes->clear();
- g->calcWindow(mVertexes, 0, 0,
- mDimension.width, mDimension.height, rect);
+ graphics->calcWindow(mVertexes,
+ 0, 0,
+ mDimension.width, mDimension.height,
+ rect);
if (mImage)
{
@@ -224,25 +270,28 @@ void Tab::draw(gcn::Graphics *graphics)
if (skin1)
{
const int padding = skin1->getPadding();
- g->calcTileCollection(mVertexes, mImage,
- padding, padding);
+ graphics->calcTileCollection(mVertexes,
+ mImage,
+ padding,
+ padding);
}
}
}
- g->drawTileCollection(mVertexes);
+ graphics->drawTileCollection(mVertexes);
}
else
{
- g->drawImageRect(0, 0,
- mDimension.width, mDimension.height, skin->getBorder());
+ graphics->drawImageRect(0, 0,
+ mDimension.width, mDimension.height,
+ skin->getBorder());
if (mImage)
{
const Skin *const skin1 = tabImg[TAB_STANDARD];
if (skin1)
{
const int padding = skin1->getPadding();
- g->drawImage2(mImage, padding, padding);
+ graphics->drawImage(mImage, padding, padding);
}
}
}
@@ -251,17 +300,17 @@ void Tab::draw(gcn::Graphics *graphics)
BLOCK_END("Tab::draw")
}
-void Tab::widgetResized(const gcn::Event &event A_UNUSED)
+void Tab::widgetResized(const Event &event A_UNUSED)
{
mRedraw = true;
}
-void Tab::widgetMoved(const gcn::Event &event A_UNUSED)
+void Tab::widgetMoved(const Event &event A_UNUSED)
{
mRedraw = true;
}
-void Tab::setLabelFont(gcn::Font *const font)
+void Tab::setLabelFont(Font *const font)
{
if (!mLabel)
return;
@@ -324,12 +373,12 @@ const std::string &Tab::getCaption() const
return mLabel->getCaption();
}
-void Tab::mouseEntered(gcn::MouseEvent& mouseEvent A_UNUSED)
+void Tab::mouseEntered(MouseEvent& mouseEvent A_UNUSED)
{
mHasMouse = true;
}
-void Tab::mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED)
+void Tab::mouseExited(MouseEvent& mouseEvent A_UNUSED)
{
mHasMouse = false;
}
diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h
index 118b1f0e2..1f52cde88 100644
--- a/src/gui/widgets/tabs/tab.h
+++ b/src/gui/widgets/tabs/tab.h
@@ -20,14 +20,56 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#ifndef GUI_WIDGETS_TABS_TAB_H
#define GUI_WIDGETS_TABS_TAB_H
-#include "gui/widgets/widget2.h"
+#include "gui/base/basiccontainer.hpp"
-#include <guichan/basiccontainer.hpp>
-#include <guichan/mouselistener.hpp>
-#include <guichan/widgetlistener.hpp>
+#include "listeners/mouselistener.h"
+#include "listeners/widgetlistener.h"
#include "localconsts.h"
@@ -40,9 +82,8 @@ class TabbedArea;
* A tab, the same as the Guichan tab in 0.8, but extended
*/
class Tab : public gcn::BasicContainer,
- public Widget2,
- public gcn::MouseListener,
- public gcn::WidgetListener
+ public MouseListener,
+ public WidgetListener
{
public:
explicit Tab(const Widget2 *const widget);
@@ -68,13 +109,13 @@ class Tab : public gcn::BasicContainer,
/**
* Draw the tabbed area.
*/
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
/**
* Set the normal color for the tab's text.
*/
- void setTabColor(const gcn::Color *const color1,
- const gcn::Color *const color2)
+ void setTabColor(const Color *const color1,
+ const Color *const color2)
{
mTabColor = color1;
mTabOutlineColor = color2;
@@ -83,8 +124,8 @@ class Tab : public gcn::BasicContainer,
/**
* Set the highlighted color for the tab's text.
*/
- void setHighlightedTabColor(const gcn::Color *const color1,
- const gcn::Color *const color2)
+ void setHighlightedTabColor(const Color *const color1,
+ const Color *const color2)
{
mTabHighlightedColor = color1;
mTabHighlightedOutlineColor = color2;
@@ -93,8 +134,8 @@ class Tab : public gcn::BasicContainer,
/**
* Set the selected color for the tab's text.
*/
- void setSelectedTabColor(const gcn::Color *const color1,
- const gcn::Color *const color2)
+ void setSelectedTabColor(const Color *const color1,
+ const Color *const color2)
{
mTabSelectedColor = color1;
mTabSelectedOutlineColor = color2;
@@ -103,8 +144,8 @@ class Tab : public gcn::BasicContainer,
/**
* Set the flash color for the tab's text.
*/
- void setFlashTabColor(const gcn::Color *const color1,
- const gcn::Color *const color2)
+ void setFlashTabColor(const Color *const color1,
+ const Color *const color2)
{
mFlashColor = color1;
mFlashOutlineColor = color2;
@@ -113,8 +154,8 @@ class Tab : public gcn::BasicContainer,
/**
* Set the player flash color for the tab's text.
*/
- void setPlayerFlashTabColor(const gcn::Color *const color1,
- const gcn::Color *const color2)
+ void setPlayerFlashTabColor(const Color *const color1,
+ const Color *const color2)
{
mPlayerFlashColor = color1;
mPlayerFlashOutlineColor = color2;
@@ -129,11 +170,11 @@ class Tab : public gcn::BasicContainer,
int getFlash() const A_WARN_UNUSED
{ return mFlash; }
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
- void widgetMoved(const gcn::Event &event) override final;
+ void widgetMoved(const Event &event) override final;
- void setLabelFont(gcn::Font *const font);
+ void setLabelFont(Font *const font);
Label *getLabel() const A_WARN_UNUSED
{ return mLabel; }
@@ -148,9 +189,9 @@ class Tab : public gcn::BasicContainer,
const std::string &getCaption() const A_WARN_UNUSED;
- void mouseEntered(gcn::MouseEvent &mouseEvent) override final;
+ void mouseEntered(MouseEvent &mouseEvent) override final;
- void mouseExited(gcn::MouseEvent &mouseEvent) override final;
+ void mouseExited(MouseEvent &mouseEvent) override final;
void setImage(Image *const image);
@@ -173,16 +214,16 @@ class Tab : public gcn::BasicContainer,
static int mInstances; /**< Number of tab instances */
static float mAlpha;
- const gcn::Color *mTabColor;
- const gcn::Color *mTabOutlineColor;
- const gcn::Color *mTabHighlightedColor;
- const gcn::Color *mTabHighlightedOutlineColor;
- const gcn::Color *mTabSelectedColor;
- const gcn::Color *mTabSelectedOutlineColor;
- const gcn::Color *mFlashColor;
- const gcn::Color *mFlashOutlineColor;
- const gcn::Color *mPlayerFlashColor;
- const gcn::Color *mPlayerFlashOutlineColor;
+ const Color *mTabColor;
+ const Color *mTabOutlineColor;
+ const Color *mTabHighlightedColor;
+ const Color *mTabHighlightedOutlineColor;
+ const Color *mTabSelectedColor;
+ const Color *mTabSelectedOutlineColor;
+ const Color *mFlashColor;
+ const Color *mFlashOutlineColor;
+ const Color *mPlayerFlashColor;
+ const Color *mPlayerFlashOutlineColor;
int mFlash;
ImageCollection *mVertexes;
Image *mImage;
diff --git a/src/gui/widgets/tabs/whispertab.cpp b/src/gui/widgets/tabs/whispertab.cpp
index ec02bb70f..023d94110 100644
--- a/src/gui/widgets/tabs/whispertab.cpp
+++ b/src/gui/widgets/tabs/whispertab.cpp
@@ -34,7 +34,8 @@
#include "debug.h"
-WhisperTab::WhisperTab(const Widget2 *const widget, const std::string &nick) :
+WhisperTab::WhisperTab(const Widget2 *const widget,
+ const std::string &nick) :
ChatTab(widget, nick, ""),
mNick(nick)
{
diff --git a/src/gui/widgets/tabs/whispertab.h b/src/gui/widgets/tabs/whispertab.h
index 5dbb05a4e..84b55ae58 100644
--- a/src/gui/widgets/tabs/whispertab.h
+++ b/src/gui/widgets/tabs/whispertab.h
@@ -57,7 +57,8 @@ class WhisperTab final : public ChatTab
*
* @param nick the name of the player this tab is whispering to
*/
- WhisperTab(const Widget2 *const widget, const std::string &nick);
+ WhisperTab(const Widget2 *const widget,
+ const std::string &nick);
~WhisperTab();
diff --git a/src/gui/widgets/tabstrip.cpp b/src/gui/widgets/tabstrip.cpp
index 24c33c614..57520afce 100644
--- a/src/gui/widgets/tabstrip.cpp
+++ b/src/gui/widgets/tabstrip.cpp
@@ -25,19 +25,21 @@
#include "debug.h"
TabStrip::TabStrip(const Widget2 *const widget,
- const std::string &group, const int height,
+ const std::string &group,
+ const int height,
const int spacing) :
WidgetGroup(widget, group, height, spacing)
{
}
TabStrip::TabStrip(const Widget2 *const widget,
- const int height, const int spacing) :
+ const int height,
+ const int spacing) :
WidgetGroup(widget, "", height, spacing)
{
}
-gcn::Widget *TabStrip::createWidget(const std::string &text) const
+Widget *TabStrip::createWidget(const std::string &text) const
{
Button *const widget = new Button(this);
widget->setStick(true);
@@ -48,12 +50,12 @@ gcn::Widget *TabStrip::createWidget(const std::string &text) const
return widget;
}
-void TabStrip::action(const gcn::ActionEvent &event)
+void TabStrip::action(const ActionEvent &event)
{
WidgetGroup::action(event);
if (event.getSource())
{
- gcn::Widget *const widget = event.getSource();
+ Widget *const widget = event.getSource();
if (static_cast<Button*>(widget)->isPressed2())
{
FOR_EACH (WidgetListConstIterator, iter, mWidgets)
diff --git a/src/gui/widgets/tabstrip.h b/src/gui/widgets/tabstrip.h
index 622ccba81..a89dd5144 100644
--- a/src/gui/widgets/tabstrip.h
+++ b/src/gui/widgets/tabstrip.h
@@ -23,24 +23,24 @@
#include "gui/widgets/widgetgroup.h"
-#include <guichan/widget.hpp>
-
class TabStrip final : public WidgetGroup
{
public:
TabStrip(const Widget2 *const widget,
- const std::string &group, const int height,
+ const std::string &group,
+ const int height,
const int spacing = 0);
TabStrip(const Widget2 *const widget,
- const int height, const int spacing = 0);
+ const int height,
+ const int spacing = 0);
A_DELETE_COPY(TabStrip)
- gcn::Widget *createWidget(const std::string &name)
- const override final A_WARN_UNUSED;
+ Widget *createWidget(const std::string &name)
+ const override final A_WARN_UNUSED;
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
};
#endif // GUI_WIDGETS_TABSTRIP_H
diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp
index f59bc0ceb..a1ce0e61d 100644
--- a/src/gui/widgets/textbox.cpp
+++ b/src/gui/widgets/textbox.cpp
@@ -22,18 +22,19 @@
#include "gui/widgets/textbox.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
-#include <guichan/font.hpp>
+#include "gui/font.h"
+#include "gui/gui.h"
#include <sstream>
#include "debug.h"
TextBox::TextBox(const Widget2 *const widget) :
- gcn::TextBox(),
- Widget2(widget),
+ gcn::TextBox(widget),
mMinWidth(getWidth())
{
mForegroundColor = getThemeColor(Theme::TEXTBOX);
@@ -87,7 +88,7 @@ void TextBox::setTextWrapped(const std::string &text, const int minDimension)
text.substr(lastNewlinePos, newlinePos - lastNewlinePos);
size_t lastSpacePos = 0;
xpos = 0;
- const gcn::Font *const font = getFont();
+ const Font *const font = getFont();
const int spaceWidth = font->getWidth(" ");
size_t sz = line.size();
@@ -165,10 +166,10 @@ void TextBox::setTextWrapped(const std::string &text, const int minDimension)
gcn::TextBox::setText(wrappedStream.str());
}
-void TextBox::keyPressed(gcn::KeyEvent& keyEvent)
+void TextBox::keyPressed(KeyEvent& keyEvent)
{
- const gcn::Key &key = keyEvent.getKey();
- const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const Key &key = keyEvent.getKey();
+ const int action = keyEvent.getActionId();
switch (action)
{
@@ -291,7 +292,7 @@ void TextBox::keyPressed(gcn::KeyEvent& keyEvent)
case Input::KEY_GUI_PAGE_UP:
{
- gcn::Widget *const par = getParent();
+ Widget *const par = getParent();
if (par)
{
@@ -307,7 +308,7 @@ void TextBox::keyPressed(gcn::KeyEvent& keyEvent)
case Input::KEY_GUI_PAGE_DOWN:
{
- gcn::Widget *const par = getParent();
+ Widget *const par = getParent();
if (par)
{
@@ -350,16 +351,16 @@ void TextBox::keyPressed(gcn::KeyEvent& keyEvent)
keyEvent.consume();
}
-void TextBox::draw(gcn::Graphics* graphics)
+void TextBox::draw(Graphics* graphics)
{
BLOCK_START("TextBox::draw")
if (mOpaque)
{
graphics->setColor(mBackgroundColor);
- graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
+ graphics->fillRectangle(Rect(0, 0, getWidth(), getHeight()));
}
- gcn::Font *const font = getFont();
+ Font *const font = getFont();
if (isFocused() && isEditable())
{
drawCaret(graphics, font->getWidth(
@@ -367,8 +368,7 @@ void TextBox::draw(gcn::Graphics* graphics)
mCaretRow * font->getHeight());
}
- static_cast<Graphics*>(graphics)->setColorAll(
- mForegroundColor, mForegroundColor2);
+ graphics->setColorAll(mForegroundColor, mForegroundColor2);
const int fontHeight = font->getHeight();
for (size_t i = 0, sz = mTextRows.size(); i < sz; i++)
@@ -379,14 +379,14 @@ void TextBox::draw(gcn::Graphics* graphics)
BLOCK_END("TextBox::draw")
}
-void TextBox::setForegroundColor(const gcn::Color &color)
+void TextBox::setForegroundColor(const Color &color)
{
mForegroundColor = color;
mForegroundColor2 = color;
}
-void TextBox::setForegroundColorAll(const gcn::Color &color1,
- const gcn::Color &color2)
+void TextBox::setForegroundColorAll(const Color &color1,
+ const Color &color2)
{
mForegroundColor = color1;
mForegroundColor2 = color2;
diff --git a/src/gui/widgets/textbox.h b/src/gui/widgets/textbox.h
index 501744515..3f78fd247 100644
--- a/src/gui/widgets/textbox.h
+++ b/src/gui/widgets/textbox.h
@@ -23,9 +23,7 @@
#ifndef GUI_WIDGETS_TEXTBOX_H
#define GUI_WIDGETS_TEXTBOX_H
-#include "gui/widgets/widget2.h"
-
-#include <guichan/widgets/textbox.hpp>
+#include "gui/base/widgets/textbox.hpp"
#include "localconsts.h"
@@ -36,8 +34,7 @@
*
* \ingroup GUI
*/
-class TextBox final : public gcn::TextBox,
- public Widget2
+class TextBox final : public gcn::TextBox
{
public:
/**
@@ -60,14 +57,14 @@ class TextBox final : public gcn::TextBox,
int getMinWidth() const A_WARN_UNUSED
{ return mMinWidth; }
- void keyPressed(gcn::KeyEvent& keyEvent) override final;
+ void keyPressed(KeyEvent& keyEvent) override final;
- void draw(gcn::Graphics* graphics) override final;
+ void draw(Graphics* graphics) override final;
- void setForegroundColor(const gcn::Color &color);
+ void setForegroundColor(const Color &color);
- void setForegroundColorAll(const gcn::Color &color1,
- const gcn::Color &color2);
+ void setForegroundColorAll(const Color &color1,
+ const Color &color2);
private:
int mMinWidth;
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 269ace775..78a2826d5 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -26,10 +26,10 @@
#include "input/inputmanager.h"
-#include "input/keyevent.h"
-
-#include "gui/sdlinput.h"
+#include "events/keyevent.h"
+#include "gui/font.h"
+#include "gui/gui.h"
#include "gui/viewport.h"
#include "gui/popups/popupmenu.h"
@@ -39,8 +39,6 @@
#include "utils/copynpaste.h"
#include "utils/timer.h"
-#include <guichan/font.hpp>
-
#undef DELETE // Win32 compatibility hack
#include "debug.h"
@@ -53,12 +51,11 @@ ImageRect TextField::skin;
TextField::TextField(const Widget2 *restrict const widget,
const std::string &restrict text,
const bool loseFocusOnTab,
- gcn::ActionListener *restrict const listener,
+ ActionListener *restrict const listener,
const std::string &restrict eventId,
const bool sendAlwaysEvents):
- gcn::TextField(text),
- gcn::FocusListener(),
- Widget2(widget),
+ gcn::TextField(widget, text),
+ FocusListener(),
mSendAlwaysEvents(sendAlwaysEvents),
mCaretColor(&getThemeColor(Theme::CARET)),
mPopupMenu(nullptr),
@@ -137,30 +134,32 @@ void TextField::updateAlpha()
}
}
-void TextField::draw(gcn::Graphics *graphics)
+void TextField::draw(Graphics *graphics)
{
BLOCK_START("TextField::draw")
updateAlpha();
- gcn::Font *const font = getFont();
+ Font *const font = getFont();
if (isFocused())
{
drawCaret(graphics,
font->getWidth(mText.substr(0, mCaretPosition)) - mXScroll);
}
- static_cast<Graphics*>(graphics)->setColorAll(
- mForegroundColor, mForegroundColor2);
+ graphics->setColorAll(mForegroundColor, mForegroundColor2);
font->drawString(graphics, mText, mPadding - mXScroll, mPadding);
BLOCK_END("TextField::draw")
}
-void TextField::drawFrame(gcn::Graphics *graphics)
+void TextField::drawFrame(Graphics *graphics)
{
BLOCK_START("TextField::drawFrame")
const int bs = 2 * mFrameSize;
- static_cast<Graphics*>(graphics)->drawImageRect(0, 0,
- mDimension.width + bs, mDimension.height + bs, skin);
+ graphics->drawImageRect(0,
+ 0,
+ mDimension.width + bs,
+ mDimension.height + bs,
+ skin);
BLOCK_END("TextField::drawFrame")
}
@@ -196,13 +195,13 @@ int TextField::getValue() const
return value;
}
-void TextField::keyPressed(gcn::KeyEvent &keyEvent)
+void TextField::keyPressed(KeyEvent &keyEvent)
{
const int val = keyEvent.getKey().getValue();
#ifdef USE_SDL2
if (val == Key::TEXTINPUT)
{
- std::string str = static_cast<KeyEvent*>(&keyEvent)->getText();
+ std::string str = keyEvent.getText();
mText.insert(mCaretPosition, str);
mCaretPosition += str.size();
keyEvent.consume();
@@ -252,7 +251,7 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
}
if (len > 1)
- buf[0] |= static_cast<char>(255 << (8 - len));
+ buf[0] |= static_cast<char>(255U << (8 - len));
mText.insert(mCaretPosition, std::string(buf, buf + len));
mCaretPosition += len;
@@ -291,7 +290,7 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
}
else
{
- const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int action = keyEvent.getActionId();
if (!inputManager.isActionActive(static_cast<int>(
Input::KEY_GUI_CTRL)))
{
@@ -661,12 +660,14 @@ void TextField::handleCopy() const
sendBuffer(text);
}
-void TextField::drawCaret(gcn::Graphics* graphics, int x)
+void TextField::drawCaret(Graphics* graphics, int x)
{
- const gcn::Rectangle &clipArea = graphics->getCurrentClipArea();
+ const Rect *const clipArea = graphics->getCurrentClipArea();
+ if (!clipArea)
+ return;
graphics->setColor(*mCaretColor);
- graphics->drawLine(x + mPadding, clipArea.height - mPadding,
+ graphics->drawLine(x + mPadding, clipArea->height - mPadding,
x + mPadding, mPadding);
}
@@ -722,13 +723,13 @@ void TextField::fontChanged()
fixScroll();
}
-void TextField::mousePressed(gcn::MouseEvent &mouseEvent)
+void TextField::mousePressed(MouseEvent &mouseEvent)
{
#ifdef ANDROID
if (!client->isKeyboardVisible())
inputManager.executeAction(Input::KEY_SHOW_KEYBOARD);
#endif
- if (mouseEvent.getButton() == gcn::MouseEvent::RIGHT)
+ if (mouseEvent.getButton() == MouseEvent::RIGHT)
{
if (viewport)
{
@@ -756,7 +757,7 @@ void TextField::mousePressed(gcn::MouseEvent &mouseEvent)
}
}
-void TextField::focusGained(const gcn::Event &event A_UNUSED)
+void TextField::focusGained(const Event &event A_UNUSED)
{
#ifdef ANDROID
if (!client->isKeyboardVisible())
@@ -764,6 +765,6 @@ void TextField::focusGained(const gcn::Event &event A_UNUSED)
#endif
}
-void TextField::focusLost(const gcn::Event &event A_UNUSED)
+void TextField::focusLost(const Event &event A_UNUSED)
{
}
diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h
index abff9cf2a..ccc1b16d6 100644
--- a/src/gui/widgets/textfield.h
+++ b/src/gui/widgets/textfield.h
@@ -23,10 +23,9 @@
#ifndef GUI_WIDGETS_TEXTFIELD_H
#define GUI_WIDGETS_TEXTFIELD_H
-#include "gui/widgets/widget2.h"
+#include "listeners/focuslistener.h"
-#include <guichan/focuslistener.hpp>
-#include <guichan/widgets/textfield.hpp>
+#include "gui/base/widgets/textfield.hpp"
#include "localconsts.h"
@@ -38,8 +37,7 @@ class PopupMenu;
* \ingroup GUI
*/
class TextField : public gcn::TextField,
- public gcn::FocusListener,
- public Widget2
+ public FocusListener
{
public:
/**
@@ -48,7 +46,7 @@ class TextField : public gcn::TextField,
explicit TextField(const Widget2 *restrict const widget,
const std::string &restrict text = "",
const bool loseFocusOnTab = true,
- gcn::ActionListener *restrict
+ ActionListener *restrict
const listener = nullptr,
const std::string &restrict eventId = "",
const bool sendAlwaysEvents = false);
@@ -60,7 +58,7 @@ class TextField : public gcn::TextField,
/**
* Draws the text field.
*/
- virtual void draw(gcn::Graphics *graphics) override;
+ virtual void draw(Graphics *graphics) override;
/**
* Update the alpha value to the graphic components.
@@ -70,7 +68,7 @@ class TextField : public gcn::TextField,
/**
* Draws the background and border.
*/
- void drawFrame(gcn::Graphics *graphics) override final;
+ void drawFrame(Graphics *graphics) override final;
/**
* Determine whether the field should be numeric or not
@@ -89,7 +87,7 @@ class TextField : public gcn::TextField,
/**
* Processes one keypress.
*/
- void keyPressed(gcn::KeyEvent &keyEvent) override;
+ void keyPressed(KeyEvent &keyEvent) override;
/**
* Set the minimum value for a range
@@ -117,15 +115,15 @@ class TextField : public gcn::TextField,
void setCaretPosition(unsigned int position);
- void mousePressed(gcn::MouseEvent &mouseEvent) override final;
+ void mousePressed(MouseEvent &mouseEvent) override final;
void handlePaste();
void handleCopy() const;
- void focusGained(const gcn::Event &event) override final;
+ void focusGained(const Event &event) override final;
- void focusLost(const gcn::Event &event) override;
+ void focusLost(const Event &event) override;
void moveCaretBack();
@@ -142,7 +140,7 @@ class TextField : public gcn::TextField,
void caretDeleteWord();
protected:
- void drawCaret(gcn::Graphics* graphics, int x) override final;
+ void drawCaret(Graphics* graphics, int x) override final;
void fixScroll();
@@ -161,7 +159,7 @@ class TextField : public gcn::TextField,
static Skin *mSkin;
private:
- const gcn::Color *mCaretColor;
+ const Color *mCaretColor;
PopupMenu *mPopupMenu;
static int instances;
static float mAlpha;
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index 8d473dd46..10bd936c6 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -24,8 +24,8 @@
#include "client.h"
+#include "gui/font.h"
#include "gui/gui.h"
-#include "gui/sdlfont.h"
#include "debug.h"
@@ -35,8 +35,7 @@ Skin *TextPreview::mSkin = nullptr;
TextPreview::TextPreview(const Widget2 *const widget,
const std::string &text) :
- gcn::Widget(),
- Widget2(widget),
+ Widget(widget),
mFont(gui->getFont()),
mText(text),
mTextColor(&getThemeColor(Theme::TEXT)),
@@ -79,49 +78,47 @@ TextPreview::~TextPreview()
}
}
-void TextPreview::draw(gcn::Graphics* graphics)
+void TextPreview::draw(Graphics* graphics)
{
+ if (!mFont)
+ return;
+
BLOCK_START("TextPreview::draw")
if (client->getGuiAlpha() != mAlpha)
mAlpha = client->getGuiAlpha();
- Graphics *const g = static_cast<Graphics*>(graphics);
const int intAlpha = static_cast<int>(mAlpha * 255.0F);
const int alpha = mTextAlpha ? intAlpha : 255;
if (mOpaque)
{
- g->setColor(gcn::Color(static_cast<int>(mBGColor->r),
+ graphics->setColor(Color(static_cast<int>(mBGColor->r),
static_cast<int>(mBGColor->g),
static_cast<int>(mBGColor->b),
static_cast<int>(mAlpha * 255.0F)));
- g->fillRectangle(gcn::Rectangle(0, 0,
+ graphics->fillRectangle(Rect(0, 0,
mDimension.width, mDimension.height));
}
if (mTextBGColor)
{
- const SDLFont *const font = dynamic_cast<SDLFont*>(mFont);
- if (font)
- {
- const int x = font->getWidth(mText) + 1
- + 2 * ((mOutline || mShadow) ? 1 :0);
- const int y = font->getHeight() + 1
- + 2 * ((mOutline || mShadow) ? 1 : 0);
- g->setColor(gcn::Color(static_cast<int>(mTextBGColor->r),
- static_cast<int>(mTextBGColor->g),
- static_cast<int>(mTextBGColor->b),
- intAlpha));
- g->fillRectangle(gcn::Rectangle(mPadding, mPadding, x, y));
- }
+ const int x = mFont->getWidth(mText) + 1
+ + 2 * ((mOutline || mShadow) ? 1 :0);
+ const int y = mFont->getHeight() + 1
+ + 2 * ((mOutline || mShadow) ? 1 : 0);
+ graphics->setColor(Color(static_cast<int>(mTextBGColor->r),
+ static_cast<int>(mTextBGColor->g),
+ static_cast<int>(mTextBGColor->b),
+ intAlpha));
+ graphics->fillRectangle(Rect(mPadding, mPadding, x, y));
}
- g->setColorAll(gcn::Color(mTextColor->r, mTextColor->g, mTextColor->b,
- alpha), gcn::Color(mTextColor2->r, mTextColor2->g, mTextColor2->b,
- alpha));
+ graphics->setColorAll(Color(mTextColor->r,
+ mTextColor->g, mTextColor->b, alpha),
+ Color(mTextColor2->r, mTextColor2->g, mTextColor2->b, alpha));
if (mOutline && mTextColor != mTextColor2)
- g->setColor2(Theme::getThemeColor(Theme::OUTLINE));
+ graphics->setColor2(Theme::getThemeColor(Theme::OUTLINE));
mFont->drawString(graphics, mText, mPadding + 1, mPadding + 1);
BLOCK_END("TextPreview::draw")
diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h
index eeb6805fb..5a09e1148 100644
--- a/src/gui/widgets/textpreview.h
+++ b/src/gui/widgets/textpreview.h
@@ -23,29 +23,27 @@
#ifndef GUI_WIDGETS_TEXTPREVIEW_H
#define GUI_WIDGETS_TEXTPREVIEW_H
-#include "gui/widgets/widget2.h"
-
-#include <guichan/widget.hpp>
+#include "gui/widgets/widget.h"
#include "localconsts.h"
/**
* Preview widget for particle colors, etc.
*/
-class TextPreview final : public gcn::Widget,
- public Widget2
+class TextPreview final : public Widget
{
public:
- TextPreview(const Widget2 *const widget, const std::string &text);
+ TextPreview(const Widget2 *const widget,
+ const std::string &text);
A_DELETE_COPY(TextPreview)
~TextPreview();
- inline void setTextColor(const gcn::Color *color)
+ inline void setTextColor(const Color *color)
{ mTextColor = color; adjustSize(); }
- inline void setTextColor2(const gcn::Color *color)
+ inline void setTextColor2(const Color *color)
{ mTextColor2 = color; adjustSize(); }
/**
@@ -62,7 +60,7 @@ class TextPreview final : public gcn::Widget,
*
* @param color the color to set
*/
- inline void setTextBGColor(const gcn::Color *color)
+ inline void setTextBGColor(const Color *color)
{ mTextBGColor = color; }
/**
@@ -70,7 +68,7 @@ class TextPreview final : public gcn::Widget,
*
* @param color the color to set
*/
- inline void setBGColor(const gcn::Color *color)
+ inline void setBGColor(const Color *color)
{ mBGColor = color; }
/**
@@ -78,7 +76,7 @@ class TextPreview final : public gcn::Widget,
*
* @param font the font to use.
*/
- inline void setFont(gcn::Font *const font)
+ inline void setFont(Font *const font)
{ mFont = font; }
/**
@@ -102,7 +100,7 @@ class TextPreview final : public gcn::Widget,
*
* @param graphics graphics to draw into
*/
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
/**
* Set opacity for this widget (whether or not to show the background
@@ -123,12 +121,12 @@ class TextPreview final : public gcn::Widget,
void adjustSize();
private:
- gcn::Font *mFont;
+ Font *mFont;
std::string mText;
- const gcn::Color *mTextColor;
- const gcn::Color *mTextColor2;
- const gcn::Color *mBGColor;
- const gcn::Color *mTextBGColor;
+ const Color *mTextColor;
+ const Color *mTextColor2;
+ const Color *mBGColor;
+ const Color *mTextBGColor;
int mPadding;
static int instances;
static float mAlpha;
diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp
index a91f20657..b86aa3e5f 100644
--- a/src/gui/widgets/vertcontainer.cpp
+++ b/src/gui/widgets/vertcontainer.cpp
@@ -24,10 +24,11 @@
#include "debug.h"
VertContainer::VertContainer(const Widget2 *const widget,
- const int verticalItemSize, const bool resizable,
+ const int verticalItemSize,
+ const bool resizable,
const int leftSpacing) :
Container(widget),
- gcn::WidgetListener(),
+ WidgetListener(),
mResizableWidgets(),
mVerticalItemSize(verticalItemSize),
mCount(0),
@@ -39,12 +40,12 @@ VertContainer::VertContainer(const Widget2 *const widget,
addWidgetListener(this);
}
-void VertContainer::add1(gcn::Widget *const widget, const int spacing)
+void VertContainer::add1(Widget *const widget, const int spacing)
{
add2(widget, mResizable, spacing);
}
-void VertContainer::add2(gcn::Widget *const widget, const bool resizable,
+void VertContainer::add2(Widget *const widget, const bool resizable,
const int spacing)
{
if (!widget)
@@ -79,8 +80,8 @@ void VertContainer::clear()
mResizableWidgets.clear();
}
-void VertContainer::widgetResized(const gcn::Event &event A_UNUSED)
+void VertContainer::widgetResized(const Event &event A_UNUSED)
{
- FOR_EACH (std::vector<gcn::Widget*>::const_iterator, it, mResizableWidgets)
+ FOR_EACH (std::vector<Widget*>::const_iterator, it, mResizableWidgets)
(*it)->setWidth(getWidth());
}
diff --git a/src/gui/widgets/vertcontainer.h b/src/gui/widgets/vertcontainer.h
index 76f6354dd..05ba2e32f 100644
--- a/src/gui/widgets/vertcontainer.h
+++ b/src/gui/widgets/vertcontainer.h
@@ -24,7 +24,7 @@
#include "gui/widgets/container.h"
-#include <guichan/widgetlistener.hpp>
+#include "listeners/widgetlistener.h"
#include <vector>
@@ -35,26 +35,28 @@
*
* This container places it's contents veritcally.
*/
-class VertContainer final : public Container, public gcn::WidgetListener
+class VertContainer final : public Container,
+ public WidgetListener
{
public:
VertContainer(const Widget2 *const widget,
- const int verticalItemSize, const bool resizable = true,
+ const int verticalItemSize,
+ const bool resizable = true,
const int leftSpacing = 0);
A_DELETE_COPY(VertContainer)
- void add2(gcn::Widget *const widget, const bool resizable,
+ void add2(Widget *const widget, const bool resizable,
const int spacing = -1);
- void add1(gcn::Widget *const widget, const int spacing = -1);
+ void add1(Widget *const widget, const int spacing = -1);
void clear();
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
private:
- std::vector<gcn::Widget*> mResizableWidgets;
+ std::vector<Widget*> mResizableWidgets;
int mVerticalItemSize;
int mCount;
int mNextY;
diff --git a/src/gui/widgets/widget.cpp b/src/gui/widgets/widget.cpp
new file mode 100644
index 000000000..5b2024b1f
--- /dev/null
+++ b/src/gui/widgets/widget.cpp
@@ -0,0 +1,666 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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/>.
+ */
+
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * For comments regarding functions please see the header file.
+ */
+
+#include "gui/widgets/widget.h"
+
+#include "events/actionevent.h"
+
+#include "events/event.h"
+
+#include "gui/focushandler.h"
+
+#include "listeners/actionlistener.h"
+#include "listeners/deathlistener.h"
+#include "listeners/widgetlistener.h"
+
+#include "render/graphics.h"
+
+#include "debug.h"
+
+Font* Widget::mGlobalFont = nullptr;
+std::list<Widget*> Widget::mWidgets;
+std::set<Widget*> Widget::mWidgetsSet;
+
+Widget::Widget(const Widget2 *const widget) :
+ Widget2(widget),
+ mMouseListeners(),
+ mKeyListeners(),
+ mActionListeners(),
+ mDeathListeners(),
+ mFocusListeners(),
+ mWidgetListeners(),
+ mForegroundColor(0x000000),
+ mBackgroundColor(0xffffff),
+ mBaseColor(0x808090),
+ mSelectionColor(0xc3d9ff),
+ mFocusHandler(nullptr),
+ mInternalFocusHandler(nullptr),
+ mParent(nullptr),
+ mDimension(),
+ mFrameSize(0),
+ mActionEventId(),
+ mFocusable(false),
+ mVisible(true),
+ mTabIn(true),
+ mTabOut(true),
+ mEnabled(true),
+ mId(),
+ mCurrentFont(nullptr)
+{
+ mWidgets.push_back(this);
+ mWidgetsSet.insert(this);
+}
+
+Widget::~Widget()
+{
+ for (DeathListenerIterator iter = mDeathListeners.begin();
+ iter != mDeathListeners.end();
+ ++iter)
+ {
+ Event event(this);
+ (*iter)->death(event);
+ }
+
+ _setFocusHandler(nullptr);
+
+ mWidgets.remove(this);
+ mWidgetsSet.erase(this);
+}
+
+void Widget::drawFrame(Graphics* graphics)
+{
+ BLOCK_START("Widget::drawFrame")
+ const Color &faceColor = getBaseColor();
+ Color highlightColor = faceColor + Color(0x303030);
+ Color shadowColor = faceColor - Color(0x303030);
+ const int alpha = getBaseColor().a;
+ const int width = getWidth() + getFrameSize() * 2 - 1;
+ const int height = getHeight() + getFrameSize() * 2 - 1;
+ highlightColor.a = alpha;
+ shadowColor.a = alpha;
+
+ for (unsigned int i = 0; i < getFrameSize(); ++i)
+ {
+ graphics->setColor(shadowColor);
+ graphics->drawLine(i, i, width - i, i);
+ graphics->drawLine(i, i + 1, i, height - i - 1);
+ graphics->setColor(highlightColor);
+ graphics->drawLine(width - i, i + 1, width - i, height - i);
+ graphics->drawLine(i, height - i, width - i - 1, height - i);
+ }
+ BLOCK_END("Widget::drawFrame")
+}
+
+void Widget::_setParent(Widget* parent)
+{
+ mParent = parent;
+}
+
+void Widget::setWidth(int width)
+{
+ Rect newDimension = mDimension;
+ newDimension.width = width;
+
+ setDimension(newDimension);
+}
+
+void Widget::setHeight(int height)
+{
+ Rect newDimension = mDimension;
+ newDimension.height = height;
+
+ setDimension(newDimension);
+}
+
+void Widget::setX(int x)
+{
+ Rect newDimension = mDimension;
+ newDimension.x = x;
+
+ setDimension(newDimension);
+}
+
+void Widget::setY(int y)
+{
+ Rect newDimension = mDimension;
+ newDimension.y = y;
+
+ setDimension(newDimension);
+}
+
+void Widget::setPosition(int x, int y)
+{
+ Rect newDimension = mDimension;
+ newDimension.x = x;
+ newDimension.y = y;
+
+ setDimension(newDimension);
+}
+
+void Widget::setDimension(const Rect& dimension)
+{
+ const Rect oldDimension = mDimension;
+ mDimension = dimension;
+
+ if (mDimension.width != oldDimension.width
+ || mDimension.height != oldDimension.height)
+ {
+ distributeResizedEvent();
+ }
+
+ if (mDimension.x != oldDimension.x
+ || mDimension.y != oldDimension.y)
+ {
+ distributeMovedEvent();
+ }
+}
+
+void Widget::setFrameSize(unsigned int frameSize)
+{
+ mFrameSize = frameSize;
+}
+
+unsigned int Widget::getFrameSize() const
+{
+ return mFrameSize;
+}
+
+const Rect& Widget::getDimension() const
+{
+ return mDimension;
+}
+
+const std::string& Widget::getActionEventId() const
+{
+ return mActionEventId;
+}
+
+void Widget::setActionEventId(const std::string& actionEventId)
+{
+ mActionEventId = actionEventId;
+}
+
+bool Widget::isFocused() const
+{
+ if (!mFocusHandler)
+ return false;
+
+ return (mFocusHandler->isFocused(this));
+}
+
+void Widget::setFocusable(bool focusable)
+{
+ if (!focusable && isFocused())
+ {
+ mFocusHandler->focusNone();
+ }
+
+ mFocusable = focusable;
+}
+
+bool Widget::isFocusable() const
+{
+ return mFocusable && isVisible() && isEnabled();
+}
+
+void Widget::requestFocus()
+{
+ if (!mFocusHandler)
+ return;
+
+ if (isFocusable())
+ mFocusHandler->requestFocus(this);
+}
+
+void Widget::requestMoveToTop()
+{
+ if (mParent)
+ mParent->moveToTop(this);
+}
+
+void Widget::requestMoveToBottom()
+{
+ if (mParent)
+ mParent->moveToBottom(this);
+}
+
+void Widget::setVisible(bool visible)
+{
+ if (!visible && isFocused())
+ mFocusHandler->focusNone();
+
+ if (visible)
+ distributeShownEvent();
+ else
+ distributeHiddenEvent();
+
+ mVisible = visible;
+}
+
+void Widget::setBaseColor(const Color& color)
+{
+ mBaseColor = color;
+}
+
+const Color& Widget::getBaseColor() const
+{
+ return mBaseColor;
+}
+
+void Widget::setForegroundColor(const Color& color)
+{
+ mForegroundColor = color;
+}
+
+const Color& Widget::getForegroundColor() const
+{
+ return mForegroundColor;
+}
+
+void Widget::setBackgroundColor(const Color& color)
+{
+ mBackgroundColor = color;
+}
+
+const Color& Widget::getBackgroundColor() const
+{
+ return mBackgroundColor;
+}
+
+void Widget::setSelectionColor(const Color& color)
+{
+ mSelectionColor = color;
+}
+
+const Color& Widget::getSelectionColor() const
+{
+ return mSelectionColor;
+}
+
+void Widget::_setFocusHandler(FocusHandler* focusHandler)
+{
+ if (mFocusHandler)
+ {
+ releaseModalFocus();
+ mFocusHandler->remove(this);
+ }
+
+ if (focusHandler)
+ focusHandler->add(this);
+
+ mFocusHandler = focusHandler;
+}
+
+FocusHandler* Widget::_getFocusHandler()
+{
+ return mFocusHandler;
+}
+
+void Widget::addActionListener(ActionListener* actionListener)
+{
+ mActionListeners.push_back(actionListener);
+}
+
+void Widget::removeActionListener(ActionListener* actionListener)
+{
+ mActionListeners.remove(actionListener);
+}
+
+void Widget::addDeathListener(DeathListener* deathListener)
+{
+ mDeathListeners.push_back(deathListener);
+}
+
+void Widget::removeDeathListener(DeathListener* deathListener)
+{
+ mDeathListeners.remove(deathListener);
+}
+
+void Widget::addKeyListener(KeyListener* keyListener)
+{
+ mKeyListeners.push_back(keyListener);
+}
+
+void Widget::removeKeyListener(KeyListener* keyListener)
+{
+ mKeyListeners.remove(keyListener);
+}
+
+void Widget::addFocusListener(FocusListener* focusListener)
+{
+ mFocusListeners.push_back(focusListener);
+}
+
+void Widget::removeFocusListener(FocusListener* focusListener)
+{
+ mFocusListeners.remove(focusListener);
+}
+
+void Widget::addMouseListener(MouseListener* mouseListener)
+{
+ mMouseListeners.push_back(mouseListener);
+}
+
+void Widget::removeMouseListener(MouseListener* mouseListener)
+{
+ mMouseListeners.remove(mouseListener);
+}
+
+void Widget::addWidgetListener(WidgetListener* widgetListener)
+{
+ mWidgetListeners.push_back(widgetListener);
+}
+
+void Widget::removeWidgetListener(WidgetListener* widgetListener)
+{
+ mWidgetListeners.remove(widgetListener);
+}
+
+void Widget::getAbsolutePosition(int& x, int& y) const
+{
+ if (!mParent)
+ {
+ x = mDimension.x;
+ y = mDimension.y;
+ return;
+ }
+
+ int parentX;
+ int parentY;
+
+ mParent->getAbsolutePosition(parentX, parentY);
+
+ const Rect &rect = mParent->getChildrenArea();
+ x = parentX + mDimension.x + rect.x;
+ y = parentY + mDimension.y + rect.y;
+}
+
+Font* Widget::getFont() const
+{
+ if (!mCurrentFont)
+ return mGlobalFont;
+ return mCurrentFont;
+}
+
+void Widget::setGlobalFont(Font* font)
+{
+ mGlobalFont = font;
+
+ for (std::list<Widget*>::const_iterator iter = mWidgets.begin();
+ iter != mWidgets.end(); ++iter)
+ {
+ if (!(*iter)->mCurrentFont)
+ (*iter)->fontChanged();
+ }
+}
+
+void Widget::setFont(Font* font)
+{
+ mCurrentFont = font;
+ fontChanged();
+}
+
+bool Widget::widgetExists(const Widget* widget)
+{
+ return mWidgetsSet.find(const_cast<Widget*>(widget))
+ != mWidgetsSet.end();
+}
+
+bool Widget::isTabInEnabled() const
+{
+ return mTabIn;
+}
+
+void Widget::setTabInEnabled(bool enabled)
+{
+ mTabIn = enabled;
+}
+
+bool Widget::isTabOutEnabled() const
+{
+ return mTabOut;
+}
+
+void Widget::setTabOutEnabled(bool enabled)
+{
+ mTabOut = enabled;
+}
+
+void Widget::setSize(int width, int height)
+{
+ Rect newDimension = mDimension;
+ newDimension.width = width;
+ newDimension.height = height;
+
+ setDimension(newDimension);
+}
+
+void Widget::setEnabled(bool enabled)
+{
+ mEnabled = enabled;
+}
+
+bool Widget::isEnabled() const
+{
+ return mEnabled && isVisible();
+}
+
+void Widget::requestModalFocus()
+{
+ if (!mFocusHandler)
+ return;
+
+ mFocusHandler->requestModalFocus(this);
+}
+
+void Widget::requestModalMouseInputFocus()
+{
+ if (!mFocusHandler)
+ return;
+
+ mFocusHandler->requestModalMouseInputFocus(this);
+}
+
+void Widget::releaseModalFocus()
+{
+ if (!mFocusHandler)
+ return;
+
+ mFocusHandler->releaseModalFocus(this);
+}
+
+void Widget::releaseModalMouseInputFocus()
+{
+ if (!mFocusHandler)
+ return;
+
+ mFocusHandler->releaseModalMouseInputFocus(this);
+}
+
+bool Widget::isModalFocused() const
+{
+ if (!mFocusHandler)
+ return false;
+
+ if (mParent)
+ {
+ return (mFocusHandler->getModalFocused() == this)
+ || mParent->isModalFocused();
+ }
+
+ return mFocusHandler->getModalFocused() == this;
+}
+
+bool Widget::isModalMouseInputFocused() const
+{
+ if (!mFocusHandler)
+ return false;
+
+ if (mParent)
+ {
+ return (mFocusHandler->getModalMouseInputFocused() == this)
+ || mParent->isModalMouseInputFocused();
+ }
+
+ return mFocusHandler->getModalMouseInputFocused() == this;
+}
+
+Widget *Widget::getWidgetAt(int x A_UNUSED, int y A_UNUSED)
+{
+ return nullptr;
+}
+
+const std::list<MouseListener*>& Widget::_getMouseListeners()
+{
+ return mMouseListeners;
+}
+
+const std::list<KeyListener*>& Widget::_getKeyListeners()
+{
+ return mKeyListeners;
+}
+
+const std::list<FocusListener*>& Widget::_getFocusListeners()
+{
+ return mFocusListeners;
+}
+
+Rect Widget::getChildrenArea()
+{
+ return Rect(0, 0, 0, 0);
+}
+
+FocusHandler* Widget::_getInternalFocusHandler()
+{
+ return mInternalFocusHandler;
+}
+
+void Widget::setInternalFocusHandler(FocusHandler* focusHandler)
+{
+ mInternalFocusHandler = focusHandler;
+}
+
+void Widget::distributeResizedEvent()
+{
+ for (WidgetListenerIterator iter = mWidgetListeners.begin();
+ iter != mWidgetListeners.end();
+ ++ iter)
+ {
+ Event event(this);
+ (*iter)->widgetResized(event);
+ }
+}
+
+void Widget::distributeMovedEvent()
+{
+ for (WidgetListenerIterator iter = mWidgetListeners.begin();
+ iter != mWidgetListeners.end();
+ ++ iter)
+ {
+ Event event(this);
+ (*iter)->widgetMoved(event);
+ }
+}
+
+void Widget::distributeHiddenEvent()
+{
+ for (WidgetListenerIterator iter = mWidgetListeners.begin();
+ iter != mWidgetListeners.end();
+ ++ iter)
+ {
+ Event event(this);
+ (*iter)->widgetHidden(event);
+ }
+}
+
+void Widget::distributeActionEvent()
+{
+ for (ActionListenerIterator iter = mActionListeners.begin();
+ iter != mActionListeners.end();
+ ++iter)
+ {
+ ActionEvent actionEvent(this, mActionEventId);
+ (*iter)->action(actionEvent);
+ }
+}
+
+void Widget::distributeShownEvent()
+{
+ for (WidgetListenerIterator iter = mWidgetListeners.begin();
+ iter != mWidgetListeners.end();
+ ++iter)
+ {
+ Event event(this);
+ (*iter)->widgetShown(event);
+ }
+}
+
+void Widget::showPart(Rect rectangle)
+{
+ if (mParent)
+ mParent->showWidgetPart(this, rectangle);
+}
diff --git a/src/gui/widgets/widget.h b/src/gui/widgets/widget.h
new file mode 100644
index 000000000..17f016c76
--- /dev/null
+++ b/src/gui/widgets/widget.h
@@ -0,0 +1,1230 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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/>.
+ */
+
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef GUI_WIDGETS_WIDGET_H
+#define GUI_WIDGETS_WIDGET_H
+
+#include <list>
+#include <set>
+#include <string>
+
+#include "gui/color.h"
+#include "gui/rect.h"
+
+#include "gui/widgets/widget2.h"
+
+#include "localconsts.h"
+
+class ActionListener;
+class DeathListener;
+class FocusHandler;
+class FocusListener;
+class Font;
+class Graphics;
+class KeyListener;
+class MouseListener;
+class WidgetListener;
+
+/**
+ * Abstract class for widgets of Guichan. It contains basic functions
+ * every widget should have.
+ *
+ * NOTE: Functions begining with underscore "_" should not
+ * be overloaded unless you know what you are doing
+ *
+ * @author Olof Naessén
+ * @author Per Larsson.
+ * @since 0.1.0
+ */
+class Widget : public Widget2
+{
+ public:
+ /**
+ * Constructor. Resets member variables. Noteable, a widget is not
+ * focusable as default, therefore, widgets that are supposed to be
+ * focusable should overide this default in their own constructor.
+ */
+ explicit Widget(const Widget2 *const widget);
+
+ A_DELETE_COPY(Widget)
+
+ /**
+ * Default destructor.
+ */
+ virtual ~Widget();
+
+ /**
+ * Draws the widget. It is called by the parent widget when it is time
+ * for the widget to draw itself. The graphics object is set up so
+ * that all drawing is relative to the widget, i.e coordinate (0,0) is
+ * the top left corner of the widget. It is not possible to draw
+ * outside of a widget's dimension.
+ *
+ * @param graphics aA graphics object to draw with.
+ * @since 0.1.0
+ */
+ virtual void draw(Graphics* graphics) = 0;
+
+ /**
+ * Called when a widget is given a chance to draw a frame around itself.
+ * The frame is not considered a part of the widget, it only allows a frame
+ * to be drawn around the widget, thus a frame will never be included when
+ * calculating if a widget should receive events from user input. Also
+ * a widget's frame will never be included when calculating a widget's
+ * position.
+ *
+ * The size of the frame is calculated using the widget's frame size.
+ * If a widget has a frame size of 10 pixels than the area the drawFrame
+ * function can draw to will be the size of the widget with an additional
+ * extension of 10 pixels in each direction.
+ *
+ * An example when drawFrame is a useful function is if a widget needs
+ * a glow around itself.
+ *
+ * @param graphics A graphics object to draw with.
+ * @see setFrameSize, getFrameSize
+ * @since 0.8.0
+ */
+ virtual void drawFrame(Graphics* graphics);
+
+ /**
+ * Sets the size of the widget's frame. The frame is not considered a part of
+ * the widget, it only allows a frame to be drawn around the widget, thus a frame
+ * will never be included when calculating if a widget should receive events
+ * from user input. Also a widget's frame will never be included when calculating
+ * a widget's position.
+ *
+ * A frame size of 0 means that the widget has no frame. The default frame size
+ * is 0.
+ *
+ * @param frameSize The size of the widget's frame.
+ * @see getFrameSize, drawFrame
+ * @since 0.8.0
+ */
+ void setFrameSize(unsigned int frameSize);
+
+ /**
+ * Gets the size of the widget's frame. The frame is not considered a part of
+ * the widget, it only allows a frame to be drawn around the widget, thus a frame
+ * will never be included when calculating if a widget should receive events
+ * from user input. Also a widget's frame will never be included when calculating
+ * a widget's position.
+ *
+ * A frame size of 0 means that the widget has no frame. The default frame size
+ * is 0.
+ *
+ * @return The size of the widget's frame.
+ * @see setFrameSize, drawFrame
+ * @since 0.8.0
+ */
+ unsigned int getFrameSize() const A_WARN_UNUSED;
+
+ /**
+ * Called for all widgets in the gui each time Gui::logic is called.
+ * You can do logic stuff here like playing an animation.
+ *
+ * @see Gui::logic
+ * @since 0.1.0
+ */
+ virtual void logic()
+ { }
+
+ /**
+ * Gets the widget's parent container.
+ *
+ * @return The widget's parent container. NULL if the widget
+ * has no parent.
+ * @since 0.1.0
+ */
+ virtual Widget* getParent() const A_WARN_UNUSED
+ { return mParent; }
+
+ /**
+ * Sets the width of the widget.
+ *
+ * @param width The width of the widget.
+ * @see getWidth, setHeight, getHeight, setSize,
+ * setDimension, getDimensi
+ * @since 0.1.0
+ */
+ void setWidth(int width);
+
+ /**
+ * Gets the width of the widget.
+ *
+ * @return The width of the widget.
+ * @see setWidth, setHeight, getHeight, setSize,
+ * setDimension, getDimension
+ * @since 0.1.0
+ */
+ int getWidth() const A_WARN_UNUSED
+ { return mDimension.width; }
+
+ /**
+ * Sets the height of the widget.
+ *
+ * @param height The height of the widget.
+ * @see getHeight, setWidth, getWidth, setSize,
+ * setDimension, getDimension
+ * @since 0.1.0
+ */
+ void setHeight(int height);
+
+ /**
+ * Gets the height of the widget.
+ *
+ * @return The height of the widget.
+ * @see setHeight, setWidth, getWidth, setSize,
+ * setDimension, getDimension
+ * @since 0.1.0
+ */
+ int getHeight() const A_WARN_UNUSED
+ { return mDimension.height; }
+
+ /**
+ * Sets the size of the widget.
+ *
+ * @param width The width of the widget.
+ * @param height The height of the widget.
+ * @see setWidth, setHeight, getWidth, getHeight,
+ * setDimension, getDimension
+ * @since 0.1.0
+ */
+ void setSize(int width, int height);
+
+ /**
+ * Sets the x coordinate of the widget. The coordinate is
+ * relateive to the widget's parent.
+ *
+ * @param x The x coordinate of the widget.
+ * @see getX, setY, getY, setPosition, setDimension, getDimension
+ * @since 0.1.0
+ */
+ void setX(int x);
+
+ /**
+ * Gets the x coordinate of the widget. The coordinate is
+ * relative to the widget's parent.
+ *
+ * @return The x coordinate of the widget.
+ * @see setX, setY, getY, setPosition, setDimension, getDimension
+ * @since 0.1.0
+ */
+ int getX() const A_WARN_UNUSED
+ { return mDimension.x; }
+
+ /**
+ * Sets the y coordinate of the widget. The coordinate is
+ * relative to the widget's parent.
+ *
+ * @param y The y coordinate of the widget.
+ * @see setY, setX, getX, setPosition, setDimension, getDimension
+ * @since 0.1.0
+ */
+ void setY(int y);
+
+ /**
+ * Gets the y coordinate of the widget. The coordinate is
+ * relative to the widget's parent.
+ *
+ * @return The y coordinate of the widget.
+ * @see setY, setX, getX, setPosition, setDimension, getDimension
+ * @since 0.1.0
+ */
+ int getY() const A_WARN_UNUSED
+ { return mDimension.y; }
+
+ /**
+ * Sets position of the widget. The position is relative
+ * to the widget's parent.
+ *
+ * @param x The x coordinate of the widget.
+ * @param y The y coordinate of the widget.
+ * @see setX, getX, setY, getY, setDimension, getDimension
+ * @since 0.1.0
+ */
+ void setPosition(int x, int y);
+
+ /**
+ * Sets the dimension of the widget. The dimension is
+ * relative to the widget's parent.
+ *
+ * @param dimension The dimension of the widget.
+ * @see getDimension, setX, getX, setY, getY, setPosition
+ * @since 0.1.0
+ */
+ void setDimension(const Rect& dimension);
+
+ /**
+ * Gets the dimension of the widget. The dimension is
+ * relative to the widget's parent.
+ *
+ * @return The dimension of the widget.
+ * @see getDimension, setX, getX, setY, getY, setPosition
+ * @since 0.1.0
+ */
+ const Rect& getDimension() const A_WARN_UNUSED;
+
+ /**
+ * Sets the widget to be fosusable, or not.
+ *
+ * @param focusable True if the widget should be focusable,
+ * false otherwise.
+ * @see isFocusable
+ * @since 0.1.0
+ */
+ void setFocusable(bool focusable);
+
+ /**
+ * Checks if a widget is focsable.
+ *
+ * @return True if the widget should be focusable, false otherwise.
+ * @see setFocusable
+ * @since 0.1.0
+ */
+ bool isFocusable() const A_WARN_UNUSED;
+
+ /**
+ * Checks if the widget is focused.
+ *
+ * @return True if the widget is focused, false otherwise.
+ * @since 0.1.0
+ */
+ virtual bool isFocused() const A_WARN_UNUSED;
+
+ /**
+ * Sets the widget to enabled, or not. A disabled
+ * widget will never recieve mouse or key events.
+ *
+ * @param enabled True if widget should be enabled,
+ * false otherwise.
+ * @see isEnabled
+ * @since 0.1.0
+ */
+ void setEnabled(bool enabled);
+
+ /**
+ * Checks if the widget is enabled. A disabled
+ * widget will never recieve mouse or key events.
+ *
+ * @return True if widget is enabled, false otherwise.
+ * @see setEnabled
+ * @since 0.1.0
+ */
+ bool isEnabled() const A_WARN_UNUSED;
+
+ /**
+ * Sets the widget to be visible, or not.
+ *
+ * @param visible True if widget should be visible, false otherwise.
+ * @see isVisible
+ * @since 0.1.0
+ */
+ void setVisible(bool visible);
+
+ /**
+ * Checks if the widget is visible.
+ *
+ * @return True if widget is be visible, false otherwise.
+ * @see setVisible
+ * @since 0.1.0
+ */
+ bool isVisible() const A_WARN_UNUSED
+ { return mVisible && (!mParent || mParent->isVisible()); }
+
+ /**
+ * Sets the base color of the widget.
+ *
+ * @param color The baseground color.
+ * @see getBaseColor
+ * @since 0.1.0
+ */
+ void setBaseColor(const Color& color);
+
+ /**
+ * Gets the base color.
+ *
+ * @return The base color.
+ * @see setBaseColor
+ * @since 0.1.0
+ */
+ const Color& getBaseColor() const A_WARN_UNUSED;
+
+ /**
+ * Sets the foreground color.
+ *
+ * @param color The foreground color.
+ * @see getForegroundColor
+ * @since 0.1.0
+ */
+ void setForegroundColor(const Color& color);
+
+ /**
+ * Gets the foreground color.
+ *
+ * @see setForegroundColor
+ * @since 0.1.0
+ */
+ const Color& getForegroundColor() const A_WARN_UNUSED;
+
+ /**
+ * Sets the background color.
+ *
+ * @param color The background Color.
+ * @see setBackgroundColor
+ * @since 0.1.0
+ */
+ void setBackgroundColor(const Color& color);
+
+ /**
+ * Gets the background color.
+ *
+ * @see setBackgroundColor
+ * @since 0.1.0
+ */
+ const Color& getBackgroundColor() const A_WARN_UNUSED;
+
+ /**
+ * Sets the selection color.
+ *
+ * @param color The selection color.
+ * @see getSelectionColor
+ * @since 0.6.0
+ */
+ void setSelectionColor(const Color& color);
+
+ /**
+ * Gets the selection color.
+ *
+ * @return The selection color.
+ * @see setSelectionColor
+ * @since 0.6.0
+ */
+ const Color& getSelectionColor() const A_WARN_UNUSED;
+
+ /**
+ * Requests focus for the widget. A widget will only recieve focus
+ * if it is focusable.
+ */
+ virtual void requestFocus();
+
+ /**
+ * Requests a move to the top in the parent widget.
+ */
+ virtual void requestMoveToTop();
+
+ /**
+ * Requests a move to the bottom in the parent widget.
+ */
+ virtual void requestMoveToBottom();
+
+ /**
+ * Sets the focus handler to be used.
+ *
+ * WARNING: This function is used internally and should not
+ * be called or overloaded unless you know what you
+ * are doing.
+ *
+ * @param focusHandler The focus handler to use.
+ * @see _getFocusHandler
+ * @since 0.1.0
+ */
+ virtual void _setFocusHandler(FocusHandler* focusHandler);
+
+ /**
+ * Gets the focus handler used.
+ *
+ * WARNING: This function is used internally and should not
+ * be called or overloaded unless you know what you
+ * are doing.
+ *
+ * @return The focus handler used.
+ * @see _setFocusHandler
+ * @since 0.1.0
+ */
+ virtual FocusHandler* _getFocusHandler() A_WARN_UNUSED;
+
+ /**
+ * Adds an action listener to the widget. When an action event
+ * is fired by the widget the action listeners of the widget
+ * will get notified.
+ *
+ * @param actionListener The action listener to add.
+ * @see removeActionListener
+ * @since 0.1.0
+ */
+ void addActionListener(ActionListener* actionListener);
+
+ /**
+ * Removes an added action listener from the widget.
+ *
+ * @param actionListener The action listener to remove.
+ * @see addActionListener
+ * @since 0.1.0
+ */
+ void removeActionListener(ActionListener* actionListener);
+
+ /**
+ * Adds a death listener to the widget. When a death event is
+ * fired by the widget the death listeners of the widget will
+ * get notified.
+ *
+ * @param deathListener The death listener to add.
+ * @see removeDeathListener
+ * @since 0.1.0
+ */
+ void addDeathListener(DeathListener* deathListener);
+
+ /**
+ * Removes an added death listener from the widget.
+ *
+ * @param deathListener The death listener to remove.
+ * @see addDeathListener
+ * @since 0.1.0
+ */
+ void removeDeathListener(DeathListener* deathListener);
+
+ /**
+ * Adds a mouse listener to the widget. When a mouse event is
+ * fired by the widget the mouse listeners of the widget will
+ * get notified.
+ *
+ * @param mouseListener The mouse listener to add.
+ * @see removeMouseListener
+ * @since 0.1.0
+ */
+ void addMouseListener(MouseListener* mouseListener);
+
+ /**
+ * Removes an added mouse listener from the widget.
+ *
+ * @param mouseListener The mouse listener to remove.
+ * @see addMouseListener
+ * @since 0.1.0
+ */
+ void removeMouseListener(MouseListener* mouseListener);
+
+ /**
+ * Adds a key listener to the widget. When a key event is
+ * fired by the widget the key listeners of the widget will
+ * get notified.
+ *
+ * @param keyListener The key listener to add.
+ * @see removeKeyListener
+ * @since 0.1.0
+ */
+ void addKeyListener(KeyListener* keyListener);
+
+ /**
+ * Removes an added key listener from the widget.
+ *
+ * @param keyListener The key listener to remove.
+ * @see addKeyListener
+ * @since 0.1.0
+ */
+ void removeKeyListener(KeyListener* keyListener);
+
+ /**
+ * Adds a focus listener to the widget. When a focus event is
+ * fired by the widget the key listeners of the widget will
+ * get notified.
+ *
+ * @param focusListener The focus listener to add.
+ * @see removeFocusListener
+ * @since 0.7.0
+ */
+ void addFocusListener(FocusListener* focusListener);
+
+ /**
+ * Removes an added focus listener from the widget.
+ *
+ * @param focusListener The focus listener to remove.
+ * @see addFocusListener
+ * @since 0.7.0
+ */
+ void removeFocusListener(FocusListener* focusListener);
+
+ /**
+ * Adds a widget listener to the widget. When a widget event is
+ * fired by the widget the key listeners of the widget will
+ * get notified.
+ *
+ * @param widgetListener The widget listener to add.
+ * @see removeWidgetListener
+ * @since 0.8.0
+ */
+ void addWidgetListener(WidgetListener* widgetListener);
+
+ /**
+ * Removes an added widget listener from the widget.
+ *
+ * @param widgetListener The widget listener to remove.
+ * @see addWidgetListener
+ * @since 0.8.0
+ */
+ void removeWidgetListener(WidgetListener* widgetListener);
+
+ /**
+ * Sets the action event identifier of the widget. The identifier is
+ * used to be able to identify which action has occured.
+ *
+ * NOTE: An action event identifier should not be used to identify a
+ * certain widget but rather a certain event in your application.
+ * Several widgets can have the same action event identifer.
+ *
+ * @param actionEventId The action event identifier.
+ * @see getActionEventId
+ * @since 0.6.0
+ */
+ void setActionEventId(const std::string& actionEventId);
+
+ /**
+ * Gets the action event identifier of the widget.
+ *
+ * @return The action event identifier of the widget.
+ * @see setActionEventId
+ * @since 0.6.0
+ */
+ const std::string& getActionEventId() const;
+
+ /**
+ * Gets the absolute position on the screen for the widget.
+ *
+ * @param x The absolute x coordinate will be stored in this parameter.
+ * @param y The absolute y coordinate will be stored in this parameter.
+ * @since 0.1.0
+ */
+ virtual void getAbsolutePosition(int& x, int& y) const;
+
+ /**
+ * Sets the parent of the widget. A parent must be a BasicContainer.
+ *
+ * WARNING: This function is used internally and should not
+ * be called or overloaded unless you know what you
+ * are doing.
+ *
+ * @param parent The parent of the widget.
+ * @see getParent
+ * @since 0.1.0
+ */
+ virtual void _setParent(Widget* parent);
+
+ /**
+ * Gets the font set for the widget. If no font has been set,
+ * the global font will be returned. If no global font has been set,
+ * the default font will be returend.
+ *
+ * @return The font set for the widget.
+ * @see setFont, setGlobalFont
+ * @since 0.1.0
+ */
+ Font *getFont() const A_WARN_UNUSED;
+
+ /**
+ * Sets the global font to be used by default for all widgets.
+ *
+ * @param font The global font.
+ * @see getGlobalFont
+ * @since 0.1.0
+ */
+ static void setGlobalFont(Font* font);
+
+ /**
+ * Sets the font for the widget. If NULL is passed, the global font
+ * will be used.
+ *
+ * @param font The font to set for the widget.
+ * @see getFont
+ * @since 0.1.0
+ */
+ void setFont(Font* font);
+
+ /**
+ * Called when the font has changed. If the change is global,
+ * this function will only be called if the widget doesn't have a
+ * font already set.
+ *
+ * @since 0.1.0
+ */
+ virtual void fontChanged()
+ { }
+
+ /**
+ * Checks if a widget exists or not, that is if it still exists
+ * an instance of the object.
+ *
+ * @param widget The widget to check.
+ * @return True if an instance of the widget exists, false otherwise.
+ * @since 0.1.0
+ */
+ static bool widgetExists(const Widget* widget) A_WARN_UNUSED;
+
+ /**
+ * Checks if tab in is enabled. Tab in means that you can set focus
+ * to this widget by pressing the tab button. If tab in is disabled
+ * then the focus handler will skip this widget and focus the next
+ * in its focus order.
+ *
+ * @return True if tab in is enabled, false otherwise.
+ * @see setTabInEnabled
+ * @since 0.1.0
+ */
+ bool isTabInEnabled() const A_WARN_UNUSED;
+
+ /**
+ * Sets tab in enabled, or not. Tab in means that you can set focus
+ * to this widget by pressing the tab button. If tab in is disabled
+ * then the FocusHandler will skip this widget and focus the next
+ * in its focus order.
+ *
+ * @param enabled True if tab in should be enabled, false otherwise.
+ * @see isTabInEnabled
+ * @since 0.1.0
+ */
+ void setTabInEnabled(bool enabled);
+
+ /**
+ * Checks if tab out is enabled. Tab out means that you can lose
+ * focus to this widget by pressing the tab button. If tab out is
+ * disabled then the FocusHandler ignores tabbing and focus will
+ * stay with this widget.
+ *
+ * @return True if tab out is enabled, false otherwise.
+ * @see setTabOutEnabled
+ * @since 0.1.0
+ */
+ bool isTabOutEnabled() const A_WARN_UNUSED;
+
+ /**
+ * Sets tab out enabled. Tab out means that you can lose
+ * focus to this widget by pressing the tab button. If tab out is
+ * disabled then the FocusHandler ignores tabbing and focus will
+ * stay with this widget.
+ *
+ * @param enabled True if tab out should be enabled, false otherwise.
+ * @see isTabOutEnabled
+ * @since 0.1.0
+ */
+ void setTabOutEnabled(bool enabled);
+
+ /**
+ * Requests modal focus. When a widget has modal focus, only that
+ * widget and it's children may recieve input.
+ *
+ * @throws Exception if another widget already has modal focus.
+ * @see releaseModalFocus, isModalFocused
+ * @since 0.4.0
+ */
+ virtual void requestModalFocus();
+
+ /**
+ * Requests modal mouse input focus. When a widget has modal input focus
+ * that widget will be the only widget receiving input even if the input
+ * occurs outside of the widget and no matter what the input is.
+ *
+ * @throws Exception if another widget already has modal focus.
+ * @see releaseModalMouseInputFocus, isModalMouseInputFocused
+ * @since 0.6.0
+ */
+ virtual void requestModalMouseInputFocus();
+
+ /**
+ * Releases modal focus. Modal focus will only be released if the
+ * widget has modal focus.
+ *
+ * @see requestModalFocus, isModalFocused
+ * @since 0.4.0
+ */
+ virtual void releaseModalFocus();
+
+ /**
+ * Releases modal mouse input focus. Modal mouse input focus will only
+ * be released if the widget has modal mouse input focus.
+ *
+ * @see requestModalMouseInputFocus, isModalMouseInputFocused
+ * @since 0.6.0
+ */
+ virtual void releaseModalMouseInputFocus();
+
+ /**
+ * Checks if the widget or it's parent has modal focus.
+ *
+ * @return True if the widget has modal focus, false otherwise.
+ * @see requestModalFocus, releaseModalFocus
+ * @since 0.8.0
+ */
+ virtual bool isModalFocused() const A_WARN_UNUSED;
+
+ /**
+ * Checks if the widget or it's parent has modal mouse input focus.
+ *
+ * @return True if the widget has modal mouse input focus, false
+ * otherwise.
+ * @see requestModalMouseInputFocus, releaseModalMouseInputFocus
+ * @since 0.8.0
+ */
+ virtual bool isModalMouseInputFocused() const A_WARN_UNUSED;
+
+ /**
+ * Gets a widget from a certain position in the widget.
+ * This function is used to decide which gets mouse input,
+ * thus it can be overloaded to change that behaviour.
+ *
+ * NOTE: This always returns NULL if the widget is not
+ * a container.
+ *
+ * @param x The x coordinate of the widget to get.
+ * @param y The y coordinate of the widget to get.
+ * @return The widget at the specified coodinate, NULL
+ * if no widget is found.
+ * @since 0.6.0
+ */
+ virtual Widget *getWidgetAt(int x, int y) A_WARN_UNUSED;
+
+ /**
+ * Gets the mouse listeners of the widget.
+ *
+ * @return The mouse listeners of the widget.
+ * @since 0.6.0
+ */
+ virtual const std::list<MouseListener*>& _getMouseListeners()
+ A_WARN_UNUSED;
+
+ /**
+ * Gets the key listeners of the widget.
+ *
+ * @return The key listeners of the widget.
+ * @since 0.6.0
+ */
+ virtual const std::list<KeyListener*>& _getKeyListeners()
+ A_WARN_UNUSED;
+
+ /**
+ * Gets the focus listeners of the widget.
+ *
+ * @return The focus listeners of the widget.
+ * @since 0.7.0
+ */
+ virtual const std::list<FocusListener*>& _getFocusListeners()
+ A_WARN_UNUSED;
+
+ /**
+ * Gets the area of the widget occupied by the widget's children.
+ * By default this method returns an empty rectangle as not all
+ * widgets are containers. If you want to make a container this
+ * method should return the area where the children resides. This
+ * method is used when drawing children of a widget when computing
+ * clip rectangles for the children.
+ *
+ * An example of a widget that overloads this method is ScrollArea.
+ * A ScrollArea has a view of its contant and that view is the
+ * children area. The size of a ScrollArea's children area might
+ * vary depending on if the scroll bars of the ScrollArea is shown
+ * or not.
+ *
+ * @return The area of the widget occupied by the widget's children.
+ * @see BasicContainer
+ * @see BasicContainer::getChildrenArea
+ * @see BasicContainer::drawChildren
+ * @since 0.1.0
+ */
+ virtual Rect getChildrenArea() A_WARN_UNUSED;
+
+ /**
+ * Gets the internal focus handler used.
+ *
+ * @return the internalFocusHandler used. If no internal focus handler
+ * is used, NULL will be returned.
+ * @see setInternalFocusHandler
+ * @since 0.1.0
+ */
+ virtual FocusHandler* _getInternalFocusHandler() A_WARN_UNUSED;
+
+ /**
+ * Sets the internal focus handler. An internal focus handler is
+ * needed if both a widget in the widget and the widget itself
+ * should be foucsed at the same time.
+ *
+ * @param focusHandler The internal focus handler to be used.
+ * @see getInternalFocusHandler
+ * @since 0.1.0
+ */
+ void setInternalFocusHandler(FocusHandler* internalFocusHandler);
+
+ /**
+ * Moves a widget to the top of this widget. The moved widget will be
+ * drawn above all other widgets in this widget.
+ *
+ * @param widget The widget to move to the top.
+ * @see moveToBottom
+ * @since 0.1.0
+ */
+ virtual void moveToTop(Widget* widget A_UNUSED)
+ { }
+
+ /**
+ * Moves a widget in this widget to the bottom of this widget.
+ * The moved widget will be drawn below all other widgets in this widget.
+ *
+ * @param widget The widget to move to the bottom.
+ * @see moveToTop
+ * @since 0.1.0
+ */
+ virtual void moveToBottom(Widget* widget A_UNUSED)
+ { }
+
+ /**
+ * Focuses the next widget in the widget.
+ *
+ * @see moveToBottom
+ * @since 0.1.0
+ */
+ virtual void focusNext()
+ { }
+
+ /**
+ * Focuses the previous widget in the widget.
+ *
+ * @see moveToBottom
+ * @since 0.1.0
+ */
+ virtual void focusPrevious()
+ { }
+
+ /**
+ * Tries to show a specific part of a widget by moving it. Used if the
+ * widget should act as a container.
+ *
+ * @param widget The target widget.
+ * @param area The area to show.
+ * @since 0.1.0
+ */
+ virtual void showWidgetPart(Widget* widget A_UNUSED,
+ Rect area A_UNUSED)
+ { }
+
+ /**
+ * Sets an id of a widget. An id can be useful if a widget needs to be
+ * identified in a container. For example, if widgets are created by an
+ * XML document, a certain widget can be retrieved given that the widget
+ * has an id.
+ *
+ * @param id The id to set to the widget.
+ * @see getId, BasicContainer::findWidgetById
+ * @since 0.8.0
+ */
+ void setId(const std::string& id)
+ { mId = id; }
+
+ /**
+ * Gets the id of a widget. An id can be useful if a widget needs to be
+ * identified in a container. For example, if widgets are created by an
+ * XML document, a certain widget can be retrieved given that the widget
+ * has an id.
+ *
+ * @param id The id to set to the widget.
+ * @see setId, BasicContainer::findWidgetById
+ * @since 0.8.0
+ */
+ const std::string& getId() const A_WARN_UNUSED
+ { return mId; }
+
+ /**
+ * Shows a certain part of a widget in the widget's parent.
+ * Used when widgets want a specific part to be visible in
+ * its parent. An example is a TextArea that wants a specific
+ * part of its text to be visible when a TextArea is a child
+ * of a ScrollArea.
+ *
+ * @param rectangle The rectangle to be shown.
+ * @since 0.8.0
+ */
+ virtual void showPart(Rect rectangle);
+
+ protected:
+ /**
+ * Distributes an action event to all action listeners
+ * of the widget.
+ *
+ * @since 0.8.0
+ */
+ void distributeActionEvent();
+
+ /**
+ * Distributes resized events to all of the widget's listeners.
+ *
+ * @since 0.8.0
+ */
+ void distributeResizedEvent();
+
+ /**
+ * Distributes moved events to all of the widget's listeners.
+ *
+ * @since 0.8.0
+ */
+ void distributeMovedEvent();
+
+ /**
+ * Distributes hidden events to all of the widget's listeners.
+ *
+ * @since 0.8.0
+ * @author Olof Naessén
+ */
+ void distributeHiddenEvent();
+
+ /**
+ * Distributes shown events to all of the widget's listeners.
+ *
+ * @since 0.8.0
+ * @author Olof Naessén
+ */
+ void distributeShownEvent();
+
+ /**
+ * Typdef.
+ */
+ typedef std::list<MouseListener*> MouseListenerList;
+
+ /**
+ * Typdef.
+ */
+ typedef MouseListenerList::iterator MouseListenerIterator;
+
+ /**
+ * Holds the mouse listeners of the widget.
+ */
+ MouseListenerList mMouseListeners;
+
+ /**
+ * Typdef.
+ */
+ typedef std::list<KeyListener*> KeyListenerList;
+
+ /**
+ * Holds the key listeners of the widget.
+ */
+ KeyListenerList mKeyListeners;
+
+ /**
+ * Typdef.
+ */
+ typedef KeyListenerList::iterator KeyListenerIterator;
+
+ /**
+ * Typdef.
+ */
+ typedef std::list<ActionListener*> ActionListenerList;
+
+ /**
+ * Holds the action listeners of the widget.
+ */
+ ActionListenerList mActionListeners;
+
+ /**
+ * Typdef.
+ */
+ typedef ActionListenerList::iterator ActionListenerIterator;
+
+ /**
+ * Typdef.
+ */
+ typedef std::list<DeathListener*> DeathListenerList;
+
+ /**
+ * Holds the death listeners of the widget.
+ */
+ DeathListenerList mDeathListeners;
+
+ /**
+ * Typdef.
+ */
+ typedef DeathListenerList::iterator DeathListenerIterator;
+
+ /**
+ * Typdef.
+ */
+ typedef std::list<FocusListener*> FocusListenerList;
+
+ /**
+ * Holds the focus listeners of the widget.
+ */
+ FocusListenerList mFocusListeners;
+
+ /**
+ * Typdef.
+ */
+ typedef FocusListenerList::iterator FocusListenerIterator;
+
+ typedef std::list<WidgetListener*> WidgetListenerList;
+
+ /**
+ * Holds the widget listeners of the widget.
+ */
+ WidgetListenerList mWidgetListeners;
+
+ /**
+ * Typdef.
+ */
+ typedef WidgetListenerList::iterator WidgetListenerIterator;
+
+ /**
+ * Holds the foreground color of the widget.
+ */
+ Color mForegroundColor;
+
+ /**
+ * Holds the background color of the widget.
+ */
+ Color mBackgroundColor;
+
+ /**
+ * Holds the base color of the widget.
+ */
+ Color mBaseColor;
+
+ /**
+ * Holds the selection color of the widget.
+ */
+ Color mSelectionColor;
+
+ /**
+ * Holds the focus handler used by the widget.
+ */
+ FocusHandler* mFocusHandler;
+
+ /**
+ * Holds the focus handler used by the widget. NULL
+ * if no internal focus handler is used.
+ */
+ FocusHandler* mInternalFocusHandler;
+
+ /**
+ * Holds the parent of the widget. NULL if the widget
+ * has no parent.
+ */
+ Widget* mParent;
+
+ /**
+ * Holds the dimension of the widget.
+ */
+ Rect mDimension;
+
+ /**
+ * Holds the frame size of the widget.
+ */
+ unsigned int mFrameSize;
+
+ /**
+ * Holds the action event of the widget.
+ */
+ std::string mActionEventId;
+
+ /**
+ * True if the widget focusable, false otherwise.
+ */
+ bool mFocusable;
+
+ /**
+ * True if the widget visible, false otherwise.
+ */
+ bool mVisible;
+
+ /**
+ * True if the widget has tab in enabled, false otherwise.
+ */
+ bool mTabIn;
+
+ /**
+ * True if the widget has tab in enabled, false otherwise.
+ */
+ bool mTabOut;
+
+ /**
+ * True if the widget is enabled, false otherwise.
+ */
+ bool mEnabled;
+
+ /**
+ * Holds the id of the widget.
+ */
+ std::string mId;
+
+ /**
+ * Holds the font used by the widget.
+ */
+ Font* mCurrentFont;
+
+ /**
+ * Holds the global font used by the widget.
+ */
+ static Font* mGlobalFont;
+
+ /**
+ * Holds a list of all instances of widgets.
+ */
+ static std::list<Widget*> mWidgets;
+
+ static std::set<Widget*> mWidgetsSet;
+};
+
+#endif // GUI_WIDGETS_WIDGET_H
diff --git a/src/gui/widgets/widget2.h b/src/gui/widgets/widget2.h
index f6e94556a..ff565815f 100644
--- a/src/gui/widgets/widget2.h
+++ b/src/gui/widgets/widget2.h
@@ -21,7 +21,6 @@
#ifndef GUI_WIDGETS_WIDGET2_H
#define GUI_WIDGETS_WIDGET2_H
-#include "gui/gui.h"
#include "gui/theme.h"
#include "render/renderers.h"
@@ -33,16 +32,16 @@ class Widget2
{
}
- inline const gcn::Color &getThemeColor(const int type,
- const int alpha = 255)
- const A_WARN_UNUSED
+ inline const Color &getThemeColor(const int type,
+ const int alpha = 255)
+ const A_WARN_UNUSED
{
return Theme::getThemeColor(mPaletteOffset + type, alpha);
}
- inline const gcn::Color &getThemeCharColor(const signed char c,
- bool &valid)
- const A_WARN_UNUSED
+ inline const Color &getThemeCharColor(const signed char c,
+ bool &valid)
+ const A_WARN_UNUSED
{
const int colorId = Theme::getThemeIdByChar(c, valid);
if (valid)
@@ -72,18 +71,12 @@ class Widget2
}
}
- void setForegroundColor2(const gcn::Color &color)
+ void setForegroundColor2(const Color &color)
{
mForegroundColor2 = color;
}
protected:
- Widget2() :
- mPaletteOffset(0),
- mForegroundColor2()
- {
- }
-
explicit Widget2(const Widget2 *const widget) :
mPaletteOffset(widget ? widget->mPaletteOffset : 0),
mForegroundColor2()
@@ -92,7 +85,7 @@ class Widget2
}
int mPaletteOffset;
- gcn::Color mForegroundColor2;
+ Color mForegroundColor2;
};
extern RenderType openGLMode;
diff --git a/src/gui/widgets/widgetgroup.cpp b/src/gui/widgets/widgetgroup.cpp
index 34cbeebb5..07c4df43c 100644
--- a/src/gui/widgets/widgetgroup.cpp
+++ b/src/gui/widgets/widgetgroup.cpp
@@ -23,11 +23,12 @@
#include "debug.h"
WidgetGroup::WidgetGroup(const Widget2 *const widget,
- const std::string &group, const int height,
+ const std::string &group,
+ const int height,
const int spacing) :
Container(widget),
- gcn::WidgetListener(),
- gcn::ActionListener(),
+ WidgetListener(),
+ ActionListener(),
mSpacing(spacing),
mCount(0),
mGroup(group),
@@ -57,7 +58,7 @@ void WidgetGroup::addButton(const std::string &restrict text,
}
}
-void WidgetGroup::action(const gcn::ActionEvent &event)
+void WidgetGroup::action(const ActionEvent &event)
{
for (ActionListenerIterator iter = mActionListeners.begin();
iter != mActionListeners.end(); ++iter)
@@ -66,7 +67,7 @@ void WidgetGroup::action(const gcn::ActionEvent &event)
}
}
-void WidgetGroup::add(gcn::Widget *const widget, const int spacing)
+void WidgetGroup::add(Widget *const widget, const int spacing)
{
if (!widget)
return;
@@ -84,6 +85,6 @@ void WidgetGroup::clear()
mCount = 0;
}
-void WidgetGroup::widgetResized(const gcn::Event &event A_UNUSED)
+void WidgetGroup::widgetResized(const Event &event A_UNUSED)
{
}
diff --git a/src/gui/widgets/widgetgroup.h b/src/gui/widgets/widgetgroup.h
index 3d63b02f8..051234cda 100644
--- a/src/gui/widgets/widgetgroup.h
+++ b/src/gui/widgets/widgetgroup.h
@@ -23,14 +23,14 @@
#include "gui/widgets/container.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/widgetlistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/widgetlistener.h"
#include "localconsts.h"
class WidgetGroup : public Container,
- public gcn::WidgetListener,
- public gcn::ActionListener
+ public WidgetListener,
+ public ActionListener
{
public:
A_DELETE_COPY(WidgetGroup)
@@ -40,21 +40,22 @@ class WidgetGroup : public Container,
virtual void addButton(const std::string &restrict text,
const std::string &restrict tag);
- void action(const gcn::ActionEvent &event) override;
+ void action(const ActionEvent &event) override;
- virtual void add(gcn::Widget *const widget,
+ virtual void add(Widget *const widget,
const int spacing);
virtual void clear();
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
virtual Widget *createWidget(const std::string &name)
const A_WARN_UNUSED = 0;
protected:
WidgetGroup(const Widget2 *const widget,
- const std::string &group, const int height,
+ const std::string &group,
+ const int height,
const int spacing);
int mSpacing;
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 36372dcaa..ec83af9a8 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -20,6 +20,49 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include "gui/widgets/window.h"
#include "client.h"
@@ -29,6 +72,8 @@
#include "soundconsts.h"
#include "soundmanager.h"
+#include "gui/focushandler.h"
+#include "gui/font.h"
#include "gui/gui.h"
#include "gui/viewport.h"
@@ -37,10 +82,6 @@
#include "resources/cursor.h"
#include "resources/image.h"
-#include <guichan/exception.hpp>
-#include <guichan/focushandler.hpp>
-#include <guichan/font.hpp>
-
#include "debug.h"
const int resizeMask = 8 + 4 + 2 + 1;
@@ -50,9 +91,17 @@ int Window::mouseResize = 0;
Window::Window(const std::string &caption, const bool modal,
Window *const parent, std::string skin) :
- gcn::Window(caption),
- Widget2(),
- gcn::WidgetListener(),
+ gcn::Container(nullptr),
+ MouseListener(),
+ WidgetListener(),
+ mCaption(caption),
+ mAlignment(Graphics::CENTER),
+ mPadding(2),
+ mTitleBarHeight(16),
+ mMovable(true),
+ mDragOffsetX(0),
+ mDragOffsetY(0),
+ mMoved(false),
mSkin(nullptr),
mDefaultX(0),
mDefaultY(0),
@@ -74,7 +123,7 @@ Window::Window(const std::string &caption, const bool modal,
mVertexes(new ImageCollection),
mCaptionOffsetX(7),
mCaptionOffsetY(5),
- mCaptionAlign(gcn::Graphics::LEFT),
+ mCaptionAlign(Graphics::LEFT),
mTitlePadding(4),
mGripPadding(2),
mResizeHandles(-1),
@@ -92,16 +141,11 @@ Window::Window(const std::string &caption, const bool modal,
{
logger->log("Window::Window(\"%s\")", caption.c_str());
-#ifndef USE_INTERNALGUICHAN
- mDragOffsetX = 0;
- mDragOffsetY = 0;
-#endif
-
- if (!windowContainer)
- throw GCN_EXCEPTION("Window::Window(): no windowContainer set");
-
windowInstances++;
+// mFrameSize = 1;
+ addMouseListener(this);
+
setFrameSize(0);
setPadding(3);
setTitleBarHeight(20);
@@ -119,7 +163,7 @@ Window::Window(const std::string &caption, const bool modal,
{
setPadding(mSkin->getPadding());
if (getOptionBool("titlebarBold"))
- mCaptionFont = reinterpret_cast<gcn::Font*>(boldFont);
+ mCaptionFont = boldFont;
mTitlePadding = mSkin->getTitlePadding();
mGripPadding = getOption("resizePadding");
mCaptionOffsetX = getOption("captionoffsetx");
@@ -128,12 +172,12 @@ Window::Window(const std::string &caption, const bool modal,
mCaptionOffsetY = getOption("captionoffsety");
if (!mCaptionOffsetY)
mCaptionOffsetY = 5;
- mCaptionAlign = static_cast<gcn::Graphics::Alignment>(
+ mCaptionAlign = static_cast<Graphics::Alignment>(
getOption("captionalign"));
- if (mCaptionAlign < gcn::Graphics::LEFT
- || mCaptionAlign > gcn::Graphics::RIGHT)
+ if (mCaptionAlign < Graphics::LEFT
+ || mCaptionAlign > Graphics::RIGHT)
{
- mCaptionAlign = gcn::Graphics::LEFT;
+ mCaptionAlign = Graphics::LEFT;
}
setTitleBarHeight(getOption("titlebarHeight"));
if (!mTitleBarHeight)
@@ -147,7 +191,8 @@ Window::Window(const std::string &caption, const bool modal,
}
// Add this window to the window container
- windowContainer->add(this);
+ if (windowContainer)
+ windowContainer->add(this);
if (mModal)
{
@@ -208,13 +253,12 @@ void Window::setWindowContainer(WindowContainer *const wc)
windowContainer = wc;
}
-void Window::draw(gcn::Graphics *graphics)
+void Window::draw(Graphics *graphics)
{
if (!mSkin)
return;
BLOCK_START("Window::draw")
- Graphics *const g = static_cast<Graphics*>(graphics);
bool update = false;
if (isBatchDrawRenders(openGLMode))
@@ -230,8 +274,11 @@ void Window::draw(gcn::Graphics *graphics)
mRedraw = false;
update = true;
mVertexes->clear();
- g->calcWindow(mVertexes, 0, 0, mDimension.width,
- mDimension.height, mSkin->getBorder());
+ graphics->calcWindow(mVertexes,
+ 0, 0,
+ mDimension.width,
+ mDimension.height,
+ mSkin->getBorder());
// Draw Close Button
if (mCloseWindowButton)
@@ -240,8 +287,10 @@ void Window::draw(gcn::Graphics *graphics)
mResizeHandles == CLOSE);
if (button)
{
- g->calcTileCollection(mVertexes, button,
- mCloseRect.x, mCloseRect.y);
+ graphics->calcTileCollection(mVertexes,
+ button,
+ mCloseRect.x,
+ mCloseRect.y);
}
}
// Draw Sticky Button
@@ -250,27 +299,33 @@ void Window::draw(gcn::Graphics *graphics)
const Image *const button = mSkin->getStickyImage(mSticky);
if (button)
{
- g->calcTileCollection(mVertexes, button,
- mStickyRect.x, mStickyRect.y);
+ graphics->calcTileCollection(mVertexes,
+ button,
+ mStickyRect.x,
+ mStickyRect.y);
}
}
if (mGrip)
{
- g->calcTileCollection(mVertexes, mGrip,
- mGripRect.x, mGripRect.y);
+ graphics->calcTileCollection(mVertexes,
+ mGrip,
+ mGripRect.x,
+ mGripRect.y);
}
}
else
{
mLastRedraw = false;
}
- g->drawTileCollection(mVertexes);
+ graphics->drawTileCollection(mVertexes);
}
else
{
- g->drawImageRect(0, 0, mDimension.width,
- mDimension.height, mSkin->getBorder());
+ graphics->drawImageRect(0, 0,
+ mDimension.width,
+ mDimension.height,
+ mSkin->getBorder());
// Draw Close Button
if (mCloseWindowButton)
@@ -278,24 +333,24 @@ void Window::draw(gcn::Graphics *graphics)
const Image *const button = mSkin->getCloseImage(
mResizeHandles == CLOSE);
if (button)
- g->drawImage2(button, mCloseRect.x, mCloseRect.y);
+ graphics->drawImage(button, mCloseRect.x, mCloseRect.y);
}
// Draw Sticky Button
if (mStickyButton)
{
const Image *const button = mSkin->getStickyImage(mSticky);
if (button)
- g->drawImage2(button, mStickyRect.x, mStickyRect.y);
+ graphics->drawImage(button, mStickyRect.x, mStickyRect.y);
}
if (mGrip)
- g->drawImage2(mGrip, mGripRect.x, mGripRect.y);
+ graphics->drawImage(mGrip, mGripRect.x, mGripRect.y);
}
// Draw title
if (mShowTitle)
{
- g->setColorAll(mForegroundColor, mForegroundColor2);
+ graphics->setColorAll(mForegroundColor, mForegroundColor2);
int x;
switch (mCaptionAlign)
{
@@ -310,14 +365,14 @@ void Window::draw(gcn::Graphics *graphics)
x = mCaptionOffsetX - mCaptionFont->getWidth(mCaption);
break;
}
- mCaptionFont->drawString(g, mCaption, x, mCaptionOffsetY);
+ mCaptionFont->drawString(graphics, mCaption, x, mCaptionOffsetY);
}
if (update)
{
- g->setRedraw(update);
+ graphics->setRedraw(update);
drawChildren(graphics);
- g->setRedraw(false);
+ graphics->setRedraw(false);
}
else
{
@@ -343,7 +398,7 @@ void Window::setContentSize(int width, int height)
setSize(width, height);
}
-void Window::setLocationRelativeTo(const gcn::Widget *const widget)
+void Window::setLocationRelativeTo(const Widget *const widget)
{
if (!widget)
return;
@@ -360,7 +415,7 @@ void Window::setLocationRelativeTo(const gcn::Widget *const widget)
- mDimension.height) / 2 - y));
}
-void Window::setLocationHorisontallyRelativeTo(const gcn::Widget *const widget)
+void Window::setLocationHorisontallyRelativeTo(const Widget *const widget)
{
if (!widget)
return;
@@ -485,9 +540,9 @@ void Window::setResizable(const bool r)
}
}
-void Window::widgetResized(const gcn::Event &event A_UNUSED)
+void Window::widgetResized(const Event &event A_UNUSED)
{
- const gcn::Rectangle area = getChildrenArea();
+ const Rect area = getChildrenArea();
if (mGrip)
{
@@ -549,12 +604,12 @@ void Window::widgetResized(const gcn::Event &event A_UNUSED)
mRedraw = true;
}
-void Window::widgetMoved(const gcn::Event& event A_UNUSED)
+void Window::widgetMoved(const Event& event A_UNUSED)
{
mRedraw = true;
}
-void Window::widgetHidden(const gcn::Event &event A_UNUSED)
+void Window::widgetHidden(const Event &event A_UNUSED)
{
if (gui)
gui->setCursorType(Cursor::CURSOR_POINTER);
@@ -608,25 +663,21 @@ void Window::setVisible(const bool visible, const bool forceSticky)
// Check if the window is off screen...
if (visible)
- {
ensureOnScreen();
- }
else
- {
mResizeHandles = 0;
- }
if (mStickyButtonLock)
- gcn::Window::setVisible(visible);
+ gcn::Container::setVisible(visible);
else
- gcn::Window::setVisible((!forceSticky && mSticky) || visible);
+ gcn::Container::setVisible((!forceSticky && mSticky) || visible);
if (visible)
{
if (mPlayVisibleSound)
soundManager.playGuiSound(SOUND_SHOW_WINDOW);
if (gui)
{
- gcn::MouseEvent *const event = reinterpret_cast<gcn::MouseEvent*>(
+ MouseEvent *const event = reinterpret_cast<MouseEvent*>(
gui->createMouseEvent(this));
if (event)
{
@@ -653,12 +704,19 @@ void Window::scheduleDelete()
windowContainer->scheduleDelete(this);
}
-void Window::mousePressed(gcn::MouseEvent &event)
+void Window::mousePressed(MouseEvent &event)
{
- // Let Guichan move window to top and figure out title bar drag
- gcn::Window::mousePressed(event);
+ if (event.getSource() == this)
+ {
+ if (getParent())
+ getParent()->moveToTop(this);
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ mDragOffsetX = event.getX();
+ mDragOffsetY = event.getY();
+ mMoved = event.getY() <= static_cast<int>(mTitleBarHeight);
+ }
+
+ if (event.getButton() == MouseEvent::LEFT)
{
const int x = event.getX();
const int y = event.getY();
@@ -696,7 +754,7 @@ void Window::close()
setVisible(false);
}
-void Window::mouseReleased(gcn::MouseEvent &event A_UNUSED)
+void Window::mouseReleased(MouseEvent &event A_UNUSED)
{
if (mGrip && mouseResize)
{
@@ -705,22 +763,21 @@ void Window::mouseReleased(gcn::MouseEvent &event A_UNUSED)
gui->setCursorType(Cursor::CURSOR_POINTER);
}
- // This should be the responsibility of Guichan (and is from 0.8.0 on)
mMoved = false;
}
-void Window::mouseEntered(gcn::MouseEvent &event)
+void Window::mouseEntered(MouseEvent &event)
{
updateResizeHandler(event);
}
-void Window::mouseExited(gcn::MouseEvent &event A_UNUSED)
+void Window::mouseExited(MouseEvent &event A_UNUSED)
{
if (mGrip && !mouseResize && gui)
gui->setCursorType(Cursor::CURSOR_POINTER);
}
-void Window::updateResizeHandler(gcn::MouseEvent &event)
+void Window::updateResizeHandler(MouseEvent &event)
{
if (!gui)
return;
@@ -755,7 +812,7 @@ void Window::updateResizeHandler(gcn::MouseEvent &event)
}
}
-void Window::mouseMoved(gcn::MouseEvent &event)
+void Window::mouseMoved(MouseEvent &event)
{
updateResizeHandler(event);
if (viewport)
@@ -767,12 +824,20 @@ bool Window::canMove() const
return !mStickyButtonLock || !mSticky;
}
-void Window::mouseDragged(gcn::MouseEvent &event)
+void Window::mouseDragged(MouseEvent &event)
{
if (canMove())
{
- // Let Guichan handle title bar drag
- gcn::Window::mouseDragged(event);
+ if (!event.isConsumed() && event.getSource() == this)
+ {
+ if (isMovable() && mMoved)
+ {
+ setPosition(event.getX() - mDragOffsetX + getX(),
+ event.getY() - mDragOffsetY + getY());
+ }
+
+ event.consume();
+ }
}
else
{
@@ -794,7 +859,7 @@ void Window::mouseDragged(gcn::MouseEvent &event)
{
const int dx = event.getX() - mDragOffsetX;
const int dy = event.getY() - mDragOffsetY;
- gcn::Rectangle newDim = getDimension();
+ Rect newDim = getDimension();
if (mouseResize & (TOP | BOTTOM))
{
@@ -1080,10 +1145,10 @@ void Window::adjustSizeToScreen()
if (mDimension.height > screenHeight)
mDimension.height = screenHeight;
if (oldWidth != mDimension.width || oldHeight != mDimension.height)
- widgetResized(gcn::Event(this));
+ widgetResized(Event(this));
}
-int Window::getResizeHandles(const gcn::MouseEvent &event)
+int Window::getResizeHandles(const MouseEvent &event)
{
if (event.getX() < 0 || event.getY() < 0)
return 0;
@@ -1120,7 +1185,7 @@ int Window::getResizeHandles(const gcn::MouseEvent &event)
return resizeHandles;
}
-bool Window::isResizeAllowed(const gcn::MouseEvent &event) const
+bool Window::isResizeAllowed(const MouseEvent &event) const
{
const int y = event.getY();
@@ -1165,7 +1230,7 @@ void Window::clearLayout()
}
}
-LayoutCell &Window::place(const int x, const int y, gcn::Widget *const wg,
+LayoutCell &Window::place(const int x, const int y, Widget *const wg,
const int w, const int h)
{
add(wg);
@@ -1192,7 +1257,7 @@ void Window::redraw()
{
if (mLayout)
{
- const gcn::Rectangle area = getChildrenArea();
+ const Rect area = getChildrenArea();
int w = area.width;
int h = area.height;
mLayout->reflow(w, h);
@@ -1228,12 +1293,12 @@ void Window::ensureOnScreen()
mDimension.y = 0;
}
-gcn::Rectangle Window::getWindowArea() const
+Rect Window::getWindowArea() const
{
- return gcn::Rectangle(mPadding,
- mPadding,
- mDimension.width - mPadding * 2,
- mDimension.height - mPadding * 2);
+ return Rect(mPadding,
+ mPadding,
+ mDimension.width - mPadding * 2,
+ mDimension.height - mPadding * 2);
}
int Window::getOption(const std::string &name, const int def) const
@@ -1255,6 +1320,37 @@ bool Window::getOptionBool(const std::string &name, const bool def) const
return def;
}
+Rect Window::getChildrenArea()
+{
+ return Rect(mPadding,
+ mTitleBarHeight,
+ mDimension.width - mPadding * 2,
+ mDimension.height - mPadding - mTitleBarHeight);
+}
+
+void Window::resizeToContent()
+{
+ int w = 0;
+ int h = 0;
+ for (WidgetListConstIterator it = mWidgets.begin();
+ it != mWidgets.end(); ++ it)
+ {
+ const Widget *const widget = *it;
+ const int x = widget->getX();
+ const int y = widget->getY();
+ const int width = widget->getWidth();
+ const int height = widget->getHeight();
+ if (x + width > w)
+ w = x + width;
+
+ if (y + height > h)
+ h = y + height;
+ }
+
+ setSize(w + 2 * mPadding,
+ h + mPadding + mTitleBarHeight);
+}
+
#ifdef USE_PROFILER
void Window::logic()
{
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
index bb0f19bb3..6369990bb 100644
--- a/src/gui/widgets/window.h
+++ b/src/gui/widgets/window.h
@@ -20,16 +20,58 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#ifndef GUI_WIDGETS_WINDOW_H
#define GUI_WIDGETS_WINDOW_H
#include "render/graphics.h"
-#include "gui/widgets/widget2.h"
+#include "listeners/mouselistener.h"
+#include "listeners/widgetlistener.h"
-#include <guichan/widgetlistener.hpp>
-
-#include <guichan/widgets/window.hpp>
+#include "gui/base/widgets/container.hpp"
#include "localconsts.h"
@@ -46,9 +88,9 @@ class WindowContainer;
*
* \ingroup GUI
*/
-class Window : public gcn::Window,
- public Widget2,
- private gcn::WidgetListener
+class Window : public gcn::Container,
+ public MouseListener,
+ private WidgetListener
{
public:
/**
@@ -80,7 +122,7 @@ class Window : public gcn::Window,
/**
* Draws the window.
*/
- void draw(gcn::Graphics *graphics) override;
+ void draw(Graphics *graphics) override;
/**
* Sets the size of this window.
@@ -90,12 +132,12 @@ class Window : public gcn::Window,
/**
* Sets the location relative to the given widget.
*/
- void setLocationRelativeTo(const gcn::Widget *const widget);
+ void setLocationRelativeTo(const Widget *const widget);
/**
* Sets the location relative to the given widget (only horisontally)
*/
- void setLocationHorisontallyRelativeTo(const gcn::Widget
+ void setLocationHorisontallyRelativeTo(const Widget
*const widget);
/**
@@ -114,14 +156,14 @@ class Window : public gcn::Window,
/**
* Called whenever the widget changes size.
*/
- virtual void widgetResized(const gcn::Event &event) override;
+ virtual void widgetResized(const Event &event) override;
- virtual void widgetMoved(const gcn::Event& event) override;
+ virtual void widgetMoved(const Event& event) override;
/**
* Called whenever the widget is hidden.
*/
- virtual void widgetHidden(const gcn::Event &event) override;
+ virtual void widgetHidden(const Event &event) override;
/**
* Sets whether or not the window has a close button.
@@ -257,35 +299,35 @@ class Window : public gcn::Window,
/**
* Starts window resizing when appropriate.
*/
- void mousePressed(gcn::MouseEvent &event) override;
+ void mousePressed(MouseEvent &event) override;
/**
* Implements window resizing and makes sure the window is not
* dragged/resized outside of the screen.
*/
- void mouseDragged(gcn::MouseEvent &event) override;
+ void mouseDragged(MouseEvent &event) override;
/**
* Implements custom cursor image changing context, based on mouse
* relative position.
*/
- void mouseMoved(gcn::MouseEvent &event) override;
+ void mouseMoved(MouseEvent &event) override;
/**
* When the mouse button has been let go, this ensures that the mouse
* custom cursor is restored back to it's standard image.
*/
- void mouseReleased(gcn::MouseEvent &event) override;
+ void mouseReleased(MouseEvent &event) override;
/**
* When the mouse leaves the window this ensures that the custom cursor
* is restored back to it's standard image.
*/
- void mouseExited(gcn::MouseEvent &event) override;
+ void mouseExited(MouseEvent &event) override;
- void mouseEntered(gcn::MouseEvent &event) override;
+ void mouseEntered(MouseEvent &event) override;
- void updateResizeHandler(gcn::MouseEvent &event);
+ void updateResizeHandler(MouseEvent &event);
/**
* Sets the name of the window. This is not the window title.
@@ -373,7 +415,7 @@ class Window : public gcn::Window,
/**
* Adds a widget to the window and sets it at given cell.
*/
- LayoutCell &place(const int x, const int y, gcn::Widget *const wg,
+ LayoutCell &place(const int x, const int y, Widget *const wg,
const int w = 1, const int h = 1);
/**
@@ -408,11 +450,11 @@ class Window : public gcn::Window,
*/
int getGuiAlpha() const A_WARN_UNUSED;
- gcn::Rectangle getWindowArea() const A_WARN_UNUSED;
+ Rect getWindowArea() const A_WARN_UNUSED;
- bool isResizeAllowed(const gcn::MouseEvent &event) const A_WARN_UNUSED;
+ bool isResizeAllowed(const MouseEvent &event) const A_WARN_UNUSED;
- void setCaptionFont(gcn::Font *font)
+ void setCaptionFont(Font *font)
{ mCaptionFont = font; }
void enableVisibleSound(bool b)
@@ -421,6 +463,105 @@ class Window : public gcn::Window,
bool isWindowVisible() const A_WARN_UNUSED
{ return mVisible; }
+ /**
+ * Sets the padding of the window. The padding is the distance between the
+ * window border and the content.
+ *
+ * @param padding The padding of the window.
+ * @see getPadding
+ */
+ void setPadding(unsigned int padding)
+ { mPadding = padding; }
+
+ /**
+ * Gets the padding of the window. The padding is the distance between the
+ * window border and the content.
+ *
+ * @return The padding of the window.
+ * @see setPadding
+ */
+ unsigned int getPadding() const
+ { return mPadding; }
+
+ /**
+ * Sets the title bar height.
+ *
+ * @param height The title height value.
+ * @see getTitleBarHeight
+ */
+ void setTitleBarHeight(unsigned int height)
+ { mTitleBarHeight = height; }
+
+ /**
+ * Gets the title bar height.
+ *
+ * @return The title bar height.
+ * @see setTitleBarHeight
+ */
+ unsigned int getTitleBarHeight()
+ { return mTitleBarHeight; }
+
+ /**
+ * Sets the caption of the window.
+ *
+ * @param caption The caption of the window.
+ * @see getCaption
+ */
+ void setCaption(const std::string& caption)
+ { mCaption = caption; }
+
+ /**
+ * Gets the caption of the window.
+ *
+ * @return the caption of the window.
+ * @see setCaption
+ */
+ const std::string& getCaption() const
+ { return mCaption; }
+
+ /**
+ * Sets the alignment of the caption.
+ *
+ * @param alignment The alignment of the caption.
+ * @see getAlignment, Graphics
+ */
+ void setAlignment(Graphics::Alignment alignment)
+ { mAlignment = alignment; }
+
+ /**
+ * Gets the alignment of the caption.
+ *
+ * @return The alignment of caption.
+ * @see setAlignment, Graphics
+ */
+ Graphics::Alignment getAlignment() const
+ { return mAlignment; }
+
+ /**
+ * Sets the window to be moveble or not.
+ *
+ * @param movable True if the window should be movable, false otherwise.
+ * @see isMovable
+ */
+ void setMovable(bool movable)
+ { mMovable = movable; }
+
+ /**
+ * Checks if the window is movable.
+ *
+ * @return True if the window is movable, false otherwise.
+ * @see setMovable
+ */
+ bool isMovable() const
+ { return mMovable; }
+
+ virtual Rect getChildrenArea();
+
+ /**
+ * Resizes the window to fit the content.
+ */
+ virtual void resizeToContent();
+
#ifdef USE_PROFILER
virtual void logic();
#endif
@@ -440,6 +581,50 @@ class Window : public gcn::Window,
int getTitlePadding() const A_WARN_UNUSED
{ return mTitlePadding; }
+ /**
+ * Holds the caption of the window.
+ */
+ std::string mCaption;
+
+ /**
+ * Holds the alignment of the caption.
+ */
+ Graphics::Alignment mAlignment;
+
+ /**
+ * Holds the padding of the window.
+ */
+ unsigned int mPadding;
+
+ /**
+ * Holds the title bar height of the window.
+ */
+ unsigned int mTitleBarHeight;
+
+ /**
+ * True if the window is movable, false otherwise.
+ */
+ bool mMovable;
+
+ /**
+ * Holds a drag offset as an x coordinate where the drag of the window
+ * started if the window is being dragged. It's used to move the window
+ * correctly when dragged.
+ */
+ int mDragOffsetX;
+
+ /**
+ * Holds a drag offset as an y coordinate where the drag of the window
+ * started if the window is being dragged. It's used to move the window
+ * correctly when dragged.
+ */
+ int mDragOffsetY;
+
+ /**
+ * True if the window is being moved, false otherwise.
+ */
+ bool mMoved;
+
Skin *mSkin; /**< Skin in use by this window */
int mDefaultX; /**< Default window X position */
int mDefaultY; /**< Default window Y position */
@@ -474,14 +659,14 @@ class Window : public gcn::Window,
*
* @see ResizeHandles
*/
- int getResizeHandles(const gcn::MouseEvent &event) A_WARN_UNUSED;
+ int getResizeHandles(const MouseEvent &event) A_WARN_UNUSED;
Image *mGrip; /**< Resize grip */
Window *mParent; /**< The parent window */
Layout *mLayout; /**< Layout handler */
- gcn::Rectangle mCloseRect; /**< Close button rectangle */
- gcn::Rectangle mStickyRect; /**< Sticky button rectangle */
- gcn::Rectangle mGripRect; /**< Resize grip rectangle */
+ Rect mCloseRect; /**< Close button rectangle */
+ Rect mStickyRect; /**< Sticky button rectangle */
+ Rect mGripRect; /**< Resize grip rectangle */
std::string mWindowName; /**< Name of the window */
int mMinWinWidth; /**< Minimum window width */
int mMinWinHeight; /**< Minimum window height */
@@ -501,12 +686,12 @@ class Window : public gcn::Window,
ImageCollection *mVertexes;
int mCaptionOffsetX;
int mCaptionOffsetY;
- gcn::Graphics::Alignment mCaptionAlign;
+ Graphics::Alignment mCaptionAlign;
int mTitlePadding;
int mGripPadding;
int mResizeHandles;
int mOldResizeHandles;
- gcn::Font *mCaptionFont;
+ Font *mCaptionFont;
bool mShowTitle; /**< Window has a title bar */
bool mModal; /**< Window is modal */
bool mCloseWindowButton; /**< Window has a close button */
diff --git a/src/gui/widgets/windowcontainer.cpp b/src/gui/widgets/windowcontainer.cpp
index d23f29bad..a9b556410 100644
--- a/src/gui/widgets/windowcontainer.cpp
+++ b/src/gui/widgets/windowcontainer.cpp
@@ -42,7 +42,7 @@ void WindowContainer::slowLogic()
mDeathList.clear();
}
-void WindowContainer::scheduleDelete(gcn::Widget *const widget)
+void WindowContainer::scheduleDelete(Widget *const widget)
{
if (widget)
mDeathList.push_back(widget);
@@ -58,8 +58,8 @@ void WindowContainer::adjustAfterResize(const int oldScreenWidth,
}
}
-void WindowContainer::moveWidgetAfter(gcn::Widget *const after,
- gcn::Widget *const widget)
+void WindowContainer::moveWidgetAfter(Widget *const after,
+ Widget *const widget)
{
const WidgetListIterator widgetIter = std::find(
mWidgets.begin(), mWidgets.end(), widget);
@@ -79,7 +79,7 @@ void WindowContainer::moveWidgetAfter(gcn::Widget *const after,
}
#ifdef USE_PROFILER
-void WindowContainer::draw(gcn::Graphics* graphics)
+void WindowContainer::draw(Graphics* graphics)
{
BLOCK_START("WindowContainer::draw")
Container::draw(graphics);
diff --git a/src/gui/widgets/windowcontainer.h b/src/gui/widgets/windowcontainer.h
index 2ee4ea37d..a822fadb5 100644
--- a/src/gui/widgets/windowcontainer.h
+++ b/src/gui/widgets/windowcontainer.h
@@ -44,7 +44,7 @@ class WindowContainer : public Container
* Schedule a widget for deletion. It will be deleted at the start of
* the next logic update.
*/
- void scheduleDelete(gcn::Widget *const widget);
+ void scheduleDelete(Widget *const widget);
/**
* Ensures that all visible windows are on the screen after the screen
@@ -53,18 +53,18 @@ class WindowContainer : public Container
void adjustAfterResize(const int oldScreenWidth,
const int oldScreenHeight);
- void moveWidgetAfter(gcn::Widget *const before,
- gcn::Widget *const widget);
+ void moveWidgetAfter(Widget *const before,
+ Widget *const widget);
#ifdef USE_PROFILER
- void draw(gcn::Graphics* graphics);
+ void draw(Graphics* graphics);
#endif
private:
/**
* List of widgets that are scheduled to be deleted.
*/
- typedef std::vector<gcn::Widget*> Widgets;
+ typedef std::vector<Widget*> Widgets;
typedef Widgets::iterator WidgetIterator;
Widgets mDeathList;
};
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index a094b5b08..795f2ad5a 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -31,9 +31,8 @@
#include "gui/popups/textpopup.h"
#include "gui/windows/skilldialog.h"
-#ifdef MANASERV_SUPPORT
-#include "gui/specialswindow.h"
-#endif
+
+#include "gui/widgets/button.h"
#include "utils/dtor.h"
#include "utils/gettext.h"
@@ -44,9 +43,9 @@
WindowMenu::WindowMenu(const Widget2 *const widget) :
Container(widget),
- gcn::ActionListener(),
- gcn::SelectionListener(),
- gcn::MouseListener(),
+ ActionListener(),
+ SelectionListener(),
+ MouseListener(),
mSkin(Theme::instance() ? Theme::instance()->load("windowmenu.xml", "")
: nullptr),
mPadding(mSkin ? mSkin->getPadding() : 1),
@@ -109,15 +108,6 @@ WindowMenu::WindowMenu(const Widget2 *const widget) :
_("Skills"), x, h, Input::KEY_WINDOW_SKILL);
}
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() == ServerInfo::MANASERV)
- {
- // TRANSLATORS: short button name for specials window.
- addButton(N_("SPE"),
- _("Specials"), x, h, Input::KEY_NO_VALUE);
- }
-#endif
-
// TRANSLATORS: short button name for social window.
addButton(N_("SOC"),
// TRANSLATORS: full button name
@@ -166,7 +156,7 @@ WindowMenu::WindowMenu(const Widget2 *const widget) :
x += mPadding - mSpacing;
if (mainGraphics)
- setDimension(gcn::Rectangle(mainGraphics->mWidth - x, 0, x, h));
+ setDimension(Rect(mainGraphics->mWidth - x, 0, x, h));
loadButtons();
@@ -213,7 +203,7 @@ WindowMenu::~WindowMenu()
}
}
-void WindowMenu::action(const gcn::ActionEvent &event)
+void WindowMenu::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
@@ -248,12 +238,12 @@ void WindowMenu::addButton(const char *const text,
mButtonTexts.push_back(new ButtonText(description, key));
}
-void WindowMenu::mousePressed(gcn::MouseEvent &event)
+void WindowMenu::mousePressed(MouseEvent &event)
{
if (!viewport)
return;
- if (!mSmallWindow && event.getButton() == gcn::MouseEvent::RIGHT)
+ if (!mSmallWindow && event.getButton() == MouseEvent::RIGHT)
{
Button *const btn = dynamic_cast<Button*>(event.getSource());
if (!btn)
@@ -266,7 +256,7 @@ void WindowMenu::mousePressed(gcn::MouseEvent &event)
}
}
-void WindowMenu::mouseMoved(gcn::MouseEvent &event)
+void WindowMenu::mouseMoved(MouseEvent &event)
{
mHaveMouse = true;
@@ -291,7 +281,7 @@ void WindowMenu::mouseMoved(gcn::MouseEvent &event)
const int x = event.getX();
const int y = event.getY();
const int key = btn->getTag();
- const gcn::Rectangle &rect = mDimension;
+ const Rect &rect = mDimension;
if (key != Input::KEY_NO_VALUE)
{
mTextPopup->show(x + rect.x, y + rect.y, btn->getDescription(),
@@ -305,7 +295,7 @@ void WindowMenu::mouseMoved(gcn::MouseEvent &event)
}
}
-void WindowMenu::mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED)
+void WindowMenu::mouseExited(MouseEvent& mouseEvent A_UNUSED)
{
mHaveMouse = false;
if (!mTextPopup)
@@ -348,7 +338,7 @@ void WindowMenu::updateButtons()
}
x += mPadding - mSpacing;
if (mainGraphics)
- setDimension(gcn::Rectangle(mainGraphics->mWidth - x, 0, x, h));
+ setDimension(Rect(mainGraphics->mWidth - x, 0, x, h));
}
void WindowMenu::loadButtons()
@@ -419,7 +409,7 @@ void WindowMenu::saveButtons() const
config.deleteKey("windowmenu" + toString(f));
}
-void WindowMenu::drawChildren(gcn::Graphics* graphics)
+void WindowMenu::drawChildren(Graphics* graphics)
{
if (mHaveMouse || !mAutoHide || (mAutoHide == 1
&& mainGraphics && (mSmallWindow || mainGraphics->mWidth > 800)))
diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h
index 38ee090a7..a1ed66a7d 100644
--- a/src/gui/windowmenu.h
+++ b/src/gui/windowmenu.h
@@ -23,21 +23,21 @@
#ifndef GUI_WINDOWMENU_H
#define GUI_WINDOWMENU_H
-#include "configlistener.h"
+#include "listeners/configlistener.h"
#include "gui/widgets/container.h"
-#include "gui/widgets/button.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/selectionlistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/mouselistener.h"
+#include "listeners/selectionlistener.h"
#include "localconsts.h"
#include <map>
#include <vector>
+class Button;
class TextPopup;
-class Window;
struct ButtonInfo final
{
@@ -77,9 +77,9 @@ struct ButtonText final
*/
class WindowMenu final : public Container,
public ConfigListener,
- public gcn::ActionListener,
- public gcn::SelectionListener,
- public gcn::MouseListener
+ public ActionListener,
+ public SelectionListener,
+ public MouseListener
{
public:
explicit WindowMenu(const Widget2 *const widget);
@@ -88,13 +88,13 @@ class WindowMenu final : public Container,
~WindowMenu();
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
- void mousePressed(gcn::MouseEvent &event) override final;
+ void mousePressed(MouseEvent &event) override final;
- void mouseMoved(gcn::MouseEvent &event) override final;
+ void mouseMoved(MouseEvent &event) override final;
- void mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED) override final;
+ void mouseExited(MouseEvent& mouseEvent A_UNUSED) override final;
std::map <std::string, ButtonInfo*> &getButtonNames() A_WARN_UNUSED
{ return mButtonNames; }
@@ -118,7 +118,7 @@ class WindowMenu final : public Container,
#endif
protected:
- void drawChildren(gcn::Graphics* graphics) override final;
+ void drawChildren(Graphics* graphics) override final;
private:
inline void addButton(const char *const text,
diff --git a/src/gui/windows/botcheckerwindow.cpp b/src/gui/windows/botcheckerwindow.cpp
index b94093ebb..d1fc0e7bd 100644
--- a/src/gui/windows/botcheckerwindow.cpp
+++ b/src/gui/windows/botcheckerwindow.cpp
@@ -101,7 +101,7 @@ public:
freeWidgets();
mPlayers.clear();
if (actorManager && botCheckerWindow
- && botCheckerWindow->mEnabled)
+ && botCheckerWindow->mBotcheckerEnabled)
{
std::set<ActorSprite*> beings = actorManager->getAll();
FOR_EACH (ActorSprites::iterator, i, beings)
@@ -125,7 +125,7 @@ public:
continue;
const Being *const player = mPlayers.at(r);
- gcn::Widget *widget = new Label(this, player->getName());
+ Widget *widget = new Label(this, player->getName());
mWidgets.push_back(widget);
@@ -235,14 +235,14 @@ public:
{
}
- gcn::Widget *getElementAt(const int row, const int column) const
+ Widget *getElementAt(const int row, const int column) const
{
return mWidgets[WIDGET_AT(row, column)];
}
void freeWidgets()
{
- for (std::vector<gcn::Widget *>::const_iterator it = mWidgets.begin();
+ for (std::vector<Widget *>::const_iterator it = mWidgets.begin();
it != mWidgets.end(); ++it)
{
delete *it;
@@ -253,17 +253,17 @@ public:
protected:
std::vector<Being*> mPlayers;
- std::vector<gcn::Widget*> mWidgets;
+ std::vector<Widget*> mWidgets;
};
BotCheckerWindow::BotCheckerWindow():
// TRANSLATORS: bot checker window header
Window(_("Bot Checker"), false, nullptr, "botchecker.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mTableModel(new UsersTableModel(this)),
mTable(new GuiTable(this, mTableModel)),
- playersScrollArea(new ScrollArea(mTable, true,
+ playersScrollArea(new ScrollArea(this, mTable, true,
"bochecker_background.xml")),
mPlayerTableTitleModel(new StaticTableModel(1, COLUMNS_NR)),
mPlayerTitleTable(new GuiTable(this, mPlayerTableTitleModel)),
@@ -271,7 +271,7 @@ BotCheckerWindow::BotCheckerWindow():
mIncButton(new Button(this, _("Reset"), "reset", this)),
mLastUpdateTime(0),
mNeedUpdate(false),
- mEnabled(false)
+ mBotcheckerEnabled(false)
{
const int w = 500;
const int h = 250;
@@ -346,7 +346,7 @@ BotCheckerWindow::BotCheckerWindow():
enableVisibleSound(true);
config.addListener("enableBotCheker", this);
- mEnabled = config.getBoolValue("enableBotCheker");
+ mBotcheckerEnabled = config.getBoolValue("enableBotCheker");
}
BotCheckerWindow::~BotCheckerWindow()
@@ -358,7 +358,7 @@ BotCheckerWindow::~BotCheckerWindow()
void BotCheckerWindow::slowLogic()
{
BLOCK_START("BotCheckerWindow::slowLogic")
- if (mEnabled && mTableModel)
+ if (mBotcheckerEnabled && mTableModel)
{
const unsigned int nowTime = cur_time;
if (nowTime - mLastUpdateTime > 5 && mNeedUpdate)
@@ -377,7 +377,7 @@ void BotCheckerWindow::slowLogic()
BLOCK_END("BotCheckerWindow::slowLogic")
}
-void BotCheckerWindow::action(const gcn::ActionEvent &event)
+void BotCheckerWindow::action(const ActionEvent &event)
{
if (event.getId() == "reset")
{
@@ -417,7 +417,7 @@ void BotCheckerWindow::reset()
void BotCheckerWindow::optionChanged(const std::string &name)
{
if (name == "enableBotCheker")
- mEnabled = config.getBoolValue("enableBotCheker");
+ mBotcheckerEnabled = config.getBoolValue("enableBotCheker");
}
#ifdef USE_PROFILER
diff --git a/src/gui/windows/botcheckerwindow.h b/src/gui/windows/botcheckerwindow.h
index d3615957d..0c86b13b0 100644
--- a/src/gui/windows/botcheckerwindow.h
+++ b/src/gui/windows/botcheckerwindow.h
@@ -23,11 +23,11 @@
#ifndef GUI_BOTCHECKERWINDOW_H
#define GUI_BOTCHECKERWINDOW_H
-#include "configlistener.h"
+#include "listeners/configlistener.h"
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
struct BOTCHK final
{
@@ -43,7 +43,7 @@ class UsersTableModel;
class StaticTableModel;
class BotCheckerWindow final : public Window,
- public gcn::ActionListener,
+ public ActionListener,
public ConfigListener
{
public:
@@ -61,7 +61,7 @@ class BotCheckerWindow final : public Window,
*/
~BotCheckerWindow();
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void update();
@@ -86,7 +86,7 @@ class BotCheckerWindow final : public Window,
Button *mIncButton;
int mLastUpdateTime;
bool mNeedUpdate;
- bool mEnabled;
+ bool mBotcheckerEnabled;
};
extern BotCheckerWindow *botCheckerWindow;
diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp
index cfefa8159..c2514a15d 100644
--- a/src/gui/windows/buydialog.cpp
+++ b/src/gui/windows/buydialog.cpp
@@ -28,13 +28,15 @@
#include "gui/windows/tradewindow.h"
+#include "gui/models/shopitems.h"
+#include "gui/models/sortlistmodelbuy.h"
+
#include "gui/widgets/button.h"
#include "gui/widgets/dropdown.h"
#include "gui/widgets/inttextfield.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layout.h"
#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/shopitems.h"
#include "gui/widgets/shoplistbox.h"
#include "gui/widgets/slider.h"
@@ -51,41 +53,6 @@
#include "debug.h"
-static const char *const SORT_NAME_BUY[7] =
-{
- // TRANSLATORS: buy dialog sort type.
- N_("unsorted"),
- // TRANSLATORS: buy dialog sort type.
- N_("by price"),
- // TRANSLATORS: buy dialog sort type.
- N_("by name"),
- // TRANSLATORS: buy dialog sort type.
- N_("by id"),
- // TRANSLATORS: buy dialog sort type.
- N_("by weight"),
- // TRANSLATORS: buy dialog sort type.
- N_("by amount"),
- // TRANSLATORS: buy dialog sort type.
- N_("by type")
-};
-
-class SortListModelBuy final : public gcn::ListModel
-{
-public:
- ~SortListModelBuy()
- { }
-
- int getNumberOfElements()
- { return 7; }
-
- std::string getElementAt(int i)
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
- return gettext(SORT_NAME_BUY[i]);
- }
-};
-
class SortItemPriceFunctor final
{
public:
@@ -193,8 +160,8 @@ BuyDialog::DialogList BuyDialog::instances;
BuyDialog::BuyDialog() :
// TRANSLATORS: buy dialog name
Window(_("Create items"), false, nullptr, "buy.xml"),
- gcn::ActionListener(),
- gcn::SelectionListener(),
+ ActionListener(),
+ SelectionListener(),
mNpcId(-2), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(),
mSortModel(nullptr),
mSortDropDown(nullptr)
@@ -205,8 +172,8 @@ BuyDialog::BuyDialog() :
BuyDialog::BuyDialog(const int npcId) :
// TRANSLATORS: buy dialog name
Window(_("Buy"), false, nullptr, "buy.xml"),
- gcn::ActionListener(),
- gcn::SelectionListener(),
+ ActionListener(),
+ SelectionListener(),
mNpcId(npcId), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(),
mSortModel(nullptr),
mSortDropDown(nullptr)
@@ -217,8 +184,8 @@ BuyDialog::BuyDialog(const int npcId) :
BuyDialog::BuyDialog(std::string nick) :
// TRANSLATORS: buy dialog name
Window(_("Buy"), false, nullptr, "buy.xml"),
- gcn::ActionListener(),
- gcn::SelectionListener(),
+ ActionListener(),
+ SelectionListener(),
mNpcId(-1), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(nick),
mSortModel(new SortListModelBuy),
mSortDropDown(new DropDown(this, mSortModel, false, false, this, "sort"))
@@ -240,14 +207,14 @@ void BuyDialog::init()
mShopItemList = new ShopListBox(this, mShopItems, mShopItems);
mShopItemList->postInit();
- mScrollArea = new ScrollArea(mShopItemList,
+ mScrollArea = new ScrollArea(this, mShopItemList,
getOptionBool("showbackground"), "buy_background.xml");
mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- mSlider = new Slider(1.0);
+ mSlider = new Slider(this, 1.0);
mQuantityLabel = new Label(this, strprintf(
"%d / %d", mAmountItems, mMaxItems));
- mQuantityLabel->setAlignment(gcn::Graphics::CENTER);
+ mQuantityLabel->setAlignment(Graphics::CENTER);
// TRANSLATORS: buy dialog label
mMoneyLabel = new Label(this, strprintf(
_("Price: %s / Total: %s"), "", ""));
@@ -388,7 +355,7 @@ void BuyDialog::sort()
}
}
-void BuyDialog::action(const gcn::ActionEvent &event)
+void BuyDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "quit")
@@ -482,7 +449,7 @@ void BuyDialog::action(const gcn::ActionEvent &event)
}
}
-void BuyDialog::valueChanged(const gcn::SelectionEvent &event A_UNUSED)
+void BuyDialog::valueChanged(const SelectionEvent &event A_UNUSED)
{
// Reset amount of items and update labels
mAmountItems = 1;
diff --git a/src/gui/windows/buydialog.h b/src/gui/windows/buydialog.h
index e11317cde..aa163d5d0 100644
--- a/src/gui/windows/buydialog.h
+++ b/src/gui/windows/buydialog.h
@@ -25,8 +25,8 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/selectionlistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/selectionlistener.h"
class Button;
class DropDown;
@@ -35,7 +35,6 @@ class ShopListBox;
class SortListModelBuy;
class IntTextField;
class Label;
-class ListBox;
class ScrollArea;
class Slider;
@@ -45,8 +44,8 @@ class Slider;
* \ingroup Interface
*/
class BuyDialog final : public Window,
- public gcn::ActionListener,
- public gcn::SelectionListener
+ public ActionListener,
+ public SelectionListener
{
public:
/**
@@ -98,7 +97,7 @@ class BuyDialog final : public Window,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Returns the number of items in the shop inventory.
@@ -108,7 +107,7 @@ class BuyDialog final : public Window,
/**
* Updates the labels according to the selected item.
*/
- void valueChanged(const gcn::SelectionEvent &event) override final;
+ void valueChanged(const SelectionEvent &event) override final;
/**
* Updates the state of buttons and labels.
diff --git a/src/gui/windows/buyselldialog.cpp b/src/gui/windows/buyselldialog.cpp
index 22f39f449..92f6503bb 100644
--- a/src/gui/windows/buyselldialog.cpp
+++ b/src/gui/windows/buyselldialog.cpp
@@ -37,7 +37,7 @@ BuySellDialog::DialogList BuySellDialog::dialogInstances;
BuySellDialog::BuySellDialog(const int npcId) :
// TRANSLATORS: shop window name
Window(_("Shop"), false, nullptr, "buysell.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mNpcId(npcId),
mNick(""),
mBuyButton(nullptr)
@@ -48,7 +48,7 @@ BuySellDialog::BuySellDialog(const int npcId) :
BuySellDialog::BuySellDialog(const std::string &nick) :
// TRANSLATORS: shop window name
Window(_("Shop"), false, nullptr, "buysell.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mNpcId(-1),
mNick(nick),
mBuyButton(nullptr)
@@ -119,7 +119,7 @@ void BuySellDialog::setVisible(bool visible)
}
}
-void BuySellDialog::action(const gcn::ActionEvent &event)
+void BuySellDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "Buy")
diff --git a/src/gui/windows/buyselldialog.h b/src/gui/windows/buyselldialog.h
index 34a716ee1..a89ff0bea 100644
--- a/src/gui/windows/buyselldialog.h
+++ b/src/gui/windows/buyselldialog.h
@@ -25,7 +25,7 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
class Button;
@@ -34,7 +34,8 @@ class Button;
*
* \ingroup Interface
*/
-class BuySellDialog final : public Window, public gcn::ActionListener
+class BuySellDialog final : public Window,
+ public ActionListener
{
public:
/**
@@ -58,7 +59,7 @@ class BuySellDialog final : public Window, public gcn::ActionListener
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Returns true if any instances exist.
diff --git a/src/gui/windows/changeemaildialog.cpp b/src/gui/windows/changeemaildialog.cpp
index a9f3b3449..b8f9c1fd2 100644
--- a/src/gui/windows/changeemaildialog.cpp
+++ b/src/gui/windows/changeemaildialog.cpp
@@ -45,7 +45,7 @@
ChangeEmailDialog::ChangeEmailDialog(LoginData *const data):
// TRANSLATORS: change email dialog header
Window(_("Change Email Address"), true, nullptr, "changeemail.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mFirstEmailField(new TextField(this)),
mSecondEmailField(new TextField(this)),
// TRANSLATORS: button in change email dialog
@@ -109,7 +109,7 @@ ChangeEmailDialog::~ChangeEmailDialog()
mWrongDataNoticeListener = nullptr;
}
-void ChangeEmailDialog::action(const gcn::ActionEvent &event)
+void ChangeEmailDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "cancel")
diff --git a/src/gui/windows/changeemaildialog.h b/src/gui/windows/changeemaildialog.h
index 31ffa7b39..d2928025d 100644
--- a/src/gui/windows/changeemaildialog.h
+++ b/src/gui/windows/changeemaildialog.h
@@ -25,7 +25,7 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
class Button;
class LoginData;
@@ -37,7 +37,8 @@ class WrongDataNoticeListener;
*
* \ingroup Interface
*/
-class ChangeEmailDialog final : public Window, public gcn::ActionListener
+class ChangeEmailDialog final : public Window,
+ public ActionListener
{
public:
/**
@@ -57,7 +58,7 @@ class ChangeEmailDialog final : public Window, public gcn::ActionListener
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* This is used to pass the pointer to where the new email should be
diff --git a/src/gui/windows/changepassworddialog.cpp b/src/gui/windows/changepassworddialog.cpp
index 4646947fa..05c7a9309 100644
--- a/src/gui/windows/changepassworddialog.cpp
+++ b/src/gui/windows/changepassworddialog.cpp
@@ -46,7 +46,7 @@
ChangePasswordDialog::ChangePasswordDialog(LoginData *const data):
// TRANSLATORS: change password window name
Window(_("Change Password"), true, nullptr, "changepassword.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mOldPassField(new PasswordField(this)),
mFirstPassField(new PasswordField(this)),
mSecondPassField(new PasswordField(this)),
@@ -88,7 +88,7 @@ ChangePasswordDialog::~ChangePasswordDialog()
mWrongDataNoticeListener = nullptr;
}
-void ChangePasswordDialog::action(const gcn::ActionEvent &event)
+void ChangePasswordDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "cancel")
diff --git a/src/gui/windows/changepassworddialog.h b/src/gui/windows/changepassworddialog.h
index ce45e6f47..adbaf109a 100644
--- a/src/gui/windows/changepassworddialog.h
+++ b/src/gui/windows/changepassworddialog.h
@@ -25,7 +25,7 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
class Button;
class LoginData;
@@ -37,7 +37,8 @@ class WrongDataNoticeListener;
*
* \ingroup Interface
*/
-class ChangePasswordDialog final : public Window, public gcn::ActionListener
+class ChangePasswordDialog final : public Window,
+ public ActionListener
{
public:
/**
@@ -57,7 +58,7 @@ class ChangePasswordDialog final : public Window, public gcn::ActionListener
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
private:
TextField *mOldPassField;
diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp
index cbce28db7..a877f45e0 100644
--- a/src/gui/windows/charcreatedialog.cpp
+++ b/src/gui/windows/charcreatedialog.cpp
@@ -24,12 +24,14 @@
#include "main.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
#include "gui/windows/okdialog.h"
#include "gui/widgets/button.h"
+#include "gui/windows/charselectdialog.h"
#include "gui/widgets/label.h"
#include "gui/widgets/playerbox.h"
#include "gui/widgets/radiobutton.h"
@@ -63,8 +65,8 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
const int slot) :
// TRANSLATORS: char create dialog name
Window(_("New Character"), true, parent, "charcreate.xml"),
- gcn::ActionListener(),
- gcn::KeyListener(),
+ ActionListener(),
+ KeyListener(),
mCharSelectDialog(parent),
mNameField(new TextField(this, "")),
// TRANSLATORS: char create dialog label
@@ -123,7 +125,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
mMaxLook(CharDB::getMaxLook()),
mPlayer(new Being(0, ActorSprite::PLAYER, static_cast<uint16_t>(mRace),
nullptr)),
- mPlayerBox(new PlayerBox(mPlayer, "charcreate_playerbox.xml",
+ mPlayerBox(new PlayerBox(this, mPlayer, "charcreate_playerbox.xml",
"charcreate_selectedplayerbox.xml")),
mHairStyle(0),
mHairColor(0),
@@ -206,13 +208,13 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
const int h = 350;
setContentSize(w, h);
- mPlayerBox->setDimension(gcn::Rectangle(360, 0, 110, 90));
+ mPlayerBox->setDimension(Rect(360, 0, 110, 90));
mActionButton->setPosition(385, 100);
mRotateButton->setPosition(415, 100);
mNameLabel->setPosition(5, 2);
mNameField->setDimension(
- gcn::Rectangle(60, 2, 300, mNameField->getHeight()));
+ Rect(60, 2, 300, mNameField->getHeight()));
const int leftX = 120;
const int rightX = 300;
@@ -318,16 +320,12 @@ CharCreateDialog::~CharCreateDialog()
Net::getCharServerHandler()->setCharCreateDialog(nullptr);
}
-void CharCreateDialog::action(const gcn::ActionEvent &event)
+void CharCreateDialog::action(const ActionEvent &event)
{
const std::string id = event.getId();
if (id == "create")
{
- if (
-#ifdef MANASERV_SUPPORT
- Net::getNetworkType() == ServerInfo::MANASERV ||
-#endif
- getName().length() >= 4)
+ if (getName().length() >= 4)
{
// Attempt to create the character
mCreateButton->setEnabled(false);
@@ -339,14 +337,7 @@ void CharCreateDialog::action(const gcn::ActionEvent &event)
mAttributeSlider[i]->getValue()));
}
-#ifdef MANASERV_SUPPORT
- int characterSlot = mSlot;
- // On Manaserv, the slots start at 1, so we offset them.
- if (Net::getNetworkType() == ServerInfo::MANASERV)
- ++characterSlot;
-#else
const int characterSlot = mSlot;
-#endif
Net::getCharServerHandler()->newCharacter(getName(), characterSlot,
mFemale->isSelected(), mHairStyle, mHairColor,
@@ -527,8 +518,8 @@ void CharCreateDialog::setAttributes(const StringVect &labels,
mAttributeLabel[i]->adjustSize();
add(mAttributeLabel[i]);
- mAttributeSlider[i] = new Slider(min, max);
- mAttributeSlider[i]->setDimension(gcn::Rectangle(140, y + i * 24,
+ mAttributeSlider[i] = new Slider(this, min, max);
+ mAttributeSlider[i]->setDimension(Rect(140, y + i * 24,
150, 12));
mAttributeSlider[i]->setActionEventId("statslider");
mAttributeSlider[i]->addActionListener(this);
@@ -664,14 +655,14 @@ void CharCreateDialog::updatePlayer()
}
}
-void CharCreateDialog::keyPressed(gcn::KeyEvent &keyEvent)
+void CharCreateDialog::keyPressed(KeyEvent &keyEvent)
{
- const int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int actionId = keyEvent.getActionId();
switch (actionId)
{
case Input::KEY_GUI_CANCEL:
keyEvent.consume();
- action(gcn::ActionEvent(mCancelButton,
+ action(ActionEvent(mCancelButton,
mCancelButton->getActionEventId()));
break;
diff --git a/src/gui/windows/charcreatedialog.h b/src/gui/windows/charcreatedialog.h
index 0d73bf805..12ddf7970 100644
--- a/src/gui/windows/charcreatedialog.h
+++ b/src/gui/windows/charcreatedialog.h
@@ -25,11 +25,13 @@
#include "being/being.h"
-#include "gui/windows/charselectdialog.h"
+#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/keylistener.h"
+class Button;
+class CharSelectDialog;
class Label;
class PlayerBox;
class RadioButton;
@@ -42,8 +44,8 @@ class TextField;
* \ingroup Interface
*/
class CharCreateDialog final : public Window,
- public gcn::ActionListener,
- public gcn::KeyListener
+ public ActionListener,
+ public KeyListener
{
public:
/**
@@ -58,7 +60,7 @@ class CharCreateDialog final : public Window,
*/
~CharCreateDialog();
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Unlocks the dialog, enabling the create character button again.
@@ -76,7 +78,7 @@ class CharCreateDialog final : public Window,
void updatePlayer();
- void keyPressed(gcn::KeyEvent &keyEvent) override final;
+ void keyPressed(KeyEvent &keyEvent) override final;
private:
int getDistributedPoints() const A_WARN_UNUSED;
diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp
index 3f44617f8..4480f06af 100644
--- a/src/gui/windows/charselectdialog.cpp
+++ b/src/gui/windows/charselectdialog.cpp
@@ -26,8 +26,9 @@
#include "configuration.h"
#include "units.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
#include "gui/windows/charcreatedialog.h"
#include "gui/windows/confirmdialog.h"
@@ -43,6 +44,7 @@
#include "net/logindata.h"
#include "net/loginhandler.h"
+#include "net/net.h"
#include "utils/gettext.h"
@@ -70,7 +72,7 @@ class CharDeleteConfirm final : public ConfirmDialog
A_DELETE_COPY(CharDeleteConfirm)
- void action(const gcn::ActionEvent &event)
+ void action(const ActionEvent &event)
{
if (event.getId() == "yes" && mMaster)
mMaster->askPasswordForDeletion(mIndex);
@@ -88,8 +90,8 @@ CharSelectDialog::CharSelectDialog(LoginData *const data):
Window(strprintf(_("Account %s (last login time %s)"),
data->username.c_str(), data->lastLogin.c_str()),
false, nullptr, "char.xml"),
- gcn::ActionListener(),
- gcn::KeyListener(),
+ ActionListener(),
+ KeyListener(),
mLoginData(data),
// TRANSLATORS: char select dialog. button.
mSwitchLoginButton(new Button(this, _("Switch Login"), "switch", this)),
@@ -205,10 +207,10 @@ void CharSelectDialog::postInit()
requestFocus();
}
-void CharSelectDialog::action(const gcn::ActionEvent &event)
+void CharSelectDialog::action(const ActionEvent &event)
{
// Check if a button of a character was pressed
- const gcn::Widget *const sourceParent = event.getSource()->getParent();
+ const Widget *const sourceParent = event.getSource()->getParent();
int selected = -1;
for (unsigned int i = 0, sz = static_cast<unsigned int>(
mCharacterEntries.size()); i < sz; ++i)
@@ -315,14 +317,14 @@ void CharSelectDialog::use(const int selected)
}
}
-void CharSelectDialog::keyPressed(gcn::KeyEvent &keyEvent)
+void CharSelectDialog::keyPressed(KeyEvent &keyEvent)
{
- const int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int actionId = keyEvent.getActionId();
switch (actionId)
{
case Input::KEY_GUI_CANCEL:
keyEvent.consume();
- action(gcn::ActionEvent(mSwitchLoginButton,
+ action(ActionEvent(mSwitchLoginButton,
mSwitchLoginButton->getActionEventId()));
break;
@@ -471,15 +473,7 @@ void CharSelectDialog::setCharacters(const Net::Characters &characters)
Net::Character *const character = *i;
- // Slots Number start at 1 for Manaserv, so we offset them by one.
-#ifdef MANASERV_SUPPORT
- int characterSlot = character->slot;
- if (Net::getNetworkType() == ServerInfo::MANASERV && characterSlot > 0)
- --characterSlot;
-#else
const int characterSlot = character->slot;
-#endif
-
if (characterSlot >= static_cast<int>(mCharacterEntries.size()))
{
logger->log("Warning: slot out of range: %d", character->slot);
@@ -563,7 +557,7 @@ void CharSelectDialog::close()
Window::close();
}
-void CharSelectDialog::widgetResized(const gcn::Event &event)
+void CharSelectDialog::widgetResized(const Event &event)
{
Window::widgetResized(event);
if (mCharacterView)
diff --git a/src/gui/windows/charselectdialog.h b/src/gui/windows/charselectdialog.h
index 3ac5d664f..38c307f30 100644
--- a/src/gui/windows/charselectdialog.h
+++ b/src/gui/windows/charselectdialog.h
@@ -29,13 +29,12 @@
#include "net/charserverhandler.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/keylistener.h"
class Button;
class CharacterDisplay;
class CharacterViewBase;
-class Label;
class LoginData;
class TextDialog;
@@ -45,8 +44,8 @@ class TextDialog;
* \ingroup Interface
*/
class CharSelectDialog final : public Window,
- public gcn::ActionListener,
- public gcn::KeyListener
+ public ActionListener,
+ public KeyListener
{
public:
friend class CharDeleteConfirm;
@@ -61,9 +60,9 @@ class CharSelectDialog final : public Window,
~CharSelectDialog();
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
- void keyPressed(gcn::KeyEvent &keyEvent) override final;
+ void keyPressed(KeyEvent &keyEvent) override final;
enum SelectAction
{
@@ -86,7 +85,7 @@ class CharSelectDialog final : public Window,
void close() override final;
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
void updateState();
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index 26f665052..d769c4397 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -35,13 +35,16 @@
#include "being/playerinfo.h"
#include "being/playerrelations.h"
+#include "events/keyevent.h"
+
#include "input/inputmanager.h"
-#include "input/keyevent.h"
-#include "gui/sdlfont.h"
-#include "gui/sdlinput.h"
+#include "gui/focushandler.h"
+#include "gui/gui.h"
#include "gui/viewport.h"
+#include "gui/models/colorlistmodel.h"
+
#include "gui/windows/emotewindow.h"
#include "gui/windows/setupwindow.h"
#include "gui/widgets/tabbedarea.h"
@@ -68,8 +71,6 @@
#include "resources/resourcemanager.h"
-#include <guichan/focushandler.hpp>
-
#include <sstream>
#include <sys/stat.h>
@@ -97,7 +98,7 @@ class ChatInput final : public TextField
* Called if the chat input loses focus. It will set itself to
* invisible as result.
*/
- void focusLost(const gcn::Event &event)
+ void focusLost(const Event &event)
{
TextField::focusLost(event);
if (mFocusGaining || !config.getBoolValue("protectChatFocus"))
@@ -145,65 +146,13 @@ class ChatInput final : public TextField
bool mFocusGaining;
};
-const char *COLOR_NAME[14] =
-{
- // TRANSLATORS: chat color
- N_("default"),
- // TRANSLATORS: chat color
- N_("black"),
- // TRANSLATORS: chat color
- N_("red"),
- // TRANSLATORS: chat color
- N_("green"),
- // TRANSLATORS: chat color
- N_("blue"),
- // TRANSLATORS: chat color
- N_("gold"),
- // TRANSLATORS: chat color
- N_("yellow"),
- // TRANSLATORS: chat color
- N_("pink"),
- // TRANSLATORS: chat color
- N_("purple"),
- // TRANSLATORS: chat color
- N_("grey"),
- // TRANSLATORS: chat color
- N_("brown"),
- // TRANSLATORS: chat color
- N_("rainbow 1"),
- // TRANSLATORS: chat color
- N_("rainbow 2"),
- // TRANSLATORS: chat color
- N_("rainbow 3"),
-};
-
-
-class ColorListModel final : public gcn::ListModel
-{
-public:
- ~ColorListModel()
- { }
-
- int getNumberOfElements()
- {
- return 14;
- }
-
- std::string getElementAt(int i)
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
- return gettext(COLOR_NAME[i]);
- }
-};
-
static const char *const ACTION_COLOR_PICKER = "color picker";
ChatWindow::ChatWindow():
// TRANSLATORS: chat window name
Window(_("Chat"), false, nullptr, "chat.xml"),
- gcn::ActionListener(),
- gcn::KeyListener(),
+ ActionListener(),
+ KeyListener(),
mItemLinkHandler(new ItemLinkHandler),
mChatTabs(new TabbedArea(this)),
mChatInput(new ChatInput(this)),
@@ -378,7 +327,7 @@ void ChatWindow::updateTabsMargin()
void ChatWindow::adjustTabSize()
{
- const gcn::Rectangle area = getChildrenArea();
+ const Rect area = getChildrenArea();
const int aw = area.width;
const int ah = area.height;
@@ -425,7 +374,7 @@ void ChatWindow::adjustTabSize()
const ChatTab *const tab = getFocused();
if (tab)
{
- gcn::Widget *const content = tab->mScrollArea;
+ Widget *const content = tab->mScrollArea;
if (content)
{
const int contentFrame2 = 2 * content->getFrameSize();
@@ -441,7 +390,7 @@ void ChatWindow::adjustTabSize()
mChatTabs->adjustSize();
}
-void ChatWindow::widgetResized(const gcn::Event &event)
+void ChatWindow::widgetResized(const Event &event)
{
Window::widgetResized(event);
@@ -514,7 +463,7 @@ void ChatWindow::defaultTab()
mChatTabs->setSelectedTabByIndex(static_cast<unsigned>(0));
}
-void ChatWindow::action(const gcn::ActionEvent &event)
+void ChatWindow::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "chatinput")
@@ -770,12 +719,12 @@ void ChatWindow::scroll(const int amount) const
tab->scroll(amount);
}
-void ChatWindow::mousePressed(gcn::MouseEvent &event)
+void ChatWindow::mousePressed(MouseEvent &event)
{
if (event.isConsumed())
return;
- if (event.getButton() == gcn::MouseEvent::RIGHT)
+ if (event.getButton() == MouseEvent::RIGHT)
{
if (viewport)
{
@@ -804,7 +753,7 @@ void ChatWindow::mousePressed(gcn::MouseEvent &event)
if (event.isConsumed())
return;
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ if (event.getButton() == MouseEvent::LEFT)
{
const ChatTab *const tab = getFocused();
if (tab)
@@ -815,7 +764,7 @@ void ChatWindow::mousePressed(gcn::MouseEvent &event)
mDragOffsetY = event.getY();
}
-void ChatWindow::mouseDragged(gcn::MouseEvent &event)
+void ChatWindow::mouseDragged(MouseEvent &event)
{
Window::mouseDragged(event);
@@ -836,10 +785,10 @@ void ChatWindow::mouseDragged(gcn::MouseEvent &event)
temp = str; \
break
-void ChatWindow::keyPressed(gcn::KeyEvent &event)
+void ChatWindow::keyPressed(KeyEvent &event)
{
const int key = event.getKey().getValue();
- const int actionId = static_cast<KeyEvent*>(&event)->getActionId();
+ const int actionId = event.getActionId();
if (actionId == static_cast<int>(Input::KEY_GUI_DOWN))
{
if (mCurHist != mHistory.end())
@@ -1884,25 +1833,25 @@ void ChatWindow::optionChanged(const std::string &name)
parseGlobalsFilter();
}
-void ChatWindow::mouseMoved(gcn::MouseEvent &event)
+void ChatWindow::mouseMoved(MouseEvent &event)
{
mHaveMouse = true;
Window::mouseMoved(event);
}
-void ChatWindow::mouseEntered(gcn::MouseEvent& mouseEvent)
+void ChatWindow::mouseEntered(MouseEvent& mouseEvent)
{
mHaveMouse = true;
Window::mouseEntered(mouseEvent);
}
-void ChatWindow::mouseExited(gcn::MouseEvent& mouseEvent)
+void ChatWindow::mouseExited(MouseEvent& mouseEvent)
{
updateVisibility();
Window::mouseExited(mouseEvent);
}
-void ChatWindow::draw(gcn::Graphics* graphics)
+void ChatWindow::draw(Graphics* graphics)
{
BLOCK_START("ChatWindow::draw")
if (!mAutoHide || mHaveMouse)
diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h
index 3093c52e9..2ec4e6bec 100644
--- a/src/gui/windows/chatwindow.h
+++ b/src/gui/windows/chatwindow.h
@@ -23,14 +23,14 @@
#ifndef GUI_WINDOWS_CHATWINDOW_H
#define GUI_WINDOWS_CHATWINDOW_H
-#include "depricatedlistener.h"
+#include "listeners/depricatedlistener.h"
-#include "configlistener.h"
+#include "listeners/configlistener.h"
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/keylistener.h"
#include <list>
#include <map>
@@ -83,8 +83,8 @@ struct CHATLOG final
* \ingroup Interface
*/
class ChatWindow final : public Window,
- public gcn::ActionListener,
- public gcn::KeyListener,
+ public ActionListener,
+ public KeyListener,
public DepricatedListener,
public ConfigListener
{
@@ -139,7 +139,7 @@ class ChatWindow final : public Window,
/**
* Performs action.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Request focus for typing chat message.
@@ -169,7 +169,7 @@ class ChatWindow final : public Window,
void localChatInput(const std::string &msg) const;
/** Called when key is pressed */
- void keyPressed(gcn::KeyEvent &event) override final;
+ void keyPressed(KeyEvent &event) override final;
/** Set the chat input as the given text. */
void setInputText(const std::string &text);
@@ -186,12 +186,12 @@ class ChatWindow final : public Window,
/**
* Handles mouse when dragged.
*/
- void mouseDragged(gcn::MouseEvent &event) override final;
+ void mouseDragged(MouseEvent &event) override final;
/**
* Handles mouse when pressed.
*/
- void mousePressed(gcn::MouseEvent &event) override final;
+ void mousePressed(MouseEvent &event) override final;
void processEvent(const Channels channel,
const DepricatedEvent &event) override final;
@@ -274,19 +274,19 @@ class ChatWindow final : public Window,
void optionChanged(const std::string &name) override final;
- void mouseEntered(gcn::MouseEvent& mouseEvent) override final;
+ void mouseEntered(MouseEvent& mouseEvent) override final;
- void mouseMoved(gcn::MouseEvent &event) override final;
+ void mouseMoved(MouseEvent &event) override final;
- void mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED) override final;
+ void mouseExited(MouseEvent& mouseEvent A_UNUSED) override final;
- void draw(gcn::Graphics* graphics) override final;
+ void draw(Graphics* graphics) override final;
void updateVisibility();
void unHideWindow();
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
void addGlobalMessage(const std::string &line);
diff --git a/src/gui/windows/confirmdialog.cpp b/src/gui/windows/confirmdialog.cpp
index e48427a5b..6eb21622d 100644
--- a/src/gui/windows/confirmdialog.cpp
+++ b/src/gui/windows/confirmdialog.cpp
@@ -29,7 +29,7 @@
#include "utils/gettext.h"
-#include <guichan/font.hpp>
+#include "gui/font.h"
#include "debug.h"
@@ -39,7 +39,7 @@ ConfirmDialog::ConfirmDialog(const std::string &restrict title,
const bool ignore,
const bool modal, Window *const parent):
Window(title, modal, parent, "confirm.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mTextBox(new TextBox(this)),
mIgnore(ignore)
{
@@ -107,7 +107,7 @@ void ConfirmDialog::postInit()
yesButton->requestFocus();
}
-void ConfirmDialog::action(const gcn::ActionEvent &event)
+void ConfirmDialog::action(const ActionEvent &event)
{
setActionEventId(event.getId());
distributeActionEvent();
diff --git a/src/gui/windows/confirmdialog.h b/src/gui/windows/confirmdialog.h
index 0b092e234..0d9f25d38 100644
--- a/src/gui/windows/confirmdialog.h
+++ b/src/gui/windows/confirmdialog.h
@@ -29,7 +29,7 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
class TextBox;
@@ -38,7 +38,8 @@ class TextBox;
*
* \ingroup GUI
*/
-class ConfirmDialog : public Window, public gcn::ActionListener
+class ConfirmDialog : public Window,
+ public ActionListener
{
public:
/**
@@ -57,7 +58,7 @@ class ConfirmDialog : public Window, public gcn::ActionListener
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override;
+ void action(const ActionEvent &event) override;
void postInit() override final;
diff --git a/src/gui/windows/connectiondialog.cpp b/src/gui/windows/connectiondialog.cpp
index 6d01dcaae..1a7c23187 100644
--- a/src/gui/windows/connectiondialog.cpp
+++ b/src/gui/windows/connectiondialog.cpp
@@ -34,14 +34,14 @@
ConnectionDialog::ConnectionDialog(const std::string &text,
const State cancelState):
Window("", false, nullptr, "connection.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mCancelState(cancelState)
{
setTitleBarHeight(0);
setMovable(false);
setMinWidth(0);
- ProgressIndicator *const progressIndicator = new ProgressIndicator;
+ ProgressIndicator *const progressIndicator = new ProgressIndicator(this);
Label *const label = new Label(this, text);
Button *const cancelButton = new Button(
// TRANSLATORS: connection dialog button
@@ -60,13 +60,13 @@ void ConnectionDialog::postInit()
setVisible(true);
}
-void ConnectionDialog::action(const gcn::ActionEvent &)
+void ConnectionDialog::action(const ActionEvent &)
{
logger->log1("Cancel pressed");
client->setState(mCancelState);
}
-void ConnectionDialog::draw(gcn::Graphics *graphics)
+void ConnectionDialog::draw(Graphics *graphics)
{
BLOCK_START("ConnectionDialog::draw")
// Don't draw the window background, only draw the children
diff --git a/src/gui/windows/connectiondialog.h b/src/gui/windows/connectiondialog.h
index 2f861bc52..059d4bd6d 100644
--- a/src/gui/windows/connectiondialog.h
+++ b/src/gui/windows/connectiondialog.h
@@ -27,14 +27,15 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
/**
* The connection dialog.
*
* \ingroup Interface
*/
-class ConnectionDialog final : public Window, private gcn::ActionListener
+class ConnectionDialog final : public Window,
+ private ActionListener
{
public:
/**
@@ -55,9 +56,9 @@ class ConnectionDialog final : public Window, private gcn::ActionListener
* Called when the user presses Cancel. Restores the global state to
* the previous one.
*/
- void action(const gcn::ActionEvent &) override;
+ void action(const ActionEvent &) override;
- void draw(gcn::Graphics *graphics) override;
+ void draw(Graphics *graphics) override;
private:
State mCancelState;
diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp
index 30d202054..50dc5dbe5 100644
--- a/src/gui/windows/debugwindow.cpp
+++ b/src/gui/windows/debugwindow.cpp
@@ -75,7 +75,7 @@ DebugWindow::DebugWindow() :
// TRANSLATORS: debug window tab
mTabs->addTab(std::string(_("Net")), mNetWidget);
- mTabs->setDimension(gcn::Rectangle(0, 0, 600, 300));
+ mTabs->setDimension(Rect(0, 0, 600, 300));
const int w = mDimension.width;
const int h = mDimension.height;
@@ -129,7 +129,7 @@ void DebugWindow::slowLogic()
BLOCK_END("DebugWindow::slowLogic")
}
-void DebugWindow::draw(gcn::Graphics *g)
+void DebugWindow::draw(Graphics *g)
{
BLOCK_START("DebugWindow::draw")
Window::draw(g);
@@ -139,8 +139,7 @@ void DebugWindow::draw(gcn::Graphics *g)
const Being *const target = player_node->getTarget();
if (target)
{
- Graphics *const g2 = static_cast<Graphics*>(g);
- target->draw(g2, -target->getPixelX() + mapTileSize / 2
+ target->draw(g, -target->getPixelX() + mapTileSize / 2
+ mDimension.width / 2, -target->getPixelY() + mapTileSize
+ mDimension.height / 2);
}
@@ -148,11 +147,11 @@ void DebugWindow::draw(gcn::Graphics *g)
BLOCK_END("DebugWindow::draw")
}
-void DebugWindow::widgetResized(const gcn::Event &event)
+void DebugWindow::widgetResized(const Event &event)
{
Window::widgetResized(event);
- mTabs->setDimension(gcn::Rectangle(0, 0,
+ mTabs->setDimension(Rect(0, 0,
mDimension.width, mDimension.height));
}
@@ -268,7 +267,7 @@ MapDebugTab::MapDebugTab(const Widget2 *const widget) :
#endif
place.getCell().matchColWidth(0, 0);
place = h.getPlacer(0, 1);
- setDimension(gcn::Rectangle(0, 0, 600, 300));
+ setDimension(Rect(0, 0, 600, 300));
}
void MapDebugTab::logic()
@@ -413,7 +412,7 @@ TargetDebugTab::TargetDebugTab(const Widget2 *const widget) :
place.getCell().matchColWidth(0, 0);
place = h.getPlacer(0, 1);
- setDimension(gcn::Rectangle(0, 0, 600, 300));
+ setDimension(Rect(0, 0, 600, 300));
}
void TargetDebugTab::logic()
@@ -532,7 +531,7 @@ NetDebugTab::NetDebugTab(const Widget2 *const widget) :
place.getCell().matchColWidth(0, 0);
place = h.getPlacer(0, 1);
- setDimension(gcn::Rectangle(0, 0, 600, 300));
+ setDimension(Rect(0, 0, 600, 300));
}
void NetDebugTab::logic()
diff --git a/src/gui/windows/debugwindow.h b/src/gui/windows/debugwindow.h
index 13e73c29e..1a56f3164 100644
--- a/src/gui/windows/debugwindow.h
+++ b/src/gui/windows/debugwindow.h
@@ -41,7 +41,7 @@ class DebugTab : public Container
}
void resize(const int x, const int y)
- { setDimension(gcn::Rectangle(0, 0, x, y)); }
+ { setDimension(Rect(0, 0, x, y)); }
protected:
explicit DebugTab(const Widget2 *const widget) :
@@ -147,11 +147,11 @@ class DebugWindow final : public Window
*/
void slowLogic();
- void draw(gcn::Graphics *g) override final;
+ void draw(Graphics *g) override final;
void setPing(int pingTime);
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
#ifdef USE_PROFILER
void logicChildren();
diff --git a/src/gui/windows/didyouknowwindow.cpp b/src/gui/windows/didyouknowwindow.cpp
index 93166e6fa..79ad4c208 100644
--- a/src/gui/windows/didyouknowwindow.cpp
+++ b/src/gui/windows/didyouknowwindow.cpp
@@ -24,7 +24,7 @@
#include "configuration.h"
-#include "gui/sdlfont.h"
+#include "gui/gui.h"
#include "gui/windows/setupwindow.h"
@@ -48,10 +48,10 @@ static const int maxTip = 18;
DidYouKnowWindow::DidYouKnowWindow() :
// TRANSLATORS: did you know window name
Window(_("Did You Know?"), false, nullptr, "didyouknow.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mBrowserBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true,
"browserbox.xml")),
- mScrollArea(new ScrollArea(mBrowserBox,
+ mScrollArea(new ScrollArea(this, mBrowserBox,
true, "didyouknow_background.xml")),
// TRANSLATORS: did you know window button
mButtonPrev(new Button(this, _("< Previous"), "prev", this)),
@@ -78,7 +78,8 @@ DidYouKnowWindow::DidYouKnowWindow() :
Button *const okButton = new Button(this, _("Close"), "close", this);
mBrowserBox->setLinkHandler(this);
- mBrowserBox->setFont(gui->getHelpFont());
+ if (gui)
+ mBrowserBox->setFont(gui->getHelpFont());
mBrowserBox->setProcessVersion(true);
mBrowserBox->setEnableImages(true);
mBrowserBox->setEnableKeys(true);
@@ -99,10 +100,10 @@ DidYouKnowWindow::DidYouKnowWindow() :
void DidYouKnowWindow::postInit()
{
- widgetResized(gcn::Event(nullptr));
+ widgetResized(Event(nullptr));
}
-void DidYouKnowWindow::action(const gcn::ActionEvent &event)
+void DidYouKnowWindow::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "close")
@@ -129,7 +130,7 @@ void DidYouKnowWindow::action(const gcn::ActionEvent &event)
}
void DidYouKnowWindow::handleLink(const std::string &link,
- gcn::MouseEvent *event A_UNUSED)
+ MouseEvent *event A_UNUSED)
{
if (strStartWith(link, "http://") || strStartWith(link, "https://"))
openBrowser(link);
diff --git a/src/gui/windows/didyouknowwindow.h b/src/gui/windows/didyouknowwindow.h
index 942bcf41c..fd539e360 100644
--- a/src/gui/windows/didyouknowwindow.h
+++ b/src/gui/windows/didyouknowwindow.h
@@ -26,7 +26,7 @@
#include "gui/widgets/linkhandler.h"
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
class Button;
class BrowserBox;
@@ -38,7 +38,7 @@ class ScrollArea;
*/
class DidYouKnowWindow final : public Window,
public LinkHandler,
- public gcn::ActionListener
+ public ActionListener
{
public:
/**
@@ -53,13 +53,13 @@ class DidYouKnowWindow final : public Window,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Handles link action.
*/
void handleLink(const std::string &link,
- gcn::MouseEvent *event) override final;
+ MouseEvent *event) override final;
void loadData(int num = 0);
diff --git a/src/gui/windows/editdialog.cpp b/src/gui/windows/editdialog.cpp
index 5c002212f..55102acdb 100644
--- a/src/gui/windows/editdialog.cpp
+++ b/src/gui/windows/editdialog.cpp
@@ -33,7 +33,7 @@ EditDialog::EditDialog(const std::string &restrict title,
const std::string &restrict eventOk, const int width,
Window *const parent, const bool modal):
Window(title, modal, parent, "edit.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mEventOk(eventOk),
mTextField(new TextField(this))
{
@@ -65,7 +65,7 @@ void EditDialog::postInit()
okButton->requestFocus();
}
-void EditDialog::action(const gcn::ActionEvent &event)
+void EditDialog::action(const ActionEvent &event)
{
// Proxy button events to our listeners
FOR_EACH (ActionListenerIterator, i, mActionListeners)
diff --git a/src/gui/windows/editdialog.h b/src/gui/windows/editdialog.h
index fa4a02bf7..b3bfe1f45 100644
--- a/src/gui/windows/editdialog.h
+++ b/src/gui/windows/editdialog.h
@@ -28,7 +28,7 @@
#include "gui/widgets/window.h"
#include "gui/widgets/textfield.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
#define ACTION_EDIT_OK "edit ok"
@@ -37,7 +37,8 @@
*
* \ingroup GUI
*/
-class EditDialog final : public Window, public gcn::ActionListener
+class EditDialog final : public Window,
+ public ActionListener
{
public:
/**
@@ -58,7 +59,7 @@ class EditDialog final : public Window, public gcn::ActionListener
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
std::string getMsg() const A_WARN_UNUSED
{ return mTextField->getText(); }
diff --git a/src/gui/windows/editserverdialog.cpp b/src/gui/windows/editserverdialog.cpp
index 900fe840b..316a7051b 100644
--- a/src/gui/windows/editserverdialog.cpp
+++ b/src/gui/windows/editserverdialog.cpp
@@ -21,8 +21,11 @@
#include "gui/windows/editserverdialog.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
+
+#include "gui/models/typelistmodel.h"
#include "gui/windows/okdialog.h"
#include "gui/windows/serverdialog.h"
@@ -35,36 +38,13 @@
#include "utils/gettext.h"
-std::string TypeListModel::getElementAt(int elementIndex)
-{
- if (elementIndex == 0)
- return "TmwAthena";
- else if (elementIndex == 1)
- return "Evol";
-#ifdef EATHENA_SUPPORT
- else if (elementIndex == 2)
- return "eAthena";
-#ifdef MANASERV_SUPPORT
- else if (elementIndex == 3)
- return "ManaServ";
-#endif
-#else
-#ifdef MANASERV_SUPPORT
- else if (elementIndex == 2)
- return "ManaServ";
-#endif
-#endif
- else
- return "Unknown";
-}
-
EditServerDialog::EditServerDialog(ServerDialog *const parent,
ServerInfo server,
const int index) :
// TRANSLATORS: edit server dialog name
Window(_("Edit Server"), true, parent),
- gcn::ActionListener(),
- gcn::KeyListener(),
+ ActionListener(),
+ KeyListener(),
mServerAddressField(new TextField(this, std::string())),
mPortField(new TextField(this, std::string())),
mNameField(new TextField(this, std::string())),
@@ -159,17 +139,6 @@ EditServerDialog::EditServerDialog(ServerDialog *const parent,
case ServerInfo::EATHENA:
mTypeField->setSelected(2);
break;
- case ServerInfo::MANASERV:
-#ifdef MANASERV_SUPPORT
- mTypeField->setSelected(3);
- break;
-#endif
-#else
- case ServerInfo::MANASERV:
-#ifdef MANASERV_SUPPORT
- mTypeField->setSelected(2);
- break;
-#endif
#endif
default:
case ServerInfo::UNKNOWN:
@@ -198,7 +167,7 @@ void EditServerDialog::postInit()
mNameField->requestFocus();
}
-void EditServerDialog::action(const gcn::ActionEvent &event)
+void EditServerDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
@@ -246,17 +215,6 @@ void EditServerDialog::action(const gcn::ActionEvent &event)
case 2:
mServer.type = ServerInfo::EATHENA;
break;
-#ifdef MANASERV_SUPPORT
- case 3:
- mServer.type = ServerInfo::MANASERV;
- break;
-#endif
-#else
-#ifdef MANASERV_SUPPORT
- case 2:
- mServer.type = ServerInfo::MANASERV;
- break;
-#endif
#endif
default:
mServer.type = ServerInfo::UNKNOWN;
@@ -284,13 +242,12 @@ void EditServerDialog::action(const gcn::ActionEvent &event)
}
}
-void EditServerDialog::keyPressed(gcn::KeyEvent &keyEvent)
+void EditServerDialog::keyPressed(KeyEvent &keyEvent)
{
if (keyEvent.isConsumed())
return;
- const int actionId = static_cast<KeyEvent*>(
- &keyEvent)->getActionId();
+ const int actionId = keyEvent.getActionId();
if (actionId == static_cast<int>(Input::KEY_GUI_CANCEL))
{
@@ -299,6 +256,6 @@ void EditServerDialog::keyPressed(gcn::KeyEvent &keyEvent)
else if (actionId == static_cast<int>(Input::KEY_GUI_SELECT)
|| actionId == static_cast<int>(Input::KEY_GUI_SELECT2))
{
- action(gcn::ActionEvent(nullptr, mOkButton->getActionEventId()));
+ action(ActionEvent(nullptr, mOkButton->getActionEventId()));
}
}
diff --git a/src/gui/windows/editserverdialog.h b/src/gui/windows/editserverdialog.h
index 525005429..b70d1031b 100644
--- a/src/gui/windows/editserverdialog.h
+++ b/src/gui/windows/editserverdialog.h
@@ -26,48 +26,14 @@ class Button;
class TextField;
class DropDown;
class ServerDialog;
+class TypeListModel;
#include "gui/widgets/window.h"
#include "net/serverinfo.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
-#include <guichan/listmodel.hpp>
-
-/**
- * Server Type List Model
- */
-class TypeListModel : public gcn::ListModel
-{
- public:
- TypeListModel()
- { }
-
- /**
- * Used to get number of line in the list
- */
- int getNumberOfElements() override final A_WARN_UNUSED
-#ifdef EATHENA_SUPPORT
-#ifdef MANASERV_SUPPORT
- { return 4; }
-#else
- { return 3; }
-#endif
-#else
-#ifdef MANASERV_SUPPORT
- { return 3; }
-#else
- { return 2; }
-#endif
-#endif
-
- /**
- * Used to get an element from the list
- */
- std::string getElementAt(int elementIndex)
- override final A_WARN_UNUSED;
-};
+#include "listeners/actionlistener.h"
+#include "listeners/keylistener.h"
/**
* The custom server addition dialog.
@@ -75,8 +41,8 @@ class TypeListModel : public gcn::ListModel
* \ingroup Interface
*/
class EditServerDialog final : public Window,
- public gcn::ActionListener,
- public gcn::KeyListener
+ public ActionListener,
+ public KeyListener
{
public:
EditServerDialog(ServerDialog *const parent, ServerInfo server,
@@ -91,9 +57,9 @@ class EditServerDialog final : public Window,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
- void keyPressed(gcn::KeyEvent &keyEvent) override final;
+ void keyPressed(KeyEvent &keyEvent) override final;
private:
TextField *mServerAddressField;
diff --git a/src/gui/windows/emotewindow.cpp b/src/gui/windows/emotewindow.cpp
index 9dd5f648c..3a7141533 100644
--- a/src/gui/windows/emotewindow.cpp
+++ b/src/gui/windows/emotewindow.cpp
@@ -20,10 +20,11 @@
#include "gui/windows/emotewindow.h"
-#include "gui/widgets/colormodel.h"
+#include "gui/models/colormodel.h"
+#include "gui/models/namesmodel.h"
+
#include "gui/widgets/colorpage.h"
#include "gui/widgets/emotepage.h"
-#include "gui/widgets/namesmodel.h"
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/tabbedarea.h"
@@ -51,10 +52,10 @@ EmoteWindow::EmoteWindow() :
mEmotePage(new EmotePage(this)),
mColorModel(ColorModel::createDefault(this)),
mColorPage(new ColorPage(this, mColorModel, "colorpage.xml")),
- mScrollColorPage(new ScrollArea(mColorPage, false, "emotepage.xml")),
+ mScrollColorPage(new ScrollArea(this, mColorPage, false, "emotepage.xml")),
mFontModel(new NamesModel),
mFontPage(new ListBox(this, mFontModel, "")),
- mScrollFontPage(new ScrollArea(mFontPage, false, "fontpage.xml")),
+ mScrollFontPage(new ScrollArea(this, mFontPage, false, "fontpage.xml")),
mImageSet(Theme::getImageSetFromThemeXml("emotetabs.xml", "", 17, 16))
{
mTabs->postInit();
@@ -207,14 +208,14 @@ void EmoteWindow::clearFont()
setVisible(false);
}
-void EmoteWindow::addListeners(gcn::ActionListener *const listener)
+void EmoteWindow::addListeners(ActionListener *const listener)
{
mEmotePage->addActionListener(listener);
mColorPage->addActionListener(listener);
mFontPage->addActionListener(listener);
}
-void EmoteWindow::widgetResized(const gcn::Event &event)
+void EmoteWindow::widgetResized(const Event &event)
{
Window::widgetResized(event);
const int pad2 = mPadding * 2;
@@ -229,7 +230,7 @@ void EmoteWindow::widgetResized(const gcn::Event &event)
mEmotePage->widgetResized(event);
}
-void EmoteWindow::widgetMoved(const gcn::Event &event)
+void EmoteWindow::widgetMoved(const Event &event)
{
Window::widgetMoved(event);
mEmotePage->widgetResized(event);
diff --git a/src/gui/windows/emotewindow.h b/src/gui/windows/emotewindow.h
index 0f15b7bc6..37a5c015f 100644
--- a/src/gui/windows/emotewindow.h
+++ b/src/gui/windows/emotewindow.h
@@ -59,11 +59,11 @@ class EmoteWindow final : public Window
void clearFont();
- void addListeners(gcn::ActionListener *const listener);
+ void addListeners(ActionListener *const listener);
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
- void widgetMoved(const gcn::Event &event) override final;
+ void widgetMoved(const Event &event) override final;
private:
TabbedArea *mTabs;
diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp
index 3b97e12d7..c793ba6ce 100644
--- a/src/gui/windows/equipmentwindow.cpp
+++ b/src/gui/windows/equipmentwindow.cpp
@@ -32,6 +32,7 @@
#include "being/localplayer.h"
#include "being/playerinfo.h"
+#include "gui/font.h"
#include "gui/viewport.h"
#include "gui/popups/itempopup.h"
@@ -46,8 +47,6 @@
#include "utils/dtor.h"
#include "utils/gettext.h"
-#include <guichan/font.hpp>
-
#include "debug.h"
static const int BOX_COUNT = 13;
@@ -57,10 +56,11 @@ EquipmentWindow::EquipmentWindow(Equipment *const equipment,
const bool foring):
// TRANSLATORS: equipment window name
Window(_("Equipment"), false, nullptr, "equipment.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mEquipment(equipment),
mItemPopup(new ItemPopup),
- mPlayerBox(new PlayerBox("equipment_playerbox.xml",
+ mPlayerBox(new PlayerBox(this,
+ "equipment_playerbox.xml",
"equipment_selectedplayerbox.xml")),
// TRANSLATORS: equipment window button
mUnequip(new Button(this, _("Unequip"), "unequip", this)),
@@ -92,7 +92,7 @@ EquipmentWindow::EquipmentWindow(Equipment *const equipment,
mBoxSize = 36;
// Control that shows the Player
- mPlayerBox->setDimension(gcn::Rectangle(50, 80, 74, 168));
+ mPlayerBox->setDimension(Rect(50, 80, 74, 168));
mPlayerBox->setPlayer(being);
if (foring)
@@ -116,7 +116,7 @@ EquipmentWindow::EquipmentWindow(Equipment *const equipment,
void EquipmentWindow::postInit()
{
- const gcn::Rectangle &area = getChildrenArea();
+ const Rect &area = getChildrenArea();
mUnequip->setPosition(area.width - mUnequip->getWidth() - mButtonPadding,
area.height - mUnequip->getHeight() - mButtonPadding);
mUnequip->setEnabled(false);
@@ -156,15 +156,14 @@ EquipmentWindow::~EquipmentWindow()
mVertexes = nullptr;
}
-void EquipmentWindow::draw(gcn::Graphics *graphics)
+void EquipmentWindow::draw(Graphics *graphics)
{
BLOCK_START("EquipmentWindow::draw")
// Draw window graphics
Window::draw(graphics);
- Graphics *const g = static_cast<Graphics*>(graphics);
int i = 0;
- gcn::Font *const font = getFont();
+ Font *const font = getFont();
const int fontHeight = font->getHeight();
if (isBatchDrawRenders(openGLMode))
@@ -179,17 +178,19 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
continue;
if (i == mSelected)
{
- g->calcTileCollection(mVertexes,
- mSlotHighlightedBackground, box->x, box->y);
+ graphics->calcTileCollection(mVertexes,
+ mSlotHighlightedBackground,
+ box->x, box->y);
}
else
{
- g->calcTileCollection(mVertexes, mSlotBackground,
+ graphics->calcTileCollection(mVertexes,
+ mSlotBackground,
box->x, box->y);
}
}
}
- g->drawTileCollection(mVertexes);
+ graphics->drawTileCollection(mVertexes);
}
else
{
@@ -200,9 +201,14 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
if (!box)
continue;
if (i == mSelected)
- g->drawImage2(mSlotHighlightedBackground, box->x, box->y);
+ {
+ graphics->drawImage(mSlotHighlightedBackground,
+ box->x, box->y);
+ }
else
- g->drawImage2(mSlotBackground, box->x, box->y);
+ {
+ graphics->drawImage(mSlotBackground, box->x, box->y);
+ }
}
}
@@ -228,13 +234,14 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
{
image->setAlpha(1.0F); // Ensure the image is drawn
// with maximum opacity
- g->drawImage2(image, box->x + mItemPadding,
+ graphics->drawImage(image, box->x + mItemPadding,
box->y + mItemPadding);
if (i == EQUIP_PROJECTILE_SLOT)
{
- g->setColorAll(mLabelsColor, mLabelsColor2);
+ graphics->setColorAll(mLabelsColor, mLabelsColor2);
const std::string str = toString(item->getQuantity());
- font->drawString(g, str,
+ font->drawString(graphics,
+ str,
box->x + (mBoxSize - font->getWidth(str)) / 2,
box->y - fontHeight);
}
@@ -242,14 +249,15 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
}
else if (box->image)
{
- g->drawImage2(box->image, box->x + mItemPadding,
+ graphics->drawImage(box->image,
+ box->x + mItemPadding,
box->y + mItemPadding);
}
}
BLOCK_END("EquipmentWindow::draw")
}
-void EquipmentWindow::action(const gcn::ActionEvent &event)
+void EquipmentWindow::action(const ActionEvent &event)
{
if (!mEquipment)
return;
@@ -275,7 +283,7 @@ Item *EquipmentWindow::getItem(const int x, const int y) const
const EquipmentBox *const box = *it;
if (!box)
continue;
- const gcn::Rectangle tRect(box->x, box->y, mBoxSize, mBoxSize);
+ const Rect tRect(box->x, box->y, mBoxSize, mBoxSize);
if (tRect.isPointInRect(x, y))
return mEquipment->getEquipment(i);
@@ -283,7 +291,7 @@ Item *EquipmentWindow::getItem(const int x, const int y) const
return nullptr;
}
-void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
+void EquipmentWindow::mousePressed(MouseEvent& mouseEvent)
{
if (!mEquipment)
{
@@ -294,7 +302,7 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
const int x = mouseEvent.getX();
const int y = mouseEvent.getY();
- if (mouseEvent.getButton() == gcn::MouseEvent::LEFT)
+ if (mouseEvent.getButton() == MouseEvent::LEFT)
{
if (mForing)
{
@@ -313,7 +321,7 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
if (!box)
continue;
const Item *const item = mEquipment->getEquipment(i);
- const gcn::Rectangle tRect(box->x, box->y, mBoxSize, mBoxSize);
+ const Rect tRect(box->x, box->y, mBoxSize, mBoxSize);
if (tRect.isPointInRect(x, y))
{
@@ -329,7 +337,7 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
return;
}
}
- else if (mouseEvent.getButton() == gcn::MouseEvent::RIGHT)
+ else if (mouseEvent.getButton() == MouseEvent::RIGHT)
{
if (Item *const item = getItem(x, y))
{
@@ -354,7 +362,7 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
Window::mousePressed(mouseEvent);
}
-void EquipmentWindow::mouseReleased(gcn::MouseEvent &mouseEvent)
+void EquipmentWindow::mouseReleased(MouseEvent &mouseEvent)
{
Window::mouseReleased(mouseEvent);
const DragDropSource src = dragDrop.getSource();
@@ -394,7 +402,7 @@ void EquipmentWindow::mouseReleased(gcn::MouseEvent &mouseEvent)
const EquipmentBox *const box = *it;
if (!box)
continue;
- const gcn::Rectangle tRect(box->x, box->y, mBoxSize, mBoxSize);
+ const Rect tRect(box->x, box->y, mBoxSize, mBoxSize);
if (tRect.isPointInRect(x, y))
return;
@@ -409,7 +417,7 @@ void EquipmentWindow::mouseReleased(gcn::MouseEvent &mouseEvent)
}
// Show ItemTooltip
-void EquipmentWindow::mouseMoved(gcn::MouseEvent &event)
+void EquipmentWindow::mouseMoved(MouseEvent &event)
{
Window::mouseMoved(event);
@@ -433,7 +441,7 @@ void EquipmentWindow::mouseMoved(gcn::MouseEvent &event)
}
// Hide ItemTooltip
-void EquipmentWindow::mouseExited(gcn::MouseEvent &event A_UNUSED)
+void EquipmentWindow::mouseExited(MouseEvent &event A_UNUSED)
{
if (mItemPopup)
mItemPopup->setVisible(false);
@@ -506,7 +514,7 @@ void EquipmentWindow::fillBoxes()
void EquipmentWindow::loadPlayerBox(const XmlNodePtr playerBoxNode)
{
- mPlayerBox->setDimension(gcn::Rectangle(
+ mPlayerBox->setDimension(Rect(
XML::getProperty(playerBoxNode, "x", 50),
XML::getProperty(playerBoxNode, "y", 80),
XML::getProperty(playerBoxNode, "width", 74),
diff --git a/src/gui/windows/equipmentwindow.h b/src/gui/windows/equipmentwindow.h
index 7387fb249..0ab4ca462 100644
--- a/src/gui/windows/equipmentwindow.h
+++ b/src/gui/windows/equipmentwindow.h
@@ -30,7 +30,7 @@
#include "utils/xml.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
#include <vector>
@@ -60,7 +60,8 @@ struct EquipmentBox final
*
* \ingroup Interface
*/
-class EquipmentWindow final : public Window, public gcn::ActionListener
+class EquipmentWindow final : public Window,
+ public ActionListener
{
public:
/**
@@ -81,11 +82,11 @@ class EquipmentWindow final : public Window, public gcn::ActionListener
/**
* Draws the equipment window.
*/
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
- void mousePressed(gcn::MouseEvent& mouseEvent) override final;
+ void mousePressed(MouseEvent& mouseEvent) override final;
const Item* getEquipment(const int i) const A_WARN_UNUSED
{ return mEquipment ? mEquipment->getEquipment(i) : nullptr; }
@@ -96,11 +97,11 @@ class EquipmentWindow final : public Window, public gcn::ActionListener
void resetBeing(const Being *const being);
- void mouseExited(gcn::MouseEvent &event) override final;
+ void mouseExited(MouseEvent &event) override final;
- void mouseMoved(gcn::MouseEvent &event) override final;
+ void mouseMoved(MouseEvent &event) override final;
- void mouseReleased(gcn::MouseEvent &event) override final;
+ void mouseReleased(MouseEvent &event) override final;
void recalcSize();
@@ -135,10 +136,10 @@ class EquipmentWindow final : public Window, public gcn::ActionListener
ImageSet *mImageSet;
Being *mBeing;
std::vector<EquipmentBox*> mBoxes;
- gcn::Color mHighlightColor;
- gcn::Color mBorderColor;
- gcn::Color mLabelsColor;
- gcn::Color mLabelsColor2;
+ Color mHighlightColor;
+ Color mBorderColor;
+ Color mLabelsColor;
+ Color mLabelsColor2;
Image *mSlotBackground;
Image *mSlotHighlightedBackground;
ImageCollection *mVertexes;
diff --git a/src/gui/windows/helpwindow.cpp b/src/gui/windows/helpwindow.cpp
index eb2300e0e..fa9963217 100644
--- a/src/gui/windows/helpwindow.cpp
+++ b/src/gui/windows/helpwindow.cpp
@@ -24,7 +24,7 @@
#include "configuration.h"
-#include "gui/sdlfont.h"
+#include "gui/gui.h"
#include "gui/windows/didyouknowwindow.h"
#include "gui/windows/setupwindow.h"
@@ -48,12 +48,13 @@
HelpWindow::HelpWindow() :
// TRANSLATORS: help window name
Window(_("Help"), false, nullptr, "help.xml"),
- gcn::ActionListener(),
+ ActionListener(),
// TRANSLATORS: help window. button.
mDYKButton(new Button(this, _("Did you know..."), "DYK", this)),
mBrowserBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true,
"browserbox.xml")),
- mScrollArea(new ScrollArea(mBrowserBox, true, "help_background.xml")),
+ mScrollArea(new ScrollArea(this, mBrowserBox,
+ true, "help_background.xml")),
mTagFileMap()
{
setMinWidth(300);
@@ -72,7 +73,8 @@ HelpWindow::HelpWindow() :
mBrowserBox->setOpaque(false);
mBrowserBox->setLinkHandler(this);
- mBrowserBox->setFont(gui->getHelpFont());
+ if (gui)
+ mBrowserBox->setFont(gui->getHelpFont());
mBrowserBox->setProcessVersion(true);
mBrowserBox->setEnableImages(true);
mBrowserBox->setEnableKeys(true);
@@ -87,10 +89,10 @@ HelpWindow::HelpWindow() :
loadWindowState();
loadTags();
enableVisibleSound(true);
- widgetResized(gcn::Event(nullptr));
+ widgetResized(Event(nullptr));
}
-void HelpWindow::action(const gcn::ActionEvent &event)
+void HelpWindow::action(const ActionEvent &event)
{
if (event.getId() == "DYK")
{
@@ -104,7 +106,7 @@ void HelpWindow::action(const gcn::ActionEvent &event)
}
void HelpWindow::handleLink(const std::string &link,
- gcn::MouseEvent *event A_UNUSED)
+ MouseEvent *event A_UNUSED)
{
if (!strStartWith(link, "http://") && !strStartWith(link, "https://"))
{
diff --git a/src/gui/windows/helpwindow.h b/src/gui/windows/helpwindow.h
index 72c0d4aba..4290c99f9 100644
--- a/src/gui/windows/helpwindow.h
+++ b/src/gui/windows/helpwindow.h
@@ -26,7 +26,7 @@
#include "gui/widgets/linkhandler.h"
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
#include "localconsts.h"
@@ -44,8 +44,9 @@ typedef std::map<std::string, HelpNames> HelpTagsMap;
/**
* The help window.
*/
-class HelpWindow final : public Window, public LinkHandler,
- public gcn::ActionListener
+class HelpWindow final : public Window,
+ public LinkHandler,
+ public ActionListener
{
public:
/**
@@ -58,13 +59,13 @@ class HelpWindow final : public Window, public LinkHandler,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Handles link action.
*/
void handleLink(const std::string &link,
- gcn::MouseEvent *event A_UNUSED) override final;
+ MouseEvent *event A_UNUSED) override final;
/**
* Loads help in the dialog.
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index 6fd2ab95b..ee8c85f06 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -28,11 +28,16 @@
#include "being/playerinfo.h"
+#include "events/keyevent.h"
+
#include "input/inputmanager.h"
-#include "input/keyevent.h"
+#include "gui/font.h"
+#include "gui/gui.h"
#include "gui/viewport.h"
+#include "gui/models/sortlistmodelinv.h"
+
#include "gui/popups/textpopup.h"
#include "gui/windows/equipmentwindow.h"
@@ -42,7 +47,6 @@
#include "gui/windows/shopwindow.h"
#include "gui/windows/tradewindow.h"
-
#include "gui/widgets/button.h"
#include "gui/widgets/dropdown.h"
#include "gui/widgets/itemcontainer.h"
@@ -57,53 +61,17 @@
#include "utils/gettext.h"
-#include <guichan/font.hpp>
-
#include <string>
#include "debug.h"
-static const char *const SORT_NAME_INVENTORY[6] =
-{
- // TRANSLATORS: inventory sort mode
- N_("default"),
- // TRANSLATORS: inventory sort mode
- N_("by name"),
- // TRANSLATORS: inventory sort mode
- N_("by id"),
- // TRANSLATORS: inventory sort mode
- N_("by weight"),
- // TRANSLATORS: inventory sort mode
- N_("by amount"),
- // TRANSLATORS: inventory sort mode
- N_("by type")
-};
-
-class SortListModelInv final : public gcn::ListModel
-{
-public:
- ~SortListModelInv()
- { }
-
- int getNumberOfElements() override final
- { return 6; }
-
- std::string getElementAt(int i) override final
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
-
- return gettext(SORT_NAME_INVENTORY[i]);
- }
-};
-
InventoryWindow::WindowList InventoryWindow::invInstances;
InventoryWindow::InventoryWindow(Inventory *const inventory):
Window("Inventory", false, nullptr, "inventory.xml"),
- gcn::ActionListener(),
- gcn::KeyListener(),
- gcn::SelectionListener(),
+ ActionListener(),
+ KeyListener(),
+ SelectionListener(),
InventoryListener(),
mInventory(inventory),
mItems(new ItemContainer(this, mInventory)),
@@ -183,8 +151,8 @@ InventoryWindow::InventoryWindow(Inventory *const inventory):
mItems->addSelectionListener(this);
- gcn::ScrollArea *const invenScroll = new ScrollArea(
- mItems, getOptionBool("showbackground"), "inventory_background.xml");
+ gcn::ScrollArea *const invenScroll = new ScrollArea(this, mItems,
+ getOptionBool("showbackground"), "inventory_background.xml");
invenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
const int size = config.getIntValue("fontSize");
@@ -295,7 +263,7 @@ void InventoryWindow::postInit()
slotsChanged(mInventory);
mItems->setSortType(mSortDropDown->getSelected());
- widgetResized(gcn::Event(nullptr));
+ widgetResized(Event(nullptr));
if (!isMainInventory())
setVisible(true);
}
@@ -335,7 +303,7 @@ void InventoryWindow::storeSortOrder()
}
}
-void InventoryWindow::action(const gcn::ActionEvent &event)
+void InventoryWindow::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "outfit")
@@ -459,13 +427,13 @@ void InventoryWindow::unselectItem()
mItems->selectNone();
}
-void InventoryWindow::widgetHidden(const gcn::Event &event)
+void InventoryWindow::widgetHidden(const Event &event)
{
Window::widgetHidden(event);
mItems->hidePopup();
}
-void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
+void InventoryWindow::mouseClicked(MouseEvent &event)
{
Window::mouseClicked(event);
@@ -481,7 +449,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
&& inputManager.isActionActive(static_cast<int>(
Input::KEY_STOP_ATTACK)));
- if (!mod && !mod2 && event.getButton() == gcn::MouseEvent::RIGHT)
+ if (!mod && !mod2 && event.getButton() == MouseEvent::RIGHT)
{
Item *const item = mItems->getSelectedItem();
@@ -501,8 +469,8 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
if (!mInventory)
return;
- if (event.getButton() == gcn::MouseEvent::LEFT
- || event.getButton() == gcn::MouseEvent::RIGHT)
+ if (event.getButton() == MouseEvent::LEFT
+ || event.getButton() == MouseEvent::RIGHT)
{
Item *const item = mItems->getSelectedItem();
@@ -513,7 +481,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
{
if (mInventory->isMainInventory())
{
- if (event.getButton() == gcn::MouseEvent::RIGHT)
+ if (event.getButton() == MouseEvent::RIGHT)
{
ItemAmountWindow::showWindow(ItemAmountWindow::StoreAdd,
inventoryWindow, item);
@@ -527,7 +495,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
}
else
{
- if (event.getButton() == gcn::MouseEvent::RIGHT)
+ if (event.getButton() == MouseEvent::RIGHT)
{
ItemAmountWindow::showWindow(ItemAmountWindow::StoreRemove,
inventoryWindow, item);
@@ -544,7 +512,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
{
if (PlayerInfo::isItemProtected(item->getId()))
return;
- if (event.getButton() == gcn::MouseEvent::RIGHT)
+ if (event.getButton() == MouseEvent::RIGHT)
{
ItemAmountWindow::showWindow(ItemAmountWindow::TradeAdd,
tradeWindow, item);
@@ -588,15 +556,15 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
}
}
-void InventoryWindow::mouseMoved(gcn::MouseEvent &event)
+void InventoryWindow::mouseMoved(MouseEvent &event)
{
Window::mouseMoved(event);
- const gcn::Widget *const src = event.getSource();
+ const Widget *const src = event.getSource();
if (src == mSlotsBar || src == mWeightBar)
{
const int x = event.getX();
const int y = event.getY();
- const gcn::Rectangle &rect = mDimension;
+ const Rect &rect = mDimension;
mTextPopup->show(rect.x + x, rect.y + y, strprintf(_("Money: %s"),
Units::formatCurrency(PlayerInfo::getAttribute(
PlayerInfo::MONEY)).c_str()));
@@ -607,30 +575,24 @@ void InventoryWindow::mouseMoved(gcn::MouseEvent &event)
}
}
-void InventoryWindow::mouseExited(gcn::MouseEvent &event A_UNUSED)
+void InventoryWindow::mouseExited(MouseEvent &event A_UNUSED)
{
mTextPopup->hide();
}
-void InventoryWindow::keyPressed(gcn::KeyEvent &event)
+void InventoryWindow::keyPressed(KeyEvent &event)
{
- if (static_cast<KeyEvent*>(&event)->getActionId()
- == static_cast<int>(Input::KEY_GUI_MOD))
- {
+ if (event.getActionId() == static_cast<int>(Input::KEY_GUI_MOD))
mSplit = true;
- }
}
-void InventoryWindow::keyReleased(gcn::KeyEvent &event)
+void InventoryWindow::keyReleased(KeyEvent &event)
{
- if (static_cast<KeyEvent*>(&event)->getActionId()
- == static_cast<int>(Input::KEY_GUI_MOD))
- {
+ if (event.getActionId() == static_cast<int>(Input::KEY_GUI_MOD))
mSplit = false;
- }
}
-void InventoryWindow::valueChanged(const gcn::SelectionEvent &event A_UNUSED)
+void InventoryWindow::valueChanged(const SelectionEvent &event A_UNUSED)
{
if (!mInventory || !mInventory->isMainInventory())
return;
@@ -812,7 +774,7 @@ bool InventoryWindow::isAnyInputFocused()
return false;
}
-void InventoryWindow::widgetResized(const gcn::Event &event)
+void InventoryWindow::widgetResized(const Event &event)
{
Window::widgetResized(event);
diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h
index 4e32f6fa2..c81e83d77 100644
--- a/src/gui/windows/inventorywindow.h
+++ b/src/gui/windows/inventorywindow.h
@@ -24,19 +24,19 @@
#define GUI_WINDOWS_INVENTORYWINDOW_H
#include "inventory.h"
-#include "depricatedlistener.h"
+
+#include "listeners/depricatedlistener.h"
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
-#include <guichan/selectionlistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/keylistener.h"
+#include "listeners/selectionlistener.h"
class Button;
class DropDown;
class Item;
class ItemContainer;
-class Label;
class LayoutCell;
class ProgressBar;
class SortListModelInv;
@@ -50,9 +50,9 @@ class TextPopup;
* \ingroup Interface
*/
class InventoryWindow final : public Window,
- public gcn::ActionListener,
- public gcn::KeyListener,
- public gcn::SelectionListener,
+ public ActionListener,
+ public KeyListener,
+ public SelectionListener,
public InventoryListener,
public DepricatedListener
{
@@ -76,7 +76,7 @@ class InventoryWindow final : public Window,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Returns the selected item.
@@ -91,27 +91,27 @@ class InventoryWindow final : public Window,
/**
* Handles closing of the window
*/
- void widgetHidden(const gcn::Event &event) override final;
+ void widgetHidden(const Event &event) override final;
/**
* Handles the mouse clicks.
*/
- void mouseClicked(gcn::MouseEvent &event) override final;
+ void mouseClicked(MouseEvent &event) override final;
/**
* Handles the key presses.
*/
- void keyPressed(gcn::KeyEvent &event) override final;
+ void keyPressed(KeyEvent &event) override final;
/**
* Handles the key releases.
*/
- void keyReleased(gcn::KeyEvent &event) override final;
+ void keyReleased(KeyEvent &event) override final;
/**
* Updates labels to currently selected item.
*/
- void valueChanged(const gcn::SelectionEvent &event) override final;
+ void valueChanged(const SelectionEvent &event) override final;
/**
* Sets whether the split button should be shown.
@@ -144,11 +144,11 @@ class InventoryWindow final : public Window,
bool isInputFocused() const A_WARN_UNUSED;
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
- void mouseMoved(gcn::MouseEvent &event) override final;
+ void mouseMoved(MouseEvent &event) override final;
- void mouseExited(gcn::MouseEvent &event) override final;
+ void mouseExited(MouseEvent &event) override final;
void setVisible(bool visible) override final;
diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp
index 975892888..fc0c5880b 100644
--- a/src/gui/windows/itemamountwindow.cpp
+++ b/src/gui/windows/itemamountwindow.cpp
@@ -33,6 +33,8 @@
#include "net/net.h"
#include "gui/viewport.h"
+#include "gui/models/itemsmodel.h"
+
#include "gui/popups/itempopup.h"
#include "gui/windows/shopwindow.h"
@@ -50,55 +52,6 @@
#include "debug.h"
-class ItemsModal final : public gcn::ListModel
-{
-public:
- ItemsModal() :
- mStrings()
- {
- const std::map<int, ItemInfo*> &items = ItemDB::getItemInfos();
- std::list<std::string> tempStrings;
-
- for (std::map<int, ItemInfo*>::const_iterator
- i = items.begin(), i_end = items.end();
- i != i_end; ++i)
- {
- if (i->first < 0)
- continue;
-
- const ItemInfo &info = *i->second;
- const std::string name = info.getName();
- if (name != "unnamed" && !info.getName().empty()
- && info.getName() != "unnamed")
- {
- tempStrings.push_back(name);
- }
- }
- tempStrings.sort();
- FOR_EACH (std::list<std::string>::const_iterator, i, tempStrings)
- mStrings.push_back(*i);
- }
-
- A_DELETE_COPY(ItemsModal)
-
- ~ItemsModal()
- { }
-
- int getNumberOfElements() override final
- {
- return static_cast<int>(mStrings.size());
- }
-
- std::string getElementAt(int i) override final
- {
- if (i < 0 || i >= getNumberOfElements())
- return "???";
- return mStrings.at(i);
- }
-private:
- StringVect mStrings;
-};
-
void ItemAmountWindow::finish(Item *const item, const int amount,
const int price, const Usage usage)
{
@@ -138,8 +91,8 @@ void ItemAmountWindow::finish(Item *const item, const int amount,
ItemAmountWindow::ItemAmountWindow(const Usage usage, Window *const parent,
Item *const item, const int maxRange) :
Window("", false, parent, "amount.xml"),
- gcn::ActionListener(),
- gcn::KeyListener(),
+ ActionListener(),
+ KeyListener(),
mItemAmountTextField(new IntTextField(this, 1)),
mItemPriceTextField(nullptr),
mGPLabel(nullptr),
@@ -148,7 +101,7 @@ ItemAmountWindow::ItemAmountWindow(const Usage usage, Window *const parent,
mMax(maxRange),
mUsage(usage),
mItemPopup(new ItemPopup),
- mItemAmountSlide(new Slider(1.0, mMax)),
+ mItemAmountSlide(new Slider(this, 1.0, mMax)),
mItemPriceSlide(nullptr),
mItemDropDown(nullptr),
mItemsModal(nullptr),
@@ -182,7 +135,7 @@ ItemAmountWindow::ItemAmountWindow(const Usage usage, Window *const parent,
mItemPriceTextField->setWidth(35);
mItemPriceTextField->addKeyListener(this);
- mItemPriceSlide = new Slider(1.0, 10000000);
+ mItemPriceSlide = new Slider(this, 1.0, 10000000);
mItemPriceSlide->setHeight(10);
mItemPriceSlide->setActionEventId("slidePrice");
mItemPriceSlide->addActionListener(this);
@@ -313,7 +266,7 @@ ItemAmountWindow::~ItemAmountWindow()
}
// Show ItemTooltip
-void ItemAmountWindow::mouseMoved(gcn::MouseEvent &event)
+void ItemAmountWindow::mouseMoved(MouseEvent &event)
{
Window::mouseMoved(event);
@@ -328,7 +281,7 @@ void ItemAmountWindow::mouseMoved(gcn::MouseEvent &event)
}
// Hide ItemTooltip
-void ItemAmountWindow::mouseExited(gcn::MouseEvent &event A_UNUSED)
+void ItemAmountWindow::mouseExited(MouseEvent &event A_UNUSED)
{
if (mItemPopup)
mItemPopup->setVisible(false);
@@ -339,7 +292,7 @@ void ItemAmountWindow::resetAmount()
mItemAmountTextField->setValue(1);
}
-void ItemAmountWindow::action(const gcn::ActionEvent &event)
+void ItemAmountWindow::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "cancel")
@@ -435,7 +388,7 @@ void ItemAmountWindow::close()
scheduleDelete();
}
-void ItemAmountWindow::keyReleased(gcn::KeyEvent &keyEvent A_UNUSED)
+void ItemAmountWindow::keyReleased(KeyEvent &keyEvent A_UNUSED)
{
mItemAmountSlide->setValue2(mItemAmountTextField->getValue());
}
diff --git a/src/gui/windows/itemamountwindow.h b/src/gui/windows/itemamountwindow.h
index 7625c4a71..cf721ee30 100644
--- a/src/gui/windows/itemamountwindow.h
+++ b/src/gui/windows/itemamountwindow.h
@@ -25,8 +25,8 @@
#include "gui/widgets/window.h"
-#include <guichan/keylistener.hpp>
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/keylistener.h"
class DropDown;
class Icon;
@@ -43,8 +43,8 @@ class Slider;
* \ingroup Interface
*/
class ItemAmountWindow final : public Window,
- public gcn::ActionListener,
- public gcn::KeyListener
+ public ActionListener,
+ public KeyListener
{
public:
enum Usage
@@ -65,7 +65,7 @@ class ItemAmountWindow final : public Window,
/**
* Called when receiving actions from widget.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Sets default amount value.
@@ -73,16 +73,16 @@ class ItemAmountWindow final : public Window,
void resetAmount();
// MouseListener
- void mouseMoved(gcn::MouseEvent &event) override final;
+ void mouseMoved(MouseEvent &event) override final;
- void mouseExited(gcn::MouseEvent &event) override final;
+ void mouseExited(MouseEvent &event) override final;
/**
* Schedules the Item Amount window for deletion.
*/
void close();
- void keyReleased(gcn::KeyEvent &keyEvent) override final;
+ void keyReleased(KeyEvent &keyEvent) override final;
/**
* Creates the dialog, or bypass it if there aren't enough items.
diff --git a/src/gui/windows/killstats.cpp b/src/gui/windows/killstats.cpp
index 0adabc3ad..710875a3c 100644
--- a/src/gui/windows/killstats.cpp
+++ b/src/gui/windows/killstats.cpp
@@ -40,7 +40,7 @@
KillStats::KillStats() :
// TRANSLATORS: kill stats window name
Window(_("Kill stats"), false, nullptr, "killstats.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mKillCounter(0),
mExpCounter(0),
mKillTCounter(0),
@@ -156,7 +156,7 @@ KillStats::~KillStats()
{
}
-void KillStats::action(const gcn::ActionEvent &event)
+void KillStats::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "reset")
diff --git a/src/gui/windows/killstats.h b/src/gui/windows/killstats.h
index 094147383..486ec9135 100644
--- a/src/gui/windows/killstats.h
+++ b/src/gui/windows/killstats.h
@@ -23,9 +23,8 @@
#ifndef GUI_WINDOWS_KILLSTATS_H
#define GUI_WINDOWS_KILLSTATS_H
-#include <guichan/actionlistener.hpp>
-
-#include "depricatedlistener.h"
+#include "listeners/actionlistener.h"
+#include "listeners/depricatedlistener.h"
#include "gui/widgets/window.h"
@@ -33,7 +32,7 @@ class Label;
class Button;
class KillStats final : public Window,
- private gcn::ActionListener,
+ private ActionListener,
public DepricatedListener
{
public:
@@ -52,7 +51,7 @@ class KillStats final : public Window,
/**
* Stuff.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void gainXp(int Xp);
diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp
index 8ec6144a0..71abf153a 100644
--- a/src/gui/windows/logindialog.cpp
+++ b/src/gui/windows/logindialog.cpp
@@ -25,8 +25,12 @@
#include "client.h"
#include "configuration.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
+
+#include "gui/models/updatelistmodel.h"
+#include "gui/models/updatetypemodel.h"
#include "gui/windows/confirmdialog.h"
@@ -53,17 +57,17 @@ std::string LoginDialog::savedPasswordKey("");
namespace
{
- struct OpenUrlListener : public gcn::ActionListener
+ struct OpenUrlListener : public ActionListener
{
OpenUrlListener() :
- gcn::ActionListener(),
+ ActionListener(),
url()
{
}
A_DELETE_COPY(OpenUrlListener)
- void action(const gcn::ActionEvent &event) override final
+ void action(const ActionEvent &event) override final
{
if (event.getId() == "yes")
openBrowser(url);
@@ -73,78 +77,12 @@ namespace
} urlListener;
} // namespace
-const char *UPDATE_TYPE_TEXT[3] =
-{
- // TRANSLATORS: update type
- N_("Normal"),
- // TRANSLATORS: update type
- N_("Auto Close"),
- // TRANSLATORS: update type
- N_("Skip"),
-};
-
-class UpdateTypeModel final : public gcn::ListModel
-{
- public:
- UpdateTypeModel()
- { }
-
- A_DELETE_COPY(UpdateTypeModel)
-
- ~UpdateTypeModel()
- { }
-
- int getNumberOfElements() override final
- {
- return 3;
- }
-
- std::string getElementAt(int i) override final
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
- return gettext(UPDATE_TYPE_TEXT[i]);
- }
-};
-
-class UpdateListModel final : public gcn::ListModel
-{
- public:
- explicit UpdateListModel(LoginData *const data) :
- gcn::ListModel(),
- mLoginData(data)
- {
- }
-
- A_DELETE_COPY(UpdateListModel)
-
- ~UpdateListModel()
- { }
-
- int getNumberOfElements() override final
- {
- if (!mLoginData)
- return 0;
- return static_cast<int>(mLoginData->updateHosts.size());
- }
-
- std::string getElementAt(int i) override final
- {
- if (!mLoginData || i >= getNumberOfElements() || i < 0)
- return "???";
- return mLoginData->updateHosts[i];
- }
-
- protected:
- LoginData *mLoginData;
-};
-
LoginDialog::LoginDialog(LoginData *const data, std::string serverName,
std::string *const updateHost):
// TRANSLATORS: login dialog name
Window(_("Login"), false, nullptr, "login.xml"),
- gcn::ActionListener(),
- gcn::KeyListener(),
+ ActionListener(),
+ KeyListener(),
mLoginData(data),
mUserField(new TextField(this, mLoginData->username)),
mPassField(new PasswordField(this, mLoginData->password)),
@@ -276,7 +214,7 @@ LoginDialog::~LoginDialog()
mUpdateListModel = nullptr;
}
-void LoginDialog::action(const gcn::ActionEvent &event)
+void LoginDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "login" && canSubmit())
@@ -318,7 +256,7 @@ void LoginDialog::action(const gcn::ActionEvent &event)
}
}
-void LoginDialog::keyPressed(gcn::KeyEvent &keyEvent)
+void LoginDialog::keyPressed(KeyEvent &keyEvent)
{
if (keyEvent.isConsumed())
{
@@ -326,16 +264,15 @@ void LoginDialog::keyPressed(gcn::KeyEvent &keyEvent)
return;
}
- const int actionId = static_cast<KeyEvent*>(
- &keyEvent)->getActionId();
+ const int actionId = keyEvent.getActionId();
if (actionId == static_cast<int>(Input::KEY_GUI_CANCEL))
{
- action(gcn::ActionEvent(nullptr, mServerButton->getActionEventId()));
+ action(ActionEvent(nullptr, mServerButton->getActionEventId()));
}
else if (actionId == static_cast<int>(Input::KEY_GUI_SELECT)
|| actionId == static_cast<int>(Input::KEY_GUI_SELECT2))
{
- action(gcn::ActionEvent(nullptr, mLoginButton->getActionEventId()));
+ action(ActionEvent(nullptr, mLoginButton->getActionEventId()));
}
else
{
diff --git a/src/gui/windows/logindialog.h b/src/gui/windows/logindialog.h
index c9d2ad61f..7150b62c1 100644
--- a/src/gui/windows/logindialog.h
+++ b/src/gui/windows/logindialog.h
@@ -25,8 +25,8 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/keylistener.h"
#include <string>
@@ -44,8 +44,9 @@ class UpdateTypeModel;
*
* \ingroup Interface
*/
-class LoginDialog final : public Window, public gcn::ActionListener,
- public gcn::KeyListener
+class LoginDialog final : public Window,
+ public ActionListener,
+ public KeyListener
{
public:
/**
@@ -65,12 +66,12 @@ class LoginDialog final : public Window, public gcn::ActionListener,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Called when a key is pressed in one of the text fields.
*/
- void keyPressed(gcn::KeyEvent &keyEvent) override final;
+ void keyPressed(KeyEvent &keyEvent) override final;
void close() override final;
diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp
index 02be64a13..ef1830763 100644
--- a/src/gui/windows/minimap.cpp
+++ b/src/gui/windows/minimap.cpp
@@ -213,7 +213,7 @@ void Minimap::setMap(const Map *const map)
setHeight(height);
}
- const gcn::Rectangle &rect = mDimension;
+ const Rect &rect = mDimension;
setDefaultSize(rect.x, rect.y, rect.width, rect.height);
resetToDefaultSize();
@@ -233,7 +233,7 @@ void Minimap::toggle()
mShow = isWindowVisible();
}
-void Minimap::draw(gcn::Graphics *graphics)
+void Minimap::draw(Graphics *graphics)
{
BLOCK_START("Minimap::draw")
Window::draw(graphics);
@@ -244,9 +244,7 @@ void Minimap::draw(gcn::Graphics *graphics)
return;
}
- Graphics *const graph = static_cast<Graphics*>(graphics);
-
- const gcn::Rectangle a = getChildrenArea();
+ const Rect a = getChildrenArea();
graphics->pushClipArea(a);
@@ -286,7 +284,7 @@ void Minimap::draw(gcn::Graphics *graphics)
mMapOriginY = 0;
}
- graph->drawImage2(mMapImage, mMapOriginX, mMapOriginY);
+ graphics->drawImage(mMapImage, mMapOriginX, mMapOriginY);
}
const ActorSprites &actors = actorManager->getAll();
@@ -348,7 +346,7 @@ void Minimap::draw(gcn::Graphics *graphics)
dotSize - 1) * mWidthProportion);
const Vector &pos = being->getPosition();
- graphics->fillRectangle(gcn::Rectangle(
+ graphics->fillRectangle(Rect(
static_cast<float>(pos.x * mWidthProportion) / 32
+ mMapOriginX - offsetWidth,
static_cast<float>(pos.y * mHeightProportion) / 32
@@ -386,7 +384,7 @@ void Minimap::draw(gcn::Graphics *graphics)
const int offsetWidth = static_cast<int>(
mWidthProportion);
- graphics->fillRectangle(gcn::Rectangle(
+ graphics->fillRectangle(Rect(
static_cast<int>(member->getX()
* mWidthProportion) + mMapOriginX - offsetWidth,
static_cast<int>(member->getY()
@@ -401,8 +399,8 @@ void Minimap::draw(gcn::Graphics *graphics)
const Vector &pos = player_node->getPosition();
- const int gw = graph->getWidth();
- const int gh = graph->getHeight();
+ const int gw = graphics->getWidth();
+ const int gh = graphics->getHeight();
int x = static_cast<float>((pos.x - (gw / 2)
+ viewport->getCameraRelativeX())
* mWidthProportion) / 32 + mMapOriginX;
@@ -431,19 +429,19 @@ void Minimap::draw(gcn::Graphics *graphics)
}
graphics->setColor(userPalette->getColor(UserPalette::PC));
- graphics->drawRectangle(gcn::Rectangle(x, y, w, h));
+ graphics->drawRectangle(Rect(x, y, w, h));
graphics->popClipArea();
BLOCK_END("Minimap::draw")
}
-void Minimap::mouseReleased(gcn::MouseEvent &event)
+void Minimap::mouseReleased(MouseEvent &event)
{
Window::mouseReleased(event);
if (!player_node || !viewport)
return;
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ if (event.getButton() == MouseEvent::LEFT)
{
int x = event.getX();
int y = event.getY();
@@ -451,7 +449,7 @@ void Minimap::mouseReleased(gcn::MouseEvent &event)
player_node->navigateTo(x, y);
}
- else if (event.getButton() == gcn::MouseEvent::RIGHT)
+ else if (event.getButton() == MouseEvent::RIGHT)
{
int x = event.getX();
int y = event.getY();
@@ -460,16 +458,16 @@ void Minimap::mouseReleased(gcn::MouseEvent &event)
}
}
-void Minimap::mouseMoved(gcn::MouseEvent &event)
+void Minimap::mouseMoved(MouseEvent &event)
{
Window::mouseMoved(event);
const int x = event.getX();
const int y = event.getY();
- const gcn::Rectangle &rect = mDimension;
+ const Rect &rect = mDimension;
mTextPopup->show(x + rect.x, y + rect.y, mCaption);
}
-void Minimap::mouseExited(gcn::MouseEvent &event)
+void Minimap::mouseExited(MouseEvent &event)
{
Window::mouseExited(event);
mTextPopup->hide();
@@ -477,7 +475,7 @@ void Minimap::mouseExited(gcn::MouseEvent &event)
void Minimap::screenToMap(int &x, int &y)
{
- const gcn::Rectangle a = getChildrenArea();
+ const Rect a = getChildrenArea();
x = (x - a.x - mMapOriginX + mWidthProportion) / mWidthProportion;
y = (y - a.y - mMapOriginY + mHeightProportion) / mHeightProportion;
}
diff --git a/src/gui/windows/minimap.h b/src/gui/windows/minimap.h
index 90c08db0f..d99aea13d 100644
--- a/src/gui/windows/minimap.h
+++ b/src/gui/windows/minimap.h
@@ -60,13 +60,13 @@ class Minimap final : public Window, public ConfigListener
/**
* Draws the minimap.
*/
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
- void mouseMoved(gcn::MouseEvent &event) override final;
+ void mouseMoved(MouseEvent &event) override final;
- void mouseReleased(gcn::MouseEvent &event) override final;
+ void mouseReleased(MouseEvent &event) override final;
- void mouseExited(gcn::MouseEvent &event) override final;
+ void mouseExited(MouseEvent &event) override final;
void screenToMap(int &x, int &y);
diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp
index b5832c7b7..db4555b26 100644
--- a/src/gui/windows/ministatuswindow.cpp
+++ b/src/gui/windows/ministatuswindow.cpp
@@ -308,21 +308,21 @@ void MiniStatusWindow::logic()
BLOCK_END("MiniStatusWindow::logic")
}
-void MiniStatusWindow::draw(gcn::Graphics *graphics)
+void MiniStatusWindow::draw(Graphics *graphics)
{
BLOCK_START("MiniStatusWindow::draw")
drawChildren(graphics);
BLOCK_END("MiniStatusWindow::draw")
}
-void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event)
+void MiniStatusWindow::mouseMoved(MouseEvent &event)
{
Popup::mouseMoved(event);
const int x = event.getX();
const int y = event.getY();
- const gcn::Rectangle &rect = mDimension;
+ const Rect &rect = mDimension;
if (event.getSource() == mStatusBar)
{
mStatusPopup->view(x + rect.x, y + rect.y);
@@ -433,12 +433,12 @@ void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event)
}
}
-void MiniStatusWindow::mousePressed(gcn::MouseEvent &event)
+void MiniStatusWindow::mousePressed(MouseEvent &event)
{
if (!viewport)
return;
- if (event.getButton() == gcn::MouseEvent::RIGHT)
+ if (event.getButton() == MouseEvent::RIGHT)
{
const ProgressBar *const bar = dynamic_cast<ProgressBar*>(
event.getSource());
@@ -452,7 +452,7 @@ void MiniStatusWindow::mousePressed(gcn::MouseEvent &event)
}
}
-void MiniStatusWindow::mouseExited(gcn::MouseEvent &event)
+void MiniStatusWindow::mouseExited(MouseEvent &event)
{
Popup::mouseExited(event);
@@ -535,12 +535,12 @@ void MiniStatusWindow::updateArrows()
StatusWindow::updateArrowsBar(mArrowsBar);
}
-gcn::Rectangle MiniStatusWindow::getChildrenArea()
+Rect MiniStatusWindow::getChildrenArea()
{
const int padding = mPadding;
const int padding2 = padding * 2;
- const gcn::Rectangle &rect = mDimension;
- return gcn::Rectangle(padding, padding,
+ const Rect &rect = mDimension;
+ return Rect(padding, padding,
rect.width - padding2,
rect.height - padding2);
}
diff --git a/src/gui/windows/ministatuswindow.h b/src/gui/windows/ministatuswindow.h
index 2a5903eca..0344d6c3a 100644
--- a/src/gui/windows/ministatuswindow.h
+++ b/src/gui/windows/ministatuswindow.h
@@ -24,7 +24,8 @@
#define GUI_WINDOWS_MINISTATUSWINDOW_H
#include "inventory.h"
-#include "depricatedlistener.h"
+
+#include "listeners/depricatedlistener.h"
#include "gui/widgets/popup.h"
@@ -68,13 +69,13 @@ class MiniStatusWindow final : public Popup,
void logic() override final;
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
- void mouseMoved(gcn::MouseEvent &mouseEvent) override final;
+ void mouseMoved(MouseEvent &mouseEvent) override final;
- void mousePressed(gcn::MouseEvent &event) override final;
+ void mousePressed(MouseEvent &event) override final;
- void mouseExited(gcn::MouseEvent &event) override final;
+ void mouseExited(MouseEvent &event) override final;
void showBar(const std::string &name, const bool visible);
@@ -87,7 +88,7 @@ class MiniStatusWindow final : public Popup,
std::vector <ProgressBar*> &getBars() A_WARN_UNUSED
{ return mBars; }
- gcn::Rectangle getChildrenArea() override final A_WARN_UNUSED;
+ Rect getChildrenArea() override final A_WARN_UNUSED;
#ifdef USE_PROFILER
void logicChildren();
diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp
index b441b724c..a1b2109fb 100644
--- a/src/gui/windows/npcdialog.cpp
+++ b/src/gui/windows/npcdialog.cpp
@@ -32,8 +32,8 @@
#include "being/being.h"
+#include "gui/font.h"
#include "gui/gui.h"
-#include "gui/sdlfont.h"
#include "gui/viewport.h"
#include "gui/windows/inventorywindow.h"
@@ -59,8 +59,6 @@
#include "utils/copynpaste.h"
#include "utils/gettext.h"
-#include <guichan/font.hpp>
-
#include "debug.h"
// TRANSLATORS: npc dialog button
@@ -80,18 +78,18 @@ typedef std::vector<Image *>::iterator ImageVectorIter;
NpcDialog::NpcDialog(const int npcId) :
// TRANSLATORS: npc dialog name
Window(_("NPC"), false, nullptr, "npc.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mNpcId(npcId),
mDefaultInt(0),
mDefaultString(),
mTextBox(new BrowserBox(this, BrowserBox::AUTO_WRAP, true,
"browserbox.xml")),
- mScrollArea(new ScrollArea(mTextBox,
+ mScrollArea(new ScrollArea(this, mTextBox,
getOptionBool("showtextbackground"), "npc_textbackground.xml")),
mText(),
mNewText(),
mItemList(new ExtendedListBox(this, this, "extendedlistbox.xml")),
- mListScrollArea(new ScrollArea(mItemList,
+ mListScrollArea(new ScrollArea(this, mItemList,
getOptionBool("showlistbackground"), "npc_listbackground.xml")),
mItems(),
mImages(),
@@ -113,7 +111,7 @@ NpcDialog::NpcDialog(const int npcId) :
mResetButton(new Button(this, _("Reset"), "reset", this)),
mInventory(new Inventory(Inventory::NPC, 1)),
mItemContainer(new ItemContainer(this, mInventory)),
- mItemScrollArea(new ScrollArea(mItemContainer,
+ mItemScrollArea(new ScrollArea(this, mItemContainer,
getOptionBool("showitemsbackground"), "npc_listbackground.xml")),
mInputState(NPC_INPUT_NONE),
mActionState(NPC_ACTION_WAIT),
@@ -170,7 +168,7 @@ NpcDialog::NpcDialog(const int npcId) :
mTextField->setVisible(true);
mIntField->setVisible(true);
- const gcn::Font *const fnt = mButton->getFont();
+ const Font *const fnt = mButton->getFont();
int width = std::max(fnt->getWidth(CAPTION_WAITING),
fnt->getWidth(CAPTION_NEXT));
width = std::max(width, fnt->getWidth(CAPTION_CLOSE));
@@ -295,7 +293,7 @@ void NpcDialog::showCloseButton()
buildLayout();
}
-void NpcDialog::action(const gcn::ActionEvent &event)
+void NpcDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "ok")
@@ -965,10 +963,10 @@ void NpcDialog::clearDialogs()
mNpcDialogs.clear();
}
-void NpcDialog::mousePressed(gcn::MouseEvent &event)
+void NpcDialog::mousePressed(MouseEvent &event)
{
Window::mousePressed(event);
- if (event.getButton() == gcn::MouseEvent::RIGHT
+ if (event.getButton() == MouseEvent::RIGHT
&& event.getSource() == mTextBox)
{
if (viewport)
diff --git a/src/gui/windows/npcdialog.h b/src/gui/windows/npcdialog.h
index 5e679d7d1..5188c2fe2 100644
--- a/src/gui/windows/npcdialog.h
+++ b/src/gui/windows/npcdialog.h
@@ -23,14 +23,15 @@
#ifndef GUI_WINDOWS_NPCDIALOG_H
#define GUI_WINDOWS_NPCDIALOG_H
-#include "configlistener.h"
+#include "listeners/configlistener.h"
+
+#include "gui/models/extendedlistmodel.h"
-#include "gui/widgets/extendedlistmodel.h"
#include "gui/widgets/window.h"
#include "utils/stringvector.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
#include <list>
@@ -45,7 +46,6 @@ class ItemContainer;
class NpcDialog;
class PlayerBox;
class ScrollArea;
-class TextBox;
class TextField;
typedef std::map<int, NpcDialog*> NpcDialogs;
@@ -56,7 +56,7 @@ typedef std::map<int, NpcDialog*> NpcDialogs;
* \ingroup Interface
*/
class NpcDialog final : public Window,
- public gcn::ActionListener,
+ public ActionListener,
public ExtendedListModel,
public ConfigListener
{
@@ -77,7 +77,7 @@ class NpcDialog final : public Window,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Sets the text shows in the dialog.
@@ -210,7 +210,7 @@ class NpcDialog final : public Window,
void clearRows();
- void mousePressed(gcn::MouseEvent &event);
+ void mousePressed(MouseEvent &event);
int isCloseState() const
{ return mActionState == NPC_ACTION_CLOSE; }
diff --git a/src/gui/windows/npcpostdialog.cpp b/src/gui/windows/npcpostdialog.cpp
index 63ae6f53b..3c63775fe 100644
--- a/src/gui/windows/npcpostdialog.cpp
+++ b/src/gui/windows/npcpostdialog.cpp
@@ -42,7 +42,7 @@ NpcPostDialog::DialogList NpcPostDialog::instances;
NpcPostDialog::NpcPostDialog(const int npcId):
// TRANSLATORS: npc post dialog caption
Window(_("NPC"), false, nullptr, "npcpost.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mNpcId(npcId),
mText(new TextBox(this)),
mSender(new TextField(this))
@@ -74,9 +74,9 @@ void NpcPostDialog::postInit()
mText->setEditable(true);
// create scroll box for letter text
- ScrollArea *const scrollArea = new ScrollArea(mText);
+ ScrollArea *const scrollArea = new ScrollArea(this, mText);
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- scrollArea->setDimension(gcn::Rectangle(
+ scrollArea->setDimension(Rect(
5, mSender->getHeight() + 5,
380, 140 - (mSender->getHeight() + sendButton->getHeight())));
@@ -98,7 +98,7 @@ NpcPostDialog::~NpcPostDialog()
instances.remove(this);
}
-void NpcPostDialog::action(const gcn::ActionEvent &event)
+void NpcPostDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "send")
diff --git a/src/gui/windows/npcpostdialog.h b/src/gui/windows/npcpostdialog.h
index e111f150e..5396aad6e 100644
--- a/src/gui/windows/npcpostdialog.h
+++ b/src/gui/windows/npcpostdialog.h
@@ -25,13 +25,13 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
class TextBox;
class TextField;
class NpcPostDialog final : public Window,
- public gcn::ActionListener
+ public ActionListener
{
public:
/**
@@ -48,7 +48,7 @@ class NpcPostDialog final : public Window,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void setVisible(bool visible) override final;
diff --git a/src/gui/windows/okdialog.cpp b/src/gui/windows/okdialog.cpp
index c16123abd..3d734b7ad 100644
--- a/src/gui/windows/okdialog.cpp
+++ b/src/gui/windows/okdialog.cpp
@@ -30,7 +30,7 @@
#include "utils/gettext.h"
-#include <guichan/font.hpp>
+#include "gui/font.h"
#include "debug.h"
@@ -40,7 +40,7 @@ OkDialog::OkDialog(const std::string &restrict title,
const bool showCenter, Window *const parent,
const int minWidth) :
Window(title, modal, parent, "ok.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mTextBox(new TextBox(this))
{
mTextBox->setEditable(false);
@@ -84,7 +84,7 @@ OkDialog::OkDialog(const std::string &restrict title,
soundManager.playGuiSound(SOUND_ERROR);
}
-void OkDialog::action(const gcn::ActionEvent &event)
+void OkDialog::action(const ActionEvent &event)
{
setActionEventId(event.getId());
distributeActionEvent();
diff --git a/src/gui/windows/okdialog.h b/src/gui/windows/okdialog.h
index 7d2ff070b..b8236dfbc 100644
--- a/src/gui/windows/okdialog.h
+++ b/src/gui/windows/okdialog.h
@@ -27,7 +27,7 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
class TextBox;
@@ -44,7 +44,7 @@ enum
* \ingroup GUI
*/
class OkDialog final : public Window,
- public gcn::ActionListener
+ public ActionListener
{
public:
/**
@@ -63,7 +63,7 @@ class OkDialog final : public Window,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
private:
TextBox *mTextBox;
diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp
index d686056ac..6fcea7d3a 100644
--- a/src/gui/windows/outfitwindow.cpp
+++ b/src/gui/windows/outfitwindow.cpp
@@ -51,7 +51,7 @@
OutfitWindow::OutfitWindow():
// TRANSLATORS: outfits window name
Window(_("Outfits"), false, nullptr, "outfits.xml"),
- gcn::ActionListener(),
+ ActionListener(),
// TRANSLATORS: outfits window button
mPreviousButton(new Button(this, _("<"), "previous", this)),
// TRANSLATORS: outfits window button
@@ -91,8 +91,8 @@ OutfitWindow::OutfitWindow():
setMinWidth(145);
setMinHeight(220);
- mCurrentLabel->setAlignment(gcn::Graphics::CENTER);
- mKeyLabel->setAlignment(gcn::Graphics::CENTER);
+ mCurrentLabel->setAlignment(Graphics::CENTER);
+ mKeyLabel->setAlignment(Graphics::CENTER);
mUnequipCheck->setActionEventId("unequip");
mUnequipCheck->addActionListener(this);
@@ -225,7 +225,7 @@ void OutfitWindow::save() const
serverConfig.setValue("OutfitAwayIndex", mAwayOutfit);
}
-void OutfitWindow::action(const gcn::ActionEvent &event)
+void OutfitWindow::action(const ActionEvent &event)
{
const std::string eventId = event.getId();
if (eventId == "next")
@@ -310,11 +310,10 @@ void OutfitWindow::copyOutfit(const int src, const int dst)
save();
}
-void OutfitWindow::draw(gcn::Graphics *graphics)
+void OutfitWindow::draw(Graphics *graphics)
{
BLOCK_START("OutfitWindow::draw")
Window::draw(graphics);
- Graphics *const g = static_cast<Graphics*>(graphics);
if (mCurrentOutfit < 0 || mCurrentOutfit
>= static_cast<signed int>(OUTFITS_COUNT))
@@ -326,12 +325,12 @@ void OutfitWindow::draw(gcn::Graphics *graphics)
{
const int itemX = mPadding + ((i % mGridWidth) * mBoxWidth);
const int itemY = mPadding + mTitleBarHeight
- + ((i / mGridWidth) * mBoxHeight);
+ + ((i / static_cast<unsigned int>(mGridWidth)) * mBoxHeight);
graphics->setColor(mBorderColor);
- graphics->drawRectangle(gcn::Rectangle(itemX, itemY, 32, 32));
+ graphics->drawRectangle(Rect(itemX, itemY, 32, 32));
graphics->setColor(mBackgroundColor);
- graphics->fillRectangle(gcn::Rectangle(itemX, itemY, 32, 32));
+ graphics->fillRectangle(Rect(itemX, itemY, 32, 32));
if (mItems[mCurrentOutfit][i] < 0)
continue;
@@ -348,7 +347,7 @@ void OutfitWindow::draw(gcn::Graphics *graphics)
const Image *const image = item->getImage();
if (image)
{
- g->drawImage2(image, itemX, itemY);
+ graphics->drawImage(image, itemX, itemY);
foundItem = true;
}
}
@@ -359,7 +358,7 @@ void OutfitWindow::draw(gcn::Graphics *graphics)
mItemColors[mCurrentOutfit][i]);
if (image)
{
- g->drawImage2(image, itemX, itemY);
+ graphics->drawImage(image, itemX, itemY);
image->decRef();
}
}
@@ -367,9 +366,9 @@ void OutfitWindow::draw(gcn::Graphics *graphics)
BLOCK_END("OutfitWindow::draw")
}
-void OutfitWindow::mouseDragged(gcn::MouseEvent &event)
+void OutfitWindow::mouseDragged(MouseEvent &event)
{
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ if (event.getButton() == MouseEvent::LEFT)
{
if (dragDrop.isEmpty() && mItemClicked)
{
@@ -410,12 +409,12 @@ void OutfitWindow::mouseDragged(gcn::MouseEvent &event)
Window::mouseDragged(event);
}
-void OutfitWindow::mousePressed(gcn::MouseEvent &event)
+void OutfitWindow::mousePressed(MouseEvent &event)
{
const int index = getIndexFromGrid(event.getX(), event.getY());
if (index == -1)
{
- if (event.getButton() == gcn::MouseEvent::RIGHT && viewport)
+ if (event.getButton() == MouseEvent::RIGHT && viewport)
{
viewport->showOutfitsPopup();
event.consume();
@@ -447,9 +446,9 @@ void OutfitWindow::mousePressed(gcn::MouseEvent &event)
Window::mousePressed(event);
}
-void OutfitWindow::mouseReleased(gcn::MouseEvent &event)
+void OutfitWindow::mouseReleased(MouseEvent &event)
{
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ if (event.getButton() == MouseEvent::LEFT)
{
if (mCurrentOutfit < 0 || mCurrentOutfit
>= static_cast<signed int>(OUTFITS_COUNT))
@@ -484,7 +483,7 @@ void OutfitWindow::mouseReleased(gcn::MouseEvent &event)
int OutfitWindow::getIndexFromGrid(const int pointX, const int pointY) const
{
- const gcn::Rectangle tRect = gcn::Rectangle(mPadding, mTitleBarHeight,
+ const Rect tRect = Rect(mPadding, mTitleBarHeight,
mGridWidth * mBoxWidth, mGridHeight * mBoxHeight);
if (!tRect.isPointInRect(pointX, pointY))
return -1;
diff --git a/src/gui/windows/outfitwindow.h b/src/gui/windows/outfitwindow.h
index eeedc2ec6..55948f834 100644
--- a/src/gui/windows/outfitwindow.h
+++ b/src/gui/windows/outfitwindow.h
@@ -25,7 +25,7 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
const unsigned int OUTFITS_COUNT = 100;
const unsigned int OUTFIT_ITEM_COUNT = 16;
@@ -35,7 +35,7 @@ class CheckBox;
class Label;
class OutfitWindow final : public Window,
- private gcn::ActionListener
+ private ActionListener
{
public:
/**
@@ -50,15 +50,15 @@ class OutfitWindow final : public Window,
*/
~OutfitWindow();
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
- void mousePressed(gcn::MouseEvent &event) override final;
+ void mousePressed(MouseEvent &event) override final;
- void mouseDragged(gcn::MouseEvent &event) override final;
+ void mouseDragged(MouseEvent &event) override final;
- void mouseReleased(gcn::MouseEvent &event) override final;
+ void mouseReleased(MouseEvent &event) override final;
void load(const bool oldConfig = false);
@@ -115,8 +115,8 @@ class OutfitWindow final : public Window,
int mItems[OUTFITS_COUNT + 1][OUTFIT_ITEM_COUNT];
int mAwayOutfit;
- gcn::Color mBorderColor;
- gcn::Color mBackgroundColor;
+ Color mBorderColor;
+ Color mBackgroundColor;
unsigned char mItemColors[OUTFITS_COUNT + 1][OUTFIT_ITEM_COUNT];
bool mItemClicked;
bool mItemsUnequip[OUTFITS_COUNT];
diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp
index e5f599f0f..eee3e4259 100644
--- a/src/gui/windows/questswindow.cpp
+++ b/src/gui/windows/questswindow.cpp
@@ -26,13 +26,15 @@
#include "being/localplayer.h"
-#include "gui/sdlfont.h"
+#include "gui/font.h"
+#include "gui/gui.h"
+
+#include "gui/models/questsmodel.h"
#include "gui/widgets/browserbox.h"
#include "gui/widgets/button.h"
#include "gui/widgets/layout.h"
#include "gui/widgets/extendedlistbox.h"
-#include "gui/widgets/extendednamesmodel.h"
#include "gui/widgets/itemlinkhandler.h"
#include "gui/widgets/scrollarea.h"
@@ -87,20 +89,6 @@ struct QuestItem final
bool broken;
};
-class QuestsModel final : public ExtendedNamesModel
-{
- public:
- QuestsModel() :
- ExtendedNamesModel()
- {
- }
-
- A_DELETE_COPY(QuestsModel)
-
- ~QuestsModel()
- { }
-};
-
struct QuestEffect final
{
QuestEffect() :
@@ -122,15 +110,15 @@ struct QuestEffect final
QuestsWindow::QuestsWindow() :
// TRANSLATORS: quests window name
Window(_("Quests"), false, nullptr, "quests.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mQuestsModel(new QuestsModel),
mQuestsListBox(new ExtendedListBox(this,
mQuestsModel, "extendedlistbox.xml")),
- mQuestScrollArea(new ScrollArea(mQuestsListBox,
+ mQuestScrollArea(new ScrollArea(this, mQuestsListBox,
getOptionBool("showlistbackground"), "quests_list_background.xml")),
mItemLinkHandler(new ItemLinkHandler),
mText(new BrowserBox(this, BrowserBox::AUTO_WRAP, true, "browserbox.xml")),
- mTextScrollArea(new ScrollArea(mText,
+ mTextScrollArea(new ScrollArea(this, mText,
getOptionBool("showtextbackground"), "quests_text_background.xml")),
// TRANSLATORS: quests window button
mCloseButton(new Button(this, _("Close"), "close", this)),
@@ -166,7 +154,7 @@ QuestsWindow::QuestsWindow() :
mText->setLinkHandler(mItemLinkHandler);
mTextScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
mQuestsListBox->setWidth(500);
- if (gui->getNpcFont()->getHeight() < 20)
+ if (gui && gui->getNpcFont()->getHeight() < 20)
mQuestsListBox->setRowHeight(20);
else
mQuestsListBox->setRowHeight(gui->getNpcFont()->getHeight());
@@ -318,7 +306,7 @@ void QuestsWindow::loadEffect(const int var, const XmlNodePtr node)
mAllEffects.push_back(effect);
}
-void QuestsWindow::action(const gcn::ActionEvent &event)
+void QuestsWindow::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "select")
diff --git a/src/gui/windows/questswindow.h b/src/gui/windows/questswindow.h
index 7ecc86c84..9000fcaa9 100644
--- a/src/gui/windows/questswindow.h
+++ b/src/gui/windows/questswindow.h
@@ -27,7 +27,7 @@
#include "utils/xml.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
#include <map>
#include <vector>
@@ -48,7 +48,7 @@ typedef std::map<int, const QuestEffect*> NpcQuestEffectMap;
typedef NpcQuestEffectMap::const_iterator NpcQuestEffectMapCIter;
class QuestsWindow final : public Window,
- public gcn::ActionListener
+ public ActionListener
{
public:
QuestsWindow();
@@ -57,7 +57,7 @@ class QuestsWindow final : public Window,
~QuestsWindow();
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void updateQuest(const int var, const int val);
diff --git a/src/gui/windows/quitdialog.cpp b/src/gui/windows/quitdialog.cpp
index ff9f669b7..98aa70c70 100644
--- a/src/gui/windows/quitdialog.cpp
+++ b/src/gui/windows/quitdialog.cpp
@@ -28,8 +28,9 @@
#include "soundconsts.h"
#include "soundmanager.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
#include "gui/viewport.h"
@@ -49,8 +50,8 @@
QuitDialog::QuitDialog(QuitDialog **const pointerToMe):
// TRANSLATORS: quit dialog name
Window(_("Quit"), true, nullptr, "quit.xml"),
- gcn::ActionListener(),
- gcn::KeyListener(),
+ ActionListener(),
+ KeyListener(),
mOptions(),
// TRANSLATORS: quit dialog button
mLogoutQuit(new RadioButton(this, _("Quit"), "quitdialog")),
@@ -147,7 +148,7 @@ void QuitDialog::placeOption(ContainerPlacer &placer,
mOptions.push_back(option);
}
-void QuitDialog::action(const gcn::ActionEvent &event)
+void QuitDialog::action(const ActionEvent &event)
{
soundManager.playGuiSound(SOUND_HIDE_WINDOW);
if (event.getId() == "ok")
@@ -202,20 +203,19 @@ void QuitDialog::action(const gcn::ActionEvent &event)
scheduleDelete();
}
-void QuitDialog::keyPressed(gcn::KeyEvent &keyEvent)
+void QuitDialog::keyPressed(KeyEvent &keyEvent)
{
- const int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int actionId = keyEvent.getActionId();
int dir = 0;
switch (actionId)
{
case Input::KEY_GUI_SELECT:
case Input::KEY_GUI_SELECT2:
- action(gcn::ActionEvent(nullptr, mOkButton->getActionEventId()));
+ action(ActionEvent(nullptr, mOkButton->getActionEventId()));
break;
case Input::KEY_GUI_CANCEL:
- action(gcn::ActionEvent(nullptr,
- mCancelButton->getActionEventId()));
+ action(ActionEvent(nullptr, mCancelButton->getActionEventId()));
break;
case Input::KEY_GUI_UP:
dir = -1;
diff --git a/src/gui/windows/quitdialog.h b/src/gui/windows/quitdialog.h
index ab395c7f4..8ce60d06c 100644
--- a/src/gui/windows/quitdialog.h
+++ b/src/gui/windows/quitdialog.h
@@ -25,8 +25,8 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/keylistener.h"
#include <vector>
@@ -38,8 +38,9 @@ class RadioButton;
*
* \ingroup Interface
*/
-class QuitDialog final : public Window, public gcn::ActionListener,
- public gcn::KeyListener
+class QuitDialog final : public Window,
+ public ActionListener,
+ public KeyListener
{
public:
/**
@@ -61,9 +62,9 @@ class QuitDialog final : public Window, public gcn::ActionListener,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
- void keyPressed(gcn::KeyEvent &keyEvent) override final;
+ void keyPressed(KeyEvent &keyEvent) override final;
private:
void placeOption(ContainerPlacer &placer,
diff --git a/src/gui/windows/registerdialog.cpp b/src/gui/windows/registerdialog.cpp
index 1867b6b40..50344f223 100644
--- a/src/gui/windows/registerdialog.cpp
+++ b/src/gui/windows/registerdialog.cpp
@@ -24,8 +24,9 @@
#include "client.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
#include "gui/windows/okdialog.h"
@@ -44,7 +45,7 @@
#include "debug.h"
WrongDataNoticeListener::WrongDataNoticeListener():
- gcn::ActionListener(),
+ ActionListener(),
mTarget(nullptr)
{
}
@@ -54,7 +55,7 @@ void WrongDataNoticeListener::setTarget(TextField *const textField)
mTarget = textField;
}
-void WrongDataNoticeListener::action(const gcn::ActionEvent &event)
+void WrongDataNoticeListener::action(const ActionEvent &event)
{
if (event.getId() == "ok" && mTarget)
mTarget->requestFocus();
@@ -63,8 +64,8 @@ void WrongDataNoticeListener::action(const gcn::ActionEvent &event)
RegisterDialog::RegisterDialog(LoginData *const data) :
// TRANSLATORS: register dialog name
Window(_("Register"), false, nullptr, "register.xml"),
- gcn::ActionListener(),
- gcn::KeyListener(),
+ ActionListener(),
+ KeyListener(),
mLoginData(data),
mUserField(new TextField(this, mLoginData->username)),
mPasswordField(new PasswordField(this, mLoginData->password)),
@@ -172,7 +173,7 @@ RegisterDialog::~RegisterDialog()
mWrongDataNoticeListener = nullptr;
}
-void RegisterDialog::action(const gcn::ActionEvent &event)
+void RegisterDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "cancel")
@@ -281,23 +282,22 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
}
}
-void RegisterDialog::keyPressed(gcn::KeyEvent &keyEvent)
+void RegisterDialog::keyPressed(KeyEvent &keyEvent)
{
if (keyEvent.isConsumed())
{
mRegisterButton->setEnabled(canSubmit());
return;
}
- const int actionId = static_cast<KeyEvent*>(
- &keyEvent)->getActionId();
+ const int actionId = keyEvent.getActionId();
if (actionId == static_cast<int>(Input::KEY_GUI_CANCEL))
{
- action(gcn::ActionEvent(nullptr, mCancelButton->getActionEventId()));
+ action(ActionEvent(nullptr, mCancelButton->getActionEventId()));
}
else if (actionId == static_cast<int>(Input::KEY_GUI_SELECT)
|| actionId == static_cast<int>(Input::KEY_GUI_SELECT2))
{
- action(gcn::ActionEvent(nullptr, mRegisterButton->getActionEventId()));
+ action(ActionEvent(nullptr, mRegisterButton->getActionEventId()));
}
else
{
diff --git a/src/gui/windows/registerdialog.h b/src/gui/windows/registerdialog.h
index 66c3e40b7..1d5b5e48b 100644
--- a/src/gui/windows/registerdialog.h
+++ b/src/gui/windows/registerdialog.h
@@ -25,8 +25,8 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/keylistener.h"
class Button;
class LoginData;
@@ -38,7 +38,7 @@ class TextField;
* to the field which contained wrong data when the Ok button was pressed on
* the error notice.
*/
-class WrongDataNoticeListener final : public gcn::ActionListener
+class WrongDataNoticeListener final : public ActionListener
{
public:
WrongDataNoticeListener();
@@ -47,7 +47,7 @@ class WrongDataNoticeListener final : public gcn::ActionListener
void setTarget(TextField *const textField);
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
private:
TextField *mTarget;
};
@@ -58,8 +58,8 @@ class WrongDataNoticeListener final : public gcn::ActionListener
* \ingroup Interface
*/
class RegisterDialog final : public Window,
- public gcn::ActionListener,
- public gcn::KeyListener
+ public ActionListener,
+ public KeyListener
{
public:
/**
@@ -82,12 +82,12 @@ class RegisterDialog final : public Window,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override;
+ void action(const ActionEvent &event) override;
/**
* Called when a key is pressed in one of the text fields.
*/
- void keyPressed(gcn::KeyEvent &keyEvent) override;
+ void keyPressed(KeyEvent &keyEvent) override;
void close() override;
diff --git a/src/gui/windows/selldialog.cpp b/src/gui/windows/selldialog.cpp
index 15389a9c3..8bfcc6728 100644
--- a/src/gui/windows/selldialog.cpp
+++ b/src/gui/windows/selldialog.cpp
@@ -30,11 +30,12 @@
#include "gui/windows/confirmdialog.h"
#include "gui/windows/tradewindow.h"
+#include "gui/models/shopitems.h"
+
#include "gui/widgets/button.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layout.h"
#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/shopitems.h"
#include "gui/widgets/shoplistbox.h"
#include "gui/widgets/slider.h"
@@ -53,8 +54,8 @@ SellDialog::DialogList SellDialog::instances;
SellDialog::SellDialog(const int npcId) :
// TRANSLATORS: sell dialog name
Window(_("Sell"), false, nullptr, "sell.xml"),
- gcn::ActionListener(),
- gcn::SelectionListener(),
+ ActionListener(),
+ SelectionListener(),
mNpcId(npcId), mMaxItems(0), mAmountItems(0), mNick("")
{
init();
@@ -63,8 +64,8 @@ SellDialog::SellDialog(const int npcId) :
SellDialog::SellDialog(const std::string &nick):
// TRANSLATORS: sell dialog name
Window(_("Sell"), false, nullptr, "sell.xml"),
- gcn::ActionListener(),
- gcn::SelectionListener(),
+ ActionListener(),
+ SelectionListener(),
mNpcId(-1), mMaxItems(0), mAmountItems(0), mNick(nick)
{
init();
@@ -86,15 +87,15 @@ void SellDialog::init()
mShopItemList = new ShopListBox(this, mShopItems, mShopItems);
mShopItemList->postInit();
mShopItemList->setProtectItems(true);
- mScrollArea = new ScrollArea(mShopItemList,
+ mScrollArea = new ScrollArea(this, mShopItemList,
getOptionBool("showbackground"), "sell_background.xml");
mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- mSlider = new Slider(1.0);
+ mSlider = new Slider(this, 1.0);
mQuantityLabel = new Label(this, strprintf(
"%d / %d", mAmountItems, mMaxItems));
- mQuantityLabel->setAlignment(gcn::Graphics::CENTER);
+ mQuantityLabel->setAlignment(Graphics::CENTER);
// TRANSLATORS: sell dialog label
mMoneyLabel = new Label(this, strprintf(_("Price: %s / Total: %s"),
"", ""));
@@ -185,7 +186,7 @@ void SellDialog::addItem(const int id, const unsigned char color,
}
-void SellDialog::action(const gcn::ActionEvent &event)
+void SellDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
@@ -257,20 +258,10 @@ void SellDialog::action(const gcn::ActionEvent &event)
mMaxItems -= mAmountItems;
while (mAmountItems > 0)
{
-#ifdef MANASERV_SUPPORT
- // This order is important, item->getCurrentInvIndex() would
- // return the inventory index of the next Duplicate otherwise.
- int itemIndex = item->getCurrentInvIndex();
- const int sellCount = item->sellCurrentDuplicate(mAmountItems);
- // For Manaserv, the Item id is to be given as index.
- if ((Net::getNetworkType() == ServerInfo::MANASERV))
- itemIndex = item->getId();
-#else
// This order is important, item->getCurrentInvIndex() would
// return the inventory index of the next Duplicate otherwise.
const int itemIndex = item->getCurrentInvIndex();
const int sellCount = item->sellCurrentDuplicate(mAmountItems);
-#endif
Net::getNpcHandler()->sellItem(mNpcId, itemIndex, sellCount);
mAmountItems -= sellCount;
}
@@ -291,7 +282,7 @@ void SellDialog::action(const gcn::ActionEvent &event)
delete mShopItems->at(selectedItem);
mShopItems->erase(selectedItem);
- gcn::Rectangle scroll;
+ Rect scroll;
scroll.y = mShopItemList->getRowHeight() * (selectedItem + 1);
scroll.height = mShopItemList->getRowHeight();
mShopItemList->showPart(scroll);
@@ -309,7 +300,7 @@ void SellDialog::action(const gcn::ActionEvent &event)
}
}
-void SellDialog::valueChanged(const gcn::SelectionEvent &event A_UNUSED)
+void SellDialog::valueChanged(const SelectionEvent &event A_UNUSED)
{
// Reset amount of items and update labels
mAmountItems = 1;
diff --git a/src/gui/windows/selldialog.h b/src/gui/windows/selldialog.h
index 15db28f10..bd270919e 100644
--- a/src/gui/windows/selldialog.h
+++ b/src/gui/windows/selldialog.h
@@ -25,8 +25,8 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/selectionlistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/selectionlistener.h"
class Button;
class Item;
@@ -42,8 +42,8 @@ class Slider;
* \ingroup Interface
*/
class SellDialog final : public Window,
- private gcn::ActionListener,
- private gcn::SelectionListener
+ private ActionListener,
+ private SelectionListener
{
public:
/**
@@ -80,14 +80,14 @@ class SellDialog final : public Window,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Updates labels according to selected item.
*
* @see SelectionListener::selectionChanged
*/
- void valueChanged(const gcn::SelectionEvent &event) override final;
+ void valueChanged(const SelectionEvent &event) override final;
/**
* Gives Player's Money amount
diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp
index 3006922c3..af29da656 100644
--- a/src/gui/windows/serverdialog.cpp
+++ b/src/gui/windows/serverdialog.cpp
@@ -27,11 +27,16 @@
#include "configuration.h"
#include "main.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
-#include "gui/sdlfont.h"
+#include "gui/font.h"
+#include "gui/gui.h"
+
+#include "gui/models/serverslistmodel.h"
+#include "gui/widgets/checkbox.h"
#include "gui/windows/editserverdialog.h"
#include "gui/windows/logindialog.h"
@@ -44,8 +49,6 @@
#include "utils/gettext.h"
#include "utils/langs.h"
-#include <guichan/font.hpp>
-
#include <string>
#include "debug.h"
@@ -60,19 +63,10 @@ static std::string serverTypeToString(const ServerInfo::Type type)
return "TmwAthena";
case ServerInfo::EVOL:
return "Evol";
-#ifdef EATHENA_SUPPORT
case ServerInfo::EATHENA:
+#ifdef EATHENA_SUPPORT
return "eAthena";
#endif
-#ifdef MANASERV_SUPPORT
- case ServerInfo::MANASERV:
- return "ManaServ";
-#else
- case ServerInfo::MANASERV:
-#endif
-#ifndef EATHENA_SUPPORT
- case ServerInfo::EATHENA:
-#endif
default:
case ServerInfo::UNKNOWN:
return "";
@@ -87,60 +81,11 @@ static uint16_t defaultPortForServerType(const ServerInfo::Type type)
case ServerInfo::EATHENA:
#ifdef EATHENA_SUPPORT
return 6900;
-#else
- return 6901;
#endif
case ServerInfo::UNKNOWN:
case ServerInfo::TMWATHENA:
case ServerInfo::EVOL:
-#ifdef MANASERV_SUPPORT
- return 6901;
- case ServerInfo::MANASERV:
- return 9601;
-#else
- case ServerInfo::MANASERV:
return 6901;
-#endif
- }
-}
-
-ServersListModel::ServersListModel(ServerInfos *const servers,
- ServerDialog *const parent) :
- mServers(servers),
- mVersionStrings(servers->size(), VersionString(0, "")),
- mParent(parent)
-{
-}
-
-int ServersListModel::getNumberOfElements()
-{
- MutexLocker lock = mParent->lock();
- return static_cast<int>(mServers->size());
-}
-
-std::string ServersListModel::getElementAt(int elementIndex)
-{
- MutexLocker lock = mParent->lock();
- const ServerInfo &server = mServers->at(elementIndex);
- std::string myServer;
- myServer.append(server.hostname);
- return myServer;
-}
-
-void ServersListModel::setVersionString(const int index,
- const std::string &version)
-{
- if (index < 0 || index >= static_cast<int>(mVersionStrings.size()))
- return;
-
- if (version.empty())
- {
- mVersionStrings[index] = VersionString(0, "");
- }
- else
- {
- mVersionStrings[index] = VersionString(
- gui->getFont()->getWidth(version), version);
}
}
@@ -157,19 +102,18 @@ public:
mHighlightColor = getThemeColor(Theme::HIGHLIGHT);
}
- void draw(gcn::Graphics *graphics) override final
+ void draw(Graphics *graphics) override final
{
if (!mListModel)
return;
ServersListModel *const model = static_cast<ServersListModel *const>(
mListModel);
- Graphics *const g = static_cast<Graphics*>(graphics);
updateAlpha();
mHighlightColor.a = static_cast<int>(mAlpha * 255.0F);
- g->setColor(mHighlightColor);
+ graphics->setColor(mHighlightColor);
const int height = getRowHeight();
mNotSupportedColor.a = static_cast<int>(mAlpha * 255.0F);
@@ -177,13 +121,13 @@ public:
// Draw filled rectangle around the selected list element
if (mSelected >= 0)
{
- graphics->fillRectangle(gcn::Rectangle(mPadding,
+ graphics->fillRectangle(Rect(mPadding,
height * mSelected + mPadding, getWidth() - 2 * mPadding,
height));
}
- gcn::Font *const font1 = boldFont;
- gcn::Font *const font2 = getFont();
+ Font *const font1 = boldFont;
+ Font *const font2 = getFont();
const int fontHeight = font1->getHeight();
const int pad1 = fontHeight + mPadding;
const int pad2 = height / 4 + mPadding;
@@ -196,12 +140,12 @@ public:
if (mSelected == i)
{
- g->setColorAll(mForegroundSelectedColor,
+ graphics->setColorAll(mForegroundSelectedColor,
mForegroundSelectedColor2);
}
else
{
- g->setColorAll(mForegroundColor, mForegroundColor2);
+ graphics->setColorAll(mForegroundColor, mForegroundColor2);
}
int top;
@@ -224,7 +168,7 @@ public:
if (info.version.first > 0)
{
- g->setColorAll(mNotSupportedColor, mNotSupportedColor2);
+ graphics->setColorAll(mNotSupportedColor, mNotSupportedColor2);
font2->drawString(graphics, info.version.second,
width - info.version.first - mPadding, top);
}
@@ -236,8 +180,8 @@ public:
return 2 * getFont()->getHeight() + 5;
}
private:
- gcn::Color mNotSupportedColor;
- gcn::Color mNotSupportedColor2;
+ Color mNotSupportedColor;
+ Color mNotSupportedColor2;
};
@@ -245,9 +189,9 @@ ServerDialog::ServerDialog(ServerInfo *const serverInfo,
const std::string &dir) :
// TRANSLATORS: servers dialog name
Window(_("Choose Your Server"), false, nullptr, "server.xml"),
- gcn::ActionListener(),
- gcn::KeyListener(),
- gcn::SelectionListener(),
+ ActionListener(),
+ KeyListener(),
+ SelectionListener(),
mMutex(),
mDescription(new Label(this, std::string())),
// TRANSLATORS: servers dialog button
@@ -294,7 +238,7 @@ ServerDialog::ServerDialog(ServerInfo *const serverInfo,
mServersList->addMouseListener(this);
- ScrollArea *const usedScroll = new ScrollArea(mServersList,
+ ScrollArea *const usedScroll = new ScrollArea(this, mServersList,
getOptionBool("showbackground"), "server_background.xml");
usedScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
@@ -405,7 +349,7 @@ void ServerDialog::connectToSelectedServer()
client->setState(STATE_CONNECT_SERVER);
}
-void ServerDialog::action(const gcn::ActionEvent &event)
+void ServerDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "connect")
@@ -445,9 +389,9 @@ void ServerDialog::action(const gcn::ActionEvent &event)
}
}
-void ServerDialog::keyPressed(gcn::KeyEvent &keyEvent)
+void ServerDialog::keyPressed(KeyEvent &keyEvent)
{
- switch (static_cast<KeyEvent*>(&keyEvent)->getActionId())
+ switch (keyEvent.getActionId())
{
case Input::KEY_GUI_CANCEL:
keyEvent.consume();
@@ -457,7 +401,7 @@ void ServerDialog::keyPressed(gcn::KeyEvent &keyEvent)
case Input::KEY_GUI_SELECT:
case Input::KEY_GUI_SELECT2:
keyEvent.consume();
- action(gcn::ActionEvent(nullptr,
+ action(ActionEvent(nullptr,
mConnectButton->getActionEventId()));
return;
@@ -495,7 +439,7 @@ void ServerDialog::keyPressed(gcn::KeyEvent &keyEvent)
mServersList->keyPressed(keyEvent);
}
-void ServerDialog::valueChanged(const gcn::SelectionEvent &)
+void ServerDialog::valueChanged(const SelectionEvent &)
{
const int index = mServersList->getSelected();
if (index == -1)
@@ -506,13 +450,13 @@ void ServerDialog::valueChanged(const gcn::SelectionEvent &)
mDeleteButton->setEnabled(true);
}
-void ServerDialog::mouseClicked(gcn::MouseEvent &mouseEvent)
+void ServerDialog::mouseClicked(MouseEvent &mouseEvent)
{
if (mouseEvent.getClickCount() == 2 &&
mouseEvent.getSource() == mServersList)
{
- action(gcn::ActionEvent(mConnectButton,
- mConnectButton->getActionEventId()));
+ action(ActionEvent(mConnectButton,
+ mConnectButton->getActionEventId()));
}
}
@@ -644,7 +588,7 @@ void ServerDialog::loadServers(const bool addNew)
version = strprintf(_("requires v%s"), version.c_str());
}
- const gcn::Font *const font = gui->getFont();
+ const Font *const font = gui->getFont();
for_each_xml_child_node(subNode, serverNode)
{
diff --git a/src/gui/windows/serverdialog.h b/src/gui/windows/serverdialog.h
index ad6f554c6..39c82279e 100644
--- a/src/gui/windows/serverdialog.h
+++ b/src/gui/windows/serverdialog.h
@@ -24,66 +24,23 @@
#define GUI_WINDOWS_SERVERDIALOG_H
#include "gui/widgets/window.h"
-#include "gui/widgets/checkbox.h"
#include "net/download.h"
#include "net/serverinfo.h"
#include "utils/mutex.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
-#include <guichan/listmodel.hpp>
-#include <guichan/selectionlistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/keylistener.h"
+#include "listeners/selectionlistener.h"
#include <string>
-#include <vector>
class Button;
+class CheckBox;
class Label;
class ListBox;
-class ServerDialog;
-
-/**
- * Server and Port List Model
- */
-class ServersListModel final : public gcn::ListModel
-{
- public:
- typedef std::pair<int, std::string> VersionString;
-
- ServersListModel(ServerInfos *const servers,
- ServerDialog *const parent);
-
- A_DELETE_COPY(ServersListModel)
-
- /**
- * Used to get number of line in the list
- */
- int getNumberOfElements() override final A_WARN_UNUSED;
-
- /**
- * Used to get an element from the list
- */
- std::string getElementAt(int elementIndex)
- override final A_WARN_UNUSED;
-
- /**
- * Used to get the corresponding Server struct
- */
- const ServerInfo &getServer(const int elementIndex) const A_WARN_UNUSED
- { return mServers->at(elementIndex); }
-
- void setVersionString(const int index, const std::string &version);
-
- private:
- typedef std::vector<VersionString> VersionStrings;
-
- ServerInfos *mServers;
- VersionStrings mVersionStrings;
- ServerDialog *mParent;
-};
-
+class ServersListModel;
/**
* The server choice dialog.
@@ -91,9 +48,9 @@ class ServersListModel final : public gcn::ListModel
* \ingroup Interface
*/
class ServerDialog final : public Window,
- public gcn::ActionListener,
- public gcn::KeyListener,
- public gcn::SelectionListener
+ public ActionListener,
+ public KeyListener,
+ public SelectionListener
{
public:
/**
@@ -115,16 +72,16 @@ class ServerDialog final : public Window,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
- void keyPressed(gcn::KeyEvent &keyEvent) override final;
+ void keyPressed(KeyEvent &keyEvent) override final;
/**
* Called when the selected value changed in the servers list box.
*/
- void valueChanged(const gcn::SelectionEvent &event) override final;
+ void valueChanged(const SelectionEvent &event) override final;
- void mouseClicked(gcn::MouseEvent &mouseEvent) override final;
+ void mouseClicked(MouseEvent &mouseEvent) override final;
void logic() override final;
diff --git a/src/gui/windows/setupwindow.cpp b/src/gui/windows/setupwindow.cpp
index 0780865aa..2bcac85a5 100644
--- a/src/gui/windows/setupwindow.cpp
+++ b/src/gui/windows/setupwindow.cpp
@@ -44,6 +44,7 @@
#include "gui/widgets/tabs/setup_video.h"
#include "gui/widgets/tabs/setup_visual.h"
+#include "gui/widgets/button.h"
#include "gui/widgets/label.h"
#include "gui/widgets/tabbedarea.h"
@@ -58,7 +59,7 @@ SetupWindow *setupWindow = nullptr;
SetupWindow::SetupWindow() :
// TRANSLATORS: setup window name
Window(_("Setup"), false, nullptr, "setup.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mTabs(),
mModsTab(nullptr),
mWindowsToReset(),
@@ -112,7 +113,7 @@ void SetupWindow::postInit()
mResetWindows = btn;
}
- mPanel->setDimension(gcn::Rectangle(5, 5, width - 10, height - 40));
+ mPanel->setDimension(Rect(5, 5, width - 10, height - 40));
mPanel->enableScrollButtons(true);
mTabs.push_back(new Setup_Video(this));
@@ -149,7 +150,7 @@ void SetupWindow::postInit()
center();
- widgetResized(gcn::Event(nullptr));
+ widgetResized(Event(nullptr));
setInGame(false);
enableVisibleSound(true);
}
@@ -160,7 +161,7 @@ SetupWindow::~SetupWindow()
mButtons.clear();
}
-void SetupWindow::action(const gcn::ActionEvent &event)
+void SetupWindow::action(const ActionEvent &event)
{
if (Game::instance())
Game::instance()->resetAdjustLevel();
@@ -260,16 +261,16 @@ void SetupWindow::setVisible(bool visible)
Window::setVisible(visible);
}
-void SetupWindow::widgetResized(const gcn::Event &event)
+void SetupWindow::widgetResized(const Event &event)
{
Window::widgetResized(event);
- const gcn::Rectangle area = getChildrenArea();
+ const Rect area = getChildrenArea();
int x = area.width;
const int height = area.height;
const int width = area.width;
const int buttonPadding = getOption("buttonPadding", 5);
- mPanel->setDimension(gcn::Rectangle(5, 5, width - 10, height - 40));
+ mPanel->setDimension(Rect(5, 5, width - 10, height - 40));
FOR_EACH (std::vector<Button*>::iterator, it, mButtons)
{
Button *const btn = *it;
diff --git a/src/gui/windows/setupwindow.h b/src/gui/windows/setupwindow.h
index f5406e8ac..38b3eb206 100644
--- a/src/gui/windows/setupwindow.h
+++ b/src/gui/windows/setupwindow.h
@@ -25,7 +25,7 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
#include <list>
@@ -41,7 +41,7 @@ class TabbedArea;
* \ingroup GUI
*/
class SetupWindow final : public Window,
- public gcn::ActionListener
+ public ActionListener
{
public:
SetupWindow();
@@ -52,7 +52,7 @@ class SetupWindow final : public Window,
void postInit() override final;
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void setInGame(const bool inGame);
@@ -71,7 +71,7 @@ class SetupWindow final : public Window,
void setVisible(bool visible) override final;
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
private:
void unloadModTab();
diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp
index a940e4cdb..32e249d35 100644
--- a/src/gui/windows/shopwindow.cpp
+++ b/src/gui/windows/shopwindow.cpp
@@ -27,12 +27,13 @@
#include "gui/windows/selldialog.h"
#include "gui/windows/tradewindow.h"
+#include "gui/models/shopitems.h"
+
#include "gui/widgets/button.h"
#include "gui/widgets/checkbox.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layout.h"
#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/shopitems.h"
#include "gui/widgets/shoplistbox.h"
#include "gui/widgets/tabs/chattab.h"
@@ -71,17 +72,17 @@ ShopWindow::DialogList ShopWindow::instances;
ShopWindow::ShopWindow():
// TRANSLATORS: shop window name
Window(_("Personal Shop"), false, nullptr, "shop.xml"),
- gcn::ActionListener(),
- gcn::SelectionListener(),
+ ActionListener(),
+ SelectionListener(),
// TRANSLATORS: shop window button
mCloseButton(new Button(this, _("Close"), "close", this)),
mBuyShopItems(new ShopItems),
mSellShopItems(new ShopItems),
mBuyShopItemList(new ShopListBox(this, mBuyShopItems, mBuyShopItems)),
mSellShopItemList(new ShopListBox(this, mSellShopItems, mSellShopItems)),
- mBuyScrollArea(new ScrollArea(mBuyShopItemList,
+ mBuyScrollArea(new ScrollArea(this, mBuyShopItemList,
getOptionBool("showbuybackground"), "shop_buy_background.xml")),
- mSellScrollArea(new ScrollArea(mSellShopItemList,
+ mSellScrollArea(new ScrollArea(this, mSellShopItemList,
getOptionBool("showsellbackground"), "shop_sell_background.xml")),
// TRANSLATORS: shop window label
mBuyLabel(new Label(this, _("Buy items"))),
@@ -205,7 +206,7 @@ ShopWindow::~ShopWindow()
instances.remove(this);
}
-void ShopWindow::action(const gcn::ActionEvent &event)
+void ShopWindow::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "close")
@@ -307,7 +308,7 @@ void ShopWindow::startTrade()
mTradeNick.clear();
}
-void ShopWindow::valueChanged(const gcn::SelectionEvent &event A_UNUSED)
+void ShopWindow::valueChanged(const SelectionEvent &event A_UNUSED)
{
updateButtonsAndLabels();
}
diff --git a/src/gui/windows/shopwindow.h b/src/gui/windows/shopwindow.h
index 95eee1e05..76971364b 100644
--- a/src/gui/windows/shopwindow.h
+++ b/src/gui/windows/shopwindow.h
@@ -25,8 +25,8 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/selectionlistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/selectionlistener.h"
class Button;
class CheckBox;
@@ -43,8 +43,8 @@ class ShopListBox;
* \ingroup Interface
*/
class ShopWindow final : public Window,
- public gcn::ActionListener,
- public gcn::SelectionListener
+ public ActionListener,
+ public SelectionListener
{
public:
enum ShopMode
@@ -72,12 +72,12 @@ class ShopWindow final : public Window,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Updates the labels according to the selected item.
*/
- void valueChanged(const gcn::SelectionEvent &event) override final;
+ void valueChanged(const SelectionEvent &event) override final;
/**
* Updates the state of buttons and labels.
diff --git a/src/gui/windows/shortcutwindow.cpp b/src/gui/windows/shortcutwindow.cpp
index 96ec8c93c..5b3c03e90 100644
--- a/src/gui/windows/shortcutwindow.cpp
+++ b/src/gui/windows/shortcutwindow.cpp
@@ -40,7 +40,8 @@ class ShortcutTab final : public Tab
{
public:
ShortcutTab(const Widget2 *const widget,
- std::string name, ShortcutContainer *const content) :
+ std::string name,
+ ShortcutContainer *const content) :
Tab(widget),
mContent(content)
{
@@ -58,7 +59,7 @@ ShortcutWindow::ShortcutWindow(const std::string &restrict title,
int width, int height) :
Window("Window", false, nullptr, skinFile),
mItems(content),
- mScrollArea(new ScrollArea(mItems, false)),
+ mScrollArea(new ScrollArea(this, mItems, false)),
mTabs(nullptr),
mPages()
{
@@ -160,7 +161,7 @@ ShortcutWindow::~ShortcutWindow()
void ShortcutWindow::addTab(const std::string &name,
ShortcutContainer *const content)
{
- ScrollArea *const scroll = new ScrollArea(content, false);
+ ScrollArea *const scroll = new ScrollArea(this, content, false);
scroll->setPosition(SCROLL_PADDING, SCROLL_PADDING);
scroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
content->setWidget2(this);
@@ -176,7 +177,7 @@ int ShortcutWindow::getTabIndex() const
return mTabs->getSelectedTabIndex();
}
-void ShortcutWindow::widgetHidden(const gcn::Event &event)
+void ShortcutWindow::widgetHidden(const Event &event)
{
if (mItems)
mItems->widgetHidden(event);
@@ -195,21 +196,21 @@ void ShortcutWindow::widgetHidden(const gcn::Event &event)
}
}
-void ShortcutWindow::mousePressed(gcn::MouseEvent &event)
+void ShortcutWindow::mousePressed(MouseEvent &event)
{
Window::mousePressed(event);
if (event.isConsumed())
return;
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ if (event.getButton() == MouseEvent::LEFT)
{
mDragOffsetX = event.getX();
mDragOffsetY = event.getY();
}
}
-void ShortcutWindow::mouseDragged(gcn::MouseEvent &event)
+void ShortcutWindow::mouseDragged(MouseEvent &event)
{
Window::mouseDragged(event);
@@ -226,7 +227,7 @@ void ShortcutWindow::mouseDragged(gcn::MouseEvent &event)
}
}
-void ShortcutWindow::widgetMoved(const gcn::Event& event)
+void ShortcutWindow::widgetMoved(const Event& event)
{
Window::widgetMoved(event);
if (mItems)
diff --git a/src/gui/windows/shortcutwindow.h b/src/gui/windows/shortcutwindow.h
index f4c417c94..5e36e68d7 100644
--- a/src/gui/windows/shortcutwindow.h
+++ b/src/gui/windows/shortcutwindow.h
@@ -60,13 +60,13 @@ class ShortcutWindow final : public Window
int getTabIndex() const A_WARN_UNUSED;
- void widgetHidden(const gcn::Event &event) override final;
+ void widgetHidden(const Event &event) override final;
- void widgetMoved(const gcn::Event& event) override final;
+ void widgetMoved(const Event& event) override final;
- void mousePressed(gcn::MouseEvent &event) override final;
+ void mousePressed(MouseEvent &event) override final;
- void mouseDragged(gcn::MouseEvent &event) override final;
+ void mouseDragged(MouseEvent &event) override final;
void nextTab();
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp
index 04baad26a..21cc009bc 100644
--- a/src/gui/windows/skilldialog.cpp
+++ b/src/gui/windows/skilldialog.cpp
@@ -29,10 +29,13 @@
#include "being/localplayer.h"
+#include "gui/font.h"
#include "gui/viewport.h"
#include "gui/popups/textpopup.h"
+#include "gui/models/skillmodel.h"
+
#include "gui/windows/setupwindow.h"
#include "gui/windows/shortcutwindow.h"
@@ -40,7 +43,6 @@
#include "gui/widgets/label.h"
#include "gui/widgets/listbox.h"
#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/skillmodel.h"
#include "gui/widgets/tabs/tab.h"
#include "gui/widgets/tabbedarea.h"
@@ -53,14 +55,13 @@
#include "resources/beingcommon.h"
-#include <guichan/font.hpp>
-
#include "debug.h"
class SkillListBox final : public ListBox
{
public:
- SkillListBox(const Widget2 *const widget, SkillModel *const model) :
+ SkillListBox(const Widget2 *const widget,
+ SkillModel *const model) :
ListBox(widget, model, "skilllistbox.xml"),
mModel(model),
mPopup(new TextPopup),
@@ -100,15 +101,13 @@ class SkillListBox final : public ListBox
return static_cast<SkillModel*>(mListModel)->getSkillAt(selected);
}
- void draw(gcn::Graphics *gcnGraphics) override
+ void draw(Graphics *graphics) override
{
if (!mListModel)
return;
SkillModel *const model = static_cast<SkillModel*>(mListModel);
updateAlpha();
- Graphics *const graphics = static_cast<Graphics *const>(
- gcnGraphics);
mHighlightColor.a = static_cast<int>(mAlpha * 255.0F);
graphics->setColor(mHighlightColor);
@@ -116,14 +115,14 @@ class SkillListBox final : public ListBox
// Draw filled rectangle around the selected list element
if (mSelected >= 0)
{
- graphics->fillRectangle(gcn::Rectangle(mPadding, getRowHeight()
+ graphics->fillRectangle(Rect(mPadding, getRowHeight()
* mSelected + mPadding, getWidth() - 2 * mPadding,
getRowHeight()));
}
// Draw the list elements
graphics->setColorAll(mTextColor, mTextColor2);
- gcn::Font *const font = getFont();
+ Font *const font = getFont();
const int space = font->getHeight() + mSpacing;
const int width2 = getWidth() - mPadding;
for (int i = 0, y = 1;
@@ -136,7 +135,7 @@ class SkillListBox final : public ListBox
const SkillData *const data = e->data;
const int yPad = y + mPadding;
const std::string &description = data->description;
- graphics->drawImage2(data->icon, mPadding, yPad);
+ graphics->drawImage(data->icon, mPadding, yPad);
font->drawString(graphics, data->name, mTextPadding, yPad);
if (!description.empty())
{
@@ -159,7 +158,7 @@ class SkillListBox final : public ListBox
unsigned int getRowHeight() const override
{ return mRowHeight; }
- const SkillInfo *getSkillByEvent(const gcn::MouseEvent &event) const
+ const SkillInfo *getSkillByEvent(const MouseEvent &event) const
{
const int y = (event.getY() + mPadding) / getRowHeight();
if (!mModel || y >= mModel->getNumberOfElements())
@@ -170,7 +169,7 @@ class SkillListBox final : public ListBox
return skill;
}
- void mouseMoved(gcn::MouseEvent &event) override
+ void mouseMoved(MouseEvent &event) override
{
ListBox::mouseMoved(event);
if (!viewport || !dragDrop.isEmpty())
@@ -184,9 +183,9 @@ class SkillListBox final : public ListBox
skill->data->dispName, skill->data->description);
}
- void mouseDragged(gcn::MouseEvent &event)
+ void mouseDragged(MouseEvent &event)
{
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ if (event.getButton() == MouseEvent::LEFT)
{
if (dragDrop.isEmpty())
{
@@ -208,10 +207,10 @@ class SkillListBox final : public ListBox
}
}
- void mousePressed(gcn::MouseEvent &event)
+ void mousePressed(MouseEvent &event)
{
ListBox::mousePressed(event);
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ if (event.getButton() == MouseEvent::LEFT)
{
const SkillInfo *const skill = getSkillByEvent(event);
if (!skill)
@@ -220,12 +219,12 @@ class SkillListBox final : public ListBox
}
}
- void mouseReleased(gcn::MouseEvent &event)
+ void mouseReleased(MouseEvent &event)
{
ListBox::mouseReleased(event);
}
- void mouseExited(gcn::MouseEvent &event A_UNUSED) override
+ void mouseExited(MouseEvent &event A_UNUSED) override
{
mPopup->hide();
}
@@ -233,8 +232,8 @@ class SkillListBox final : public ListBox
private:
SkillModel *mModel;
TextPopup *mPopup;
- gcn::Color mTextColor;
- gcn::Color mTextColor2;
+ Color mTextColor;
+ Color mTextColor2;
int mTextPadding;
int mSpacing;
bool mSkillClicked;
@@ -244,7 +243,8 @@ class SkillTab final : public Tab
{
public:
SkillTab(const Widget2 *const widget,
- const std::string &name, SkillListBox *const listBox) :
+ const std::string &name,
+ SkillListBox *const listBox) :
Tab(widget),
mListBox(listBox)
{
@@ -281,7 +281,7 @@ class SkillTab final : public Tab
SkillDialog::SkillDialog() :
// TRANSLATORS: skills dialog name
Window(_("Skills"), false, nullptr, "skills.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mSkills(),
mTabs(new TabbedArea(this)),
mDeleteTabs(),
@@ -323,7 +323,7 @@ SkillDialog::~SkillDialog()
clearSkills();
}
-void SkillDialog::action(const gcn::ActionEvent &event)
+void SkillDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "inc")
@@ -544,7 +544,7 @@ void SkillDialog::loadXmlFile(const std::string &fileName)
SkillListBox *const listbox = new SkillListBox(this, model);
listbox->setActionEventId("sel");
listbox->addActionListener(this);
- ScrollArea *const scroll = new ScrollArea(listbox, false);
+ ScrollArea *const scroll = new ScrollArea(this, listbox, false);
scroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
scroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS);
@@ -619,7 +619,7 @@ SkillInfo* SkillDialog::getSkillByItem(const int itemId) const
return nullptr;
}
-void SkillDialog::widgetResized(const gcn::Event &event)
+void SkillDialog::widgetResized(const Event &event)
{
Window::widgetResized(event);
diff --git a/src/gui/windows/skilldialog.h b/src/gui/windows/skilldialog.h
index 4a6182d38..3bf64df9b 100644
--- a/src/gui/windows/skilldialog.h
+++ b/src/gui/windows/skilldialog.h
@@ -25,7 +25,7 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
const int SKILL_MIN_ID = 200000;
const unsigned int SKILL_VAR_MIN_ID = 1000000;
@@ -43,7 +43,8 @@ struct SkillInfo;
*
* \ingroup Interface
*/
-class SkillDialog final : public Window, public gcn::ActionListener
+class SkillDialog final : public Window,
+ public ActionListener
{
public:
SkillDialog();
@@ -57,7 +58,7 @@ class SkillDialog final : public Window, public gcn::ActionListener
/**
* Called when receiving actions from widget.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Update the given skill's display
@@ -87,7 +88,7 @@ class SkillDialog final : public Window, public gcn::ActionListener
bool hasSkills() const A_WARN_UNUSED
{ return !mSkills.empty(); }
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
void useItem(const int itemId) const;
diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp
index 2385066be..f33534a85 100644
--- a/src/gui/windows/socialwindow.cpp
+++ b/src/gui/windows/socialwindow.cpp
@@ -33,6 +33,8 @@
#include "input/keyboardconfig.h"
+#include "gui/models/beingslistmodel.h"
+
#include "gui/windows/confirmdialog.h"
#include "gui/windows/okdialog.h"
#include "gui/windows/setupwindow.h"
@@ -41,6 +43,7 @@
#include "gui/windows/outfitwindow.h"
+#include "gui/widgets/avatarlistbox.h"
#include "gui/widgets/button.h"
#include "gui/widgets/browserbox.h"
#include "gui/widgets/label.h"
@@ -115,6 +118,11 @@ public:
virtual void selectIndex(const unsigned num A_UNUSED)
{ }
+ virtual void buildCounter(const int online A_UNUSED = 0,
+ const int total A_UNUSED = 0)
+ {
+ }
+
protected:
friend class SocialWindow;
@@ -157,11 +165,6 @@ protected:
socialWindow->setCounter(this, mCounterString);
}
- virtual void buildCounter(const int online A_UNUSED = 0,
- const int total A_UNUSED = 0)
- {
- }
-
TextDialog *mInviteDialog;
ConfirmDialog *mConfirmDialog;
ScrollArea *mScroll;
@@ -169,13 +172,14 @@ protected:
std::string mCounterString;
};
-class SocialGuildTab final : public SocialTab, public gcn::ActionListener
+class SocialGuildTab final : public SocialTab, public ActionListener
{
public:
SocialGuildTab(const Widget2 *const widget,
- Guild *const guild, const bool showBackground) :
+ Guild *const guild,
+ const bool showBackground) :
SocialTab(widget),
- gcn::ActionListener(),
+ ActionListener(),
mGuild(guild)
{
// TRANSLATORS: tab in social window
@@ -191,7 +195,7 @@ public:
mList = new AvatarListBox(this, guild);
mList->postInit();
- mScroll = new ScrollArea(mList, showBackground,
+ mScroll = new ScrollArea(this, mList, showBackground,
"social_background.xml");
mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
@@ -208,7 +212,7 @@ public:
mScroll = nullptr;
}
- void action(const gcn::ActionEvent &event) override final
+ void action(const ActionEvent &event) override final
{
const std::string &eventId = event.getId();
if (eventId == "do invite")
@@ -305,13 +309,14 @@ private:
Guild *mGuild;
};
-class SocialGuildTab2 final : public SocialTab, public gcn::ActionListener
+class SocialGuildTab2 final : public SocialTab, public ActionListener
{
public:
- SocialGuildTab2(const Widget2 *const widget, Guild *const guild,
+ SocialGuildTab2(const Widget2 *const widget,
+ Guild *const guild,
const bool showBackground) :
SocialTab(widget),
- gcn::ActionListener()
+ ActionListener()
{
// TRANSLATORS: tab in social window
setCaption(_("Guild"));
@@ -326,7 +331,7 @@ public:
mList = new AvatarListBox(this, guild);
mList->postInit();
- mScroll = new ScrollArea(mList, showBackground,
+ mScroll = new ScrollArea(this, mList, showBackground,
"social_background.xml");
mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
@@ -343,7 +348,7 @@ public:
mScroll = nullptr;
}
- void action(const gcn::ActionEvent &event A_UNUSED) override final
+ void action(const ActionEvent &event A_UNUSED) override final
{
}
@@ -372,13 +377,14 @@ public:
}
};
-class SocialPartyTab final : public SocialTab, public gcn::ActionListener
+class SocialPartyTab final : public SocialTab, public ActionListener
{
public:
SocialPartyTab(const Widget2 *const widget,
- Party *const party, const bool showBackground) :
+ Party *const party,
+ const bool showBackground) :
SocialTab(widget),
- gcn::ActionListener(),
+ ActionListener(),
mParty(party)
{
// TRANSLATORS: tab in social window
@@ -394,7 +400,7 @@ public:
mList = new AvatarListBox(this, party);
mList->postInit();
- mScroll = new ScrollArea(mList, showBackground,
+ mScroll = new ScrollArea(this, mList, showBackground,
"social_background.xml");
mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
@@ -411,7 +417,7 @@ public:
mScroll = nullptr;
}
- void action(const gcn::ActionEvent &event) override final
+ void action(const ActionEvent &event) override final
{
const std::string &eventId = event.getId();
if (eventId == "do invite")
@@ -499,52 +505,18 @@ private:
Party *mParty;
};
-class BeingsListModal final : public AvatarListModel
-{
-public:
- BeingsListModal() :
- AvatarListModel(),
- mMembers()
- {
- }
-
- A_DELETE_COPY(BeingsListModal)
-
- ~BeingsListModal()
- {
- delete_all(mMembers);
- mMembers.clear();
- }
-
- std::vector<Avatar*> *getMembers()
- {
- return &mMembers;
- }
-
- Avatar *getAvatarAt(int index) override final
- {
- return mMembers[index];
- }
-
- int getNumberOfElements() override final
- {
- return static_cast<int>(mMembers.size());
- }
-
- std::vector<Avatar*> mMembers;
-};
-
class SocialPlayersTab final : public SocialTab
{
public:
SocialPlayersTab(const Widget2 *const widget,
- std::string name, const bool showBackground) :
+ std::string name,
+ const bool showBackground) :
SocialTab(widget),
- mBeings(new BeingsListModal)
+ mBeings(new BeingsListModel)
{
mList = new AvatarListBox(this, mBeings);
mList->postInit();
- mScroll = new ScrollArea(mList, showBackground,
+ mScroll = new ScrollArea(this, mList, showBackground,
"social_background.xml");
mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
@@ -696,7 +668,7 @@ public:
}
private:
- BeingsListModal *mBeings;
+ BeingsListModel *mBeings;
};
@@ -706,11 +678,11 @@ public:
SocialNavigationTab(const Widget2 *const widget,
const bool showBackground) :
SocialTab(widget),
- mBeings(new BeingsListModal)
+ mBeings(new BeingsListModel)
{
mList = new AvatarListBox(this, mBeings);
mList->postInit();
- mScroll = new ScrollArea(mList, showBackground,
+ mScroll = new ScrollArea(this, mList, showBackground,
"social_background.xml");
mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
@@ -973,7 +945,7 @@ public:
}
private:
- BeingsListModal *mBeings;
+ BeingsListModel *mBeings;
};
@@ -1035,11 +1007,11 @@ public:
SocialAttackTab(const Widget2 *const widget,
const bool showBackground) :
SocialTab(widget),
- mBeings(new BeingsListModal)
+ mBeings(new BeingsListModel)
{
mList = new AvatarListBox(this, mBeings);
mList->postInit();
- mScroll = new ScrollArea(mList, showBackground,
+ mScroll = new ScrollArea(this, mList, showBackground,
"social_background.xml");
mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
@@ -1073,7 +1045,7 @@ public:
}
private:
- BeingsListModal *mBeings;
+ BeingsListModel *mBeings;
};
class SocialPickupTab final : public SocialTab
@@ -1082,11 +1054,11 @@ public:
SocialPickupTab(const Widget2 *const widget,
const bool showBackground) :
SocialTab(widget),
- mBeings(new BeingsListModal)
+ mBeings(new BeingsListModel)
{
mList = new AvatarListBox(this, mBeings);
mList->postInit();
- mScroll = new ScrollArea(mList, showBackground,
+ mScroll = new ScrollArea(this, mList, showBackground,
"social_background.xml");
mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
@@ -1118,7 +1090,7 @@ public:
}
private:
- BeingsListModal *mBeings;
+ BeingsListModel *mBeings;
};
@@ -1126,13 +1098,14 @@ class SocialFriendsTab final : public SocialTab
{
public:
SocialFriendsTab(const Widget2 *const widget,
- std::string name, const bool showBackground) :
+ std::string name,
+ const bool showBackground) :
SocialTab(widget),
- mBeings(new BeingsListModal)
+ mBeings(new BeingsListModel)
{
mList = new AvatarListBox(this, mBeings);
mList->postInit();
- mScroll = new ScrollArea(mList, showBackground,
+ mScroll = new ScrollArea(this, mList, showBackground,
"social_background.xml");
mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
@@ -1208,7 +1181,7 @@ public:
}
private:
- BeingsListModal *mBeings;
+ BeingsListModel *mBeings;
};
@@ -1242,7 +1215,7 @@ public:
A_DELETE_COPY(CreatePopup)
void handleLink(const std::string &link,
- gcn::MouseEvent *event A_UNUSED) override final
+ MouseEvent *event A_UNUSED) override final
{
if (link == "guild" && socialWindow)
{
@@ -1256,7 +1229,7 @@ public:
setVisible(false);
}
- void show(gcn::Widget *parent)
+ void show(Widget *parent)
{
if (!parent)
return;
@@ -1276,7 +1249,7 @@ private:
SocialWindow::SocialWindow() :
// TRANSLATORS: social window name
Window(_("Social"), false, nullptr, "social.xml"),
- gcn::ActionListener(),
+ ActionListener(),
PlayerRelationsListener(),
mGuildInvited(0),
mGuildAcceptDialog(nullptr),
@@ -1336,7 +1309,7 @@ void SocialWindow::postInit()
place(0, 1, mCountLabel);
place(0, 2, mTabs, 4, 4);
- widgetResized(gcn::Event(nullptr));
+ widgetResized(Event(nullptr));
loadWindowState();
@@ -1482,7 +1455,7 @@ bool SocialWindow::removeTab(Party *const party)
return true;
}
-void SocialWindow::action(const gcn::ActionEvent &event)
+void SocialWindow::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
@@ -1744,7 +1717,6 @@ void SocialWindow::slowLogic()
const unsigned int nowTime = cur_time;
if (mNeedUpdate && nowTime - mLastUpdateTime > 1)
{
- logger->log("soc update");
mPlayers->updateList();
mFriends->updateList();
mNeedUpdate = false;
@@ -1863,7 +1835,7 @@ void SocialWindow::updateParty()
}
}
-void SocialWindow::widgetResized(const gcn::Event &event)
+void SocialWindow::widgetResized(const Event &event)
{
Window::widgetResized(event);
if (mTabs)
diff --git a/src/gui/windows/socialwindow.h b/src/gui/windows/socialwindow.h
index e8dc44043..57fbd5be5 100644
--- a/src/gui/windows/socialwindow.h
+++ b/src/gui/windows/socialwindow.h
@@ -24,9 +24,8 @@
#include "gui/widgets/window.h"
-#include "being/playerrelationslistener.h"
-
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/playerrelationslistener.h"
#include <string>
#include <map>
@@ -48,7 +47,7 @@ class TextDialog;
* \ingroup Interface
*/
class SocialWindow final : public Window,
- private gcn::ActionListener,
+ private ActionListener,
public PlayerRelationsListener
{
public:
@@ -68,7 +67,7 @@ public:
bool removeTab(Party *const party);
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void showGuildInvite(const std::string &restrict guildName,
const int guildId,
@@ -123,7 +122,7 @@ public:
void updatePickupFilter();
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
void setCounter(const SocialTab *const tab, const std::string &str);
diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp
index 80e86e66f..05172c9b3 100644
--- a/src/gui/windows/statuswindow.cpp
+++ b/src/gui/windows/statuswindow.cpp
@@ -113,7 +113,7 @@ class DerDisplay final : public AttrDisplay
{ return DERIVED; }
};
-class ChangeDisplay final : public AttrDisplay, gcn::ActionListener
+class ChangeDisplay final : public AttrDisplay, ActionListener
{
public:
ChangeDisplay(const Widget2 *const widget,
@@ -129,7 +129,7 @@ class ChangeDisplay final : public AttrDisplay, gcn::ActionListener
void setPointsNeeded(const int needed);
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
private:
int mNeeded;
@@ -142,7 +142,7 @@ class ChangeDisplay final : public AttrDisplay, gcn::ActionListener
StatusWindow::StatusWindow() :
Window(player_node ? player_node->getName() :
"?", false, nullptr, "status.xml"),
- gcn::ActionListener(),
+ ActionListener(),
// TRANSLATORS: status window label
mLvlLabel(new Label(this, strprintf(_("Level: %d"), 0))),
// TRANSLATORS: status window label
@@ -159,9 +159,9 @@ StatusWindow::StatusWindow() :
mJobLabel(nullptr),
mJobBar(nullptr),
mAttrCont(new VertContainer(this, 32)),
- mAttrScroll(new ScrollArea(mAttrCont, false)),
+ mAttrScroll(new ScrollArea(this, mAttrCont, false)),
mDAttrCont(new VertContainer(this, 32)),
- mDAttrScroll(new ScrollArea(mDAttrCont, false)),
+ mDAttrScroll(new ScrollArea(this, mDAttrCont, false)),
mCharacterPointsLabel(new Label(this, "C")),
mCorrectionPointsLabel(nullptr),
// TRANSLATORS: status window button
@@ -746,7 +746,7 @@ void StatusWindow::updateStatusBar(ProgressBar *const bar,
bar->setBackgroundColor(Theme::getThemeColor(Theme::STATUSBAR_OFF));
}
-void StatusWindow::action(const gcn::ActionEvent &event)
+void StatusWindow::action(const ActionEvent &event)
{
if (!chatWindow)
return;
@@ -820,7 +820,7 @@ ChangeDisplay::ChangeDisplay(const Widget2 *const widget,
const int id, const std::string &restrict name,
const std::string &restrict shortName) :
AttrDisplay(widget, id, name, shortName),
- gcn::ActionListener(),
+ ActionListener(),
mNeeded(1),
// TRANSLATORS: status window label
mPoints(new Label(this, _("Max"))),
@@ -873,7 +873,7 @@ void ChangeDisplay::setPointsNeeded(const int needed)
update();
}
-void ChangeDisplay::action(const gcn::ActionEvent &event)
+void ChangeDisplay::action(const ActionEvent &event)
{
if (Net::getPlayerHandler()->canCorrectAttributes() &&
event.getSource() == mDec)
diff --git a/src/gui/windows/statuswindow.h b/src/gui/windows/statuswindow.h
index 94f1aaa65..3b171a25e 100644
--- a/src/gui/windows/statuswindow.h
+++ b/src/gui/windows/statuswindow.h
@@ -23,11 +23,11 @@
#ifndef GUI_WINDOWS_STATUSWINDOW_H
#define GUI_WINDOWS_STATUSWINDOW_H
-#include "depricatedlistener.h"
+#include "listeners/depricatedlistener.h"
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
#include <map>
@@ -44,7 +44,7 @@ class VertContainer;
* \ingroup Interface
*/
class StatusWindow final : public Window,
- public gcn::ActionListener,
+ public ActionListener,
public DepricatedListener
{
public:
@@ -83,7 +83,7 @@ class StatusWindow final : public Window,
const int id,
const bool percent = true);
- void action(const gcn::ActionEvent &event) override;
+ void action(const ActionEvent &event) override;
void clearAttributes();
diff --git a/src/gui/windows/textcommandeditor.cpp b/src/gui/windows/textcommandeditor.cpp
index 4ae098a3c..dead469bc 100644
--- a/src/gui/windows/textcommandeditor.cpp
+++ b/src/gui/windows/textcommandeditor.cpp
@@ -27,6 +27,10 @@
#include "input/keyboardconfig.h"
+#include "gui/models/iconsmodel.h"
+#include "gui/models/magicschoolmodel.h"
+#include "gui/models/targettypemodel.h"
+
#include "gui/widgets/button.h"
#include "gui/widgets/dropdown.h"
#include "gui/widgets/inttextfield.h"
@@ -36,131 +40,12 @@
#include "utils/gettext.h"
-#include "resources/iteminfo.h"
-
-#include "resources/db/itemdb.h"
-
#include "debug.h"
-class IconsModal final : public gcn::ListModel
-{
-public:
- IconsModal() :
- mStrings()
- {
- const std::map<int, ItemInfo*> &items = ItemDB::getItemInfos();
- std::list<std::string> tempStrings;
-
- for (std::map<int, ItemInfo*>::const_iterator
- i = items.begin(), i_end = items.end();
- i != i_end; ++i)
- {
- if (i->first < 0)
- continue;
-
- const ItemInfo &info = (*i->second);
- const std::string name = info.getName();
- if (name != "unnamed" && !info.getName().empty()
- && info.getName() != "unnamed")
- {
- tempStrings.push_back(name);
- }
- }
- tempStrings.sort();
- mStrings.push_back("");
- FOR_EACH (std::list<std::string>::const_iterator, i, tempStrings)
- mStrings.push_back(*i);
- }
-
- A_DELETE_COPY(IconsModal)
-
- ~IconsModal()
- { }
-
- int getNumberOfElements() override final
- {
- return static_cast<int>(mStrings.size());
- }
-
- std::string getElementAt(int i) override final
- {
- if (i < 0 || i >= getNumberOfElements())
- return "???";
- return mStrings.at(i);
- }
-private:
- StringVect mStrings;
-};
-
-
-const char *TARGET_TYPE_TEXT[3] =
-{
- // TRANSLATORS: target type
- N_("No Target"),
- // TRANSLATORS: target type
- N_("Allow Target"),
- // TRANSLATORS: target type
- N_("Need Target"),
-};
-
-const char *MAGIC_SCHOOL_TEXT[6] =
-{
- // TRANSLATORS: magic school
- N_("General Magic"),
- // TRANSLATORS: magic school
- N_("Life Magic"),
- // TRANSLATORS: magic school
- N_("War Magic"),
- // TRANSLATORS: magic school
- N_("Transmute Magic"),
- // TRANSLATORS: magic school
- N_("Nature Magic"),
- // TRANSLATORS: magic school
- N_("Astral Magic")
-};
-
-class TargetTypeModel final : public gcn::ListModel
-{
-public:
- ~TargetTypeModel()
- { }
-
- int getNumberOfElements() override final
- {
- return 3;
- }
-
- std::string getElementAt(int i) override final
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
- return TARGET_TYPE_TEXT[i];
- }
-};
-
-class MagicSchoolModel final : public gcn::ListModel
-{
-public:
- ~MagicSchoolModel()
- { }
-
- int getNumberOfElements() override final
- {
- return 6;
- }
-
- std::string getElementAt(int i) override final
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
- return MAGIC_SCHOOL_TEXT[i];
- }
-};
-
TextCommandEditor::TextCommandEditor(TextCommand *const command) :
// TRANSLATORS: command editor name
Window(_("Command Editor"), false, nullptr, "commandeditor.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mIsMagicCommand(command->getCommandType() == TEXT_COMMAND_MAGIC),
mCommand(command),
// TRANSLATORS: command editor button
@@ -180,10 +65,10 @@ TextCommandEditor::TextCommandEditor(TextCommand *const command) :
// TRANSLATORS: command editor label
mTypeLabel(new Label(this, _("Target Type:"))),
mTypeDropDown(new DropDown(this, mTargetTypeModel)),
- mIconsModal(new IconsModal),
+ mIconsModel(new IconsModel),
// TRANSLATORS: command editor label
mIconLabel(new Label(this, _("Icon:"))),
- mIconDropDown(new DropDown(this, mIconsModal)),
+ mIconDropDown(new DropDown(this, mIconsModel)),
// TRANSLATORS: command editor label
mManaLabel(new Label(this, _("Mana:"))),
mManaField(new IntTextField(this, 0)),
@@ -306,15 +191,15 @@ void TextCommandEditor::postInit()
TextCommandEditor::~TextCommandEditor()
{
- delete mIconsModal;
- mIconsModal = nullptr;
+ delete mIconsModel;
+ mIconsModel = nullptr;
delete mTargetTypeModel;
mTargetTypeModel = nullptr;
delete mMagicSchoolModel;
mMagicSchoolModel = nullptr;
}
-void TextCommandEditor::action(const gcn::ActionEvent &event)
+void TextCommandEditor::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "magic")
diff --git a/src/gui/windows/textcommandeditor.h b/src/gui/windows/textcommandeditor.h
index a31cdbaf2..de7f3b1a4 100644
--- a/src/gui/windows/textcommandeditor.h
+++ b/src/gui/windows/textcommandeditor.h
@@ -25,11 +25,11 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
class Button;
class DropDown;
-class IconsModal;
+class IconsModel;
class IntTextField;
class Label;
class MagicSchoolModel;
@@ -38,7 +38,8 @@ class TargetTypeModel;
class TextCommand;
class TextField;
-class TextCommandEditor final : public Window, public gcn::ActionListener
+class TextCommandEditor final : public Window,
+ public ActionListener
{
public:
/**
@@ -55,7 +56,7 @@ class TextCommandEditor final : public Window, public gcn::ActionListener
void postInit() override final;
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void scheduleDelete() override final;
@@ -82,7 +83,7 @@ class TextCommandEditor final : public Window, public gcn::ActionListener
TargetTypeModel *mTargetTypeModel;
Label *mTypeLabel;
DropDown *mTypeDropDown;
- IconsModal *mIconsModal;
+ IconsModel *mIconsModel;
Label *mIconLabel;
DropDown *mIconDropDown;
Label *mManaLabel;
diff --git a/src/gui/windows/textdialog.cpp b/src/gui/windows/textdialog.cpp
index 936f08c76..9b7bb3eb1 100644
--- a/src/gui/windows/textdialog.cpp
+++ b/src/gui/windows/textdialog.cpp
@@ -30,7 +30,7 @@
#include "utils/gettext.h"
-#include <guichan/font.hpp>
+#include "gui/font.h"
#include "debug.h"
@@ -41,7 +41,7 @@ TextDialog::TextDialog(const std::string &restrict title,
Window *const parent,
const bool isPassword):
Window(title, true, parent, "textdialog.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mTextField(nullptr),
mPasswordField(nullptr),
// TRANSLATORS: text dialog button
@@ -68,7 +68,7 @@ TextDialog::TextDialog(const std::string &restrict title,
place(2, 2, mOkButton);
place(3, 2, cancelButton);
- const gcn::Font *const font = getFont();
+ const Font *const font = getFont();
if (font)
{
int width = font->getWidth(title);
@@ -104,7 +104,7 @@ TextDialog::~TextDialog()
instances--;
}
-void TextDialog::action(const gcn::ActionEvent &event)
+void TextDialog::action(const ActionEvent &event)
{
if (event.getId() == "CANCEL")
setActionEventId("~" + getActionEventId());
diff --git a/src/gui/windows/textdialog.h b/src/gui/windows/textdialog.h
index 9bfb4ae5f..8e69e8a3d 100644
--- a/src/gui/windows/textdialog.h
+++ b/src/gui/windows/textdialog.h
@@ -25,7 +25,7 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
class Button;
class PasswordField;
@@ -36,7 +36,8 @@ class TextField;
*
* \ingroup GUI
*/
-class TextDialog final : public Window, public gcn::ActionListener
+class TextDialog final : public Window,
+ public ActionListener
{
public:
/**
@@ -58,7 +59,7 @@ public:
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Get the text in the textfield
diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp
index a379f0f28..506f25c17 100644
--- a/src/gui/windows/tradewindow.cpp
+++ b/src/gui/windows/tradewindow.cpp
@@ -31,7 +31,8 @@
#include "being/playerinfo.h"
#include "being/playerrelations.h"
-#include "gui/sdlfont.h"
+#include "gui/font.h"
+#include "gui/gui.h"
#include "gui/windows/inventorywindow.h"
#include "gui/windows/itemamountwindow.h"
@@ -51,8 +52,6 @@
#include "utils/gettext.h"
-#include <guichan/font.hpp>
-
#include "debug.h"
// TRANSLATORS: trade window button
@@ -67,8 +66,8 @@
TradeWindow::TradeWindow():
// TRANSLATORS: trade window caption
Window(_("Trade: You"), false, nullptr, "trade.xml"),
- gcn::ActionListener(),
- gcn::SelectionListener(),
+ ActionListener(),
+ SelectionListener(),
mMyInventory(new Inventory(Inventory::TRADE)),
mPartnerInventory(new Inventory(Inventory::TRADE)),
mMyItemContainer(new ItemContainer(this, mMyInventory.get())),
@@ -102,7 +101,7 @@ TradeWindow::TradeWindow():
if (setupWindow)
setupWindow->registerWindowForReset(this);
- const gcn::Font *const fnt = mOkButton->getFont();
+ const Font *const fnt = mOkButton->getFont();
int width = std::max(fnt->getWidth(CAPTION_PROPOSE),
fnt->getWidth(CAPTION_CONFIRMED));
width = std::max(width, fnt->getWidth(CAPTION_ACCEPT));
@@ -112,13 +111,14 @@ TradeWindow::TradeWindow():
mMyItemContainer->addSelectionListener(this);
- ScrollArea *const myScroll = new ScrollArea(mMyItemContainer,
+ ScrollArea *const myScroll = new ScrollArea(this, mMyItemContainer,
true, "trade_background.xml");
myScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
mPartnerItemContainer->addSelectionListener(this);
- ScrollArea *const partnerScroll = new ScrollArea(mPartnerItemContainer,
+ ScrollArea *const partnerScroll = new ScrollArea(this,
+ mPartnerItemContainer,
true, "trade_background.xml");
partnerScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
@@ -130,8 +130,7 @@ TradeWindow::TradeWindow():
place(1, 0, mMoneyLabel);
place(0, 1, myScroll).setPadding(3);
place(1, 1, partnerScroll).setPadding(3);
- ContainerPlacer placer;
- placer = getPlacer(0, 0);
+ ContainerPlacer placer = getPlacer(0, 0);
placer(0, 0, moneyLabel2);
placer(1, 0, mMoneyField, 2);
placer(3, 0, mMoneyChangeButton).setHAlign(LayoutCell::LEFT);
@@ -268,7 +267,7 @@ void TradeWindow::tradeItem(const Item *const item, const int quantity,
Net::getTradeHandler()->addItem(item, quantity);
}
-void TradeWindow::valueChanged(const gcn::SelectionEvent &event)
+void TradeWindow::valueChanged(const SelectionEvent &event)
{
if (!mMyItemContainer || !mPartnerItemContainer)
return;
@@ -318,7 +317,7 @@ void TradeWindow::setStatus(const Status s)
mOkButton->setEnabled((s != PROPOSING && s != ACCEPTED));
}
-void TradeWindow::action(const gcn::ActionEvent &event)
+void TradeWindow::action(const ActionEvent &event)
{
if (!inventoryWindow)
return;
diff --git a/src/gui/windows/tradewindow.h b/src/gui/windows/tradewindow.h
index ac49c1f52..9704c1e80 100644
--- a/src/gui/windows/tradewindow.h
+++ b/src/gui/windows/tradewindow.h
@@ -25,8 +25,8 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/selectionlistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/selectionlistener.h"
#include <memory>
@@ -43,8 +43,8 @@ class TextField;
* \ingroup Interface
*/
class TradeWindow final : public Window,
- private gcn::ActionListener,
- private gcn::SelectionListener
+ private ActionListener,
+ private SelectionListener
{
public:
/**
@@ -109,12 +109,12 @@ class TradeWindow final : public Window,
* Updates the labels and makes sure only one item is selected in
* either my inventory or partner inventory.
*/
- void valueChanged(const gcn::SelectionEvent &event) override final;
+ void valueChanged(const SelectionEvent &event) override final;
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Closes the Trade Window, as well as telling the server that the
diff --git a/src/gui/windows/unregisterdialog.cpp b/src/gui/windows/unregisterdialog.cpp
index 76afb1539..3326ca2bb 100644
--- a/src/gui/windows/unregisterdialog.cpp
+++ b/src/gui/windows/unregisterdialog.cpp
@@ -45,7 +45,7 @@
UnRegisterDialog::UnRegisterDialog(LoginData *const data) :
// TRANSLATORS: unregister dialog name
Window(_("Unregister"), true, nullptr, "unregister.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mLoginData(data),
mPasswordField(new PasswordField(this, mLoginData->password)),
// TRANSLATORS: unregister dialog. button.
@@ -101,7 +101,7 @@ UnRegisterDialog::~UnRegisterDialog()
mWrongDataNoticeListener = nullptr;
}
-void UnRegisterDialog::action(const gcn::ActionEvent &event)
+void UnRegisterDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "cancel")
diff --git a/src/gui/windows/unregisterdialog.h b/src/gui/windows/unregisterdialog.h
index fd40810ac..206c05413 100644
--- a/src/gui/windows/unregisterdialog.h
+++ b/src/gui/windows/unregisterdialog.h
@@ -25,7 +25,7 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
class Button;
class LoginData;
@@ -37,7 +37,8 @@ class WrongDataNoticeListener;
*
* \ingroup Interface
*/
-class UnRegisterDialog final : public Window, public gcn::ActionListener
+class UnRegisterDialog final : public Window,
+ public ActionListener
{
public:
/**
@@ -56,7 +57,7 @@ class UnRegisterDialog final : public Window, public gcn::ActionListener
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
private:
LoginData *mLoginData;
diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp
index eab1bea1b..e72308da7 100644
--- a/src/gui/windows/updaterwindow.cpp
+++ b/src/gui/windows/updaterwindow.cpp
@@ -25,8 +25,9 @@
#include "client.h"
#include "configuration.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
#include "gui/widgets/browserbox.h"
#include "gui/widgets/button.h"
@@ -156,8 +157,8 @@ UpdaterWindow::UpdaterWindow(const std::string &restrict updateHost,
const int updateType):
// TRANSLATORS: updater window name
Window(_("Updating..."), false, nullptr, "update.xml"),
- gcn::ActionListener(),
- gcn::KeyListener(),
+ ActionListener(),
+ KeyListener(),
mDownloadStatus(UPDATE_NEWS),
mUpdateHost(updateHost),
mUpdatesDir(updatesDir),
@@ -189,7 +190,8 @@ UpdaterWindow::UpdaterWindow(const std::string &restrict updateHost,
"updateprogressbar.xml", "updateprogressbar_fill.xml")),
mBrowserBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true,
"browserbox.xml")),
- mScrollArea(new ScrollArea(mBrowserBox, true, "update_background.xml")),
+ mScrollArea(new ScrollArea(this, mBrowserBox,
+ true, "update_background.xml")),
mUpdateServerPath(mUpdateHost)
{
setWindowName("UpdaterWindow");
@@ -270,7 +272,7 @@ void UpdaterWindow::enable()
client->setState(STATE_LOAD_DATA);
}
-void UpdaterWindow::action(const gcn::ActionEvent &event)
+void UpdaterWindow::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "cancel")
@@ -290,12 +292,12 @@ void UpdaterWindow::action(const gcn::ActionEvent &event)
}
}
-void UpdaterWindow::keyPressed(gcn::KeyEvent &keyEvent)
+void UpdaterWindow::keyPressed(KeyEvent &keyEvent)
{
- const int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int actionId = keyEvent.getActionId();
if (actionId == static_cast<int>(Input::KEY_GUI_CANCEL))
{
- action(gcn::ActionEvent(nullptr, mCancelButton->getActionEventId()));
+ action(ActionEvent(nullptr, mCancelButton->getActionEventId()));
client->setState(STATE_LOGIN);
}
else if (actionId == static_cast<int>(Input::KEY_GUI_SELECT)
@@ -304,12 +306,11 @@ void UpdaterWindow::keyPressed(gcn::KeyEvent &keyEvent)
if (mDownloadStatus == UPDATE_COMPLETE ||
mDownloadStatus == UPDATE_ERROR)
{
- action(gcn::ActionEvent(nullptr, mPlayButton->getActionEventId()));
+ action(ActionEvent(nullptr, mPlayButton->getActionEventId()));
}
else
{
- action(gcn::ActionEvent(nullptr,
- mCancelButton->getActionEventId()));
+ action(ActionEvent(nullptr, mCancelButton->getActionEventId()));
}
}
}
@@ -971,7 +972,7 @@ unsigned long UpdaterWindow::getFileHash(const std::string &filePath)
}
void UpdaterWindow::handleLink(const std::string &link,
- gcn::MouseEvent *event A_UNUSED)
+ MouseEvent *event A_UNUSED)
{
if (strStartWith(link, "http://") || strStartWith(link, "https://"))
openBrowser(link);
diff --git a/src/gui/windows/updaterwindow.h b/src/gui/windows/updaterwindow.h
index bddd3ef9e..79d764752 100644
--- a/src/gui/windows/updaterwindow.h
+++ b/src/gui/windows/updaterwindow.h
@@ -30,8 +30,8 @@
#include "utils/mutex.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/keylistener.h"
#include <string>
#include <vector>
@@ -69,9 +69,9 @@ struct UpdateFile final
* \ingroup GUI
*/
class UpdaterWindow final : public Window,
- public gcn::ActionListener,
+ public ActionListener,
public LinkHandler,
- public gcn::KeyListener
+ public KeyListener
{
public:
/**
@@ -119,14 +119,14 @@ class UpdaterWindow final : public Window,
void loadPatch();
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
- void keyPressed(gcn::KeyEvent &keyEvent) override final;
+ void keyPressed(KeyEvent &keyEvent) override final;
void logic() override final;
void handleLink(const std::string &link,
- gcn::MouseEvent *event A_UNUSED) override final;
+ MouseEvent *event A_UNUSED) override final;
void loadFile(std::string file);
diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp
index fd54076ed..dabc8c7c1 100644
--- a/src/gui/windows/whoisonline.cpp
+++ b/src/gui/windows/whoisonline.cpp
@@ -87,7 +87,7 @@ WhoIsOnline::WhoIsOnline() :
mCurlError(new char[CURL_ERROR_SIZE]),
mBrowserBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true,
"onlinebrowserbox.xml")),
- mScrollArea(new ScrollArea(mBrowserBox, false)),
+ mScrollArea(new ScrollArea(this, mBrowserBox, false)),
mUpdateTimer(0),
mOnlinePlayers(),
mOnlineNicks(),
@@ -116,10 +116,10 @@ void WhoIsOnline::postInit()
setSaveVisible(true);
mUpdateButton->setEnabled(false);
- mUpdateButton->setDimension(gcn::Rectangle(5, 5, w - 10, 20 + 5));
+ mUpdateButton->setDimension(Rect(5, 5, w - 10, 20 + 5));
mBrowserBox->setOpaque(false);
- mScrollArea->setDimension(gcn::Rectangle(5, 20 + 10, w - 10, h - 10 - 30));
+ mScrollArea->setDimension(Rect(5, 20 + 10, w - 10, h - 10 - 30));
mScrollArea->setSize(w - 10, h - 10 - 30);
mBrowserBox->setLinkHandler(this);
@@ -133,7 +133,7 @@ void WhoIsOnline::postInit()
download();
- widgetResized(gcn::Event(nullptr));
+ widgetResized(Event(nullptr));
config.addListener("updateOnlineList", this);
config.addListener("groupFriends", this);
mGroupFriends = config.getBoolValue("groupFriends");
@@ -159,9 +159,9 @@ WhoIsOnline::~WhoIsOnline()
mOnlineNicks.clear();
}
-void WhoIsOnline::handleLink(const std::string& link, gcn::MouseEvent *event)
+void WhoIsOnline::handleLink(const std::string& link, MouseEvent *event)
{
- if (!event || event->getButton() == gcn::MouseEvent::LEFT)
+ if (!event || event->getButton() == MouseEvent::LEFT)
{
if (chatWindow)
{
@@ -177,7 +177,7 @@ void WhoIsOnline::handleLink(const std::string& link, gcn::MouseEvent *event)
}
}
}
- else if (event->getButton() == gcn::MouseEvent::RIGHT)
+ else if (event->getButton() == MouseEvent::RIGHT)
{
if (player_node && link == player_node->getName())
return;
@@ -683,7 +683,7 @@ void WhoIsOnline::slowLogic()
BLOCK_END("WhoIsOnline::slowLogic")
}
-void WhoIsOnline::action(const gcn::ActionEvent &event)
+void WhoIsOnline::action(const ActionEvent &event)
{
if (event.getId() == "update")
{
@@ -715,7 +715,7 @@ void WhoIsOnline::action(const gcn::ActionEvent &event)
}
}
-void WhoIsOnline::widgetResized(const gcn::Event &event)
+void WhoIsOnline::widgetResized(const Event &event)
{
Window::widgetResized(event);
updateSize();
@@ -723,7 +723,7 @@ void WhoIsOnline::widgetResized(const gcn::Event &event)
void WhoIsOnline::updateSize()
{
- const gcn::Rectangle area = getChildrenArea();
+ const Rect area = getChildrenArea();
if (mUpdateButton)
mUpdateButton->setWidth(area.width - 10);
diff --git a/src/gui/windows/whoisonline.h b/src/gui/windows/whoisonline.h
index 10a8be4b5..bc04c8066 100644
--- a/src/gui/windows/whoisonline.h
+++ b/src/gui/windows/whoisonline.h
@@ -23,14 +23,14 @@
#ifndef GUI_WINDOWS_WHOISONLINE_H
#define GUI_WINDOWS_WHOISONLINE_H
-#include "configlistener.h"
+#include "listeners/configlistener.h"
#include "gui/widgets/linkhandler.h"
#include "gui/widgets/window.h"
#include <set>
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
class BrowserBox;
class Button;
@@ -102,7 +102,7 @@ class OnlinePlayer final
*/
class WhoIsOnline final : public Window,
public LinkHandler,
- public gcn::ActionListener,
+ public ActionListener,
public ConfigListener
{
public:
@@ -128,15 +128,15 @@ public:
void loadList(std::vector<OnlinePlayer*> &list);
void handleLink(const std::string& link,
- gcn::MouseEvent *event) override final;
+ MouseEvent *event) override final;
void logic() override final;
void slowLogic();
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
const std::set<OnlinePlayer*> &getOnlinePlayers() const A_WARN_UNUSED
{ return mOnlinePlayers; }
diff --git a/src/gui/windows/worldselectdialog.cpp b/src/gui/windows/worldselectdialog.cpp
index a3fd0fc73..77d167c82 100644
--- a/src/gui/windows/worldselectdialog.cpp
+++ b/src/gui/windows/worldselectdialog.cpp
@@ -24,14 +24,17 @@
#include "client.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
#include "gui/widgets/button.h"
#include "gui/widgets/layout.h"
#include "gui/widgets/listbox.h"
#include "gui/widgets/scrollarea.h"
+#include "gui/models/worldlistmodel.h"
+
#include "net/loginhandler.h"
#include "net/net.h"
@@ -41,49 +44,11 @@
extern WorldInfo **server_info;
-/**
- * The list model for the server list.
- */
-class WorldListModel final : public gcn::ListModel
-{
- public:
- explicit WorldListModel(Worlds worlds) :
- mWorlds(worlds)
- {
- }
-
- A_DELETE_COPY(WorldListModel)
-
- ~WorldListModel()
- { }
-
- int getNumberOfElements() override final
- {
- return static_cast<int>(mWorlds.size());
- }
-
- std::string getElementAt(int i) override final
- {
- const WorldInfo *const si = mWorlds[i];
- if (si)
- {
- return std::string(si->name).append(" (").append(
- toString(si->online_users)).append(")");
- }
- else
- {
- return "???";
- }
- }
- private:
- Worlds mWorlds;
-};
-
WorldSelectDialog::WorldSelectDialog(Worlds worlds):
// TRANSLATORS: world select dialog name
Window(_("Select World"), false, nullptr, "world.xml"),
- gcn::ActionListener(),
- gcn::KeyListener(),
+ ActionListener(),
+ KeyListener(),
mWorldListModel(new WorldListModel(worlds)),
mWorldList(new ListBox(this, mWorldListModel, "")),
// TRANSLATORS: world dialog button
@@ -92,7 +57,7 @@ WorldSelectDialog::WorldSelectDialog(Worlds worlds):
mChooseWorld(new Button(this, _("Choose World"), "world", this))
{
mWorldList->postInit();
- ScrollArea *const worldsScroll = new ScrollArea(mWorldList,
+ ScrollArea *const worldsScroll = new ScrollArea(this, mWorldList,
getOptionBool("showbackground"), "world_background.xml");
worldsScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
@@ -134,7 +99,7 @@ WorldSelectDialog::~WorldSelectDialog()
mWorldListModel = nullptr;
}
-void WorldSelectDialog::action(const gcn::ActionEvent &event)
+void WorldSelectDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "world")
@@ -153,19 +118,18 @@ void WorldSelectDialog::action(const gcn::ActionEvent &event)
}
}
-void WorldSelectDialog::keyPressed(gcn::KeyEvent &keyEvent)
+void WorldSelectDialog::keyPressed(KeyEvent &keyEvent)
{
- const int actionId = static_cast<KeyEvent*>(
- &keyEvent)->getActionId();
+ const int actionId = keyEvent.getActionId();
if (actionId == static_cast<int>(Input::KEY_GUI_CANCEL))
{
- action(gcn::ActionEvent(nullptr,
+ action(ActionEvent(nullptr,
mChangeLoginButton->getActionEventId()));
}
else if (actionId == static_cast<int>(Input::KEY_GUI_SELECT)
|| actionId == static_cast<int>(Input::KEY_GUI_SELECT2))
{
- action(gcn::ActionEvent(nullptr, mChooseWorld->getActionEventId()));
+ action(ActionEvent(nullptr, mChooseWorld->getActionEventId()));
}
}
diff --git a/src/gui/windows/worldselectdialog.h b/src/gui/windows/worldselectdialog.h
index f7491689b..9d06ac25e 100644
--- a/src/gui/windows/worldselectdialog.h
+++ b/src/gui/windows/worldselectdialog.h
@@ -27,8 +27,8 @@
#include "net/worldinfo.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/keylistener.h"
class Button;
class ListBox;
@@ -39,8 +39,9 @@ class WorldListModel;
*
* \ingroup Interface
*/
-class WorldSelectDialog final : public Window, public gcn::ActionListener,
- public gcn::KeyListener
+class WorldSelectDialog final : public Window,
+ public ActionListener,
+ public KeyListener
{
public:
/**
@@ -62,9 +63,9 @@ class WorldSelectDialog final : public Window, public gcn::ActionListener,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
- void keyPressed(gcn::KeyEvent &keyEvent) override final;
+ void keyPressed(KeyEvent &keyEvent) override final;
private:
WorldListModel *mWorldListModel;
diff --git a/src/guichan/actionevent.cpp b/src/guichan/actionevent.cpp
deleted file mode 100644
index 2a31bfc8b..000000000
--- a/src/guichan/actionevent.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * For comments regarding functions please see the header file.
- */
-
-#include "guichan/actionevent.hpp"
-
-#include "debug.h"
-
-namespace gcn
-{
- ActionEvent::ActionEvent(Widget *const source, const std::string &id)
- :Event(source),
- mId(id)
- {
- }
-
- ActionEvent::~ActionEvent()
- {
- }
-
- const std::string& ActionEvent::getId() const
- {
- return mId;
- }
-} // namespace gcn
diff --git a/src/guichan/cliprectangle.cpp b/src/guichan/cliprectangle.cpp
deleted file mode 100644
index c09990087..000000000
--- a/src/guichan/cliprectangle.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * For comments regarding functions please see the header file.
- */
-
-#include "guichan/cliprectangle.hpp"
-
-#include "debug.h"
-
-namespace gcn
-{
- ClipRectangle::ClipRectangle() :
- Rectangle(),
- xOffset(0),
- yOffset(0)
- {
- x = 0;
- y = 0;
- width = 0;
- height = 0;
- }
-
- ClipRectangle::ClipRectangle(const int x0, const int y0,
- const int width0, const int height0,
- const int xOffset0, const int yOffset0) :
- Rectangle(),
- xOffset(xOffset0),
- yOffset(yOffset0)
- {
- x = x0;
- y = y0;
- width = width0;
- height = height0;
- }
-
- const ClipRectangle& ClipRectangle::operator=(const Rectangle& other)
- {
- x = other.x;
- y = other.y;
- width = other.width;
- height = other.height;
-
- return *this;
- }
-} // namespace gcn
diff --git a/src/guichan/color.cpp b/src/guichan/color.cpp
deleted file mode 100644
index 27612876f..000000000
--- a/src/guichan/color.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * For comments regarding functions please see the header file.
- */
-
-#include "guichan/color.hpp"
-
-#include "debug.h"
-
-namespace gcn
-{
- Color::Color() :
- r(0),
- g(0),
- b(0),
- a(255)
- {
- }
-
- Color::Color(const int color) :
- r((color >> 16) & 0xFF),
- g((color >> 8) & 0xFF),
- b(color & 0xFF),
- a(255)
- {
- }
-
- Color::Color(const int ar, const int ag, const int ab, const int aa) :
- r(ar),
- g(ag),
- b(ab),
- a(aa)
- {
- }
-
- Color Color::operator+(const Color& color) const
- {
- Color result(r + color.r,
- g + color.g,
- b + color.b,
- 255);
-
- result.r = (result.r>255?255:(result.r<0?0:result.r));
- result.g = (result.g>255?255:(result.g<0?0:result.g));
- result.b = (result.b>255?255:(result.b<0?0:result.b));
-
- return result;
- }
-
- Color Color::operator-(const Color& color) const
- {
- Color result(r - color.r,
- g - color.g,
- b - color.b,
- 255);
-
- result.r = (result.r > 255 ? 255 : (result.r < 0 ? 0 : result.r));
- result.g = (result.g > 255 ? 255 : (result.g < 0 ? 0 : result.g));
- result.b = (result.b > 255 ? 255 : (result.b < 0 ? 0 : result.b));
-
- return result;
- }
-
- Color Color::operator*(const float value) const
- {
- Color result(static_cast<int>(static_cast<float>(r) * value),
- static_cast<int>(static_cast<float>(g) * value),
- static_cast<int>(static_cast<float>(b) * value),
- a);
-
- result.r = (result.r > 255 ? 255 : (result.r < 0 ? 0 : result.r));
- result.g = (result.g > 255 ? 255 : (result.g < 0 ? 0 : result.g));
- result.b = (result.b > 255 ? 255 : (result.b < 0 ? 0 : result.b));
-
- return result;
- }
-
- bool Color::operator==(const Color& color) const
- {
- return r == color.r && g == color.g && b == color.b && a == color.a;
- }
-
- bool Color::operator!=(const Color& color) const
- {
- return !(r == color.r && g == color.g && b == color.b && a == color.a);
- }
-
- std::ostream& operator<<(std::ostream& out,
- const Color& color)
- {
- out << "Color [r = "
- << color.r
- << ", g = "
- << color.g
- << ", b = "
- << color.b
- << ", a = "
- << color.a
- << "]";
-
- return out;
- }
-} // namespace gcn
diff --git a/src/guichan/event.cpp b/src/guichan/event.cpp
deleted file mode 100644
index f4a03bc19..000000000
--- a/src/guichan/event.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * For comments regarding functions please see the header file.
- */
-
-#include "guichan/event.hpp"
-
-#include "debug.h"
-
-namespace gcn
-{
- Event::Event(Widget *const source) :
- mSource(source)
- {
- }
-
- Event::~Event()
- {
- }
-
- Widget* Event::getSource() const
- {
- return mSource;
- }
-} // namespace gcn
diff --git a/src/guichan/exception.cpp b/src/guichan/exception.cpp
deleted file mode 100644
index b02df93eb..000000000
--- a/src/guichan/exception.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * For comments regarding functions please see the header file.
- */
-
-#include "guichan/exception.hpp"
-
-#include "debug.h"
-
-namespace gcn
-{
- Exception::Exception()
- : mFunction("?"),
- mMessage(""),
- mFilename("?"),
- mLine(0)
- {
- }
-
- Exception::Exception(const std::string& message)
- : mFunction("?"),
- mMessage(message),
- mFilename("?"),
- mLine(0)
- {
- }
-
- Exception::Exception(const std::string& message,
- const std::string& function,
- const std::string& filename,
- const unsigned int line)
- : mFunction(function),
- mMessage(message),
- mFilename(filename),
- mLine(line)
- {
- }
-
- const std::string& Exception::getFunction() const
- {
- return mFunction;
- }
-
- const std::string& Exception::getMessage() const
- {
- return mMessage;
- }
-
- const std::string& Exception::getFilename() const
- {
- return mFilename;
- }
-
- unsigned int Exception::getLine() const
- {
- return mLine;
- }
-} // namespace gcn
diff --git a/src/guichan/focushandler.cpp b/src/guichan/focushandler.cpp
deleted file mode 100644
index 3249703a3..000000000
--- a/src/guichan/focushandler.cpp
+++ /dev/null
@@ -1,571 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * For comments regarding functions please see the header file.
- */
-
-#include "guichan/focushandler.hpp"
-
-#include "guichan/focuslistener.hpp"
-#include "guichan/exception.hpp"
-#include "guichan/widget.hpp"
-
-#include "debug.h"
-
-namespace gcn
-{
- FocusHandler::FocusHandler() :
- mWidgets(),
- mFocusedWidget(nullptr),
- mModalFocusedWidget(nullptr),
- mModalMouseInputFocusedWidget(nullptr),
- mDraggedWidget(nullptr),
- mLastWidgetWithMouse(nullptr),
- mLastWidgetWithModalFocus(nullptr),
- mLastWidgetWithModalMouseInputFocus(nullptr),
- mLastWidgetPressed(nullptr)
- {
- }
-
- void FocusHandler::requestFocus(Widget* widget)
- {
- if (!widget || widget == mFocusedWidget)
- return;
-
- int toBeFocusedIndex = -1;
- for (unsigned int i = 0, sz = static_cast<unsigned int>(
- mWidgets.size()); i < sz; ++i)
- {
- if (mWidgets[i] == widget)
- {
- toBeFocusedIndex = i;
- break;
- }
- }
-
- if (toBeFocusedIndex < 0)
- throw GCN_EXCEPTION("Trying to focus a none existing widget.");
-
- Widget *const oldFocused = mFocusedWidget;
-
- if (oldFocused != widget)
- {
- mFocusedWidget = mWidgets.at(toBeFocusedIndex);
-
- if (oldFocused)
- {
- Event focusEvent(oldFocused);
- distributeFocusLostEvent(focusEvent);
- }
-
- Event focusEvent(mWidgets.at(toBeFocusedIndex));
- distributeFocusGainedEvent(focusEvent);
- }
- }
-
- void FocusHandler::requestModalFocus(Widget* widget)
- {
- if (mModalFocusedWidget && mModalFocusedWidget != widget)
- throw GCN_EXCEPTION("Another widget already has modal focus.");
-
- mModalFocusedWidget = widget;
-
- if (mFocusedWidget && !mFocusedWidget->isModalFocused())
- focusNone();
- }
-
- void FocusHandler::requestModalMouseInputFocus(Widget* widget)
- {
- if (mModalMouseInputFocusedWidget
- && mModalMouseInputFocusedWidget != widget)
- {
- throw GCN_EXCEPTION("Another widget already has "
- "modal input focus.");
- }
-
- mModalMouseInputFocusedWidget = widget;
- }
-
- void FocusHandler::releaseModalFocus(Widget* widget)
- {
- if (mModalFocusedWidget == widget)
- mModalFocusedWidget = nullptr;
- }
-
- void FocusHandler::releaseModalMouseInputFocus(Widget* widget)
- {
- if (mModalMouseInputFocusedWidget == widget)
- mModalMouseInputFocusedWidget = nullptr;
- }
-
- Widget* FocusHandler::getFocused() const
- {
- return mFocusedWidget;
- }
-
- Widget* FocusHandler::getModalFocused() const
- {
- return mModalFocusedWidget;
- }
-
- Widget* FocusHandler::getModalMouseInputFocused() const
- {
- return mModalMouseInputFocusedWidget;
- }
-
- void FocusHandler::focusNext()
- {
- int i;
- int focusedWidget = -1;
- const int sz = static_cast<int>(mWidgets.size());
- for (i = 0; i < sz; ++i)
- {
- if (mWidgets[i] == mFocusedWidget)
- focusedWidget = i;
- }
- const int focused = focusedWidget;
-
- // i is a counter that ensures that the following loop
- // won't get stuck in an infinite loop
- i = sz;
- do
- {
- ++ focusedWidget;
-
- if (i == 0)
- {
- focusedWidget = -1;
- break;
- }
-
- -- i;
-
- if (focusedWidget >= sz)
- focusedWidget = 0;
-
- if (focusedWidget == focused)
- return;
- }
- while (!mWidgets.at(focusedWidget)->isFocusable());
-
- if (focusedWidget >= 0)
- {
- mFocusedWidget = mWidgets.at(focusedWidget);
-
- Event focusEvent(mFocusedWidget);
- distributeFocusGainedEvent(focusEvent);
- }
-
- if (focused >= 0)
- {
- Event focusEvent(mWidgets.at(focused));
- distributeFocusLostEvent(focusEvent);
- }
- }
-
- void FocusHandler::focusPrevious()
- {
- if (mWidgets.empty())
- {
- mFocusedWidget = nullptr;
- return;
- }
-
- int i;
- int focusedWidget = -1;
- const int sz = static_cast<int>(mWidgets.size());
- for (i = 0; i < sz; ++ i)
- {
- if (mWidgets[i] == mFocusedWidget)
- focusedWidget = i;
- }
- const int focused = focusedWidget;
-
- // i is a counter that ensures that the following loop
- // won't get stuck in an infinite loop
- i = sz;
- do
- {
- -- focusedWidget;
-
- if (i == 0)
- {
- focusedWidget = -1;
- break;
- }
-
- -- i;
-
- if (focusedWidget <= 0)
- focusedWidget = sz - 1;
-
- if (focusedWidget == focused)
- return;
- }
- while (!mWidgets.at(focusedWidget)->isFocusable());
-
- if (focusedWidget >= 0)
- {
- mFocusedWidget = mWidgets.at(focusedWidget);
- Event focusEvent(mFocusedWidget);
- distributeFocusGainedEvent(focusEvent);
- }
-
- if (focused >= 0)
- {
- Event focusEvent(mWidgets.at(focused));
- distributeFocusLostEvent(focusEvent);
- }
- }
-
- bool FocusHandler::isFocused(const Widget* widget) const
- {
- return mFocusedWidget == widget;
- }
-
- void FocusHandler::add(Widget* widget)
- {
- mWidgets.push_back(widget);
- }
-
- void FocusHandler::remove(Widget* widget)
- {
- if (isFocused(widget))
- mFocusedWidget = nullptr;
-
- for (WidgetIterator iter = mWidgets.begin();
- iter != mWidgets.end(); ++iter)
- {
- if ((*iter) == widget)
- {
- mWidgets.erase(iter);
- break;
- }
- }
-
- if (mDraggedWidget == widget)
- {
- mDraggedWidget = nullptr;
- return;
- }
-
- if (mLastWidgetWithMouse == widget)
- {
- mLastWidgetWithMouse = nullptr;
- return;
- }
-
- if (mLastWidgetWithModalFocus == widget)
- {
- mLastWidgetWithModalFocus = nullptr;
- return;
- }
-
- if (mLastWidgetWithModalMouseInputFocus == widget)
- {
- mLastWidgetWithModalMouseInputFocus = nullptr;
- return;
- }
-
- if (mLastWidgetPressed == widget)
- {
- mLastWidgetPressed = nullptr;
- return;
- }
- }
-
- void FocusHandler::focusNone()
- {
- if (mFocusedWidget)
- {
- Widget *const focused = mFocusedWidget;
- mFocusedWidget = nullptr;
-
- Event focusEvent(focused);
- distributeFocusLostEvent(focusEvent);
- }
- }
-
- void FocusHandler::tabNext()
- {
- if (mFocusedWidget)
- {
- if (!mFocusedWidget->isTabOutEnabled())
- return;
- }
-
- if (mWidgets.empty())
- {
- mFocusedWidget = nullptr;
- return;
- }
-
- int i;
- int focusedWidget = -1;
- const int sz = static_cast<int>(mWidgets.size());
- for (i = 0; i < sz; ++ i)
- {
- if (mWidgets[i] == mFocusedWidget)
- focusedWidget = i;
- }
- const int focused = focusedWidget;
- bool done = false;
-
- // i is a counter that ensures that the following loop
- // won't get stuck in an infinite loop
- i = sz;
- do
- {
- ++ focusedWidget;
-
- if (i == 0)
- {
- focusedWidget = -1;
- break;
- }
-
- -- i;
-
- if (focusedWidget >= sz)
- focusedWidget = 0;
-
- if (focusedWidget == focused)
- return;
-
- const Widget *const widget = mWidgets.at(focusedWidget);
- if (widget->isFocusable() && widget->isTabInEnabled() &&
- (!mModalFocusedWidget || widget->isModalFocused()))
- {
- done = true;
- }
- }
- while (!done);
-
- if (focusedWidget >= 0)
- {
- mFocusedWidget = mWidgets.at(focusedWidget);
- Event focusEvent(mFocusedWidget);
- distributeFocusGainedEvent(focusEvent);
- }
-
- if (focused >= 0)
- {
- Event focusEvent(mWidgets.at(focused));
- distributeFocusLostEvent(focusEvent);
- }
- }
-
- void FocusHandler::tabPrevious()
- {
- if (mFocusedWidget)
- {
- if (!mFocusedWidget->isTabOutEnabled())
- return;
- }
-
- if (mWidgets.empty())
- {
- mFocusedWidget = nullptr;
- return;
- }
-
- int i;
- int focusedWidget = -1;
- const int sz = static_cast<int>(mWidgets.size());
- for (i = 0; i < sz; ++ i)
- {
- if (mWidgets[i] == mFocusedWidget)
- focusedWidget = i;
- }
- const int focused = focusedWidget;
- bool done = false;
-
- // i is a counter that ensures that the following loop
- // won't get stuck in an infinite loop
- i = sz;
- do
- {
- -- focusedWidget;
-
- if (i == 0)
- {
- focusedWidget = -1;
- break;
- }
-
- -- i;
-
- if (focusedWidget <= 0)
- focusedWidget = sz - 1;
-
- if (focusedWidget == focused)
- return;
-
- const Widget *const widget = mWidgets.at(focusedWidget);
- if (widget->isFocusable() && widget->isTabInEnabled() &&
- (!mModalFocusedWidget || widget->isModalFocused()))
- {
- done = true;
- }
- }
- while (!done);
-
- if (focusedWidget >= 0)
- {
- mFocusedWidget = mWidgets.at(focusedWidget);
- Event focusEvent(mFocusedWidget);
- distributeFocusGainedEvent(focusEvent);
- }
-
- if (focused >= 0)
- {
- Event focusEvent(mWidgets.at(focused));
- distributeFocusLostEvent(focusEvent);
- }
- }
-
- void FocusHandler::distributeFocusLostEvent(const Event& focusEvent)
- {
- Widget *const sourceWidget = focusEvent.getSource();
-
- std::list<FocusListener*> focusListeners
- = sourceWidget->_getFocusListeners();
-
- // Send the event to all focus listeners of the widget.
- for (std::list<FocusListener*>::const_iterator
- it = focusListeners.begin();
- it != focusListeners.end();
- ++ it)
- {
- (*it)->focusLost(focusEvent);
- }
- }
-
- void FocusHandler::distributeFocusGainedEvent(const Event& focusEvent)
- {
- Widget *const sourceWidget = focusEvent.getSource();
-
- std::list<FocusListener*> focusListeners
- = sourceWidget->_getFocusListeners();
-
- // Send the event to all focus listeners of the widget.
- for (std::list<FocusListener*>::const_iterator
- it = focusListeners.begin();
- it != focusListeners.end();
- ++ it)
- {
- (*it)->focusGained(focusEvent);
- }
- }
-
- Widget* FocusHandler::getDraggedWidget()
- {
- return mDraggedWidget;
- }
-
- void FocusHandler::setDraggedWidget(Widget* draggedWidget)
- {
- mDraggedWidget = draggedWidget;
- }
-
- Widget* FocusHandler::getLastWidgetWithMouse()
- {
- return mLastWidgetWithMouse;
- }
-
- void FocusHandler::setLastWidgetWithMouse(Widget* lastWidgetWithMouse)
- {
- mLastWidgetWithMouse = lastWidgetWithMouse;
- }
-
- Widget* FocusHandler::getLastWidgetWithModalFocus()
- {
- return mLastWidgetWithModalFocus;
- }
-
- void FocusHandler::setLastWidgetWithModalFocus(Widget* widget)
- {
- mLastWidgetWithModalFocus = widget;
- }
-
- Widget* FocusHandler::getLastWidgetWithModalMouseInputFocus()
- {
- return mLastWidgetWithModalMouseInputFocus;
- }
-
- void FocusHandler::setLastWidgetWithModalMouseInputFocus(Widget* widget)
- {
- mLastWidgetWithModalMouseInputFocus = widget;
- }
-
- Widget* FocusHandler::getLastWidgetPressed()
- {
- return mLastWidgetPressed;
- }
-
- void FocusHandler::setLastWidgetPressed(Widget* lastWidgetPressed)
- {
- mLastWidgetPressed = lastWidgetPressed;
- }
-} // namespace gcn
diff --git a/src/guichan/font.cpp b/src/guichan/font.cpp
deleted file mode 100644
index 982e1ac8c..000000000
--- a/src/guichan/font.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * For comments regarding functions please see the header file.
- */
-
-#include "guichan/font.hpp"
-
-#include <string>
-
-#include "debug.h"
-
-namespace gcn
-{
- int Font::getStringIndexAt(const std::string& text, const int x) const
- {
- const size_t sz = text.size();
- for (size_t i = 0; i < sz; ++i)
- {
- if (getWidth(text.substr(0, i)) > x)
- return i;
- }
-
- return static_cast<int>(sz);
- }
-} // namespace gcn
diff --git a/src/guichan/graphics.cpp b/src/guichan/graphics.cpp
deleted file mode 100644
index b63c4b58c..000000000
--- a/src/guichan/graphics.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * For comments regarding functions please see the header file.
- */
-
-#include "guichan/graphics.hpp"
-
-#include "guichan/exception.hpp"
-#include "guichan/font.hpp"
-#include "guichan/image.hpp"
-
-#include "debug.h"
-
-namespace gcn
-{
-
- Graphics::Graphics() :
- mClipStack(),
- mFont(nullptr)
- {
- }
-
- bool Graphics::pushClipArea(Rectangle area)
- {
- // Ignore area with a negate width or height
- // by simple pushing an empty clip area
- // to the stack.
- if (area.width < 0 || area.height < 0)
- {
- ClipRectangle carea;
- mClipStack.push(carea);
- return true;
- }
-
- if (mClipStack.empty())
- {
- ClipRectangle carea;
- carea.x = area.x;
- carea.y = area.y;
- carea.width = area.width;
- carea.height = area.height;
- carea.xOffset = area.x;
- carea.yOffset = area.y;
- mClipStack.push(carea);
- return true;
- }
-
- const ClipRectangle &top = mClipStack.top();
- ClipRectangle carea;
- carea = area;
- carea.xOffset = top.xOffset + carea.x;
- carea.yOffset = top.yOffset + carea.y;
- carea.x += top.xOffset;
- carea.y += top.yOffset;
-
- // Clamp the pushed clip rectangle.
- if (carea.x < top.x)
- carea.x = top.x;
-
- if (carea.y < top.y)
- carea.y = top.y;
-
- if (carea.x + carea.width > top.x + top.width)
- {
- carea.width = top.x + top.width - carea.x;
-
- if (carea.width < 0)
- carea.width = 0;
- }
-
- if (carea.y + carea.height > top.y + top.height)
- {
- carea.height = top.y + top.height - carea.y;
-
- if (carea.height < 0)
- carea.height = 0;
- }
-
- const bool result = carea.isIntersecting(top);
-
- mClipStack.push(carea);
-
- return result;
- }
-
- void Graphics::popClipArea()
- {
- if (mClipStack.empty())
- throw GCN_EXCEPTION("Tried to pop clip area from empty stack.");
-
- mClipStack.pop();
- }
-
- const ClipRectangle& Graphics::getCurrentClipArea()
- {
- if (mClipStack.empty())
- throw GCN_EXCEPTION("The clip area stack is empty.");
-
- return mClipStack.top();
- }
-
- void Graphics::drawImage(const Image* image A_UNUSED,
- int dstX A_UNUSED, int dstY A_UNUSED)
- {
- }
-
-/*
- void Graphics::setFont(Font* font)
- {
- }
-
- void Graphics::drawText(const std::string& text, int x, int y,
- Alignment alignment)
- {
- }
-*/
-} // namespace gcn
diff --git a/src/guichan/include/guichan/cliprectangle.hpp b/src/guichan/include/guichan/cliprectangle.hpp
deleted file mode 100644
index 148a73d5a..000000000
--- a/src/guichan/include/guichan/cliprectangle.hpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GCN_CLIPRECTANGLE_HPP
-#define GCN_CLIPRECTANGLE_HPP
-
-#include "guichan/rectangle.hpp"
-
-#include "localconsts.h"
-
-namespace gcn
-{
- /**
- * A rectangle used when dealing with clipping. A clip rectangle is
- * a regular rectangle extended with variables for x offsets and y
- * offsets. The offsets are used for calculations from relative
- * screen coordinates to actual screen coordinates.
- */
- class ClipRectangle final : public Rectangle
- {
- public:
- /**
- * Constructor.
- */
- ClipRectangle();
-
- /**
- * Constructor.
- *
- * @param x0 The rectangle x coordinate.
- * @param y0 The rectangle y coordinate.
- * @param width0 The rectangle width.
- * @param height0 The rectangle height.
- * @param xOffset0 The offset of the x coordinate. Used to for
- * calculating the actual screen coordinate from
- * the relative screen coordinate.
- * @param yOffset0 The offset of the y coordinate. Used to for
- * calculating the actual screen coordinate from
- * the relative screen coordinate.
- */
- ClipRectangle(const int x0,
- const int y0,
- const int width0,
- const int height0,
- const int xOffset0,
- const int yOffset0);
-
- /**
- * Copy constructor. Copies x, y, width and height
- * field from a rectangle to a clip rectangle.
- *
- * @param other The rectangle to copy data from.
- * @returns A clip rectangle with data copyied from a rectangle.
- */
- const ClipRectangle& operator=(const Rectangle& other);
-
- /**
- * Holds the x offset of the x coordinate.
- */
- int xOffset;
-
- /**
- * Holds the y offset of the y coordinate.
- */
- int yOffset;
- };
-} // namespace gcn
-
-#endif // end GCN_CLIPRECTANGLE_HPP
diff --git a/src/guichan/include/guichan/exception.hpp b/src/guichan/include/guichan/exception.hpp
deleted file mode 100644
index a60152c96..000000000
--- a/src/guichan/include/guichan/exception.hpp
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GCN_EXCEPTION_HPP
-#define GCN_EXCEPTION_HPP
-
-#include <string>
-
-#include "localconsts.h"
-
-#ifndef __FUNCTION__
-#define __FUNCTION__ "?"
-#endif
-
-/*
- * A macro used to create a standard exception object.
- * What it basicly does is that it creates a new exception
- * and automatically sets the filename and line number where
- * the exception occured by using other compiler macros.
- */
-#define GCN_EXCEPTION(mess) gcn::Exception(mess, \
- __FUNCTION__, \
- __FILE__, \
- __LINE__)
-
-namespace gcn
-{
-
- /**
- * An exception containing a message, a file and a line number
- * where the exception occured. Guichan will only throw exceptions
- * of this class.
- *
- * You can use this class for your own exceptions that has
- * something to do with a GUI exception. A nifty feature of the
- * excpetion class is that it can tell you from which line and
- * file it was thrown. To make things easier when throwing
- * exceptions there exists a macro for creating exceptions
- * which automatically sets the filename and line number.
- *
- * EXAMPLE: @code
- * throw GCN_EXCEPTION("my error message");
- * @endcode
- */
- class Exception final
- {
- public:
- /**
- * Constructor.
- */
- Exception();
-
- /**
- * Constructor.
- *
- * @param message The error message of the exception.
- */
- explicit Exception(const std::string& message);
-
- /**
- * Constructor.
- *
- * NOTE: Don't use this constructor. Use the GCN_EXCEPTION macro instead.
- * This constructor merely exists for the GCN_EXCEPTION macro to
- * use.
- *
- * @param message The error message of the exception.
- * @param function The function name where the exception occured.
- * @param filename The name of the file where the exception occured.
- * @param line The line number in the source code where the exception
- * occured.
- */
- Exception(const std::string& message,
- const std::string& function,
- const std::string& filename,
- const unsigned int line);
-
- /**
- * Gets the function name where the exception occured.
- *
- * @return The function name where the exception occured.
- */
- const std::string& getFunction() const A_WARN_UNUSED;
-
- /**
- * Gets the error message of the exception.
- *
- * @return The error message of the exception.
- */
- const std::string& getMessage() const A_WARN_UNUSED;
-
- /**
- * Gets the filename where the exception occured.
- *
- * @return The filename where the exception occured.
- */
- const std::string& getFilename() const A_WARN_UNUSED;
-
- /**
- * Gets the line number where the exception occured.
- *
- * @return The line number where the exception occured.
- */
- unsigned int getLine() const A_WARN_UNUSED;
-
- protected:
- /**
- * Holds the name of the function name where the
- * exception occured.
- */
- std::string mFunction;
-
- /**
- * Holds the error message of the exception.
- */
- std::string mMessage;
-
- /**
- * Holds the filename where the exception occured.
- */
- std::string mFilename;
-
- /**
- * Holds the line number where the exception occured.
- */
- unsigned int mLine;
- };
-} // namespace gcn
-
-#endif // end GCN_EXCEPTION_HPP
-
-/*
- * "Final Fantasy XI is the BEST!... It's even better then water!"
- * - Astrolite
- * I believe it's WoW now days.
- */
diff --git a/src/guichan/include/guichan/focushandler.hpp b/src/guichan/include/guichan/focushandler.hpp
deleted file mode 100644
index 6cd326d33..000000000
--- a/src/guichan/include/guichan/focushandler.hpp
+++ /dev/null
@@ -1,417 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GCN_FOCUSHANDLER_HPP
-#define GCN_FOCUSHANDLER_HPP
-
-#include <vector>
-
-#include "guichan/event.hpp"
-
-namespace gcn
-{
- class Widget;
-
- /**
- * Handles focus for widgets in a Gui. Each Gui has at least one
- * focus handler.
- * You will probably not use the focus handler directly as Widget
- * has functions that automatically uses the active focus handler.
- *
- * @see Widget::isFocus, Widget::isModalFocused,
- * Widget::isModalMouseInputFocused, Widget::requestFocus,
- * Widget::requestModalFocus, Widget::requestModalMouseInputFocus,
- * Widget::releaseModalFocus, Widget::relaseModalMouseInputFocus,
- * Widget::setFocusable, Widget::isFocusable, FocusListener
- *
- * @since 0.1.0
- */
- class FocusHandler
- {
- public:
- /**
- * Constructor.
- */
- FocusHandler();
-
- A_DELETE_COPY(FocusHandler)
-
- /**
- * Destructor.
- */
- virtual ~FocusHandler()
- { }
-
- /**
- * Requests focus for a widget. Focus will only be granted to a widget
- * if it's focusable and if no other widget has modal focus.
- * If a widget receives focus a focus event will be sent to the
- * focus listeners of the widget.
- *
- * @param widget The widget to request focus for.
- * @see isFocused, Widget::requestFocus
- */
- virtual void requestFocus(Widget* widget);
-
- /**
- * Requests modal focus for a widget. Focus will only be granted
- * to a widget if it's focusable and if no other widget has modal
- * focus.
- *
- * @param widget The widget to request modal focus for.
- * @throws Exception when another widget already has modal focus.
- * @see releaseModalFocus, Widget::requestModalFocus
- */
- virtual void requestModalFocus(Widget* widget);
-
- /**
- * Requests modal mouse input focus for a widget. Focus will only
- * be granted to a widget if it's focusable and if no other widget
- * has modal mouse input focus.
- *
- * Modal mouse input focus means no other widget then the widget with
- * modal mouse input focus will receive mouse input. The widget with
- * modal mouse input focus will also receive mouse input no matter what
- * the mouse input is or where the mouse input occurs.
- *
- * @param widget The widget to focus for modal mouse input focus.
- * @throws Exception when another widget already has modal mouse input
- * focus.
- * @see releaseModalMouseInputFocus, Widget::requestModalMouseInputFocus
- */
- virtual void requestModalMouseInputFocus(Widget* widget);
-
- /**
- * Releases modal focus if the widget has modal focus.
- * If the widget doesn't have modal focus no relase will occur.
- *
- * @param widget The widget to release modal focus for.
- * @see reuqestModalFocus, Widget::releaseModalFocus
- */
- virtual void releaseModalFocus(Widget* widget);
-
- /**
- * Releases modal mouse input focus if the widget has modal mouse input
- * focus. If the widget doesn't have modal mouse input focus no relase
- * will occur.
- *
- * @param widget the widget to release modal mouse input focus for.
- * @see requestModalMouseInputFocus, Widget::releaseModalMouseInputFocus
- */
- virtual void releaseModalMouseInputFocus(Widget* widget);
-
- /**
- * Checks if a widget is focused.
- *
- * @param widget The widget to check.
- * @return True if the widget is focused, false otherwise.
- * @see Widget::isFocused
- */
- virtual bool isFocused(const Widget* widget) const;
-
- /**
- * Gets the widget with focus.
- *
- * @return The widget with focus. NULL if no widget has focus.
- */
- virtual Widget* getFocused() const A_WARN_UNUSED;
-
- /**
- * Gets the widget with modal focus.
- *
- * @return The widget with modal focus. NULL if no widget has
- * modal focus.
- */
- virtual Widget* getModalFocused() const A_WARN_UNUSED;
-
- /**
- * Gets the widget with modal mouse input focus.
- *
- * @return The widget with modal mouse input focus. NULL if
- * no widget has modal mouse input focus.
- */
- virtual Widget* getModalMouseInputFocused() const A_WARN_UNUSED;
-
- /**
- * Focuses the next widget added to a conainer.
- * If no widget has focus the first widget gets focus. The order
- * in which the widgets are focused is determined by the order
- * they were added to a container.
- *
- * @see focusPrevious
- */
- virtual void focusNext();
-
- /**
- * Focuses the previous widget added to a contaienr.
- * If no widget has focus the first widget gets focus. The order
- * in which the widgets are focused is determined by the order
- * they were added to a container.
- *
- * @see focusNext
- */
- virtual void focusPrevious();
-
- /**
- * Adds a widget to by handles by the focus handler.
- *
- * @param widget The widget to add.
- * @see remove
- */
- virtual void add(Widget* widget);
-
- /**
- * Removes a widget from the focus handler.
- *
- * @param widget The widget to remove.
- * @see add
- */
- virtual void remove(Widget* widget);
-
- /**
- * Focuses nothing. A focus event will also be sent to the
- * focused widget's focus listeners if a widget has focus.
- */
- virtual void focusNone();
-
- /**
- * Focuses the next widget which allows tabbing in unless
- * the current focused Widget disallows tabbing out.
- *
- * @see tabPrevious
- */
- virtual void tabNext();
-
- /**
- * Focuses the previous widget which allows tabbing in unless
- * current focused widget disallows tabbing out.
- *
- * @see tabNext
- */
- virtual void tabPrevious();
-
- /**
- * Gets the widget being dragged. Used by the Gui class to
- * keep track of the dragged widget.
- *
- * @return the widget being dragged.
- * @see setDraggedWidget
- */
- virtual Widget* getDraggedWidget() A_WARN_UNUSED;
-
- /**
- * Sets the widget being dragged. Used by the Gui class to
- * keep track of the dragged widget.
- *
- * @param draggedWidget The widget being dragged.
- * @see getDraggedWidget
- */
- virtual void setDraggedWidget(Widget* draggedWidget);
-
- /**
- * Gets the last widget with the mouse. Used by the Gui class
- * to keep track the last widget with the mouse.
- *
- * @return The last widget with the mouse.
- * @see setLastWidgetWithMouse
- */
- virtual Widget* getLastWidgetWithMouse() A_WARN_UNUSED;
-
- /**
- * Sets the last widget with the mouse. Used by the Gui class
- * to keep track the last widget with the mouse.
- *
- * @param lastWidgetWithMouse The last widget with the mouse.
- * @see getLastWidgetWithMouse
- */
- virtual void setLastWidgetWithMouse(Widget* lastWidgetWithMouse);
-
- /**
- * Gets the last widget with modal focus.
- *
- * @return The last widget with modal focus.
- * @see setLastWidgetWithModalFocus
- */
- virtual Widget* getLastWidgetWithModalFocus() A_WARN_UNUSED;
-
- /**
- * Sets the last widget with modal focus.
- *
- * @param widget The last widget with modal focus.
- * @see getLastWidgetWithModalFocus
- */
- virtual void setLastWidgetWithModalFocus(Widget* widget);
-
- /**
- * Gets the last widget with modal mouse input focus.
- *
- * @return The last widget with modal mouse input focus.
- * @see setLastWidgetWithModalMouseInputFocus
- */
- virtual Widget* getLastWidgetWithModalMouseInputFocus() A_WARN_UNUSED;
-
- /**
- * Sets the last widget with modal mouse input focus.
- *
- * @param widget The last widget with modal mouse input focus.
- * @see getLastWidgetWithModalMouseInputFocus
- */
- virtual void setLastWidgetWithModalMouseInputFocus(Widget* widget);
-
- /**
- * Gets the last widget pressed. Used by the Gui class to keep track
- * of pressed widgets.
- *
- * @return The last widget pressed.
- * @see setLastWidgetPressed
- */
- virtual Widget* getLastWidgetPressed() A_WARN_UNUSED;
-
- /**
- * Sets the last widget pressed. Used by the Gui class to keep track
- * of pressed widgets.
- *
- * @param lastWidgetPressed The last widget pressed.
- * @see getLastWidgetPressed
- */
- virtual void setLastWidgetPressed(Widget* lastWidgetPressed);
-
- protected:
- /**
- * Distributes a focus lost event.
- *
- * @param focusEvent the event to distribute.
- * @since 0.7.0
- */
- virtual void distributeFocusLostEvent(const Event& focusEvent);
-
- /**
- * Distributes a focus gained event.
- *
- * @param focusEvent the event to distribute.
- * @since 0.7.0
- */
- virtual void distributeFocusGainedEvent(const Event& focusEvent);
-
- /**
- * Typedef.
- */
- typedef std::vector<Widget*> WidgetVector;
-
- /**
- * Typedef.
- */
- typedef WidgetVector::iterator WidgetIterator;
-
- /**
- * Holds the widgets currently being handled by the
- * focus handler.
- */
- WidgetVector mWidgets;
-
- /**
- * Holds the focused widget. NULL if no widget has focus.
- */
- Widget* mFocusedWidget;
-
- /**
- * Holds the modal focused widget. NULL if no widget has
- * modal focused.
- */
- Widget* mModalFocusedWidget;
-
- /**
- * Holds the modal mouse input focused widget. NULL if no widget
- * is being dragged.
- */
- Widget* mModalMouseInputFocusedWidget;
-
- /**
- * Holds the dragged widget. NULL if no widget is
- * being dragged.
- */
- Widget* mDraggedWidget;
-
- /**
- * Holds the last widget with the mouse.
- */
- Widget* mLastWidgetWithMouse;
-
- /**
- * Holds the last widget with modal focus.
- */
- Widget* mLastWidgetWithModalFocus;
-
- /**
- * Holds the last widget with modal mouse input focus.
- */
- Widget* mLastWidgetWithModalMouseInputFocus;
-
- /**
- * Holds the last widget pressed.
- */
- Widget* mLastWidgetPressed;
- };
-} // namespace gcn
-
-#endif // end GCN_FOCUSHANDLER_HPP
diff --git a/src/guichan/include/guichan/font.hpp b/src/guichan/include/guichan/font.hpp
deleted file mode 100644
index 8e8ad18c9..000000000
--- a/src/guichan/include/guichan/font.hpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GCN_FONT_HPP
-#define GCN_FONT_HPP
-
-#include <string>
-
-#include "localconsts.h"
-
-namespace gcn
-{
- class Graphics;
-
- /**
- * Interface for a font.
- *
- * @see ImageFont
- */
- class Font
- {
- public:
- /**
- * Destructor.
- */
- virtual ~Font()
- { }
-
- /**
- * Gets the width of a string. The width of a string is not necesserily
- * the sum of all the widths of it's glyphs.
- *
- * @param text The string to return the width of.
- * @return The width of a string.
- */
- virtual int getWidth(const std::string& text) const A_WARN_UNUSED = 0;
-
- /**
- * Gets the height of the glyphs in the font.
- *
- * @return The height of the glyphs int the font.
- */
- virtual int getHeight() const A_WARN_UNUSED = 0;
-
- /**
- * Gets a string index in a string providing an x coordinate.
- * Used to retrive a string index (for a character in a
- * string) at a certain x position. It is especially useful
- * when a mouse clicks in a TextField and you want to know which
- * character was clicked.
- *
- * @return A string index in a string providing an x coordinate.
- */
- virtual int getStringIndexAt(const std::string& text,
- const int x) const A_WARN_UNUSED;
-
- /**
- * Draws a string.
- *
- * NOTE: You normally won't use this function to draw text since
- * Graphics contains better functions for drawing text.
- *
- * @param graphics A Graphics object to use for drawing.
- * @param text The string to draw.
- * @param x The x coordinate where to draw the string.
- * @param y The y coordinate where to draw the string.
- */
- virtual void drawString(Graphics* graphics, const std::string& text,
- int x, int y) = 0;
- };
-} // namespace gcn
-
-#endif // end GCN_FONT_HPP
diff --git a/src/guichan/include/guichan/graphics.hpp b/src/guichan/include/guichan/graphics.hpp
deleted file mode 100644
index dd15827fd..000000000
--- a/src/guichan/include/guichan/graphics.hpp
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GCN_GRAPHICS_HPP
-#define GCN_GRAPHICS_HPP
-
-#include <iosfwd>
-#include <stack>
-
-#include "guichan/cliprectangle.hpp"
-
-namespace gcn
-{
- class Color;
- class Font;
- class Image;
-
- /**
- * Abstract class for providing drawing primitve functions.
- * It contains all vital functions for drawing.
- *
- * Guichan contains implementations of Graphics for common
- * libraries like the Allegro library, the HGE library,
- * the OpenGL library, the OpenLayer library, and the SDL library.
- * To make Guichan usable with other libraries, a Graphics class
- * must be implemented.
- *
- * In Graphics you can set clip areas to limit drawing to certain
- * areas of the screen. Clip areas are put on a stack, which
- * means that you can push smaller and smaller clip areas onto the
- * stack. All coordinates will be relative to the top most clip area.
- * In most cases you won't have to worry about the clip areas,
- * unless you want to implement some really complex widget.
- * Pushing and poping of clip areas are handled automatically by
- * container widgets when their child widgets are drawn.
- *
- * IMPORTANT: Remember to pop each clip area that you pushed on the stack
- * after you are done with it.
- *
- * If you feel that Graphics is to restrictive for your needs,
- * there is no one stopping you from using your own code for drawing
- * in widgets. You could for instance use pure SDL in the drawing of
- * widgets bypassing Graphics. This might however hurt portability of
- * your application.
- *
- * If you implement a Graphics class not present in Guichan we would
- * be very happy to add it to Guichan.
- *
- * @see AllegroGraphics, HGEGraphics, OpenLayerGraphics, OpenGLGraphics,
- * SDLGraphics, Image
- * @since 0.1.0
- */
- class Graphics
- {
- public:
- /**
- * Alignments for text drawing.
- */
- enum Alignment
- {
- LEFT = 0,
- CENTER,
- RIGHT
- };
-
- /**
- * Constructor.
- */
- Graphics();
-
- A_DELETE_COPY(Graphics)
-
- /**
- * Destructor.
- */
- virtual ~Graphics()
- { }
-
- /**
- * Initializes drawing. Called by the Gui when Gui::draw() is called.
- * It is needed by some implementations of Graphics to perform
- * preparations before drawing. An example of such an implementation
- * is the OpenGLGraphics.
- *
- * NOTE: You will never need to call this function yourself, unless
- * you use a Graphics object outside of Guichan.
- *
- * @see _endDraw, Gui::draw
- */
- virtual void _beginDraw()
- { }
-
- /**
- * Deinitializes drawing. Called by the Gui when a Gui::draw() is done.
- * done. It should reset any state changes made by _beginDraw().
- *
- * NOTE: You will never need to call this function yourself, unless
- * you use a Graphics object outside of Guichan.
- *
- * @see _beginDraw, Gui::draw
- */
- virtual void _endDraw()
- { }
-
- /**
- * Pushes a clip area onto the stack. The x and y coordinates in the
- * rectangle is relative to the last pushed clip area.
- * If the new area falls outside the current clip area, it will be
- * clipped as necessary.
- *
- * If a clip area is outside of the top clip area a clip area with
- * zero width and height will be pushed.
- *
- * @param area The clip area to be pushed onto the stack.
- * @return False if the the new area lays outside the current clip
- * area.
- */
- virtual bool pushClipArea(Rectangle area);
-
- /**
- * Removes the top most clip area from the stack.
- *
- * @throws Exception if the stack is empty.
- */
- virtual void popClipArea();
-
- /**
- * Gets the current clip area. Usefull if you want to do drawing
- * bypassing Graphics.
- *
- * @return The current clip area.
- */
- virtual const ClipRectangle& getCurrentClipArea();
-
- /**
- * Draws a part of an image.
- *
- * NOTE: Width and height arguments will not scale the image but
- * specifies the size of the part to be drawn. If you want
- * to draw the whole image there is a simplified version of
- * this function.
- *
- * EXAMPLE: @code drawImage(myImage, 10, 10, 20, 20, 40, 40); @endcode
- * Will draw a rectangular piece of myImage starting at
- * coordinate (10, 10) in myImage, with width and height 40.
- * The piece will be drawn with it's top left corner at
- * coordinate (20, 20).
- *
- * @param image The image to draw.
- * @param srcX The source image x coordinate.
- * @param srcY The source image y coordinate.
- * @param dstX The destination x coordinate.
- * @param dstY The destination y coordinate.
- * @param width The width of the piece.
- * @param height The height of the piece.
- */
- virtual void drawImage(const Image* image,
- int srcX,
- int srcY,
- int dstX,
- int dstY,
- int width,
- int height) = 0;
- /**
- * Draws an image. A simplified version of the other drawImage.
- * It will draw a whole image at the coordinate you specify.
- * It is equivalent to calling:
- * @code drawImage(myImage, 0, 0, dstX, dstY, image->getWidth(), \
- image->getHeight()); @endcode
- */
- virtual void drawImage(const Image* image, int dstX, int dstY);
-
- /**
- * Draws a single point/pixel.
- *
- * @param x The x coordinate.
- * @param y The y coordinate.
- */
- virtual void drawPoint(int x, int y) = 0;
-
- /**
- * Ddraws a line.
- *
- * @param x1 The first x coordinate.
- * @param y1 The first y coordinate.
- * @param x2 The second x coordinate.
- * @param y2 The second y coordinate.
- */
- virtual void drawLine(int x1, int y1, int x2, int y2) = 0;
-
- /**
- * Draws a simple, non-filled, rectangle with a one pixel width.
- *
- * @param rectangle The rectangle to draw.
- */
- virtual void drawRectangle(const Rectangle& rectangle) = 0;
-
- /**
- * Draws a filled rectangle.
- *
- * @param rectangle The filled rectangle to draw.
- */
- virtual void fillRectangle(const Rectangle& rectangle) = 0;
-
- /**
- * Sets the color to use when drawing.
- *
- * @param color A color.
- * @see getColor
- */
- virtual void setColor(const Color& color) = 0;
-
- /**
- * Gets the color to use when drawing.
- *
- * @return The color used when drawing.
- * @see setColor
- */
- virtual const Color& getColor() const = 0;
-
- protected:
- /**
- * Holds the clip area stack.
- */
- std::stack<ClipRectangle> mClipStack;
-
- /**
- * Holds the current font.
- */
- Font* mFont;
- };
-} // namespace gcn
-
-#endif // end GCN_GRAPHICS_HPP
diff --git a/src/guichan/include/guichan/inputevent.hpp b/src/guichan/include/guichan/inputevent.hpp
deleted file mode 100644
index 30b46676d..000000000
--- a/src/guichan/include/guichan/inputevent.hpp
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GCN_INPUTEVENT_HPP
-#define GCN_INPUTEVENT_HPP
-
-#include "guichan/event.hpp"
-
-namespace gcn
-{
- /**
- * Base class for all events concerning input.
- *
- * @author Olof Naessén
- * @since 0.6.0
- */
- class InputEvent: public Event
- {
- public:
- /**
- * Constructor.
- *
- * @param source The source widget of the event.
- * @param isShiftPressed True if shift is pressed, false otherwise.
- * @param isControlPressed True if control is pressed, false otherwise.
- * @param isAltPressed True if alt is pressed, false otherwise.
- * @param isMetaPressed True if meta is pressed, false otherwise.
- */
- InputEvent(Widget *const source,
- const bool shiftPressed,
- const bool controlPressed,
- const bool altPressed,
- const bool metaPressed);
-
- /**
- * Checks if shift is pressed.
- *
- * @return True if shift was pressed at the same time as the key,
- * false otherwise.
- */
- bool isShiftPressed() const A_WARN_UNUSED;
-
- /**
- * Checks if control is pressed.
- *
- * @return True if control was pressed at the same time as the key,
- * false otherwise.
- */
- bool isControlPressed() const A_WARN_UNUSED;
-
- /**
- * Checks if alt is pressed.
- *
- * @return True if alt was pressed at the same time as the key,
- * false otherwise.
- */
- bool isAltPressed() const A_WARN_UNUSED;
-
- /**
- * Checks whether meta is pressed.
- *
- * @return True if meta was pressed at the same time as the key,
- * false otherwise.
- */
- bool isMetaPressed() const A_WARN_UNUSED;
-
- /**
- * Marks the event as consumed. Input event listeners may discard
- * consumed input or act on consumed input. An example of a widget
- * that discards consumed input is the ScrollArea widget that
- * discards consumed mouse wheel events so the ScrollArea will not
- * scroll if for instance a Slider's value inside the ScrollArea was
- * changed with the mouse wheel.
- *
- * @see isConsumed
- */
- void consume();
-
- /**
- * Checks if the input event is consumed.
- *
- * @return True if the input event is consumed,
- * false otherwise.
- * @see consume
- */
- bool isConsumed() const A_WARN_UNUSED;
-
- protected:
- /**
- * True if shift is pressed, false otherwise.
- */
- bool mShiftPressed;
-
- /**
- * True if control is pressed, false otherwise.
- */
- bool mControlPressed;
-
- /**
- * True if alt is pressed, false otherwise.
- */
- bool mAltPressed;
-
- /**
- * True if meta is pressed, false otherwise.
- */
- bool mMetaPressed;
-
- /**
- * True if the input event is consumed,
- * false otherwise.
- */
- bool mIsConsumed;
- };
-} // namespace gcn
-
-#endif // end GCN_INPUTEVENT_HPP
diff --git a/src/guichan/include/guichan/keyinput.hpp b/src/guichan/include/guichan/keyinput.hpp
deleted file mode 100644
index 421165d1c..000000000
--- a/src/guichan/include/guichan/keyinput.hpp
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GCN_KEYINPUT_HPP
-#define GCN_KEYINPUT_HPP
-
-#include "guichan/key.hpp"
-
-namespace gcn
-{
- /**
- * Internal class that represents key input. Generally you won't have to
- * bother using this class unless you implement an Input class for
- * a back end.
- *
- * @since 0.1.0
- */
- class KeyInput
- {
- public:
- /**
- * Constructor.
- */
- KeyInput() :
- mKey(0),
- mType(0),
- mShiftPressed(false),
- mControlPressed(false),
- mAltPressed(false),
- mMetaPressed(false),
- mNumericPad(false)
- { }
-
- /**
- * Constructor.
- *
- * @param key The key of the key input.
- * @param type The type of key input.
- */
- KeyInput(const Key& key, unsigned int type);
-
- /**
- * Sets the type of the key input.
- *
- * @param type The type of key input.
- * @see getType
- */
- void setType(unsigned int type);
-
- /**
- * Gets the type of the key input.
- *
- * @return the input type.
- * @see setType
- */
- int getType() const A_WARN_UNUSED;
-
- /**
- * Sets the key of the key input.
- *
- * @param key The key of the key input.
- * @see getKey
- */
- void setKey(const Key& key);
-
- /**
- * Gets the key of the key input.
- *
- * @return The key of the key input.
- * @see setKey
- */
- const Key& getKey() const A_WARN_UNUSED;
-
- /**
- * Checks if shift is pressed.
- *
- * @return True if shift was pressed at the same
- * time as the key, false otherwise.
- * @see setShiftPressed
- * @since 0.6.0
- */
- bool isShiftPressed() const A_WARN_UNUSED;
-
- /**
- * Sets shift to be pressed at the same time as the key,
- * or not.
- *
- * @param pressed True if shift is pressed, false otherwise.
- * @see isShiftPressed
- * @since 0.6.0
- */
- void setShiftPressed(bool pressed);
-
- /**
- * Checks if control is pressed.
- *
- * @return True if control was pressed at the same
- * time as the key, false otherwise.
- * @see setControlPressed
- * @since 0.6.0
- */
- bool isControlPressed() const A_WARN_UNUSED;
-
- /**
- * Sets control to be pressed at the same time as the key,
- * or not.
- *
- * @param pressed True if control is pressed, false otherwise.
- * @see isControlPressed
- * @since 0.6.0
- */
- void setControlPressed(bool pressed);
-
- /**
- * Checks if alt is pressed.
- *
- * @return True if alt was pressed at the same
- * time as the key, false otherwise.
- * @see setAltPressed
- * @since 0.6.0
- */
- bool isAltPressed() const;
-
- /**
- * Sets the alt to be pressed at the same time as the key,
- * or not.
- *
- * @param pressed True if alt is pressed at the same
- * time as the key, , false otherwise.
- * @see isAltPressed
- * @since 0.6.0
- */
- void setAltPressed(bool pressed);
-
- /**
- * Checks if meta is pressed.
- *
- * @return True if meta was pressed at the same
- * time as the key, false otherwise.
- * @see setMetaPressed
- * @since 0.6.0
- */
- bool isMetaPressed() const A_WARN_UNUSED;
-
- /**
- * Sets meta to be pressed at the same time as the key,
- * or not.
- *
- * @param pressed True if meta is pressed at the same
- * time as the key, false otherwise.
- * @see isMetaPressed
- * @since 0.6.0
- */
- void setMetaPressed(bool pressed);
-
- /**
- * Checks if the key was pressed at the numeric pad.
- *
- * @return True if key pressed at the numeric pad,
- * false otherwise.
- * @setNumericPad
- * @since 0.6.0
- */
- bool isNumericPad() const A_WARN_UNUSED;
-
- /**
- * Sets the key to be pressed at the numeric pad.
- *
- * @param numpad True if the key was pressed at the numeric
- * pad, false otherwise.
- * @see isNumericPad
- * @since 0.6.0
- */
- void setNumericPad(bool numpad);
-
- /**
- * Key input types. This enum corresponds to the enum with event
- * types on KeyEvent for easy mapping.
- */
- enum
- {
- PRESSED = 0,
- RELEASED
- };
-
- protected:
- /**
- * Holds the key of the key input.
- */
- Key mKey;
-
- /**
- * Holds the type of the key input.
- */
- unsigned int mType;
-
- /**
- * True if shift was pressed at the same time as the key,
- * false otherwise.
- */
- bool mShiftPressed;
-
- /**
- * True if control was pressed at the same time as the key,
- * false otherwise.
- */
- bool mControlPressed;
-
- /**
- * True if alt was pressed at the same time as the key,
- * false otherwise.
- */
- bool mAltPressed;
-
- /**
- * True if meta was pressed at the same time as the key,
- * false otherwise.
- */
- bool mMetaPressed;
-
- /**
- * True if the numeric pad was used when the key was pressed,
- * false otherwise.
- */
- bool mNumericPad;
- };
-} // namespace gcn
-
-#endif // end GCN_KEYINPUT_HPP
diff --git a/src/guichan/include/guichan/mouseinput.hpp b/src/guichan/include/guichan/mouseinput.hpp
deleted file mode 100644
index 018205740..000000000
--- a/src/guichan/include/guichan/mouseinput.hpp
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GCN_MOUSEINPUT_HPP
-#define GCN_MOUSEINPUT_HPP
-
-#include "localconsts.h"
-
-namespace gcn
-{
-
- /**
- * Internal class that represents mouse input. Generally you won't have to
- * bother using this class unless you implement an Input class for
- * a back end.
- *
- * @author Olof Naessén
- * @author Per Larsson
- * @since 0.1.0
- */
- class MouseInput
- {
- public:
- /**
- * Constructor.
- */
- MouseInput() :
- mType(0),
- mButton(0),
- mTimeStamp(0),
- mX(0),
- mY(0)
- { }
-
- /**
- * Constructor.
- *
- * @param button The button pressed.
- * @param type The type of mouse input.
- * @param x The mouse x coordinate.
- * @param y The mouse y coordinate.
- * @param timeStamp The timestamp of the mouse input. Used to
- * check for double clicks.
- */
- MouseInput(const unsigned int button,
- const unsigned int type,
- const int x,
- const int y,
- const int timeStamp);
-
- /**
- * Sets the type of the mouse input.
- *
- * @param type The type of the mouse input. Should be a value from the
- * mouse event type enum
- * @see getType
- * @since 0.1.0
- */
- void setType(unsigned int type);
-
- /**
- * Gets the type of the mouse input.
- *
- * @return The type of the mouse input. A value from the mouse event
- * type enum.
- * @see setType
- * @since 0.1.0
- */
- unsigned int getType() const A_WARN_UNUSED;
-
- /**
- * Sets the button pressed.
- *
- * @param button The button pressed. Should be one of the values
- * in the mouse event button enum.
- * @see getButton.
- * @since 0.1.0
- */
- void setButton(unsigned int button);
-
- /**
- * Gets the button pressed.
- *
- * @return The button pressed. A value from the mouse event
- * button enum.
- * @see setButton
- * @since 0.1.0
- */
- unsigned int getButton() const A_WARN_UNUSED;
-
- /**
- * Sets the timestamp for the mouse input.
- * Used to check for double clicks.
- *
- * @param timeStamp The timestamp of the mouse input.
- * @see getTimeStamp
- * @since 0.1.0
- */
- void setTimeStamp(int timeStamp);
-
- /**
- * Gets the time stamp of the input.
- * Used to check for double clicks.
- *
- * @return The time stamp of the mouse input.
- * @see setTimeStamp
- * @since 0.1.0
- */
- int getTimeStamp() const A_WARN_UNUSED;
-
- /**
- * Sets the x coordinate of the mouse input.
- *
- * @param x The x coordinate of the mouse input.
- * @see getX
- * @since 0.6.0
- */
- void setX(int x);
-
- /**
- * Gets the x coordinate of the mouse input.
- *
- * @return The x coordinate of the mouse input.
- * @see setX
- * @since 0.6.0
- */
- int getX() const A_WARN_UNUSED;
-
- /**
- * Sets the y coordinate of the mouse input.
- *
- * @param y The y coordinate of the mouse input.
- * @see getY
- * @since 0.6.0
- */
- void setY(int y);
-
- /**
- * Gets the y coordinate of the mouse input.
- *
- * @return The y coordinate of the mouse input.
- * @see setY
- * @since 0.6.0
- */
- int getY() const A_WARN_UNUSED;
-
- /**
- * Mouse input event types. This enum partially corresponds
- * to the enum with event types in MouseEvent for easy mapping.
- */
- enum
- {
- MOVED = 0,
- PRESSED,
- RELEASED,
- WHEEL_MOVED_DOWN,
- WHEEL_MOVED_UP
- };
-
- /**
- * Mouse button types.
- */
- enum
- {
- EMPTY = 0,
- LEFT,
- RIGHT,
- MIDDLE
- };
-
- protected:
- /**
- * Holds the type of the mouse input.
- */
- unsigned int mType;
-
- /**
- * Holds the button of the mouse input.
- */
- unsigned int mButton;
-
- /**
- * Holds the timestamp of the mouse input. Used to
- * check for double clicks.
- */
- int mTimeStamp;
-
- /**
- * Holds the x coordinate of the mouse input.
- */
- int mX;
-
- /**
- * Holds the y coordinate of the mouse input.
- */
- int mY;
- };
-} // namespace gcn
-
-#endif // end GCN_MOUSEINPUT_HPP
diff --git a/src/guichan/include/guichan/sdl/sdlpixel.hpp b/src/guichan/include/guichan/sdl/sdlpixel.hpp
deleted file mode 100644
index 99818d42e..000000000
--- a/src/guichan/include/guichan/sdl/sdlpixel.hpp
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GCN_SDLPIXEL_HPP
-#define GCN_SDLPIXEL_HPP
-
-#include "SDL.h"
-#include "guichan/color.hpp"
-
-namespace gcn
-{
-
- /**
- * Checks a pixels color of an SDL_Surface.
- *
- * @param surface an SDL_Surface where to check for a pixel color.
- * @param x the x coordinate on the surface.
- * @param y the y coordinate on the surface.
- * @return a color of a pixel.
- */
- inline const Color SDLgetPixel(SDL_Surface* surface, int x, int y)
- {
- if (!surface)
- return Color(0, 0, 0, 0);
-
- int bpp = surface->format->BytesPerPixel;
-
- SDL_LockSurface(surface);
-
- Uint8 *p = static_cast<uint8_t*>(surface->pixels)
- + y * surface->pitch + x * bpp;
-
- unsigned int color = 0;
-
- switch (bpp)
- {
- case 1:
- color = *p;
- break;
-
- case 2:
- color = *reinterpret_cast<Uint16*>(p);
- break;
-
- case 3:
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- color = p[0] << 16 | p[1] << 8 | p[2];
-#else
- color = p[0] | p[1] << 8 | p[2] << 16;
-#endif
- break;
-
- case 4:
- color = *reinterpret_cast<Uint32*>(p);
- break;
-
- default:
- color = *p;
- break;
- }
-
- unsigned char r, g, b, a;
-
- SDL_GetRGBA(color, surface->format, &r, &g, &b, &a);
- SDL_UnlockSurface(surface);
-
- return Color(r, g, b, a);
- }
-
- /**
- * Puts a pixel on an SDL_Surface.
- *
- * @param x the x coordinate on the surface.
- * @param y the y coordinate on the surface.
- * @param color the color the pixel should be in.
- */
- inline void SDLputPixel(SDL_Surface* surface, int x, int y,
- const Color& color)
- {
- if (!surface)
- return;
-
- int bpp = surface->format->BytesPerPixel;
-
- SDL_LockSurface(surface);
-
- Uint8 *p = static_cast<uint8_t*>(surface->pixels)
- + y * surface->pitch + x * bpp;
-
- Uint32 pixel = SDL_MapRGB(surface->format,
- static_cast<uint8_t>(color.r), static_cast<uint8_t>(color.g),
- static_cast<uint8_t>(color.b));
-
- switch (bpp)
- {
- case 1:
- *p = static_cast<uint8_t>(pixel);
- break;
-
- case 2:
- *reinterpret_cast<uint16_t*>(p) = static_cast<uint16_t>(pixel);
- break;
-
- case 3:
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- p[0] = static_cast<uint8_t>((pixel >> 16) & 0xff);
- p[1] = static_cast<uint8_t>((pixel >> 8) & 0xff);
- p[2] = static_cast<uint8_t>((pixel) & 0xff);
-#else
- p[0] = static_cast<uint8_t>((pixel) & 0xff);
- p[1] = static_cast<uint8_t>((pixel >> 8) & 0xff);
- p[2] = static_cast<uint8_t>((pixel >> 16) & 0xff);
-#endif
- break;
-
- case 4:
- *reinterpret_cast<Uint32*>(p) = pixel;
- break;
-
- default:
- break;
- }
-
- SDL_UnlockSurface(surface);
- }
-
- /**
- * Blends two 32 bit colors together.
- *
- * @param src the source color.
- * @param dst the destination color.
- * @param a alpha.
- */
- inline unsigned int SDLAlpha32(unsigned int src, unsigned int dst,
- unsigned char a)
- {
- unsigned int b = ((src & 0xff) * a + (dst & 0xff) * (255 - a)) >> 8;
- unsigned int g = ((src & 0xff00) * a + (dst & 0xff00)
- * (255 - a)) >> 8;
- unsigned int r = ((src & 0xff0000) * a + (dst & 0xff0000)
- * (255 - a)) >> 8;
-
- return (b & 0xff) | (g & 0xff00) | (r & 0xff0000);
- }
-
- /**
- * Blends two 16 bit colors together.
- *
- * @param src the source color.
- * @param dst the destination color.
- * @param a alpha.
- */
- inline unsigned short SDLAlpha16(unsigned short src, unsigned short dst,
- unsigned char a, const SDL_PixelFormat *f)
- {
- unsigned int b = ((src & f->Rmask) * a + (dst & f->Rmask)
- * (255 - a)) >> 8;
- unsigned int g = ((src & f->Gmask) * a + (dst & f->Gmask)
- * (255 - a)) >> 8;
- unsigned int r = ((src & f->Bmask) * a + (dst & f->Bmask)
- * (255 - a)) >> 8;
-
- return static_cast<unsigned short>((b & f->Rmask)
- | (g & f->Gmask) | (r & f->Bmask));
- }
-
- /*
- typedef struct{
- SDL_Palette *palette;
- Uint8 BitsPerPixel;
- Uint8 BytesPerPixel;
- Uint32 Rmask, Gmask, Bmask, Amask;
- Uint8 Rshift, Gshift, Bshift, Ashift;
- Uint8 Rloss, Gloss, Bloss, Aloss;
- Uint32 colorkey;
- Uint8 alpha;
- } SDL_PixelFormat;
- */
-
- /**
- * Puts a pixel on an SDL_Surface with alpha
- *
- * @param x the x coordinate on the surface.
- * @param y the y coordinate on the surface.
- * @param color the color the pixel should be in.
- */
- inline void SDLputPixelAlpha(SDL_Surface* surface, int x, int y,
- const Color& color)
- {
- int bpp = surface->format->BytesPerPixel;
-
- SDL_LockSurface(surface);
-
- Uint8 *p = static_cast<uint8_t*>(surface->pixels)
- + y * surface->pitch + x * bpp;
-
- Uint32 pixel = SDL_MapRGB(surface->format,
- static_cast<uint8_t>(color.r),
- static_cast<uint8_t>(color.g),
- static_cast<uint8_t>(color.b));
-
- switch (bpp)
- {
- case 1:
- *p = static_cast<uint8_t>(pixel);
- break;
-
- case 2:
- *reinterpret_cast<Uint16*>(p) = SDLAlpha16(
- static_cast<unsigned short>(pixel),
- *reinterpret_cast<unsigned short*>(p),
- static_cast<unsigned char>(color.a), surface->format);
- break;
-
- case 3:
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- p[2] = static_cast<uint8_t>((p[2] * (255 - color.a)
- + color.b * color.a) >> 8);
- p[1] = static_cast<uint8_t>((p[1] * (255 - color.a)
- + color.g * color.a) >> 8);
- p[0] = static_cast<uint8_t>((p[0] * (255 - color.a)
- + color.r * color.a) >> 8);
-#else
- p[0] = static_cast<uint8_t>((p[0] * (255 - color.a)
- + color.b * color.a) >> 8);
- p[1] = static_cast<uint8_t>((p[1] * (255 - color.a)
- + color.g * color.a) >> 8);
- p[2] = static_cast<uint8_t>((p[2] * (255 - color.a)
- + color.r * color.a) >> 8);
-#endif
- break;
-
- case 4:
- *reinterpret_cast<Uint32*>(p) = SDLAlpha32(pixel,
- *reinterpret_cast<Uint32*>(p),
- static_cast<unsigned char>(color.a));
- break;
- default:
- break;
- }
-
- SDL_UnlockSurface(surface);
- }
-} // namespace gcn
-
-#endif // end GCN_SDLPIXEL_HPP
diff --git a/src/guichan/include/guichan/widget.hpp b/src/guichan/include/guichan/widget.hpp
deleted file mode 100644
index fe02d3b14..000000000
--- a/src/guichan/include/guichan/widget.hpp
+++ /dev/null
@@ -1,1232 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GCN_WIDGET_HPP
-#define GCN_WIDGET_HPP
-
-#include <list>
-#include <set>
-#include <string>
-
-#include "guichan/color.hpp"
-#include "guichan/rectangle.hpp"
-
-#include "localconsts.h"
-
-namespace gcn
-{
- class ActionListener;
- class BasicContainer;
- class DeathListener;
- class FocusHandler;
- class FocusListener;
- class Font;
- class Graphics;
- class KeyInput;
- class KeyListener;
- class MouseInput;
- class MouseListener;
- class WidgetListener;
-
- /**
- * Abstract class for widgets of Guichan. It contains basic functions
- * every widget should have.
- *
- * NOTE: Functions begining with underscore "_" should not
- * be overloaded unless you know what you are doing
- *
- * @author Olof Naessén
- * @author Per Larsson.
- * @since 0.1.0
- */
- class Widget
- {
- public:
- /**
- * Constructor. Resets member variables. Noteable, a widget is not
- * focusable as default, therefore, widgets that are supposed to be
- * focusable should overide this default in their own constructor.
- */
- Widget();
-
- A_DELETE_COPY(Widget)
-
- /**
- * Default destructor.
- */
- virtual ~Widget();
-
- /**
- * Draws the widget. It is called by the parent widget when it is time
- * for the widget to draw itself. The graphics object is set up so
- * that all drawing is relative to the widget, i.e coordinate (0,0) is
- * the top left corner of the widget. It is not possible to draw
- * outside of a widget's dimension.
- *
- * @param graphics aA graphics object to draw with.
- * @since 0.1.0
- */
- virtual void draw(Graphics* graphics) = 0;
-
- /**
- * Called when a widget is given a chance to draw a frame around itself.
- * The frame is not considered a part of the widget, it only allows a frame
- * to be drawn around the widget, thus a frame will never be included when
- * calculating if a widget should receive events from user input. Also
- * a widget's frame will never be included when calculating a widget's
- * position.
- *
- * The size of the frame is calculated using the widget's frame size.
- * If a widget has a frame size of 10 pixels than the area the drawFrame
- * function can draw to will be the size of the widget with an additional
- * extension of 10 pixels in each direction.
- *
- * An example when drawFrame is a useful function is if a widget needs
- * a glow around itself.
- *
- * @param graphics A graphics object to draw with.
- * @see setFrameSize, getFrameSize
- * @since 0.8.0
- */
- virtual void drawFrame(Graphics* graphics);
-
- /**
- * Sets the size of the widget's frame. The frame is not considered a part of
- * the widget, it only allows a frame to be drawn around the widget, thus a frame
- * will never be included when calculating if a widget should receive events
- * from user input. Also a widget's frame will never be included when calculating
- * a widget's position.
- *
- * A frame size of 0 means that the widget has no frame. The default frame size
- * is 0.
- *
- * @param frameSize The size of the widget's frame.
- * @see getFrameSize, drawFrame
- * @since 0.8.0
- */
- void setFrameSize(unsigned int frameSize);
-
- /**
- * Gets the size of the widget's frame. The frame is not considered a part of
- * the widget, it only allows a frame to be drawn around the widget, thus a frame
- * will never be included when calculating if a widget should receive events
- * from user input. Also a widget's frame will never be included when calculating
- * a widget's position.
- *
- * A frame size of 0 means that the widget has no frame. The default frame size
- * is 0.
- *
- * @return The size of the widget's frame.
- * @see setFrameSize, drawFrame
- * @since 0.8.0
- */
- unsigned int getFrameSize() const A_WARN_UNUSED;
-
- /**
- * Called for all widgets in the gui each time Gui::logic is called.
- * You can do logic stuff here like playing an animation.
- *
- * @see Gui::logic
- * @since 0.1.0
- */
- virtual void logic()
- { }
-
- /**
- * Gets the widget's parent container.
- *
- * @return The widget's parent container. NULL if the widget
- * has no parent.
- * @since 0.1.0
- */
- virtual Widget* getParent() const A_WARN_UNUSED
- { return mParent; }
-
- /**
- * Sets the width of the widget.
- *
- * @param width The width of the widget.
- * @see getWidth, setHeight, getHeight, setSize,
- * setDimension, getDimensi
- * @since 0.1.0
- */
- void setWidth(int width);
-
- /**
- * Gets the width of the widget.
- *
- * @return The width of the widget.
- * @see setWidth, setHeight, getHeight, setSize,
- * setDimension, getDimension
- * @since 0.1.0
- */
- int getWidth() const A_WARN_UNUSED
- { return mDimension.width; }
-
- /**
- * Sets the height of the widget.
- *
- * @param height The height of the widget.
- * @see getHeight, setWidth, getWidth, setSize,
- * setDimension, getDimension
- * @since 0.1.0
- */
- void setHeight(int height);
-
- /**
- * Gets the height of the widget.
- *
- * @return The height of the widget.
- * @see setHeight, setWidth, getWidth, setSize,
- * setDimension, getDimension
- * @since 0.1.0
- */
- int getHeight() const A_WARN_UNUSED
- { return mDimension.height; }
-
- /**
- * Sets the size of the widget.
- *
- * @param width The width of the widget.
- * @param height The height of the widget.
- * @see setWidth, setHeight, getWidth, getHeight,
- * setDimension, getDimension
- * @since 0.1.0
- */
- void setSize(int width, int height);
-
- /**
- * Sets the x coordinate of the widget. The coordinate is
- * relateive to the widget's parent.
- *
- * @param x The x coordinate of the widget.
- * @see getX, setY, getY, setPosition, setDimension, getDimension
- * @since 0.1.0
- */
- void setX(int x);
-
- /**
- * Gets the x coordinate of the widget. The coordinate is
- * relative to the widget's parent.
- *
- * @return The x coordinate of the widget.
- * @see setX, setY, getY, setPosition, setDimension, getDimension
- * @since 0.1.0
- */
- int getX() const A_WARN_UNUSED
- { return mDimension.x; }
-
- /**
- * Sets the y coordinate of the widget. The coordinate is
- * relative to the widget's parent.
- *
- * @param y The y coordinate of the widget.
- * @see setY, setX, getX, setPosition, setDimension, getDimension
- * @since 0.1.0
- */
- void setY(int y);
-
- /**
- * Gets the y coordinate of the widget. The coordinate is
- * relative to the widget's parent.
- *
- * @return The y coordinate of the widget.
- * @see setY, setX, getX, setPosition, setDimension, getDimension
- * @since 0.1.0
- */
- int getY() const A_WARN_UNUSED
- { return mDimension.y; }
-
- /**
- * Sets position of the widget. The position is relative
- * to the widget's parent.
- *
- * @param x The x coordinate of the widget.
- * @param y The y coordinate of the widget.
- * @see setX, getX, setY, getY, setDimension, getDimension
- * @since 0.1.0
- */
- void setPosition(int x, int y);
-
- /**
- * Sets the dimension of the widget. The dimension is
- * relative to the widget's parent.
- *
- * @param dimension The dimension of the widget.
- * @see getDimension, setX, getX, setY, getY, setPosition
- * @since 0.1.0
- */
- void setDimension(const Rectangle& dimension);
-
- /**
- * Gets the dimension of the widget. The dimension is
- * relative to the widget's parent.
- *
- * @return The dimension of the widget.
- * @see getDimension, setX, getX, setY, getY, setPosition
- * @since 0.1.0
- */
- const Rectangle& getDimension() const A_WARN_UNUSED;
-
- /**
- * Sets the widget to be fosusable, or not.
- *
- * @param focusable True if the widget should be focusable,
- * false otherwise.
- * @see isFocusable
- * @since 0.1.0
- */
- void setFocusable(bool focusable);
-
- /**
- * Checks if a widget is focsable.
- *
- * @return True if the widget should be focusable, false otherwise.
- * @see setFocusable
- * @since 0.1.0
- */
- bool isFocusable() const A_WARN_UNUSED;
-
- /**
- * Checks if the widget is focused.
- *
- * @return True if the widget is focused, false otherwise.
- * @since 0.1.0
- */
- virtual bool isFocused() const A_WARN_UNUSED;
-
- /**
- * Sets the widget to enabled, or not. A disabled
- * widget will never recieve mouse or key events.
- *
- * @param enabled True if widget should be enabled,
- * false otherwise.
- * @see isEnabled
- * @since 0.1.0
- */
- void setEnabled(bool enabled);
-
- /**
- * Checks if the widget is enabled. A disabled
- * widget will never recieve mouse or key events.
- *
- * @return True if widget is enabled, false otherwise.
- * @see setEnabled
- * @since 0.1.0
- */
- bool isEnabled() const A_WARN_UNUSED;
-
- /**
- * Sets the widget to be visible, or not.
- *
- * @param visible True if widget should be visible, false otherwise.
- * @see isVisible
- * @since 0.1.0
- */
- void setVisible(bool visible);
-
- /**
- * Checks if the widget is visible.
- *
- * @return True if widget is be visible, false otherwise.
- * @see setVisible
- * @since 0.1.0
- */
- bool isVisible() const A_WARN_UNUSED
- { return mVisible && (!mParent || mParent->isVisible()); }
-
- /**
- * Sets the base color of the widget.
- *
- * @param color The baseground color.
- * @see getBaseColor
- * @since 0.1.0
- */
- void setBaseColor(const Color& color);
-
- /**
- * Gets the base color.
- *
- * @return The base color.
- * @see setBaseColor
- * @since 0.1.0
- */
- const Color& getBaseColor() const A_WARN_UNUSED;
-
- /**
- * Sets the foreground color.
- *
- * @param color The foreground color.
- * @see getForegroundColor
- * @since 0.1.0
- */
- void setForegroundColor(const Color& color);
-
- /**
- * Gets the foreground color.
- *
- * @see setForegroundColor
- * @since 0.1.0
- */
- const Color& getForegroundColor() const A_WARN_UNUSED;
-
- /**
- * Sets the background color.
- *
- * @param color The background Color.
- * @see setBackgroundColor
- * @since 0.1.0
- */
- void setBackgroundColor(const Color& color);
-
- /**
- * Gets the background color.
- *
- * @see setBackgroundColor
- * @since 0.1.0
- */
- const Color& getBackgroundColor() const A_WARN_UNUSED;
-
- /**
- * Sets the selection color.
- *
- * @param color The selection color.
- * @see getSelectionColor
- * @since 0.6.0
- */
- void setSelectionColor(const Color& color);
-
- /**
- * Gets the selection color.
- *
- * @return The selection color.
- * @see setSelectionColor
- * @since 0.6.0
- */
- const Color& getSelectionColor() const A_WARN_UNUSED;
-
- /**
- * Requests focus for the widget. A widget will only recieve focus
- * if it is focusable.
- */
- virtual void requestFocus();
-
- /**
- * Requests a move to the top in the parent widget.
- */
- virtual void requestMoveToTop();
-
- /**
- * Requests a move to the bottom in the parent widget.
- */
- virtual void requestMoveToBottom();
-
- /**
- * Sets the focus handler to be used.
- *
- * WARNING: This function is used internally and should not
- * be called or overloaded unless you know what you
- * are doing.
- *
- * @param focusHandler The focus handler to use.
- * @see _getFocusHandler
- * @since 0.1.0
- */
- virtual void _setFocusHandler(FocusHandler* focusHandler);
-
- /**
- * Gets the focus handler used.
- *
- * WARNING: This function is used internally and should not
- * be called or overloaded unless you know what you
- * are doing.
- *
- * @return The focus handler used.
- * @see _setFocusHandler
- * @since 0.1.0
- */
- virtual FocusHandler* _getFocusHandler() A_WARN_UNUSED;
-
- /**
- * Adds an action listener to the widget. When an action event
- * is fired by the widget the action listeners of the widget
- * will get notified.
- *
- * @param actionListener The action listener to add.
- * @see removeActionListener
- * @since 0.1.0
- */
- void addActionListener(ActionListener* actionListener);
-
- /**
- * Removes an added action listener from the widget.
- *
- * @param actionListener The action listener to remove.
- * @see addActionListener
- * @since 0.1.0
- */
- void removeActionListener(ActionListener* actionListener);
-
- /**
- * Adds a death listener to the widget. When a death event is
- * fired by the widget the death listeners of the widget will
- * get notified.
- *
- * @param deathListener The death listener to add.
- * @see removeDeathListener
- * @since 0.1.0
- */
- void addDeathListener(DeathListener* deathListener);
-
- /**
- * Removes an added death listener from the widget.
- *
- * @param deathListener The death listener to remove.
- * @see addDeathListener
- * @since 0.1.0
- */
- void removeDeathListener(DeathListener* deathListener);
-
- /**
- * Adds a mouse listener to the widget. When a mouse event is
- * fired by the widget the mouse listeners of the widget will
- * get notified.
- *
- * @param mouseListener The mouse listener to add.
- * @see removeMouseListener
- * @since 0.1.0
- */
- void addMouseListener(MouseListener* mouseListener);
-
- /**
- * Removes an added mouse listener from the widget.
- *
- * @param mouseListener The mouse listener to remove.
- * @see addMouseListener
- * @since 0.1.0
- */
- void removeMouseListener(MouseListener* mouseListener);
-
- /**
- * Adds a key listener to the widget. When a key event is
- * fired by the widget the key listeners of the widget will
- * get notified.
- *
- * @param keyListener The key listener to add.
- * @see removeKeyListener
- * @since 0.1.0
- */
- void addKeyListener(KeyListener* keyListener);
-
- /**
- * Removes an added key listener from the widget.
- *
- * @param keyListener The key listener to remove.
- * @see addKeyListener
- * @since 0.1.0
- */
- void removeKeyListener(KeyListener* keyListener);
-
- /**
- * Adds a focus listener to the widget. When a focus event is
- * fired by the widget the key listeners of the widget will
- * get notified.
- *
- * @param focusListener The focus listener to add.
- * @see removeFocusListener
- * @since 0.7.0
- */
- void addFocusListener(FocusListener* focusListener);
-
- /**
- * Removes an added focus listener from the widget.
- *
- * @param focusListener The focus listener to remove.
- * @see addFocusListener
- * @since 0.7.0
- */
- void removeFocusListener(FocusListener* focusListener);
-
- /**
- * Adds a widget listener to the widget. When a widget event is
- * fired by the widget the key listeners of the widget will
- * get notified.
- *
- * @param widgetListener The widget listener to add.
- * @see removeWidgetListener
- * @since 0.8.0
- */
- void addWidgetListener(WidgetListener* widgetListener);
-
- /**
- * Removes an added widget listener from the widget.
- *
- * @param widgetListener The widget listener to remove.
- * @see addWidgetListener
- * @since 0.8.0
- */
- void removeWidgetListener(WidgetListener* widgetListener);
-
- /**
- * Sets the action event identifier of the widget. The identifier is
- * used to be able to identify which action has occured.
- *
- * NOTE: An action event identifier should not be used to identify a
- * certain widget but rather a certain event in your application.
- * Several widgets can have the same action event identifer.
- *
- * @param actionEventId The action event identifier.
- * @see getActionEventId
- * @since 0.6.0
- */
- void setActionEventId(const std::string& actionEventId);
-
- /**
- * Gets the action event identifier of the widget.
- *
- * @return The action event identifier of the widget.
- * @see setActionEventId
- * @since 0.6.0
- */
- const std::string& getActionEventId() const;
-
- /**
- * Gets the absolute position on the screen for the widget.
- *
- * @param x The absolute x coordinate will be stored in this parameter.
- * @param y The absolute y coordinate will be stored in this parameter.
- * @since 0.1.0
- */
- virtual void getAbsolutePosition(int& x, int& y) const;
-
- /**
- * Sets the parent of the widget. A parent must be a BasicContainer.
- *
- * WARNING: This function is used internally and should not
- * be called or overloaded unless you know what you
- * are doing.
- *
- * @param parent The parent of the widget.
- * @see getParent
- * @since 0.1.0
- */
- virtual void _setParent(Widget* parent);
-
- /**
- * Gets the font set for the widget. If no font has been set,
- * the global font will be returned. If no global font has been set,
- * the default font will be returend.
- *
- * @return The font set for the widget.
- * @see setFont, setGlobalFont
- * @since 0.1.0
- */
- Font *getFont() const A_WARN_UNUSED;
-
- /**
- * Sets the global font to be used by default for all widgets.
- *
- * @param font The global font.
- * @see getGlobalFont
- * @since 0.1.0
- */
- static void setGlobalFont(Font* font);
-
- /**
- * Sets the font for the widget. If NULL is passed, the global font
- * will be used.
- *
- * @param font The font to set for the widget.
- * @see getFont
- * @since 0.1.0
- */
- void setFont(Font* font);
-
- /**
- * Called when the font has changed. If the change is global,
- * this function will only be called if the widget doesn't have a
- * font already set.
- *
- * @since 0.1.0
- */
- virtual void fontChanged()
- { }
-
- /**
- * Checks if a widget exists or not, that is if it still exists
- * an instance of the object.
- *
- * @param widget The widget to check.
- * @return True if an instance of the widget exists, false otherwise.
- * @since 0.1.0
- */
- static bool widgetExists(const Widget* widget) A_WARN_UNUSED;
-
- /**
- * Checks if tab in is enabled. Tab in means that you can set focus
- * to this widget by pressing the tab button. If tab in is disabled
- * then the focus handler will skip this widget and focus the next
- * in its focus order.
- *
- * @return True if tab in is enabled, false otherwise.
- * @see setTabInEnabled
- * @since 0.1.0
- */
- bool isTabInEnabled() const A_WARN_UNUSED;
-
- /**
- * Sets tab in enabled, or not. Tab in means that you can set focus
- * to this widget by pressing the tab button. If tab in is disabled
- * then the FocusHandler will skip this widget and focus the next
- * in its focus order.
- *
- * @param enabled True if tab in should be enabled, false otherwise.
- * @see isTabInEnabled
- * @since 0.1.0
- */
- void setTabInEnabled(bool enabled);
-
- /**
- * Checks if tab out is enabled. Tab out means that you can lose
- * focus to this widget by pressing the tab button. If tab out is
- * disabled then the FocusHandler ignores tabbing and focus will
- * stay with this widget.
- *
- * @return True if tab out is enabled, false otherwise.
- * @see setTabOutEnabled
- * @since 0.1.0
- */
- bool isTabOutEnabled() const A_WARN_UNUSED;
-
- /**
- * Sets tab out enabled. Tab out means that you can lose
- * focus to this widget by pressing the tab button. If tab out is
- * disabled then the FocusHandler ignores tabbing and focus will
- * stay with this widget.
- *
- * @param enabled True if tab out should be enabled, false otherwise.
- * @see isTabOutEnabled
- * @since 0.1.0
- */
- void setTabOutEnabled(bool enabled);
-
- /**
- * Requests modal focus. When a widget has modal focus, only that
- * widget and it's children may recieve input.
- *
- * @throws Exception if another widget already has modal focus.
- * @see releaseModalFocus, isModalFocused
- * @since 0.4.0
- */
- virtual void requestModalFocus();
-
- /**
- * Requests modal mouse input focus. When a widget has modal input focus
- * that widget will be the only widget receiving input even if the input
- * occurs outside of the widget and no matter what the input is.
- *
- * @throws Exception if another widget already has modal focus.
- * @see releaseModalMouseInputFocus, isModalMouseInputFocused
- * @since 0.6.0
- */
- virtual void requestModalMouseInputFocus();
-
- /**
- * Releases modal focus. Modal focus will only be released if the
- * widget has modal focus.
- *
- * @see requestModalFocus, isModalFocused
- * @since 0.4.0
- */
- virtual void releaseModalFocus();
-
- /**
- * Releases modal mouse input focus. Modal mouse input focus will only
- * be released if the widget has modal mouse input focus.
- *
- * @see requestModalMouseInputFocus, isModalMouseInputFocused
- * @since 0.6.0
- */
- virtual void releaseModalMouseInputFocus();
-
- /**
- * Checks if the widget or it's parent has modal focus.
- *
- * @return True if the widget has modal focus, false otherwise.
- * @see requestModalFocus, releaseModalFocus
- * @since 0.8.0
- */
- virtual bool isModalFocused() const A_WARN_UNUSED;
-
- /**
- * Checks if the widget or it's parent has modal mouse input focus.
- *
- * @return True if the widget has modal mouse input focus, false
- * otherwise.
- * @see requestModalMouseInputFocus, releaseModalMouseInputFocus
- * @since 0.8.0
- */
- virtual bool isModalMouseInputFocused() const A_WARN_UNUSED;
-
- /**
- * Gets a widget from a certain position in the widget.
- * This function is used to decide which gets mouse input,
- * thus it can be overloaded to change that behaviour.
- *
- * NOTE: This always returns NULL if the widget is not
- * a container.
- *
- * @param x The x coordinate of the widget to get.
- * @param y The y coordinate of the widget to get.
- * @return The widget at the specified coodinate, NULL
- * if no widget is found.
- * @since 0.6.0
- */
- virtual Widget *getWidgetAt(int x, int y) A_WARN_UNUSED;
-
- /**
- * Gets the mouse listeners of the widget.
- *
- * @return The mouse listeners of the widget.
- * @since 0.6.0
- */
- virtual const std::list<MouseListener*>& _getMouseListeners()
- A_WARN_UNUSED;
-
- /**
- * Gets the key listeners of the widget.
- *
- * @return The key listeners of the widget.
- * @since 0.6.0
- */
- virtual const std::list<KeyListener*>& _getKeyListeners()
- A_WARN_UNUSED;
-
- /**
- * Gets the focus listeners of the widget.
- *
- * @return The focus listeners of the widget.
- * @since 0.7.0
- */
- virtual const std::list<FocusListener*>& _getFocusListeners()
- A_WARN_UNUSED;
-
- /**
- * Gets the area of the widget occupied by the widget's children.
- * By default this method returns an empty rectangle as not all
- * widgets are containers. If you want to make a container this
- * method should return the area where the children resides. This
- * method is used when drawing children of a widget when computing
- * clip rectangles for the children.
- *
- * An example of a widget that overloads this method is ScrollArea.
- * A ScrollArea has a view of its contant and that view is the
- * children area. The size of a ScrollArea's children area might
- * vary depending on if the scroll bars of the ScrollArea is shown
- * or not.
- *
- * @return The area of the widget occupied by the widget's children.
- * @see BasicContainer
- * @see BasicContainer::getChildrenArea
- * @see BasicContainer::drawChildren
- * @since 0.1.0
- */
- virtual Rectangle getChildrenArea() A_WARN_UNUSED;
-
- /**
- * Gets the internal focus handler used.
- *
- * @return the internalFocusHandler used. If no internal focus handler
- * is used, NULL will be returned.
- * @see setInternalFocusHandler
- * @since 0.1.0
- */
- virtual FocusHandler* _getInternalFocusHandler() A_WARN_UNUSED;
-
- /**
- * Sets the internal focus handler. An internal focus handler is
- * needed if both a widget in the widget and the widget itself
- * should be foucsed at the same time.
- *
- * @param focusHandler The internal focus handler to be used.
- * @see getInternalFocusHandler
- * @since 0.1.0
- */
- void setInternalFocusHandler(FocusHandler* internalFocusHandler);
-
- /**
- * Moves a widget to the top of this widget. The moved widget will be
- * drawn above all other widgets in this widget.
- *
- * @param widget The widget to move to the top.
- * @see moveToBottom
- * @since 0.1.0
- */
- virtual void moveToTop(Widget* widget A_UNUSED)
- { }
-
- /**
- * Moves a widget in this widget to the bottom of this widget.
- * The moved widget will be drawn below all other widgets in this widget.
- *
- * @param widget The widget to move to the bottom.
- * @see moveToTop
- * @since 0.1.0
- */
- virtual void moveToBottom(Widget* widget A_UNUSED)
- { }
-
- /**
- * Focuses the next widget in the widget.
- *
- * @see moveToBottom
- * @since 0.1.0
- */
- virtual void focusNext()
- { }
-
- /**
- * Focuses the previous widget in the widget.
- *
- * @see moveToBottom
- * @since 0.1.0
- */
- virtual void focusPrevious()
- { }
-
- /**
- * Tries to show a specific part of a widget by moving it. Used if the
- * widget should act as a container.
- *
- * @param widget The target widget.
- * @param area The area to show.
- * @since 0.1.0
- */
- virtual void showWidgetPart(Widget* widget A_UNUSED,
- Rectangle area A_UNUSED)
- { }
-
- /**
- * Sets an id of a widget. An id can be useful if a widget needs to be
- * identified in a container. For example, if widgets are created by an
- * XML document, a certain widget can be retrieved given that the widget
- * has an id.
- *
- * @param id The id to set to the widget.
- * @see getId, BasicContainer::findWidgetById
- * @since 0.8.0
- */
- void setId(const std::string& id);
-
- /**
- * Gets the id of a widget. An id can be useful if a widget needs to be
- * identified in a container. For example, if widgets are created by an
- * XML document, a certain widget can be retrieved given that the widget
- * has an id.
- *
- * @param id The id to set to the widget.
- * @see setId, BasicContainer::findWidgetById
- * @since 0.8.0
- */
- const std::string& getId() A_WARN_UNUSED;
-
- /**
- * Shows a certain part of a widget in the widget's parent.
- * Used when widgets want a specific part to be visible in
- * its parent. An example is a TextArea that wants a specific
- * part of its text to be visible when a TextArea is a child
- * of a ScrollArea.
- *
- * @param rectangle The rectangle to be shown.
- * @since 0.8.0
- */
- virtual void showPart(Rectangle rectangle);
-
- protected:
- /**
- * Distributes an action event to all action listeners
- * of the widget.
- *
- * @since 0.8.0
- */
- void distributeActionEvent();
-
- /**
- * Distributes resized events to all of the widget's listeners.
- *
- * @since 0.8.0
- */
- void distributeResizedEvent();
-
- /**
- * Distributes moved events to all of the widget's listeners.
- *
- * @since 0.8.0
- */
- void distributeMovedEvent();
-
- /**
- * Distributes hidden events to all of the widget's listeners.
- *
- * @since 0.8.0
- * @author Olof Naessén
- */
- void distributeHiddenEvent();
-
- /**
- * Distributes shown events to all of the widget's listeners.
- *
- * @since 0.8.0
- * @author Olof Naessén
- */
- void distributeShownEvent();
-
- /**
- * Typdef.
- */
- typedef std::list<MouseListener*> MouseListenerList;
-
- /**
- * Typdef.
- */
- typedef MouseListenerList::iterator MouseListenerIterator;
-
- /**
- * Holds the mouse listeners of the widget.
- */
- MouseListenerList mMouseListeners;
-
- /**
- * Typdef.
- */
- typedef std::list<KeyListener*> KeyListenerList;
-
- /**
- * Holds the key listeners of the widget.
- */
- KeyListenerList mKeyListeners;
-
- /**
- * Typdef.
- */
- typedef KeyListenerList::iterator KeyListenerIterator;
-
- /**
- * Typdef.
- */
- typedef std::list<ActionListener*> ActionListenerList;
-
- /**
- * Holds the action listeners of the widget.
- */
- ActionListenerList mActionListeners;
-
- /**
- * Typdef.
- */
- typedef ActionListenerList::iterator ActionListenerIterator;
-
- /**
- * Typdef.
- */
- typedef std::list<DeathListener*> DeathListenerList;
-
- /**
- * Holds the death listeners of the widget.
- */
- DeathListenerList mDeathListeners;
-
- /**
- * Typdef.
- */
- typedef DeathListenerList::iterator DeathListenerIterator;
-
- /**
- * Typdef.
- */
- typedef std::list<FocusListener*> FocusListenerList;
-
- /**
- * Holds the focus listeners of the widget.
- */
- FocusListenerList mFocusListeners;
-
- /**
- * Typdef.
- */
- typedef FocusListenerList::iterator FocusListenerIterator;
-
- typedef std::list<WidgetListener*> WidgetListenerList;
-
- /**
- * Holds the widget listeners of the widget.
- */
- WidgetListenerList mWidgetListeners;
-
- /**
- * Typdef.
- */
- typedef WidgetListenerList::iterator WidgetListenerIterator;
-
- /**
- * Holds the foreground color of the widget.
- */
- Color mForegroundColor;
-
- /**
- * Holds the background color of the widget.
- */
- Color mBackgroundColor;
-
- /**
- * Holds the base color of the widget.
- */
- Color mBaseColor;
-
- /**
- * Holds the selection color of the widget.
- */
- Color mSelectionColor;
-
- /**
- * Holds the focus handler used by the widget.
- */
- FocusHandler* mFocusHandler;
-
- /**
- * Holds the focus handler used by the widget. NULL
- * if no internal focus handler is used.
- */
- FocusHandler* mInternalFocusHandler;
-
- /**
- * Holds the parent of the widget. NULL if the widget
- * has no parent.
- */
- Widget* mParent;
-
- /**
- * Holds the dimension of the widget.
- */
- Rectangle mDimension;
-
- /**
- * Holds the frame size of the widget.
- */
- unsigned int mFrameSize;
-
- /**
- * Holds the action event of the widget.
- */
- std::string mActionEventId;
-
- /**
- * True if the widget focusable, false otherwise.
- */
- bool mFocusable;
-
- /**
- * True if the widget visible, false otherwise.
- */
- bool mVisible;
-
- /**
- * True if the widget has tab in enabled, false otherwise.
- */
- bool mTabIn;
-
- /**
- * True if the widget has tab in enabled, false otherwise.
- */
- bool mTabOut;
-
- /**
- * True if the widget is enabled, false otherwise.
- */
- bool mEnabled;
-
- /**
- * Holds the id of the widget.
- */
- std::string mId;
-
- /**
- * Holds the font used by the widget.
- */
- Font* mCurrentFont;
-
- /**
- * Holds the global font used by the widget.
- */
- static Font* mGlobalFont;
-
- /**
- * Holds a list of all instances of widgets.
- */
- static std::list<Widget*> mWidgets;
-
- static std::set<Widget*> mWidgetsSet;
- };
-} // namespace gcn
-
-#endif // end GCN_WIDGET_HPP
diff --git a/src/guichan/include/guichan/widgets/window.hpp b/src/guichan/include/guichan/widgets/window.hpp
deleted file mode 100644
index bf5dd2e7c..000000000
--- a/src/guichan/include/guichan/widgets/window.hpp
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GCN_WINDOW_HPP
-#define GCN_WINDOW_HPP
-
-#include <string>
-
-#include "guichan/mouselistener.hpp"
-#include "guichan/widgets/container.hpp"
-
-namespace gcn
-{
- /**
- * An implementation of a movable window that can contain other widgets.
- */
- class Window : public Container,
- public MouseListener
- {
- public:
- /**
- * Constructor.
- */
- Window();
-
- /**
- * Constructor. The window will be automatically resized in height
- * to fit the caption.
- *
- * @param caption the caption of the window.
- */
- explicit Window(const std::string& caption);
-
- A_DELETE_COPY(Window)
-
- /**
- * Destructor.
- */
- virtual ~Window();
-
- /**
- * Sets the caption of the window.
- *
- * @param caption The caption of the window.
- * @see getCaption
- */
- void setCaption(const std::string& caption);
-
- /**
- * Gets the caption of the window.
- *
- * @return the caption of the window.
- * @see setCaption
- */
- const std::string& getCaption() const;
-
- /**
- * Sets the alignment of the caption.
- *
- * @param alignment The alignment of the caption.
- * @see getAlignment, Graphics
- */
- void setAlignment(Graphics::Alignment alignment);
-
- /**
- * Gets the alignment of the caption.
- *
- * @return The alignment of caption.
- * @see setAlignment, Graphics
- */
- Graphics::Alignment getAlignment() const;
-
- /**
- * Sets the padding of the window. The padding is the distance between the
- * window border and the content.
- *
- * @param padding The padding of the window.
- * @see getPadding
- */
- void setPadding(unsigned int padding);
-
- /**
- * Gets the padding of the window. The padding is the distance between the
- * window border and the content.
- *
- * @return The padding of the window.
- * @see setPadding
- */
- unsigned int getPadding() const;
-
- /**
- * Sets the title bar height.
- *
- * @param height The title height value.
- * @see getTitleBarHeight
- */
- void setTitleBarHeight(unsigned int height);
-
- /**
- * Gets the title bar height.
- *
- * @return The title bar height.
- * @see setTitleBarHeight
- */
- unsigned int getTitleBarHeight();
-
- /**
- * Sets the window to be moveble or not.
- *
- * @param movable True if the window should be movable, false otherwise.
- * @see isMovable
- */
- void setMovable(bool movable);
-
- /**
- * Checks if the window is movable.
- *
- * @return True if the window is movable, false otherwise.
- * @see setMovable
- */
- bool isMovable() const;
-
- /**
- * Sets the window to be opaque or not. An opaque window will draw it's background
- * and it's content. A non opaque window will only draw it's content.
- *
- * @param opaque True if the window should be opaque, false otherwise.
- * @see isOpaque
- */
- void setOpaque(bool opaque);
-
- /**
- * Checks if the window is opaque.
- *
- * @return True if the window is opaque, false otherwise.
- * @see setOpaque
- */
- bool isOpaque();
-
- /**
- * Resizes the window to fit the content.
- */
- virtual void resizeToContent();
-
- // Inherited from BasicContainer
-
- virtual Rectangle getChildrenArea();
-
- // Inherited from MouseListener
-
- virtual void mousePressed(MouseEvent& mouseEvent) override;
-
- virtual void mouseDragged(MouseEvent& mouseEvent) override;
-
- virtual void mouseReleased(MouseEvent& mouseEvent) override;
-
- protected:
- /**
- * Holds the caption of the window.
- */
- std::string mCaption;
-
- /**
- * Holds the alignment of the caption.
- */
- Graphics::Alignment mAlignment;
-
- /**
- * Holds the padding of the window.
- */
- unsigned int mPadding;
-
- /**
- * Holds the title bar height of the window.
- */
- unsigned int mTitleBarHeight;
-
- /**
- * True if the window is movable, false otherwise.
- */
- bool mMovable;
-
- /**
- * True if the window is opaque, false otherwise.
- */
- bool mOpaque;
-
- /**
- * Holds a drag offset as an x coordinate where the drag of the window
- * started if the window is being dragged. It's used to move the window
- * correctly when dragged.
- */
- int mDragOffsetX;
-
- /**
- * Holds a drag offset as an y coordinate where the drag of the window
- * started if the window is being dragged. It's used to move the window
- * correctly when dragged.
- */
- int mDragOffsetY;
-
- /**
- * True if the window is being moved, false otherwise.
- */
- bool mMoved;
- };
-} // namespace gcn
-
-#endif // end GCN_WINDOW_HPP
diff --git a/src/guichan/inputevent.cpp b/src/guichan/inputevent.cpp
deleted file mode 100644
index ac7eea5bd..000000000
--- a/src/guichan/inputevent.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * For comments regarding functions please see the header file.
- */
-
-#include "guichan/inputevent.hpp"
-
-#include "debug.h"
-
-namespace gcn
-{
- InputEvent::InputEvent(Widget *const source,
- const bool shiftPressed,
- const bool controlPressed,
- const bool altPressed,
- const bool metaPressed)
- :Event(source),
- mShiftPressed(shiftPressed),
- mControlPressed(controlPressed),
- mAltPressed(altPressed),
- mMetaPressed(metaPressed),
- mIsConsumed(false)
- {
- }
-
- bool InputEvent::isShiftPressed() const
- {
- return mShiftPressed;
- }
-
- bool InputEvent::isControlPressed() const
- {
- return mControlPressed;
- }
-
- bool InputEvent::isAltPressed() const
- {
- return mAltPressed;
- }
-
- bool InputEvent::isMetaPressed() const
- {
- return mMetaPressed;
- }
-
- void InputEvent::consume()
- {
- mIsConsumed = true;
- }
-
- bool InputEvent::isConsumed() const
- {
- return mIsConsumed;
- }
-} // namespace gcn
diff --git a/src/guichan/keyevent.cpp b/src/guichan/keyevent.cpp
deleted file mode 100644
index 1f325ef1d..000000000
--- a/src/guichan/keyevent.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * For comments regarding functions please see the header file.
- */
-
-#include "guichan/keyevent.hpp"
-
-#include "debug.h"
-
-namespace gcn
-{
- KeyEvent::KeyEvent(Widget *const source,
- const bool shiftPressed,
- const bool controlPressed,
- const bool altPressed,
- const bool metaPressed,
- const unsigned int type,
- const bool numericPad,
- const Key& key) :
- InputEvent(source,
- shiftPressed,
- controlPressed,
- altPressed,
- metaPressed),
- mType(type),
- mIsNumericPad(numericPad),
- mKey(key)
- {
- }
-
- KeyEvent::~KeyEvent()
- {
- }
-
- unsigned int KeyEvent::getType() const
- {
- return mType;
- }
-
- bool KeyEvent::isNumericPad() const
- {
- return mIsNumericPad;
- }
-
- const Key& KeyEvent::getKey() const
- {
- return mKey;
- }
-} // namespace gcn
diff --git a/src/guichan/mouseevent.cpp b/src/guichan/mouseevent.cpp
deleted file mode 100644
index c24be1252..000000000
--- a/src/guichan/mouseevent.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * For comments regarding functions please see the header file.
- */
-
-#include "guichan/mouseevent.hpp"
-
-#include "debug.h"
-
-namespace gcn
-{
- MouseEvent::MouseEvent(Widget *const source,
- const bool shiftPressed,
- const bool controlPressed,
- const bool altPressed,
- const bool metaPressed,
- const unsigned int type,
- const unsigned int button,
- const int x,
- const int y,
- const int clickCount) :
- InputEvent(source,
- shiftPressed,
- controlPressed,
- altPressed,
- metaPressed),
- mType(type),
- mButton(button),
- mX(x),
- mY(y),
- mClickCount(clickCount)
- {
- }
-
- unsigned int MouseEvent::getButton() const
- {
- return mButton;
- }
-
- int MouseEvent::getX() const
- {
- return mX;
- }
-
- int MouseEvent::getY() const
- {
- return mY;
- }
-
- int MouseEvent::getClickCount() const
- {
- return mClickCount;
- }
-
- unsigned int MouseEvent::getType() const
- {
- return mType;
- }
-} // namespace gcn
diff --git a/src/guichan/rectangle.cpp b/src/guichan/rectangle.cpp
deleted file mode 100644
index 3aca53a0a..000000000
--- a/src/guichan/rectangle.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * For comments regarding functions please see the header file.
- */
-
-#include "guichan/rectangle.hpp"
-
-#include "debug.h"
-
-namespace gcn
-{
- Rectangle::Rectangle()
- : x(0),
- y(0),
- width(0),
- height(0)
- {
- }
-
- Rectangle::Rectangle(const int x_, const int y_,
- const int width_, const int height_) :
- x(x_),
- y(y_),
- width(width_),
- height(height_)
- {
- }
-
- void Rectangle::setAll(int x_, int y_, int width_, int height_)
- {
- x = x_;
- y = y_;
- width = width_;
- height = height_;
- }
-
- bool Rectangle::isIntersecting(const Rectangle& rectangle) const
- {
- int x_ = x;
- int y_ = y;
- int width_ = width;
- int height_ = height;
-
- x_ -= rectangle.x;
- y_ -= rectangle.y;
-
- if (x_ < 0)
- {
- width_ += x_;
-// x_ = 0;
- }
- else if (x_ + width_ > rectangle.width)
- {
- width_ = rectangle.width - x_;
- }
-
- if (y_ < 0)
- {
- height_ += y_;
-// y_ = 0;
- }
- else if (y_ + height_ > rectangle.height)
- {
- height_ = rectangle.height - y_;
- }
-
- if (width_ <= 0 || height_ <= 0)
- {
- return false;
- }
-
- return true;
- }
-
- bool Rectangle::isPointInRect(int x_, int y_) const
- {
- return x_ >= x
- && y_ >= y
- && x_ < x + width
- && y_ < y + height;
- }
-
- std::ostream& operator<<(std::ostream& out,
- const Rectangle& rectangle)
- {
- out << "Rectangle [x = " << rectangle.x
- << ", y = " << rectangle.y
- << ", width = " << rectangle.width
- << ", height = " << rectangle.height
- << "]";
-
- return out;
- }
-} // namespace gcn
diff --git a/src/guichan/selectionevent.cpp b/src/guichan/selectionevent.cpp
deleted file mode 100644
index 2606d84ef..000000000
--- a/src/guichan/selectionevent.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * For comments regarding functions please see the header file.
- */
-
-#include "guichan/selectionevent.hpp"
-
-#include "debug.h"
-
-namespace gcn
-{
- SelectionEvent::SelectionEvent(Widget *const source) :
- Event(source)
- {
- }
-
- SelectionEvent::~SelectionEvent()
- {
- }
-} // namespace gcn
diff --git a/src/guichan/widget.cpp b/src/guichan/widget.cpp
deleted file mode 100644
index 0cd7883d7..000000000
--- a/src/guichan/widget.cpp
+++ /dev/null
@@ -1,695 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * For comments regarding functions please see the header file.
- */
-
-#include "guichan/widget.hpp"
-
-#include "guichan/actionevent.hpp"
-#include "guichan/actionlistener.hpp"
-#include "guichan/basiccontainer.hpp"
-#include "guichan/deathlistener.hpp"
-#include "guichan/event.hpp"
-#include "guichan/exception.hpp"
-#include "guichan/focushandler.hpp"
-#include "guichan/graphics.hpp"
-#include "guichan/keyinput.hpp"
-#include "guichan/keylistener.hpp"
-#include "guichan/mouseinput.hpp"
-#include "guichan/mouselistener.hpp"
-#include "guichan/widgetlistener.hpp"
-
-#include "debug.h"
-
-namespace gcn
-{
- Font* Widget::mGlobalFont = nullptr;
- std::list<Widget*> Widget::mWidgets;
- std::set<Widget*> Widget::mWidgetsSet;
-
- Widget::Widget() :
- mMouseListeners(),
- mKeyListeners(),
- mActionListeners(),
- mDeathListeners(),
- mFocusListeners(),
- mWidgetListeners(),
- mForegroundColor(0x000000),
- mBackgroundColor(0xffffff),
- mBaseColor(0x808090),
- mSelectionColor(0xc3d9ff),
- mFocusHandler(nullptr),
- mInternalFocusHandler(nullptr),
- mParent(nullptr),
- mDimension(),
- mFrameSize(0),
- mActionEventId(),
- mFocusable(false),
- mVisible(true),
- mTabIn(true),
- mTabOut(true),
- mEnabled(true),
- mId(),
- mCurrentFont(nullptr)
- {
- mWidgets.push_back(this);
- mWidgetsSet.insert(this);
- }
-
- Widget::~Widget()
- {
- for (DeathListenerIterator iter = mDeathListeners.begin();
- iter != mDeathListeners.end();
- ++iter)
- {
- Event event(this);
- (*iter)->death(event);
- }
-
- _setFocusHandler(nullptr);
-
- mWidgets.remove(this);
- mWidgetsSet.erase(this);
- }
-
- void Widget::drawFrame(Graphics* graphics)
- {
- BLOCK_START("Widget::drawFrame")
- const Color &faceColor = getBaseColor();
- Color highlightColor = faceColor + Color(0x303030);
- Color shadowColor = faceColor - Color(0x303030);
- const int alpha = getBaseColor().a;
- const int width = getWidth() + getFrameSize() * 2 - 1;
- const int height = getHeight() + getFrameSize() * 2 - 1;
- highlightColor.a = alpha;
- shadowColor.a = alpha;
-
- for (unsigned int i = 0; i < getFrameSize(); ++i)
- {
- graphics->setColor(shadowColor);
- graphics->drawLine(i, i, width - i, i);
- graphics->drawLine(i, i + 1, i, height - i - 1);
- graphics->setColor(highlightColor);
- graphics->drawLine(width - i, i + 1, width - i, height - i);
- graphics->drawLine(i, height - i, width - i - 1, height - i);
- }
- BLOCK_END("Widget::drawFrame")
- }
-
- void Widget::_setParent(Widget* parent)
- {
- mParent = parent;
- }
-
- void Widget::setWidth(int width)
- {
- Rectangle newDimension = mDimension;
- newDimension.width = width;
-
- setDimension(newDimension);
- }
-
- void Widget::setHeight(int height)
- {
- Rectangle newDimension = mDimension;
- newDimension.height = height;
-
- setDimension(newDimension);
- }
-
- void Widget::setX(int x)
- {
- Rectangle newDimension = mDimension;
- newDimension.x = x;
-
- setDimension(newDimension);
- }
-
- void Widget::setY(int y)
- {
- Rectangle newDimension = mDimension;
- newDimension.y = y;
-
- setDimension(newDimension);
- }
-
- void Widget::setPosition(int x, int y)
- {
- Rectangle newDimension = mDimension;
- newDimension.x = x;
- newDimension.y = y;
-
- setDimension(newDimension);
- }
-
- void Widget::setDimension(const Rectangle& dimension)
- {
- const Rectangle oldDimension = mDimension;
- mDimension = dimension;
-
- if (mDimension.width != oldDimension.width
- || mDimension.height != oldDimension.height)
- {
- distributeResizedEvent();
- }
-
- if (mDimension.x != oldDimension.x
- || mDimension.y != oldDimension.y)
- {
- distributeMovedEvent();
- }
- }
-
- void Widget::setFrameSize(unsigned int frameSize)
- {
- mFrameSize = frameSize;
- }
-
- unsigned int Widget::getFrameSize() const
- {
- return mFrameSize;
- }
-
- const Rectangle& Widget::getDimension() const
- {
- return mDimension;
- }
-
- const std::string& Widget::getActionEventId() const
- {
- return mActionEventId;
- }
-
- void Widget::setActionEventId(const std::string& actionEventId)
- {
- mActionEventId = actionEventId;
- }
-
- bool Widget::isFocused() const
- {
- if (!mFocusHandler)
- return false;
-
- return (mFocusHandler->isFocused(this));
- }
-
- void Widget::setFocusable(bool focusable)
- {
- if (!focusable && isFocused())
- {
- mFocusHandler->focusNone();
- }
-
- mFocusable = focusable;
- }
-
- bool Widget::isFocusable() const
- {
- return mFocusable && isVisible() && isEnabled();
- }
-
- void Widget::requestFocus()
- {
- if (!mFocusHandler)
- {
- throw GCN_EXCEPTION("No focushandler set (did you add "
- "the widget to the gui?).");
- }
-
- if (isFocusable())
- mFocusHandler->requestFocus(this);
- }
-
- void Widget::requestMoveToTop()
- {
- if (mParent)
- mParent->moveToTop(this);
- }
-
- void Widget::requestMoveToBottom()
- {
- if (mParent)
- mParent->moveToBottom(this);
- }
-
- void Widget::setVisible(bool visible)
- {
- if (!visible && isFocused())
- mFocusHandler->focusNone();
-
- if (visible)
- distributeShownEvent();
- else
- distributeHiddenEvent();
-
- mVisible = visible;
- }
-
- void Widget::setBaseColor(const Color& color)
- {
- mBaseColor = color;
- }
-
- const Color& Widget::getBaseColor() const
- {
- return mBaseColor;
- }
-
- void Widget::setForegroundColor(const Color& color)
- {
- mForegroundColor = color;
- }
-
- const Color& Widget::getForegroundColor() const
- {
- return mForegroundColor;
- }
-
- void Widget::setBackgroundColor(const Color& color)
- {
- mBackgroundColor = color;
- }
-
- const Color& Widget::getBackgroundColor() const
- {
- return mBackgroundColor;
- }
-
- void Widget::setSelectionColor(const Color& color)
- {
- mSelectionColor = color;
- }
-
- const Color& Widget::getSelectionColor() const
- {
- return mSelectionColor;
- }
-
- void Widget::_setFocusHandler(FocusHandler* focusHandler)
- {
- if (mFocusHandler)
- {
- releaseModalFocus();
- mFocusHandler->remove(this);
- }
-
- if (focusHandler)
- focusHandler->add(this);
-
- mFocusHandler = focusHandler;
- }
-
- FocusHandler* Widget::_getFocusHandler()
- {
- return mFocusHandler;
- }
-
- void Widget::addActionListener(ActionListener* actionListener)
- {
- mActionListeners.push_back(actionListener);
- }
-
- void Widget::removeActionListener(ActionListener* actionListener)
- {
- mActionListeners.remove(actionListener);
- }
-
- void Widget::addDeathListener(DeathListener* deathListener)
- {
- mDeathListeners.push_back(deathListener);
- }
-
- void Widget::removeDeathListener(DeathListener* deathListener)
- {
- mDeathListeners.remove(deathListener);
- }
-
- void Widget::addKeyListener(KeyListener* keyListener)
- {
- mKeyListeners.push_back(keyListener);
- }
-
- void Widget::removeKeyListener(KeyListener* keyListener)
- {
- mKeyListeners.remove(keyListener);
- }
-
- void Widget::addFocusListener(FocusListener* focusListener)
- {
- mFocusListeners.push_back(focusListener);
- }
-
- void Widget::removeFocusListener(FocusListener* focusListener)
- {
- mFocusListeners.remove(focusListener);
- }
-
- void Widget::addMouseListener(MouseListener* mouseListener)
- {
- mMouseListeners.push_back(mouseListener);
- }
-
- void Widget::removeMouseListener(MouseListener* mouseListener)
- {
- mMouseListeners.remove(mouseListener);
- }
-
- void Widget::addWidgetListener(WidgetListener* widgetListener)
- {
- mWidgetListeners.push_back(widgetListener);
- }
-
- void Widget::removeWidgetListener(WidgetListener* widgetListener)
- {
- mWidgetListeners.remove(widgetListener);
- }
-
- void Widget::getAbsolutePosition(int& x, int& y) const
- {
- if (!mParent)
- {
- x = mDimension.x;
- y = mDimension.y;
- return;
- }
-
- int parentX;
- int parentY;
-
- mParent->getAbsolutePosition(parentX, parentY);
-
- const Rectangle &rect = mParent->getChildrenArea();
- x = parentX + mDimension.x + rect.x;
- y = parentY + mDimension.y + rect.y;
- }
-
- Font* Widget::getFont() const
- {
- if (!mCurrentFont)
- return mGlobalFont;
- return mCurrentFont;
- }
-
- void Widget::setGlobalFont(Font* font)
- {
- mGlobalFont = font;
-
- for (std::list<Widget*>::const_iterator iter = mWidgets.begin();
- iter != mWidgets.end(); ++iter)
- {
- if (!(*iter)->mCurrentFont)
- (*iter)->fontChanged();
- }
- }
-
- void Widget::setFont(Font* font)
- {
- mCurrentFont = font;
- fontChanged();
- }
-
- bool Widget::widgetExists(const Widget* widget)
- {
- return mWidgetsSet.find(const_cast<Widget*>(widget))
- != mWidgetsSet.end();
- }
-
- bool Widget::isTabInEnabled() const
- {
- return mTabIn;
- }
-
- void Widget::setTabInEnabled(bool enabled)
- {
- mTabIn = enabled;
- }
-
- bool Widget::isTabOutEnabled() const
- {
- return mTabOut;
- }
-
- void Widget::setTabOutEnabled(bool enabled)
- {
- mTabOut = enabled;
- }
-
- void Widget::setSize(int width, int height)
- {
- Rectangle newDimension = mDimension;
- newDimension.width = width;
- newDimension.height = height;
-
- setDimension(newDimension);
- }
-
- void Widget::setEnabled(bool enabled)
- {
- mEnabled = enabled;
- }
-
- bool Widget::isEnabled() const
- {
- return mEnabled && isVisible();
- }
-
- void Widget::requestModalFocus()
- {
- if (!mFocusHandler)
- {
- throw GCN_EXCEPTION("No focushandler set (did you add "
- "the widget to the gui?).");
- }
-
- mFocusHandler->requestModalFocus(this);
- }
-
- void Widget::requestModalMouseInputFocus()
- {
- if (!mFocusHandler)
- {
- throw GCN_EXCEPTION("No focushandler set (did you add "
- "the widget to the gui?).");
- }
-
- mFocusHandler->requestModalMouseInputFocus(this);
- }
-
- void Widget::releaseModalFocus()
- {
- if (!mFocusHandler)
- return;
-
- mFocusHandler->releaseModalFocus(this);
- }
-
- void Widget::releaseModalMouseInputFocus()
- {
- if (!mFocusHandler)
- return;
-
- mFocusHandler->releaseModalMouseInputFocus(this);
- }
-
- bool Widget::isModalFocused() const
- {
- if (!mFocusHandler)
- {
- throw GCN_EXCEPTION("No focushandler set (did you add "
- "the widget to the gui?).");
- }
-
- if (mParent)
- {
- return (mFocusHandler->getModalFocused() == this)
- || mParent->isModalFocused();
- }
-
- return mFocusHandler->getModalFocused() == this;
- }
-
- bool Widget::isModalMouseInputFocused() const
- {
- if (!mFocusHandler)
- {
- throw GCN_EXCEPTION("No focushandler set (did you add "
- "the widget to the gui?).");
- }
-
- if (mParent)
- {
- return (mFocusHandler->getModalMouseInputFocused() == this)
- || mParent->isModalMouseInputFocused();
- }
-
- return mFocusHandler->getModalMouseInputFocused() == this;
- }
-
- Widget *Widget::getWidgetAt(int x A_UNUSED, int y A_UNUSED)
- {
- return nullptr;
- }
-
- const std::list<MouseListener*>& Widget::_getMouseListeners()
- {
- return mMouseListeners;
- }
-
- const std::list<KeyListener*>& Widget::_getKeyListeners()
- {
- return mKeyListeners;
- }
-
- const std::list<FocusListener*>& Widget::_getFocusListeners()
- {
- return mFocusListeners;
- }
-
- Rectangle Widget::getChildrenArea()
- {
- return Rectangle(0, 0, 0, 0);
- }
-
- FocusHandler* Widget::_getInternalFocusHandler()
- {
- return mInternalFocusHandler;
- }
-
- void Widget::setInternalFocusHandler(FocusHandler* focusHandler)
- {
- mInternalFocusHandler = focusHandler;
- }
-
- void Widget::setId(const std::string& id)
- {
- mId = id;
- }
-
- const std::string& Widget::getId()
- {
- return mId;
- }
-
- void Widget::distributeResizedEvent()
- {
- for (WidgetListenerIterator iter = mWidgetListeners.begin();
- iter != mWidgetListeners.end();
- ++ iter)
- {
- Event event(this);
- (*iter)->widgetResized(event);
- }
- }
-
- void Widget::distributeMovedEvent()
- {
- for (WidgetListenerIterator iter = mWidgetListeners.begin();
- iter != mWidgetListeners.end();
- ++ iter)
- {
- Event event(this);
- (*iter)->widgetMoved(event);
- }
- }
-
- void Widget::distributeHiddenEvent()
- {
- for (WidgetListenerIterator iter = mWidgetListeners.begin();
- iter != mWidgetListeners.end();
- ++ iter)
- {
- Event event(this);
- (*iter)->widgetHidden(event);
- }
- }
-
- void Widget::distributeActionEvent()
- {
- for (ActionListenerIterator iter = mActionListeners.begin();
- iter != mActionListeners.end();
- ++iter)
- {
- ActionEvent actionEvent(this, mActionEventId);
- (*iter)->action(actionEvent);
- }
- }
-
- void Widget::distributeShownEvent()
- {
- for (WidgetListenerIterator iter = mWidgetListeners.begin();
- iter != mWidgetListeners.end();
- ++iter)
- {
- Event event(this);
- (*iter)->widgetShown(event);
- }
- }
-
- void Widget::showPart(Rectangle rectangle)
- {
- if (mParent)
- mParent->showWidgetPart(this, rectangle);
- }
-} // namespace gcn
diff --git a/src/guichan/widgets/window.cpp b/src/guichan/widgets/window.cpp
deleted file mode 100644
index 8865444e0..000000000
--- a/src/guichan/widgets/window.cpp
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * For comments regarding functions please see the header file.
- */
-
-#include "guichan/widgets/window.hpp"
-
-#include "guichan/exception.hpp"
-#include "guichan/font.hpp"
-#include "guichan/graphics.hpp"
-#include "guichan/mouseinput.hpp"
-
-#include "debug.h"
-
-namespace gcn
-{
- Window::Window() :
- Container(),
- gcn::MouseListener(),
- mCaption(),
- mAlignment(Graphics::CENTER),
- mPadding(2),
- mTitleBarHeight(16),
- mMovable(true),
- mOpaque(true),
- mDragOffsetX(0),
- mDragOffsetY(0),
- mMoved(false)
- {
- mFrameSize = 1;
- addMouseListener(this);
- }
-
- Window::Window(const std::string& caption) :
- Container(),
- gcn::MouseListener(),
- mCaption(caption),
- mAlignment(Graphics::CENTER),
- mPadding(2),
- mTitleBarHeight(16),
- mMovable(true),
- mOpaque(true),
- mDragOffsetX(0),
- mDragOffsetY(0),
- mMoved(false)
- {
- mFrameSize = 1;
- addMouseListener(this);
- }
-
- Window::~Window()
- {
- }
-
- void Window::setPadding(unsigned int padding)
- {
- mPadding = padding;
- }
-
- unsigned int Window::getPadding() const
- {
- return mPadding;
- }
-
- void Window::setTitleBarHeight(unsigned int height)
- {
- mTitleBarHeight = height;
- }
-
- unsigned int Window::getTitleBarHeight()
- {
- return mTitleBarHeight;
- }
-
- void Window::setCaption(const std::string& caption)
- {
- mCaption = caption;
- }
-
- const std::string& Window::getCaption() const
- {
- return mCaption;
- }
-
- void Window::setAlignment(Graphics::Alignment alignment)
- {
- mAlignment = alignment;
- }
-
- Graphics::Alignment Window::getAlignment() const
- {
- return mAlignment;
- }
-
- void Window::mousePressed(MouseEvent& mouseEvent)
- {
- if (mouseEvent.getSource() != this)
- return;
-
- if (getParent())
- getParent()->moveToTop(this);
-
- mDragOffsetX = mouseEvent.getX();
- mDragOffsetY = mouseEvent.getY();
-
- mMoved = mouseEvent.getY() <= static_cast<int>(mTitleBarHeight);
- }
-
- void Window::mouseReleased(MouseEvent& mouseEvent A_UNUSED)
- {
- mMoved = false;
- }
-
- void Window::mouseDragged(MouseEvent& mouseEvent)
- {
- if (mouseEvent.isConsumed() || mouseEvent.getSource() != this)
- return;
-
- if (isMovable() && mMoved)
- {
- setPosition(mouseEvent.getX() - mDragOffsetX + getX(),
- mouseEvent.getY() - mDragOffsetY + getY());
- }
-
- mouseEvent.consume();
- }
-
- Rectangle Window::getChildrenArea()
- {
- return Rectangle(getPadding(),
- getTitleBarHeight(),
- getWidth() - getPadding() * 2,
- getHeight() - getPadding() - getTitleBarHeight());
- }
-
- void Window::setMovable(bool movable)
- {
- mMovable = movable;
- }
-
- bool Window::isMovable() const
- {
- return mMovable;
- }
-
- void Window::setOpaque(bool opaque)
- {
- mOpaque = opaque;
- }
-
- bool Window::isOpaque()
- {
- return mOpaque;
- }
-
- void Window::resizeToContent()
- {
- int w = 0, h = 0;
- for (WidgetListConstIterator it = mWidgets.begin();
- it != mWidgets.end(); ++ it)
- {
- if ((*it)->getX() + (*it)->getWidth() > w)
- w = (*it)->getX() + (*it)->getWidth();
-
- if ((*it)->getY() + (*it)->getHeight() > h)
- h = (*it)->getY() + (*it)->getHeight();
- }
-
- setSize(w + 2* getPadding(), h + getPadding() + getTitleBarHeight());
- }
-} // namespace gcn
diff --git a/src/guild.h b/src/guild.h
index 48b3d17b2..6206271e0 100644
--- a/src/guild.h
+++ b/src/guild.h
@@ -25,7 +25,7 @@
#include "avatar.h"
-#include "gui/widgets/avatarlistbox.h"
+#include "gui/models/avatarlistmodel.h"
#include "utils/dtor.h"
#include "utils/stringvector.h"
diff --git a/src/imagesprite.cpp b/src/imagesprite.cpp
index c40e49856..965c333bf 100644
--- a/src/imagesprite.cpp
+++ b/src/imagesprite.cpp
@@ -56,5 +56,5 @@ void ImageSprite::draw(Graphics *const graphics,
return;
mImage->setAlpha(mAlpha);
- graphics->drawImage2(mImage, posX, posY);
+ graphics->drawImage(mImage, posX, posY);
}
diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp
index cc37001cc..5d157f0fa 100644
--- a/src/input/inputmanager.cpp
+++ b/src/input/inputmanager.cpp
@@ -28,7 +28,6 @@
#include "input/keyboardconfig.h"
#include "input/keyboarddata.h"
#include "being/localplayer.h"
-#include "being/playerinfo.h"
#ifdef USE_SDL2
#include "input/multitouchmanager.h"
#endif
@@ -47,12 +46,10 @@
#include "gui/windows/setupwindow.h"
#include "gui/windows/textdialog.h"
#include "gui/windows/tradewindow.h"
-#include "gui/windows/quitdialog.h"
#include "utils/timer.h"
-#include <guichan/exception.hpp>
-#include <guichan/focushandler.hpp>
+#include "gui/focushandler.h"
#include <algorithm>
@@ -60,6 +57,8 @@
InputManager inputManager;
+class QuitDialog;
+
extern QuitDialog *quitDialog;
static class KeyFunctor final
@@ -549,18 +548,10 @@ bool InputManager::handleEvent(const SDL_Event &event)
if (quitDialog || TextDialog::isActive() ||
NpcPostDialog::isActive())
{
- try
- {
- if (guiInput)
- guiInput->pushInput(event);
- if (gui)
- gui->handleInput();
- }
- catch(const gcn::Exception &e)
- {
- const char *const err = e.getMessage().c_str();
- logger->log("Warning: guichan input exception: %s", err);
- }
+ if (guiInput)
+ guiInput->pushInput(event);
+ if (gui)
+ gui->handleInput();
return true;
}
break;
@@ -605,16 +596,8 @@ bool InputManager::handleEvent(const SDL_Event &event)
break;
}
- try
- {
- if (guiInput)
- guiInput->pushInput(event);
- }
- catch(const gcn::Exception &e)
- {
- const char *const err = e.getMessage().c_str();
- logger->log("Warning: guichan input exception: %s", err);
- }
+ if (guiInput)
+ guiInput->pushInput(event);
if (gui)
{
const bool res = gui->handleInput();
diff --git a/src/input/inputmanager.h b/src/input/inputmanager.h
index 630b52948..fcd1252c0 100644
--- a/src/input/inputmanager.h
+++ b/src/input/inputmanager.h
@@ -21,7 +21,8 @@
#ifndef INPUT_INPUTMANAGER_H
#define INPUT_INPUTMANAGER_H
-#include "input/inputevent.h"
+#include "events/inputevent.h"
+
#include "input/keydata.h"
#include <string>
diff --git a/src/input/joystick.h b/src/input/joystick.h
index 06823ca27..8693d0d75 100644
--- a/src/input/joystick.h
+++ b/src/input/joystick.h
@@ -23,7 +23,7 @@
#ifndef INPUT_JOYSTICK_H
#define INPUT_JOYSTICK_H
-#include "input/inputevent.h"
+#include "events/inputevent.h"
#include <SDL_events.h>
diff --git a/src/guichan/key.cpp b/src/input/key.cpp
index 24d817fdb..13d2a301d 100644
--- a/src/guichan/key.cpp
+++ b/src/input/key.cpp
@@ -65,49 +65,46 @@
* For comments regarding functions please see the header file.
*/
-#include "guichan/key.hpp"
+#include "input/key.h"
#include "debug.h"
-namespace gcn
+Key::Key(const int value) :
+ mValue(value)
{
- Key::Key(const int value) :
- mValue(value)
- {
- }
+}
- bool Key::isCharacter() const
- {
- return (mValue >= 32 && mValue <= 126)
- || (mValue >= 162 && mValue <= 255)
- || (mValue == 9);
- }
+bool Key::isCharacter() const
+{
+ return (mValue >= 32 && mValue <= 126)
+ || (mValue >= 162 && mValue <= 255)
+ || (mValue == 9);
+}
- bool Key::isNumber() const
- {
- return mValue >= 48 && mValue <= 57;
- }
+bool Key::isNumber() const
+{
+ return mValue >= 48 && mValue <= 57;
+}
- bool Key::isLetter() const
- {
- return (((mValue >= 65 && mValue <= 90)
- || (mValue >= 97 && mValue <= 122)
- || (mValue >= 192 && mValue <= 255))
- && (mValue != 215) && (mValue != 247));
- }
+bool Key::isLetter() const
+{
+ return (((mValue >= 65 && mValue <= 90)
+ || (mValue >= 97 && mValue <= 122)
+ || (mValue >= 192 && mValue <= 255))
+ && (mValue != 215) && (mValue != 247));
+}
- int Key::getValue() const
- {
- return mValue;
- }
+int Key::getValue() const
+{
+ return mValue;
+}
- bool Key::operator==(const Key& key) const
- {
- return mValue == key.mValue;
- }
+bool Key::operator==(const Key& key) const
+{
+ return mValue == key.mValue;
+}
- bool Key::operator!=(const Key& key) const
- {
- return (mValue != key.mValue);
- }
-} // namespace gcn
+bool Key::operator!=(const Key& key) const
+{
+ return (mValue != key.mValue);
+}
diff --git a/src/guichan/include/guichan/key.hpp b/src/input/key.h
index 46b36a179..97bc7113d 100644
--- a/src/guichan/include/guichan/key.hpp
+++ b/src/input/key.h
@@ -61,8 +61,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef GCN_KEY_HPP
-#define GCN_KEY_HPP
+#ifndef INPUT_KEY_H
+#define INPUT_KEY_H
#include "localconsts.h"
@@ -73,78 +73,26 @@
#undef DELETE
#endif
-namespace gcn
+/**
+ * Represents a key or a character.
+ */
+class Key final
{
- /**
- * Represents a key or a character.
- */
- class Key final
- {
public:
/**
- * Constructor.
- *
- * @param value The ascii or enum value for the key.
- */
+ * Constructor.
+ *
+ * @param value The ascii or enum value for the key.
+ */
explicit Key(const int value = 0);
- /**
- * Checks if a key is a character.
- *
- * @return True if the key is a letter, number or whitespace,
- * false otherwise.
- */
- bool isCharacter() const A_WARN_UNUSED;
-
- /**
- * Checks if a key is a number.
- *
- * @return True if the key is a number (0-9),
- * false otherwise.
- */
- bool isNumber() const A_WARN_UNUSED;
-
- /**
- * Checks if a key is a letter.
- *
- * @return True if the key is a letter (a-z,A-Z),
- * false otherwise.
- */
- bool isLetter() const A_WARN_UNUSED;
-
- /**
- * Gets the value of the key. If an ascii value exists it
- * will be returned. Otherwise an enum value will be returned.
- *
- * @return the value of the key.
- */
- int getValue() const A_WARN_UNUSED;
-
- /**
- * Compares two keys.
- *
- * @param key The key to compare this key with.
- * @return True if the keys are equal, false otherwise.
- */
- bool operator==(const Key& key) const;
-
- /**
- * Compares two keys.
- *
- * @param key The key to compare this key with.
- * @return True if the keys are not equal, false otherwise.
- */
- bool operator!=(const Key& key) const;
-
- /**
- * An enum with key values.
- */
enum
{
SPACE = ' ',
TAB = '\t',
ENTER = '\n',
- LEFT_ALT = 1000,
+ // Negative values, to avoid conflicts with higher character codes.
+ LEFT_ALT = -1000,
RIGHT_ALT,
LEFT_SHIFT,
RIGHT_SHIFT,
@@ -157,7 +105,7 @@ namespace gcn
INSERT,
HOME,
PAGE_UP,
- DELETE,
+ DELETE_,
END,
PAGE_DOWN,
ESCAPE,
@@ -186,16 +134,64 @@ namespace gcn
LEFT,
RIGHT,
UP,
- DOWN
+ DOWN,
+ TEXTINPUT
};
+ /**
+ * Checks if a key is a character.
+ *
+ * @return True if the key is a letter, number or whitespace,
+ * false otherwise.
+ */
+ bool isCharacter() const A_WARN_UNUSED;
+
+ /**
+ * Checks if a key is a number.
+ *
+ * @return True if the key is a number (0-9),
+ * false otherwise.
+ */
+ bool isNumber() const A_WARN_UNUSED;
+
+ /**
+ * Checks if a key is a letter.
+ *
+ * @return True if the key is a letter (a-z,A-Z),
+ * false otherwise.
+ */
+ bool isLetter() const A_WARN_UNUSED;
+
+ /**
+ * Gets the value of the key. If an ascii value exists it
+ * will be returned. Otherwise an enum value will be returned.
+ *
+ * @return the value of the key.
+ */
+ int getValue() const A_WARN_UNUSED;
+
+ /**
+ * Compares two keys.
+ *
+ * @param key The key to compare this key with.
+ * @return True if the keys are equal, false otherwise.
+ */
+ bool operator==(const Key& key) const;
+
+ /**
+ * Compares two keys.
+ *
+ * @param key The key to compare this key with.
+ * @return True if the keys are not equal, false otherwise.
+ */
+ bool operator!=(const Key& key) const;
+
protected:
/**
- * Holds the value of the key. It may be an ascii value
- * or an enum value.
- */
+ * Holds the value of the key. It may be an ascii value
+ * or an enum value.
+ */
int mValue;
- };
-} // namespace gcn
+};
-#endif // end GCN_KEY_HPP
+#endif // INPUT_KEY_H
diff --git a/src/input/keyboardconfig.h b/src/input/keyboardconfig.h
index 7f7102964..425a0c70c 100644
--- a/src/input/keyboardconfig.h
+++ b/src/input/keyboardconfig.h
@@ -27,7 +27,7 @@
#include "sdlshared.h"
-#include "input/inputevent.h"
+#include "events/inputevent.h"
#include <string>
diff --git a/src/input/keydata.h b/src/input/keydata.h
index 2ceb957c5..62517b64b 100644
--- a/src/input/keydata.h
+++ b/src/input/keydata.h
@@ -23,7 +23,7 @@
#ifndef INPUT_KEYDATA_H
#define INPUT_KEYDATA_H
-#include "input/inputevent.h"
+#include "events/inputevent.h"
#include <string>
diff --git a/src/input/keyevent.h b/src/input/keyevent.h
deleted file mode 100644
index e0b2e8e17..000000000
--- a/src/input/keyevent.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 INPUT_KEYEVENT_H
-#define INPUT_KEYEVENT_H
-
-#include <guichan/key.hpp>
-#include <guichan/keyevent.hpp>
-
-#include <string>
-
-#include "localconsts.h"
-
-class KeyEvent final : public gcn::KeyEvent
-{
- public:
- KeyEvent(gcn::Widget *const source,
- const bool shiftPressed,
- const bool controlPressed,
- const bool altPressed,
- const bool metaPressed,
- const unsigned int type,
- const bool numericPad,
- const int actionId,
- const gcn::Key& key);
-
- A_DELETE_COPY(KeyEvent)
-
- ~KeyEvent();
-
- int getActionId() const A_WARN_UNUSED
- { return mActionId; }
-
-#ifdef USE_SDL2
- void setText(const std::string &text)
- { mText = text; }
-
- std::string getText() const
- { return mText; }
-#endif
-
- protected:
- int mActionId;
-#ifdef USE_SDL2
- std::string mText;
-#endif
-};
-
-#endif // INPUT_KEYEVENT_H
diff --git a/src/input/keyinput.h b/src/input/keyinput.h
index 25deeae19..9920cfa17 100644
--- a/src/input/keyinput.h
+++ b/src/input/keyinput.h
@@ -18,41 +18,226 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#ifndef INPUT_KEYINPUT_H
#define INPUT_KEYINPUT_H
-#include <guichan/keyinput.hpp>
+#include "input/key.h"
#include <string>
#include "localconsts.h"
-class KeyInput final : public gcn::KeyInput
+class KeyInput final
{
public:
- KeyInput();
+ KeyInput() :
+ mKey(0),
+ mType(0),
+#ifdef USE_SDL2
+ mText(),
+#endif
+ mActionId(-2),
+ mShiftPressed(false),
+ mControlPressed(false),
+ mAltPressed(false),
+ mMetaPressed(false),
+ mNumericPad(false)
+ { }
+
+ ~KeyInput()
+ { }
+
+ /**
+ * Key input types. This enum corresponds to the enum with event
+ * types on KeyEvent for easy mapping.
+ */
+ enum
+ {
+ PRESSED = 0,
+ RELEASED
+ };
+
+ void setType(unsigned int type)
+ {
+ mType = type;
+ }
+
+ int getType() const
+ {
+ return mType;
+ }
+
+ void setKey(const Key& key)
+ {
+ mKey = key;
+ }
+
+ const Key& getKey() const
+ {
+ return mKey;
+ }
+
+ bool isShiftPressed() const
+ {
+ return mShiftPressed;
+ }
+
+ void setShiftPressed(bool pressed)
+ {
+ mShiftPressed = pressed;
+ }
- ~KeyInput();
+ bool isControlPressed() const
+ {
+ return mControlPressed;
+ }
+
+ void setControlPressed(bool pressed)
+ {
+ mControlPressed = pressed;
+ }
+
+ bool isAltPressed() const
+ {
+ return mAltPressed;
+ }
+
+ void setAltPressed(bool pressed)
+ {
+ mAltPressed = pressed;
+ }
+
+ bool isMetaPressed() const
+ {
+ return mMetaPressed;
+ }
+
+ void setMetaPressed(bool pressed)
+ {
+ mMetaPressed = pressed;
+ }
+
+ bool isNumericPad() const
+ {
+ return mNumericPad;
+ }
+
+ void setNumericPad(bool numpad)
+ {
+ mNumericPad = numpad;
+ }
void setActionId(const int n)
- { mActionId = n; }
+ {
+ mActionId = n;
+ }
int getActionId() const A_WARN_UNUSED
- { return mActionId; }
+ {
+ return mActionId;
+ }
#ifdef USE_SDL2
void setText(const std::string &text)
- { mText = text; }
+ {
+ mText = text;
+ }
std::string getText() const
- { return mText; }
+ {
+ return mText;
+ }
#endif
protected:
- int mActionId;
+ /**
+ * Holds the key of the key input.
+ */
+ Key mKey;
+
+ /**
+ * Holds the type of the key input.
+ */
+ unsigned int mType;
+
#ifdef USE_SDL2
std::string mText;
#endif
+
+ int mActionId;
+
+ /**
+ * True if shift was pressed at the same time as the key,
+ * false otherwise.
+ */
+ bool mShiftPressed;
+
+ /**
+ * True if control was pressed at the same time as the key,
+ * false otherwise.
+ */
+ bool mControlPressed;
+
+ /**
+ * True if alt was pressed at the same time as the key,
+ * false otherwise.
+ */
+ bool mAltPressed;
+
+ /**
+ * True if meta was pressed at the same time as the key,
+ * false otherwise.
+ */
+ bool mMetaPressed;
+
+ /**
+ * True if the numeric pad was used when the key was pressed,
+ * false otherwise.
+ */
+ bool mNumericPad;
};
#endif // INPUT_KEYINPUT_H
diff --git a/src/guichan/include/guichan/image.hpp b/src/input/mouseinput.h
index c39fe21ab..a90a1366d 100644
--- a/src/guichan/include/guichan/image.hpp
+++ b/src/input/mouseinput.h
@@ -1,6 +1,6 @@
/*
* The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
+ * Copyright (C) 2012-2014 The ManaPlus Developers
*
* This file is part of The ManaPlus Client.
*
@@ -61,102 +61,156 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef GCN_IMAGE_HPP
-#define GCN_IMAGE_HPP
+#ifndef INPUT_MOUSEINPUT_H
+#define INPUT_MOUSEINPUT_H
-#include <string>
+#include "input/mouseinput.h"
#include "localconsts.h"
-namespace gcn
+class MouseInput final
{
- class Color;
-
- /**
- * Holds an image. To be able to use this class you must first set an
- * ImageLoader in Image by calling
- * @code Image::setImageLoader(myImageLoader) @endcode
- * The function is static. If this is not done, the constructor taking a
- * filename will throw an exception. The ImageLoader you use must be
- * compatible with the Graphics object you use.
- *
- * EXAMPLE: If you use SDLGraphics you should use SDLImageLoader.
- * Otherwise your program might crash in a most bizarre way.
- * @see AllegroImageLoader, HGEImageLoader, OpenLayerImageLoader,
- * OpenGLAllegroImageLoader, OpenGLSDLImageLoader, SDLImageLoader
- * @since 0.1.0
- */
- class Image
- {
public:
- /**
- * Constructor.
- */
- Image();
+ MouseInput() :
+ mType(0),
+ mButton(0),
+ mTimeStamp(0),
+ mX(0),
+ mY(0),
+ mRealX(0),
+ mRealY(0)
+ { }
+
+ ~MouseInput()
+ { }
/**
- * Destructor.
+ * Mouse input event types. This enum partially corresponds
+ * to the enum with event types in MouseEvent for easy mapping.
*/
- virtual ~Image();
+ enum
+ {
+ MOVED = 0,
+ PRESSED,
+ RELEASED,
+ WHEEL_MOVED_DOWN,
+ WHEEL_MOVED_UP
+ };
/**
- * Frees an image.
- *
- * @since 0.5.0
+ * Mouse button types.
*/
- virtual void free() = 0;
+ enum
+ {
+ EMPTY = 0,
+ LEFT,
+ RIGHT,
+ MIDDLE
+ };
+
+ void setType(unsigned int type)
+ {
+ mType = type;
+ }
+
+ unsigned int getType() const
+ {
+ return mType;
+ }
+
+ void setButton(unsigned int button)
+ {
+ mButton = button;
+ }
+
+ unsigned int getButton() const
+ {
+ return mButton;
+ }
+
+ int getTimeStamp() const
+ {
+ return mTimeStamp;
+ }
+
+ void setTimeStamp(int timeStamp)
+ {
+ mTimeStamp = timeStamp;
+ }
+
+ void setX(int x)
+ {
+ mX = x;
+ }
+
+ int getX() const
+ {
+ return mX;
+ }
+
+ void setY(int y)
+ {
+ mY = y;
+ }
+ int getY() const
+ {
+ return mY;
+ }
+
+ void setReal(const int x, const int y)
+ { mRealX = x; mRealY = y; }
+
+ int getRealX() const A_WARN_UNUSED
+ { return mRealX; }
+
+ int getRealY() const A_WARN_UNUSED
+ { return mRealY; }
+
+#ifdef ANDROID
+ int getTouchX() const A_WARN_UNUSED
+ { return mRealX; }
+
+ int getTouchY() const A_WARN_UNUSED
+ { return mRealY; }
+#else
+ int getTouchX() const A_WARN_UNUSED
+ { return mX; }
+
+ int getTouchY() const A_WARN_UNUSED
+ { return mY; }
+#endif
+
+ protected:
/**
- * Gets the width of the image.
- *
- * @return The width of the image.
- *
- * @since 0.1.0
+ * Holds the type of the mouse input.
*/
- virtual int getWidth() const A_WARN_UNUSED = 0;
+ unsigned int mType;
/**
- * Gets the height of the image.
- *
- * @return The height of the image.
- *
- * @since 0.1.0
+ * Holds the button of the mouse input.
*/
- virtual int getHeight() const A_WARN_UNUSED = 0;
+ unsigned int mButton;
- /**
- * Gets the color of a pixel at coordinate (x, y) in the image.
- *
- * IMPORTANT: Only guaranteed to work before the image has been
- * converted to display format.
- *
- * @param x The x coordinate.
- * @param y The y coordinate.
- * @return The color of the pixel.
- *
- * @since 0.5.0
+ /**
+ * Holds the timestamp of the mouse input. Used to
+ * check for double clicks.
*/
- virtual Color getPixel(int x, int y) A_WARN_UNUSED = 0;
+ int mTimeStamp;
- /**
- * Puts a pixel with a certain color at coordinate (x, y).
- *
- * @param x The x coordinate.
- * @param y The y coordinate.
- * @param color The color of the pixel to put.
- * @since 0.5.0
+ /**
+ * Holds the x coordinate of the mouse input.
*/
- virtual void putPixel(int x, int y, const Color& color) = 0;
+ int mX;
- /**
- * Converts the image, if possible, to display format.
- *
- * IMPORTANT: Only guaranteed to work before the image has been
- * converted to display format.
- * @since 0.5.0
+ /**
+ * Holds the y coordinate of the mouse input.
*/
- virtual void convertToDisplayFormat() = 0;
- };
-} // namespace gcn
+ int mY;
+
+ int mRealX;
+
+ int mRealY;
+};
-#endif // end GCN_IMAGE_HPP
+#endif // INPUT_MOUSEINPUT_H
diff --git a/src/input/multitouchmanager.cpp b/src/input/multitouchmanager.cpp
index 7e6798807..446e40aa1 100644
--- a/src/input/multitouchmanager.cpp
+++ b/src/input/multitouchmanager.cpp
@@ -82,7 +82,7 @@ void MultiTouchManager::checkDevice(const int touchId,
const int w = mainGraphics->mWidth;
const int h = mainGraphics->mHeight;
guiInput->simulateMouseClick(finger0.x * w, finger0.y * h,
- gcn::MouseInput::RIGHT);
+ MouseInput::RIGHT);
}
}
}
diff --git a/src/input/multitouchmanager.h b/src/input/multitouchmanager.h
index 076ccb3a8..82bfd0881 100644
--- a/src/input/multitouchmanager.h
+++ b/src/input/multitouchmanager.h
@@ -25,7 +25,9 @@
#include "localconsts.h"
+#ifdef USE_SDL2
union SDL_Event;
+#endif
struct MultiTouchEvent
{
diff --git a/src/guichan/include/guichan/actionlistener.hpp b/src/listeners/actionlistener.h
index 0f017873b..895cc985d 100644
--- a/src/guichan/include/guichan/actionlistener.hpp
+++ b/src/listeners/actionlistener.h
@@ -61,52 +61,49 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef GCN_ACTIONLISTENER_HPP
-#define GCN_ACTIONLISTENER_HPP
+#ifndef LISTENERS_ACTIONLISTENER_H
+#define LISTENERS_ACTIONLISTENER_H
#include <string>
-#include "guichan/actionevent.hpp"
+#include "events/actionevent.h"
-namespace gcn
+/**
+ * Interface for listening for action events from widgets.
+ *
+ * @see Widget::addActionListener, Widget::removeActionListener,
+ * ActionEvent
+ * @author Olof Naessén
+ * @author Per Larsson
+ */
+class ActionListener
{
- /**
- * Interface for listening for action events from widgets.
- *
- * @see Widget::addActionListener, Widget::removeActionListener,
- * ActionEvent
- * @author Olof Naessén
- * @author Per Larsson
- */
- class ActionListener
- {
public:
/**
- * Destructor.
- */
+ * Destructor.
+ */
virtual ~ActionListener()
{ }
/**
- * Called when an action is recieved from a widget. It is used
- * to be able to recieve a notification that an action has
- * occured.
- *
- * @param actionEvent The event of the action.
- * @since 0.6.0
- */
- virtual void action(const ActionEvent& actionEvent) = 0;
+ * Called when an action is recieved from a widget. It is used
+ * to be able to recieve a notification that an action has
+ * occured.
+ *
+ * @param actionEvent The event of the action.
+ * @since 0.6.0
+ */
+ virtual void action(const ActionEvent &actionEvent) = 0;
protected:
/**
- * Constructor.
- *
- * You should not be able to make an instance of ActionListener,
- * therefore its constructor is protected.
- */
+ * Constructor.
+ *
+ * You should not be able to make an instance of ActionListener,
+ * therefore its constructor is protected.
+ */
ActionListener()
{ }
- };
-} // namespace gcn
+};
-#endif // end GCN_ACTIONLISTENER_HPP
+#endif // LISTENERS_ACTIONLISTENER_H
diff --git a/src/being/actorspritelistener.h b/src/listeners/actorspritelistener.h
index c89495c85..7b4d89b44 100644
--- a/src/being/actorspritelistener.h
+++ b/src/listeners/actorspritelistener.h
@@ -19,8 +19,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef BEING_ACTORSPRITELISTENER_H
-#define BEING_ACTORSPRITELISTENER_H
+#ifndef LISTENERS_ACTORSPRITELISTENER_H
+#define LISTENERS_ACTORSPRITELISTENER_H
class ActorSprite;
@@ -41,4 +41,4 @@ class ActorSpriteListener
virtual void actorSpriteDestroyed(const ActorSprite &actorSprite) = 0;
};
-#endif // BEING_ACTORSPRITELISTENER_H
+#endif // LISTENERS_ACTORSPRITELISTENER_H
diff --git a/src/configlistener.h b/src/listeners/configlistener.h
index 3de898692..757d24bfc 100644
--- a/src/configlistener.h
+++ b/src/listeners/configlistener.h
@@ -20,8 +20,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef CONFIGLISTENER_H
-#define CONFIGLISTENER_H
+#ifndef LISTENERS_CONFIGLISTENER_H
+#define LISTENERS_CONFIGLISTENER_H
#include <string>
@@ -47,4 +47,4 @@ class ConfigListener
virtual void optionChanged(const std::string &name) = 0;
};
-#endif // CONFIGLISTENER_H
+#endif // LISTENERS_CONFIGLISTENER_H
diff --git a/src/guichan/include/guichan/deathlistener.hpp b/src/listeners/deathlistener.h
index cc8d11990..ddd7db910 100644
--- a/src/guichan/include/guichan/deathlistener.hpp
+++ b/src/listeners/deathlistener.h
@@ -61,49 +61,46 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef GCN_DEATHLISTENER_HPP
-#define GCN_DEATHLISTENER_HPP
+#ifndef LISTENERS_DEATHLISTENER_H
+#define LISTENERS_DEATHLISTENER_H
#include <string>
-#include "guichan/event.hpp"
+#include "events/event.h"
-namespace gcn
+/**
+ * Interface for listening for death events from widgets.
+ *
+ * @see Widget::addDeathListener, Widget::removeDeathListener
+ * @author Olof Naessén
+ * @since 0.6.0
+ */
+class DeathListener
{
- /**
- * Interface for listening for death events from widgets.
- *
- * @see Widget::addDeathListener, Widget::removeDeathListener
- * @author Olof Naessén
- * @since 0.6.0
- */
- class DeathListener
- {
public:
/**
- * Destructor.
- */
+ * Destructor.
+ */
virtual ~DeathListener()
{ }
/**
- * Called when a widget dies. It is used to be able to recieve
- * a notification when a death of a widget occurs.
- *
- * @param event The event of the death.
- */
- virtual void death(const Event& event) = 0;
+ * Called when a widget dies. It is used to be able to recieve
+ * a notification when a death of a widget occurs.
+ *
+ * @param event The event of the death.
+ */
+ virtual void death(const Event &event) = 0;
protected:
/**
- * Constructor.
- *
- * You should not be able to make an instance of DeathListener,
- * therefore its constructor is protected.
- */
+ * Constructor.
+ *
+ * You should not be able to make an instance of DeathListener,
+ * therefore its constructor is protected.
+ */
DeathListener()
{ }
- };
-} // namespace gcn
+};
-#endif // end GCN_DEATHLISTENER_HPP
+#endif // LISTENERS_DEATHLISTENER_H
diff --git a/src/depricatedlistener.cpp b/src/listeners/depricatedlistener.cpp
index 0cd473852..c853c028d 100644
--- a/src/depricatedlistener.cpp
+++ b/src/listeners/depricatedlistener.cpp
@@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "depricatedlistener.h"
+#include "listeners/depricatedlistener.h"
#include "debug.h"
diff --git a/src/depricatedlistener.h b/src/listeners/depricatedlistener.h
index 52596b70f..175eec74a 100644
--- a/src/depricatedlistener.h
+++ b/src/listeners/depricatedlistener.h
@@ -19,8 +19,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DEPRICATEDLISTENER_H
-#define DEPRICATEDLISTENER_H
+#ifndef LISTENERS_DEPRICATEDLISTENER_H
+#define LISTENERS_DEPRICATEDLISTENER_H
#include "depricatedevent.h"
@@ -37,4 +37,4 @@ class DepricatedListener
const DepricatedEvent &event) = 0;
};
-#endif // DEPRICATEDLISTENER_H
+#endif // LISTENERS_DEPRICATEDLISTENER_H
diff --git a/src/guichan/include/guichan/focuslistener.hpp b/src/listeners/focuslistener.h
index 6b3de5c83..10e4a2af0 100644
--- a/src/guichan/include/guichan/focuslistener.hpp
+++ b/src/listeners/focuslistener.h
@@ -61,59 +61,56 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef GCN_FOCUSLISTENER_HPP
-#define GCN_FOCUSLISTENER_HPP
+#ifndef LISTENERS_FOCUSLISTENER_H
+#define LISTENERS_FOCUSLISTENER_H
#include <string>
-#include "guichan/event.hpp"
+#include "events/event.h"
#include "localconsts.h"
-namespace gcn
+/**
+ * Interface for listening for focus events from widgets.
+ *
+ * @see Widget::addFocusListener, Widget::removeFocusListener
+ * @author Olof Naessén
+ * @since 0.7.0
+ */
+class FocusListener
{
- /**
- * Interface for listening for focus events from widgets.
- *
- * @see Widget::addFocusListener, Widget::removeFocusListener
- * @author Olof Naessén
- * @since 0.7.0
- */
- class FocusListener
- {
public:
/**
- * Destructor.
- */
+ * Destructor.
+ */
virtual ~FocusListener()
{ }
/**
- * Called when a widget gains focus.
- *
- * @param event Discribes the event.
- */
- virtual void focusGained(const Event& event A_UNUSED)
+ * Called when a widget gains focus.
+ *
+ * @param event Discribes the event.
+ */
+ virtual void focusGained(const Event &event A_UNUSED)
{ }
/**
- * Called when a widget loses focus.
- *
- * @param event Discribes the event.
- */
- virtual void focusLost(const Event& event A_UNUSED)
+ * Called when a widget loses focus.
+ *
+ * @param event Discribes the event.
+ */
+ virtual void focusLost(const Event &event A_UNUSED)
{ }
protected:
/**
- * Constructor.
- *
- * You should not be able to make an instance of FocusListener,
- * therefore its constructor is protected.
- */
+ * Constructor.
+ *
+ * You should not be able to make an instance of FocusListener,
+ * therefore its constructor is protected.
+ */
FocusListener()
{ }
- };
-} // namespace gcn
+};
-#endif // end GCN_FOCUSLISTENER_HPP
+#endif // LISTENERS_FOCUSLISTENER_H
diff --git a/src/guichan/include/guichan/keylistener.hpp b/src/listeners/keylistener.h
index bb676052d..efc387300 100644
--- a/src/guichan/include/guichan/keylistener.hpp
+++ b/src/listeners/keylistener.h
@@ -61,59 +61,56 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef GCN_KEYLISTENER_HPP
-#define GCN_KEYLISTENER_HPP
+#ifndef LISTENERS_KEYLISTENER_H
+#define LISTENERS_KEYLISTENER_H
-#include "guichan/keyevent.hpp"
+#include "events/keyevent.h"
#include "localconsts.h"
-namespace gcn
-{
- class Key;
+class Key;
- /**
- * Interface for listening for key events from widgets.
- *
- * @see Widget::addKeyListener, Widget::removeKeyListener
- */
- class KeyListener
- {
+/**
+ * Interface for listening for key events from widgets.
+ *
+ * @see Widget::addKeyListener, Widget::removeKeyListener
+ */
+class KeyListener
+{
public:
/**
- * Destructor.
- */
+ * Destructor.
+ */
virtual ~KeyListener()
{ }
/**
- * Called if a key is pressed when the widget has keyboard focus.
- * If a key is held down the widget will generate multiple key
- * presses.
- *
- * @param keyEvent Discribes the event.
- */
- virtual void keyPressed(KeyEvent& keyEvent A_UNUSED)
+ * Called if a key is pressed when the widget has keyboard focus.
+ * If a key is held down the widget will generate multiple key
+ * presses.
+ *
+ * @param keyEvent Discribes the event.
+ */
+ virtual void keyPressed(KeyEvent &keyEvent A_UNUSED)
{ }
/**
- * Called if a key is released when the widget has keyboard focus.
- *
- * @param keyEvent Discribes the event.
- */
- virtual void keyReleased(KeyEvent& keyEvent A_UNUSED)
+ * Called if a key is released when the widget has keyboard focus.
+ *
+ * @param keyEvent Discribes the event.
+ */
+ virtual void keyReleased(KeyEvent &keyEvent A_UNUSED)
{ }
protected:
/**
- * Constructor.
- *
- * You should not be able to make an instance of KeyListener,
- * therefore its constructor is protected.
- */
+ * Constructor.
+ *
+ * You should not be able to make an instance of KeyListener,
+ * therefore its constructor is protected.
+ */
KeyListener()
{ }
- };
-} // namespace gcn
+};
-#endif // end GCN_KEYLISTENER_HPP
+#endif // LISTENERS_KEYLISTENER_H
diff --git a/src/guichan/include/guichan/mouselistener.hpp b/src/listeners/mouselistener.h
index a024d202f..9a2a4ef04 100644
--- a/src/guichan/include/guichan/mouselistener.hpp
+++ b/src/listeners/mouselistener.h
@@ -61,136 +61,133 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef GCN_MOUSELISTENER_HPP
-#define GCN_MOUSELISTENER_HPP
+#ifndef LISTENERS_MOUSELISTENER_H
+#define LISTENERS_MOUSELISTENER_H
-#include "guichan/mouseevent.hpp"
+#include "events/mouseevent.h"
#include "localconsts.h"
-namespace gcn
+/**
+ * Interface for listening for mouse events from widgets.
+ *
+ * @see Widget::addMouseListener, Widget::removeMouseListener
+ * @since 0.1.0
+ */
+class MouseListener
{
- /**
- * Interface for listening for mouse events from widgets.
- *
- * @see Widget::addMouseListener, Widget::removeMouseListener
- * @since 0.1.0
- */
- class MouseListener
- {
public:
/**
- * Destructor.
- */
+ * Destructor.
+ */
virtual ~MouseListener()
{ }
/**
- * Called when the mouse has entered into the widget area.
- *
- * @param mouseEvent Describes the event.
- * @since 0.6.0
- */
- virtual void mouseEntered(MouseEvent& mouseEvent A_UNUSED)
+ * Called when the mouse has entered into the widget area.
+ *
+ * @param mouseEvent Describes the event.
+ * @since 0.6.0
+ */
+ virtual void mouseEntered(MouseEvent &mouseEvent A_UNUSED)
{
}
/**
- * Called when the mouse has exited the widget area.
- *
- * @param mouseEvent Describes the event.
- * @since 0.6.0
- */
- virtual void mouseExited(MouseEvent& mouseEvent A_UNUSED)
+ * Called when the mouse has exited the widget area.
+ *
+ * @param mouseEvent Describes the event.
+ * @since 0.6.0
+ */
+ virtual void mouseExited(MouseEvent &mouseEvent A_UNUSED)
{
}
/**
- * Called when a mouse button has been pressed on the widget area.
- *
- * NOTE: A mouse press is NOT equal to a mouse click.
- * Use mouseClickMessage to check for mouse clicks.
- *
- * @param mouseEvent Describes the event.
- * @since 0.6.0
- */
- virtual void mousePressed(MouseEvent& mouseEvent A_UNUSED)
+ * Called when a mouse button has been pressed on the widget area.
+ *
+ * NOTE: A mouse press is NOT equal to a mouse click.
+ * Use mouseClickMessage to check for mouse clicks.
+ *
+ * @param mouseEvent Describes the event.
+ * @since 0.6.0
+ */
+ virtual void mousePressed(MouseEvent &mouseEvent A_UNUSED)
{
}
/**
- * Called when a mouse button has been released on the widget area.
- *
- * @param mouseEvent Describes the event.
- * @since 0.6.0
- */
- virtual void mouseReleased(MouseEvent& mouseEvent A_UNUSED)
+ * Called when a mouse button has been released on the widget area.
+ *
+ * @param mouseEvent Describes the event.
+ * @since 0.6.0
+ */
+ virtual void mouseReleased(MouseEvent &mouseEvent A_UNUSED)
{
}
/**
- * Called when a mouse button is pressed and released (clicked) on
- * the widget area.
- *
- * @param mouseEvent Describes the event.
- * @since 0.6.0
- */
- virtual void mouseClicked(MouseEvent& mouseEvent A_UNUSED)
+ * Called when a mouse button is pressed and released (clicked) on
+ * the widget area.
+ *
+ * @param mouseEvent Describes the event.
+ * @since 0.6.0
+ */
+ virtual void mouseClicked(MouseEvent &mouseEvent A_UNUSED)
{
}
/**
- * Called when the mouse wheel has moved up on the widget area.
- *
- * @param mouseEvent Describes the event.
- * @since 0.6.0
- */
- virtual void mouseWheelMovedUp(MouseEvent& mouseEvent A_UNUSED)
+ * Called when the mouse wheel has moved up on the widget area.
+ *
+ * @param mouseEvent Describes the event.
+ * @since 0.6.0
+ */
+ virtual void mouseWheelMovedUp(MouseEvent &mouseEvent A_UNUSED)
{
}
/**
- * Called when the mouse wheel has moved down on the widget area.
- *
- * @param mousEvent Describes the event.
- * @since 0.6.0
- */
- virtual void mouseWheelMovedDown(MouseEvent& mouseEvent A_UNUSED)
+ * Called when the mouse wheel has moved down on the widget area.
+ *
+ * @param mousEvent Describes the event.
+ * @since 0.6.0
+ */
+ virtual void mouseWheelMovedDown(MouseEvent &mouseEvent A_UNUSED)
{
}
/**
- * Called when the mouse has moved in the widget area and no mouse button
- * has been pressed (i.e no widget is being dragged).
- *
- * @param mouseEvent Describes the event.
- * @since 0.6.0
- */
- virtual void mouseMoved(MouseEvent& mouseEvent A_UNUSED)
+ * Called when the mouse has moved in the widget area and no mouse button
+ * has been pressed (i.e no widget is being dragged).
+ *
+ * @param mouseEvent Describes the event.
+ * @since 0.6.0
+ */
+ virtual void mouseMoved(MouseEvent &mouseEvent A_UNUSED)
{
}
/**
- * Called when the mouse has moved and the mouse has previously been
- * pressed on the widget.
- *
- * @param mouseEvent Describes the event.
- * @since 0.6.0
- */
- virtual void mouseDragged(MouseEvent& mouseEvent A_UNUSED)
+ * Called when the mouse has moved and the mouse has previously been
+ * pressed on the widget.
+ *
+ * @param mouseEvent Describes the event.
+ * @since 0.6.0
+ */
+ virtual void mouseDragged(MouseEvent &mouseEvent A_UNUSED)
{
}
protected:
/**
- * Constructor.
- *
- * You should not be able to make an instance of MouseListener,
- * therefore its constructor is protected.
- */
+ * Constructor.
+ *
+ * You should not be able to make an instance of MouseListener,
+ * therefore its constructor is protected.
+ */
MouseListener()
{ }
- };
-} // namespace gcn
+};
-#endif // end GCN_MOUSELISTENER_HPP
+#endif // LISTENERS_MOUSELISTENER_H
diff --git a/src/being/playerrelationslistener.h b/src/listeners/playerrelationslistener.h
index 983f731e4..6a8bf3b20 100644
--- a/src/being/playerrelationslistener.h
+++ b/src/listeners/playerrelationslistener.h
@@ -20,8 +20,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef BEING_PLAYERRELATIONSLISTENER_H
-#define BEING_PLAYERRELATIONSLISTENER_H
+#ifndef LISTENERS_PLAYERRELATIONSLISTENER_H
+#define LISTENERS_PLAYERRELATIONSLISTENER_H
#include <string>
@@ -40,4 +40,4 @@ class PlayerRelationsListener
{ }
};
-#endif // BEING_PLAYERRELATIONSLISTENER_H
+#endif // LISTENERS_PLAYERRELATIONSLISTENER_H
diff --git a/src/guichan/include/guichan/selectionlistener.hpp b/src/listeners/selectionlistener.h
index 0d7f63bd8..2efe0a67e 100644
--- a/src/guichan/include/guichan/selectionlistener.hpp
+++ b/src/listeners/selectionlistener.h
@@ -61,57 +61,54 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef GCN_SELECTIONLISTENER_HPP
-#define GCN_SELECTIONLISTENER_HPP
+#ifndef LISTENERS_SELECTIONLISTENER_H
+#define LISTENERS_SELECTIONLISTENER_H
#include <string>
-#include "guichan/selectionevent.hpp"
+#include "events/selectionevent.h"
#include "localconsts.h"
-namespace gcn
+/**
+ * Interface for listening for selection events from widgets.
+ *
+ * @see ListBox::addSelectionListener,
+ * ListBox::removeSelectionListener,
+ * DropDown::addSelectionListener,
+ * DropDown::removeSelectionListener
+ * @author Olof Naessén
+ * @since 0.8.0
+ */
+class SelectionListener
{
- /**
- * Interface for listening for selection events from widgets.
- *
- * @see ListBox::addSelectionListener,
- * ListBox::removeSelectionListener,
- * DropDown::addSelectionListener,
- * DropDown::removeSelectionListener
- * @author Olof Naessén
- * @since 0.8.0
- */
- class SelectionListener
- {
public:
/**
- * Destructor.
- */
+ * Destructor.
+ */
virtual ~SelectionListener()
{ }
/**
- * Called when the value of a selection has been changed in a Widget.
- * It is used to be able to recieve a notification that a value has
- * been changed.
- *
- * @param event The event of the value change.
- * @since 0.8.0
- */
- virtual void valueChanged(const SelectionEvent& event A_UNUSED)
+ * Called when the value of a selection has been changed in a Widget.
+ * It is used to be able to recieve a notification that a value has
+ * been changed.
+ *
+ * @param event The event of the value change.
+ * @since 0.8.0
+ */
+ virtual void valueChanged(const SelectionEvent &event A_UNUSED)
{ }
protected:
/**
- * Constructor.
- *
- * You should not be able to make an instance of SelectionListener,
- * therefore its constructor is protected.
- */
+ * Constructor.
+ *
+ * You should not be able to make an instance of SelectionListener,
+ * therefore its constructor is protected.
+ */
SelectionListener()
{ }
- };
-} // namespace gcn
+};
-#endif // end GCN_SELECTIONLISTENER_HPP
+#endif // LISTENERS_SELECTIONLISTENER_H
diff --git a/src/guichan/include/guichan/widgetlistener.hpp b/src/listeners/widgetlistener.h
index eb584b0ed..48641cbaa 100644
--- a/src/guichan/include/guichan/widgetlistener.hpp
+++ b/src/listeners/widgetlistener.h
@@ -61,83 +61,80 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef GCN_WIDGETLISTENER_HPP
-#define GCN_WIDGETLISTENER_HPP
+#ifndef LISTENERS_WIDGETLISTENER_H
+#define LISTENERS_WIDGETLISTENER_H
#include <string>
-#include "guichan/event.hpp"
+#include "events/event.h"
#include "localconsts.h"
-namespace gcn
+/**
+ * Interface for listening for events from widgets. When a widget's size,
+ * location or visibility changes, the relevant method of the listener is
+ * invoked.
+ *
+ * @see Widget::addWidgetListener, Widget::removeWidgetListener
+ * @author Olof Naessén
+ * @since 0.8.0
+ */
+class WidgetListener
{
- /**
- * Interface for listening for events from widgets. When a widget's size,
- * location or visibility changes, the relevant method of the listener is
- * invoked.
- *
- * @see Widget::addWidgetListener, Widget::removeWidgetListener
- * @author Olof Naessén
- * @since 0.8.0
- */
- class WidgetListener
- {
public:
/**
- * Destructor.
- */
+ * Destructor.
+ */
virtual ~WidgetListener()
{ }
/**
- * Invoked when a widget changes its size.
- *
- * @param event Describes the event.
- * @since 0.8.0
- */
- virtual void widgetResized(const Event& event A_UNUSED)
+ * Invoked when a widget changes its size.
+ *
+ * @param event Describes the event.
+ * @since 0.8.0
+ */
+ virtual void widgetResized(const Event &event A_UNUSED)
{ }
/**
- * Invoked when a widget is moved.
- *
- * @param event Describes the event.
- * @since 0.8.0
- */
- virtual void widgetMoved(const Event& event A_UNUSED)
+ * Invoked when a widget is moved.
+ *
+ * @param event Describes the event.
+ * @since 0.8.0
+ */
+ virtual void widgetMoved(const Event &event A_UNUSED)
{ }
/**
- * Invoked when a widget is hidden, i.e it's set to be
- * not visible.
- *
- * @param event Describes the event.
- * @since 0.8.0
- */
- virtual void widgetHidden(const Event& event A_UNUSED)
+ * Invoked when a widget is hidden, i.e it's set to be
+ * not visible.
+ *
+ * @param event Describes the event.
+ * @since 0.8.0
+ */
+ virtual void widgetHidden(const Event &event A_UNUSED)
{ }
/**
- * Invoked when a widget is shown, i.e it's set to be
- * visible.
- *
- * @param event Describes the event.
- * @since 0.8.0
- */
- virtual void widgetShown(const Event& event A_UNUSED)
+ * Invoked when a widget is shown, i.e it's set to be
+ * visible.
+ *
+ * @param event Describes the event.
+ * @since 0.8.0
+ */
+ virtual void widgetShown(const Event &event A_UNUSED)
{ }
protected:
/**
- * Constructor.
- *
- * You should not be able to make an instance of WidgetListener,
- * therefore its constructor is protected.
- */
+ * Constructor.
+ *
+ * You should not be able to make an instance of WidgetListener,
+ * therefore its constructor is protected.
+ */
WidgetListener()
{ }
- };
-} // namespace gcn
+};
-#endif // end GCN_WIDGETLISTENER_HPP
+#endif // LISTENERS_WIDGETLISTENER_H
diff --git a/src/localconsts.h b/src/localconsts.h
index 58b469f01..92c36d92a 100644
--- a/src/localconsts.h
+++ b/src/localconsts.h
@@ -33,13 +33,6 @@
#endif
#endif
-#ifndef DEBUGBUILD
-#ifndef USE_INTERNALGUICHAN
-#warning using depricated way for linking with guichan. \
- Please removed configure flag --without-internalguichan
-#endif
-#endif
-
#if !defined(__GXX_EXPERIMENTAL_CXX0X__)
#undef nullptr
#define nullptr 0
diff --git a/src/logger.cpp b/src/logger.cpp
index c430aefec..21fea14d7 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -22,9 +22,10 @@
#include "logger.h"
-#include <iostream>
#include <sstream>
+#include <iostream>
+
#ifdef WIN32
#include <windows.h>
#elif defined __APPLE__
diff --git a/src/main.h b/src/main.h
index 2035338a6..4d43f9447 100644
--- a/src/main.h
+++ b/src/main.h
@@ -40,13 +40,13 @@
* by the map, interleaved with the tiles in the fringe layer.
*
* The client supports two servers, \link EAthena eAthena\endlink (the TMW
- * version) and the \link ManaServ Mana server\endlink. To achieve this, the
+ * version) and the \link EvolServ server\endlink. To achieve this, the
* \link Net network communication layer\endlink is abstracted in many
* different interfaces, which have different implementations for each server.
*/
-#define SMALL_VERSION "1.4.2.15"
-#define CHECK_VERSION "01.04.02.15"
+#define SMALL_VERSION "1.4.3.1"
+#define CHECK_VERSION "01.04.03.01"
#ifdef HAVE_CONFIG_H
#include "../config.h"
diff --git a/src/map.cpp b/src/map.cpp
index 5dc1bfc0f..70a48b811 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -401,7 +401,7 @@ void Map::draw(Graphics *const graphics, int scrollX, int scrollY)
graphics->setColor(userPalette->getColorWithAlpha(
UserPalette::WALKABLE_HIGHLIGHT));
- graphics->fillRectangle(gcn::Rectangle(0, 0,
+ graphics->fillRectangle(Rect(0, 0,
graphics->mWidth, graphics->mHeight));
}
@@ -549,7 +549,7 @@ void Map::draw(Graphics *const graphics, int scrollX, int scrollY)
{\
graphics->setColor(userPalette->getColorWithAlpha(\
UserPalette::color));\
- graphics->fillRectangle(gcn::Rectangle(\
+ graphics->fillRectangle(Rect(\
x0 * mTileWidth - scrollX, \
y * mTileHeight - scrollY, \
width, mapTileSize));\
@@ -800,131 +800,6 @@ const std::string Map::getFilename() const
return fileName.substr(lastSlash, fileName.rfind(".") - lastSlash);
}
-#ifdef MANASERV_SUPPORT
-Position Map::checkNodeOffsets(int radius, const unsigned char walkMask,
- const Position &position) const
-{
- // Pre-computing character's position in tiles
- const int tx = position.x / mapTileSize;
- const int ty = position.y / mapTileSize;
-
- // Pre-computing character's position offsets.
- int fx = position.x % mapTileSize;
- int fy = position.y % mapTileSize;
-
- // Compute the being radius:
- // FIXME: Hande beings with more than 1/2 tile radius by not letting them
- // go or spawn in too narrow places. The server will have to be aware
- // of being's radius value (in tiles) to handle this gracefully.
- if (radius > mapTileSize / 2)
- radius = mapTileSize / 2;
- // set a default value if no value returned.
- if (radius < 1)
- radius = mapTileSize / 3;
-
- // We check diagonal first as they are more restrictive.
- // Top-left border check
- if (!getWalk(tx - 1, ty - 1, walkMask)
- && fy < radius && fx < radius)
- {
- fx = radius;
- fy = radius;
- }
- // Top-right border check
- if (!getWalk(tx + 1, ty - 1, walkMask)
- && (fy < radius) && fx > (mapTileSize - radius))
- {
- fx = mapTileSize - radius;
- fy = radius;
- }
- // Bottom-left border check
- if (!getWalk(tx - 1, ty + 1, walkMask)
- && fy > (mapTileSize - radius) && fx < radius)
- {
- fx = radius;
- fy = mapTileSize - radius;
- }
- // Bottom-right border check
- if (!getWalk(tx + 1, ty + 1, walkMask)
- && fy > (mapTileSize - radius) && fx > (mapTileSize - radius))
- {
- fx = mapTileSize - radius;
- fy = fx;
- }
-
- // Fix coordinates so that the player does not seem to dig into walls.
- if (fx > (mapTileSize - radius) && !getWalk(tx + 1, ty, walkMask))
- fx = mapTileSize - radius;
- else if (fx < radius && !getWalk(tx - 1, ty, walkMask))
- fx = radius;
- else if (fy > (mapTileSize - radius) && !getWalk(tx, ty + 1, walkMask))
- fy = mapTileSize - radius;
- else if (fy < radius && !getWalk(tx, ty - 1, walkMask))
- fy = radius;
-
- return Position(tx * mapTileSize + fx, ty * mapTileSize + fy);
-}
-
-Path Map::findPixelPath(const int startPixelX, const int startPixelY,
- const int endPixelX, const int endPixelY,
- const int radius, const unsigned char walkMask,
- const int maxCost)
-{
- Path myPath = findPath(startPixelX / mapTileSize,
- startPixelY / mapTileSize,
- endPixelX / mapTileSize,
- endPixelY / mapTileSize,
- walkMask, maxCost);
-
- // Don't compute empty coordinates.
- if (myPath.empty())
- return myPath;
-
- // Find the starting offset
- const float startOffsetX = static_cast<float>(startPixelX % mapTileSize);
- const float startOffsetY = static_cast<float>(startPixelY % mapTileSize);
-
- // Find the ending offset
- const float endOffsetX = static_cast<float>(endPixelX % mapTileSize);
- const float endOffsetY = static_cast<float>(endPixelY % mapTileSize);
-
- const int sz = static_cast<int>(myPath.size());
- // Find the distance, and divide it by the number of steps
- const int changeX = static_cast<int>((endOffsetX - startOffsetX)
- / static_cast<float>(sz));
- const int changeY = static_cast<int>((endOffsetY - startOffsetY)
- / static_cast<float>(sz));
-
- // Convert the map path to pixels over tiles
- // And add interpolation between the starting and ending offsets
- Path::iterator it = myPath.begin();
- const Path::iterator it_end = myPath.end();
- int i = 0;
- while (it != it_end)
- {
- // A position that is valid on the start and end tile is not
- // necessarily valid on all the tiles in between, so check the offsets.
- *it = checkNodeOffsets(radius, walkMask,
- it->x * mapTileSize + startOffsetX
- + static_cast<float>(changeX * i),
- it->y * mapTileSize + startOffsetY
- + static_cast<float>(changeY * i));
- i++;
- ++it;
- }
-
- // Remove the last path node, as it's more clever to go to the destination.
- // It also permit to avoid zigzag at the end of the path,
- // especially with mouse.
- const Position destination = checkNodeOffsets(radius, walkMask,
- endPixelX, endPixelY);
- myPath.pop_back();
- myPath.push_back(destination);
-
- return myPath;
-}
-#endif
-
Path Map::findPath(const int startX, const int startY,
const int destX, const int destY,
const unsigned char walkmask, const int maxCost)
diff --git a/src/map.h b/src/map.h
index 26303da7a..0ad048e7e 100644
--- a/src/map.h
+++ b/src/map.h
@@ -23,12 +23,13 @@
#ifndef MAP_H
#define MAP_H
-#include "configlistener.h"
#include "position.h"
#include "properties.h"
#include "being/actor.h"
+#include "listeners/configlistener.h"
+
#include "render/renderers.h"
#include <string>
@@ -277,29 +278,6 @@ class Map final : public Properties, public ConfigListener
*/
const std::string getFilename() const A_WARN_UNUSED;
-#ifdef MANASERV_SUPPORT
- /**
- * Check the current position against surrounding blocking tiles, and
- * correct the position offset within tile when needed.
- */
- Position checkNodeOffsets(int radius, const unsigned char walkMask,
- const Position &position)
- const A_WARN_UNUSED;
-
- Position checkNodeOffsets(const int radius,
- const unsigned char walkMask,
- const int x, const int y) const A_WARN_UNUSED
- { return checkNodeOffsets(radius, walkMask, Position(x, y)); }
-
- /**
- * Find a pixel path from one location to the next.
- */
- Path findPixelPath(const int startPixelX, const int startPixelY,
- const int destPixelX, const int destPixelY,
- const int radius, const unsigned char walkmask,
- const int maxCost = 20) A_WARN_UNUSED;
-#endif
-
/**
* Find a path from one location to the next.
*/
diff --git a/src/maplayer.cpp b/src/maplayer.cpp
index 3da8ba7d9..701fa9958 100644
--- a/src/maplayer.cpp
+++ b/src/maplayer.cpp
@@ -33,10 +33,11 @@
#include "render/graphics.h"
+#include "resources/image.h"
#include "resources/resourcemanager.h"
+#include "gui/font.h"
#include "gui/gui.h"
-#include "gui/sdlfont.h"
#include "utils/dtor.h"
@@ -139,7 +140,7 @@ void MapLayer::draw(Graphics *const graphics,
if (!c)
{
- graphics->drawImage2(img, px, py);
+ graphics->drawImage(img, px, py);
}
else
{
@@ -455,7 +456,7 @@ void MapLayer::drawFringe(Graphics *const graphics, int startX, int startY,
if (!c)
{
- graphics->drawImage2(img, px, py);
+ graphics->drawImage(img, px, py);
}
else
{
@@ -537,10 +538,10 @@ void MapLayer::drawFringe(Graphics *const graphics, int startX, int startY,
{
graphics->setColor(userPalette->getColorWithAlpha(
UserPalette::ATTACK_RANGE));
- graphics->fillRectangle(gcn::Rectangle(x, y, w, h));
+ graphics->fillRectangle(Rect(x, y, w, h));
graphics->setColor(userPalette->getColorWithAlpha(
UserPalette::ATTACK_RANGE_BORDER));
- graphics->drawRectangle(gcn::Rectangle(x, y, w, h));
+ graphics->drawRectangle(Rect(x, y, w, h));
}
}
}
@@ -797,7 +798,7 @@ void MapItem::draw(Graphics *const graphics, const int x, const int y,
{
BLOCK_START("MapItem::draw")
if (mImage)
- graphics->drawImage2(mImage, x, y);
+ graphics->drawImage(mImage, x, y);
switch (mType)
{
@@ -805,17 +806,17 @@ void MapItem::draw(Graphics *const graphics, const int x, const int y,
case CROSS:
graphics->setColor(userPalette->getColorWithAlpha(
UserPalette::ROAD_POINT));
- graphics->fillRectangle(gcn::Rectangle(x + dx / 3, y + dy / 3,
+ graphics->fillRectangle(Rect(x + dx / 3, y + dy / 3,
dx / 3, dy / 3));
break;
case HOME:
{
graphics->setColor(userPalette->getColorWithAlpha(
UserPalette::HOME_PLACE));
- graphics->fillRectangle(gcn::Rectangle(x, y, dx, dy));
+ graphics->fillRectangle(Rect(x, y, dx, dy));
graphics->setColor(userPalette->getColorWithAlpha(
UserPalette::HOME_PLACE_BORDER));
- graphics->drawRectangle(gcn::Rectangle(x, y, dx, dy));
+ graphics->drawRectangle(Rect(x, y, dx, dy));
break;
}
default:
@@ -823,7 +824,7 @@ void MapItem::draw(Graphics *const graphics, const int x, const int y,
}
if (!mName.empty() && mType != PORTAL && mType != EMPTY)
{
- gcn::Font *const font = gui->getFont();
+ Font *const font = gui->getFont();
if (font)
{
graphics->setColor(userPalette->getColor(UserPalette::BEING));
diff --git a/src/maplayer.h b/src/maplayer.h
index dcfdb991e..88db82214 100644
--- a/src/maplayer.h
+++ b/src/maplayer.h
@@ -23,10 +23,11 @@
#ifndef MAPLAYER_H
#define MAPLAYER_H
-#include "configlistener.h"
#include "position.h"
#include "main.h"
+#include "listeners/configlistener.h"
+
#include "being/actor.h"
#include <string>
diff --git a/src/mouseinput.h b/src/mouseinput.h
deleted file mode 100644
index 1ed155aa8..000000000
--- a/src/mouseinput.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 MOUSEINPUT_H
-#define MOUSEINPUT_H
-
-#include <guichan/mouseinput.hpp>
-
-#include "localconsts.h"
-
-class MouseInput final : public gcn::MouseInput
-{
- public:
- MouseInput();
-
- ~MouseInput();
-
- void setReal(const int x, const int y)
- { mRealX = x; mRealY = y; }
-
- int getRealX() const A_WARN_UNUSED
- { return mRealX; }
-
- int getRealY() const A_WARN_UNUSED
- { return mRealY; }
-
-#ifdef ANDROID
- int getTouchX() const A_WARN_UNUSED
- { return mRealX; }
-
- int getTouchY() const A_WARN_UNUSED
- { return mRealY; }
-#else
- int getTouchX() const A_WARN_UNUSED
- { return mX; }
-
- int getTouchY() const A_WARN_UNUSED
- { return mY; }
-#endif
-
- protected:
- int mRealX;
- int mRealY;
-};
-
-#endif // MOUSEINPUT_H
diff --git a/src/net/download.cpp b/src/net/download.cpp
index d0c6515fc..141a7772f 100644
--- a/src/net/download.cpp
+++ b/src/net/download.cpp
@@ -568,6 +568,7 @@ size_t Download::writeFunction(void *ptr,
memcpy(buf, ptr, totalMem);
buf[totalMem] = 0;
mUploadResponse.append(buf);
+ delete [] buf;
return totalMem;
}
diff --git a/src/net/ea/buysellhandler.cpp b/src/net/ea/buysellhandler.cpp
index 0f592b123..d55a3cea6 100644
--- a/src/net/ea/buysellhandler.cpp
+++ b/src/net/ea/buysellhandler.cpp
@@ -39,8 +39,6 @@
#include "net/chathandler.h"
#include "net/net.h"
-#include "net/ea/eaprotocol.h"
-
#include "utils/timer.h"
#include "debug.h"
diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp
index a11c157fd..d541ce09b 100644
--- a/src/net/ea/charserverhandler.cpp
+++ b/src/net/ea/charserverhandler.cpp
@@ -33,6 +33,7 @@
#include "net/ea/gamehandler.h"
#include "net/ea/network.h"
+#include "net/messagein.h"
#include "net/net.h"
#include "utils/dtor.h"
diff --git a/src/net/ea/charserverhandler.h b/src/net/ea/charserverhandler.h
index 5ffd714f2..af6aafa9b 100644
--- a/src/net/ea/charserverhandler.h
+++ b/src/net/ea/charserverhandler.h
@@ -24,8 +24,13 @@
#define NET_EA_CHARSERVERHANDLER_H
#include "net/charserverhandler.h"
-#include "net/messagein.h"
-#include "net/serverinfo.h"
+
+class ServerInfo;
+
+namespace Net
+{
+ class MessageIn;
+}
namespace Ea
{
diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp
index 6654950f2..997e4bfc1 100644
--- a/src/net/ea/chathandler.cpp
+++ b/src/net/ea/chathandler.cpp
@@ -38,6 +38,8 @@
#include "gui/widgets/tabs/chattab.h"
+#include "net/messagein.h"
+
#include <string>
#include "debug.h"
diff --git a/src/net/ea/chathandler.h b/src/net/ea/chathandler.h
index 1fabda09d..237abf10a 100644
--- a/src/net/ea/chathandler.h
+++ b/src/net/ea/chathandler.h
@@ -24,10 +24,14 @@
#define NET_EA_CHATHANDLER_H
#include "net/chathandler.h"
-#include "net/messagein.h"
#include <queue>
+namespace Net
+{
+ class MessageIn;
+}
+
namespace Ea
{
diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp
index 6e1982b6d..de1d6f151 100644
--- a/src/net/ea/gamehandler.cpp
+++ b/src/net/ea/gamehandler.cpp
@@ -31,6 +31,8 @@
#include "gui/windows/okdialog.h"
+#include "net/messagein.h"
+
#include "debug.h"
namespace Ea
diff --git a/src/net/ea/gamehandler.h b/src/net/ea/gamehandler.h
index 8a31ee030..4a0624be0 100644
--- a/src/net/ea/gamehandler.h
+++ b/src/net/ea/gamehandler.h
@@ -24,7 +24,11 @@
#define NET_EA_GAMEHANDLER_H
#include "net/gamehandler.h"
-#include "net/messagein.h"
+
+namespace Net
+{
+ class MessageIn;
+}
namespace Ea
{
diff --git a/src/net/ea/gui/guildtab.cpp b/src/net/ea/gui/guildtab.cpp
index 46b1f1649..af8c3b8df 100644
--- a/src/net/ea/gui/guildtab.cpp
+++ b/src/net/ea/gui/guildtab.cpp
@@ -28,10 +28,9 @@
#include "soundconsts.h"
#include "soundmanager.h"
+#include "net/guildhandler.h"
#include "net/net.h"
-#include "net/ea/guildhandler.h"
-
#include "utils/gettext.h"
#include "debug.h"
diff --git a/src/net/ea/gui/guildtab.h b/src/net/ea/gui/guildtab.h
index 2b6a4bd1a..931b53397 100644
--- a/src/net/ea/gui/guildtab.h
+++ b/src/net/ea/gui/guildtab.h
@@ -31,7 +31,8 @@ namespace Ea
/**
* A tab for a guild chat channel.
*/
-class GuildTab : public ChatTab, public ConfigListener
+class GuildTab : public ChatTab,
+ public ConfigListener
{
public:
explicit GuildTab(const Widget2 *const widget);
diff --git a/src/net/ea/gui/partytab.h b/src/net/ea/gui/partytab.h
index d141452d0..6c61990dd 100644
--- a/src/net/ea/gui/partytab.h
+++ b/src/net/ea/gui/partytab.h
@@ -31,7 +31,8 @@ namespace Ea
/**
* A tab for a party chat channel.
*/
-class PartyTab : public ChatTab, public ConfigListener
+class PartyTab : public ChatTab,
+ public ConfigListener
{
public:
explicit PartyTab(const Widget2 *const widget);
diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp
index 536c93263..1e56ac75b 100644
--- a/src/net/ea/guildhandler.cpp
+++ b/src/net/ea/guildhandler.cpp
@@ -30,6 +30,10 @@
#include "gui/windows/socialwindow.h"
+#include "net/messagein.h"
+
+#include "net/ea/gui/guildtab.h"
+
#include "debug.h"
namespace Ea
diff --git a/src/net/ea/guildhandler.h b/src/net/ea/guildhandler.h
index 191d6fd44..e8bec6a09 100644
--- a/src/net/ea/guildhandler.h
+++ b/src/net/ea/guildhandler.h
@@ -23,12 +23,15 @@
#define NET_EA_GUILDHANDLER_H
#include "net/guildhandler.h"
-#include "net/messagein.h"
-#include "net/ea/gui/guildtab.h"
+namespace Net
+{
+ class MessageIn;
+}
namespace Ea
{
+class GuildTab;
class GuildHandler : public Net::GuildHandler
{
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
index 74f0a4ba7..2262a79f9 100644
--- a/src/net/ea/inventoryhandler.cpp
+++ b/src/net/ea/inventoryhandler.cpp
@@ -29,6 +29,8 @@
#include "gui/windows/ministatuswindow.h"
+#include "net/messagein.h"
+
#include "net/ea/eaprotocol.h"
#include "debug.h"
@@ -150,7 +152,7 @@ int InventoryHandler::convertFromServerSlot(const int serverSlot) const
return EQUIP_CONVERT[serverSlot];
}
-int InventoryHandler::getSlot(const int eAthenaSlot) const
+int InventoryHandler::getSlot(const int eAthenaSlot)
{
if (eAthenaSlot == 0)
return Equipment::EQUIP_VECTOREND;
@@ -158,7 +160,7 @@ int InventoryHandler::getSlot(const int eAthenaSlot) const
if (eAthenaSlot & 0x8000)
return Equipment::EQUIP_PROJECTILE_SLOT;
- int mask = 1;
+ unsigned int mask = 1;
int position = 0;
while (!(eAthenaSlot & mask))
{
@@ -564,7 +566,7 @@ void InventoryHandler::processPlayerUnEquip(Net::MessageIn &msg)
miniStatusWindow->updateArrows();
}
-void InventoryHandler::processPlayerAttackRange(Net::MessageIn &msg) const
+void InventoryHandler::processPlayerAttackRange(Net::MessageIn &msg)
{
const int range = msg.readInt16();
if (player_node)
diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h
index 6e8ecec38..ac88c1d6c 100644
--- a/src/net/ea/inventoryhandler.h
+++ b/src/net/ea/inventoryhandler.h
@@ -33,11 +33,15 @@
#include "gui/windows/inventorywindow.h"
#include "net/inventoryhandler.h"
-#include "net/messagein.h"
#include <vector>
#include <queue>
+namespace Net
+{
+ class MessageIn;
+}
+
namespace Ea
{
@@ -171,7 +175,7 @@ class InventoryHandler : public Net::InventoryHandler
void pushPickup(const int floorId)
{ mSentPickups.push(floorId); }
- int getSlot(const int eAthenaSlot) const A_WARN_UNUSED;
+ static int getSlot(const int eAthenaSlot) A_WARN_UNUSED;
void processPlayerInventory(Net::MessageIn &msg,
const bool playerInvintory);
@@ -200,7 +204,7 @@ class InventoryHandler : public Net::InventoryHandler
void processPlayerUnEquip(Net::MessageIn &msg);
- void processPlayerAttackRange(Net::MessageIn &msg) const;
+ static void processPlayerAttackRange(Net::MessageIn &msg);
void processPlayerArrowEquip(Net::MessageIn &msg);
diff --git a/src/net/ea/itemhandler.cpp b/src/net/ea/itemhandler.cpp
index 9ce85a59b..383ba2753 100644
--- a/src/net/ea/itemhandler.cpp
+++ b/src/net/ea/itemhandler.cpp
@@ -24,6 +24,8 @@
#include "actormanager.h"
+#include "net/messagein.h"
+
#include "debug.h"
namespace Ea
diff --git a/src/net/ea/itemhandler.h b/src/net/ea/itemhandler.h
index 6bc23fb10..80c0a4dbf 100644
--- a/src/net/ea/itemhandler.h
+++ b/src/net/ea/itemhandler.h
@@ -25,6 +25,13 @@
#include "net/messagein.h"
+#include "localconsts.h"
+
+namespace Net
+{
+ class MessageIn;
+}
+
namespace Ea
{
diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp
index 57edcefbf..44d834b94 100644
--- a/src/net/ea/loginhandler.cpp
+++ b/src/net/ea/loginhandler.cpp
@@ -32,6 +32,8 @@
#include "utils/gettext.h"
#include "utils/paths.h"
+#include "net/messagein.h"
+
#include "debug.h"
namespace Ea
@@ -68,12 +70,7 @@ void LoginHandler::loginAccount(LoginData *const loginData1) const
{
if (loginData1)
{
- // Since we're attempting to use the tAthena protocol,
- // let's reset the character slots to the good value,
- // in case we just logged out a Manaserv server
- // with a different config.
loginData1->resetCharacterSlots();
-
sendLoginRegister(loginData1->username, loginData1->password, "");
}
}
diff --git a/src/net/ea/loginhandler.h b/src/net/ea/loginhandler.h
index 8fea9d49f..f539176f5 100644
--- a/src/net/ea/loginhandler.h
+++ b/src/net/ea/loginhandler.h
@@ -24,7 +24,6 @@
#define NET_EA_LOGINHANDLER_H
#include "net/loginhandler.h"
-#include "net/messagein.h"
#include "net/ea/token.h"
@@ -32,6 +31,11 @@
class LoginData;
+namespace Net
+{
+ class MessageIn;
+}
+
namespace Ea
{
diff --git a/src/net/ea/npchandler.cpp b/src/net/ea/npchandler.cpp
index 70c4ce08a..03def7298 100644
--- a/src/net/ea/npchandler.cpp
+++ b/src/net/ea/npchandler.cpp
@@ -24,6 +24,8 @@
#include "gui/windows/npcdialog.h"
+#include "net/messagein.h"
+
#include "debug.h"
namespace Ea
diff --git a/src/net/ea/npchandler.h b/src/net/ea/npchandler.h
index b8a10bc18..07c281587 100644
--- a/src/net/ea/npchandler.h
+++ b/src/net/ea/npchandler.h
@@ -23,11 +23,17 @@
#ifndef NET_EA_NPCHANDLER_H
#define NET_EA_NPCHANDLER_H
-#include "net/messagein.h"
#include "net/npchandler.h"
+#include "localconsts.h"
+
class NpcDialog;
+namespace Net
+{
+ class MessageIn;
+}
+
namespace Ea
{
diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp
index 98dec750a..4e4cac3df 100644
--- a/src/net/ea/partyhandler.cpp
+++ b/src/net/ea/partyhandler.cpp
@@ -25,11 +25,16 @@
#include "configuration.h"
#include "notifications.h"
#include "notifymanager.h"
+#include "party.h"
#include "being/localplayer.h"
#include "gui/windows/socialwindow.h"
+#include "net/messagein.h"
+
+#include "net/ea/gui/partytab.h"
+
#include "debug.h"
namespace Ea
@@ -55,7 +60,7 @@ void PartyHandler::join(const int partyId A_UNUSED) const
{
}
-void PartyHandler::reload() const
+void PartyHandler::reload()
{
taParty = Party::getParty(1);
}
diff --git a/src/net/ea/partyhandler.h b/src/net/ea/partyhandler.h
index e7ab8f8ef..24923bd4a 100644
--- a/src/net/ea/partyhandler.h
+++ b/src/net/ea/partyhandler.h
@@ -22,15 +22,18 @@
#ifndef NET_EA_PARTYHANDLER_H
#define NET_EA_PARTYHANDLER_H
-#include "net/messagein.h"
#include "net/partyhandler.h"
-#include "net/ea/gui/partytab.h"
+class Party;
-#include "party.h"
+namespace Net
+{
+ class MessageIn;
+}
namespace Ea
{
+class PartyTab;
class PartyHandler : public Net::PartyHandler
{
@@ -49,7 +52,7 @@ class PartyHandler : public Net::PartyHandler
PartyShare getShareItems() const override final A_WARN_UNUSED
{ return mShareItems; }
- void reload() const;
+ static void reload();
void clear() const override final;
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index 3e5db9169..de376cead 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -41,6 +41,7 @@
#include "resources/db/deaddb.h"
+#include "net/messagein.h"
#include "net/net.h"
#include "net/ea/eaprotocol.h"
@@ -60,9 +61,9 @@ namespace
/**
* Listener used for handling the overweigth message.
*/
- struct WeightListener final : public gcn::ActionListener
+ struct WeightListener final : public ActionListener
{
- void action(const gcn::ActionEvent &event A_UNUSED)
+ void action(const ActionEvent &event A_UNUSED)
{
weightNotice = nullptr;
}
@@ -71,9 +72,9 @@ namespace
/**
* Listener used for handling death message.
*/
- struct DeathListener final : public gcn::ActionListener
+ struct DeathListener final : public ActionListener
{
- void action(const gcn::ActionEvent &event A_UNUSED)
+ void action(const ActionEvent &event A_UNUSED)
{
if (Net::getPlayerHandler())
Net::getPlayerHandler()->respawn();
diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h
index 589874e2e..087627f92 100644
--- a/src/net/ea/playerhandler.h
+++ b/src/net/ea/playerhandler.h
@@ -23,9 +23,13 @@
#ifndef NET_EA_PLAYERHANDLER_H
#define NET_EA_PLAYERHANDLER_H
-#include "net/messagein.h"
#include "net/playerhandler.h"
+namespace Net
+{
+ class MessageIn;
+}
+
namespace Ea
{
diff --git a/src/net/ea/skillhandler.cpp b/src/net/ea/skillhandler.cpp
index 3a5a1ab75..fd10a6087 100644
--- a/src/net/ea/skillhandler.cpp
+++ b/src/net/ea/skillhandler.cpp
@@ -33,6 +33,8 @@
#include "utils/stringutils.h"
+#include "net/messagein.h"
+
#include "debug.h"
/** job dependend identifiers (?) */
diff --git a/src/net/ea/skillhandler.h b/src/net/ea/skillhandler.h
index 8dc724e0a..484ca6878 100644
--- a/src/net/ea/skillhandler.h
+++ b/src/net/ea/skillhandler.h
@@ -23,9 +23,15 @@
#ifndef NET_EA_SKILLHANDLER_H
#define NET_EA_SKILLHANDLER_H
-#include "net/messagein.h"
#include "net/skillhandler.h"
+#include "localconsts.h"
+
+namespace Net
+{
+ class MessageIn;
+}
+
namespace Ea
{
diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp
index 9457a31db..19e597967 100644
--- a/src/net/ea/tradehandler.cpp
+++ b/src/net/ea/tradehandler.cpp
@@ -34,6 +34,7 @@
#include "gui/windows/confirmdialog.h"
#include "gui/windows/tradewindow.h"
+#include "net/messagein.h"
#include "net/net.h"
#include "net/ea/eaprotocol.h"
@@ -48,9 +49,9 @@ ConfirmDialog *confirmDlg = nullptr;
*/
namespace
{
- struct RequestTradeListener : public gcn::ActionListener
+ struct RequestTradeListener : public ActionListener
{
- void action(const gcn::ActionEvent &event)
+ void action(const ActionEvent &event)
{
confirmDlg = nullptr;
const std::string &eventId = event.getId();
diff --git a/src/net/ea/tradehandler.h b/src/net/ea/tradehandler.h
index 22a78e9e6..d4c9510b8 100644
--- a/src/net/ea/tradehandler.h
+++ b/src/net/ea/tradehandler.h
@@ -23,9 +23,13 @@
#ifndef NET_EA_TRADEHANDLER_H
#define NET_EA_TRADEHANDLER_H
-#include "net/messagein.h"
#include "net/tradehandler.h"
+namespace Net
+{
+ class MessageIn;
+}
+
namespace Ea
{
diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp
index 61e0a8404..a9d11f563 100644
--- a/src/net/eathena/chathandler.cpp
+++ b/src/net/eathena/chathandler.cpp
@@ -24,8 +24,7 @@
#include "being/localplayer.h"
-#include "gui/widgets/tabs/chattab.h"
-
+#include "net/eathena/messageout.h"
#include "net/eathena/protocol.h"
#include <string>
diff --git a/src/net/eathena/chathandler.h b/src/net/eathena/chathandler.h
index 9c6b8ea0c..3efaf2d31 100644
--- a/src/net/eathena/chathandler.h
+++ b/src/net/eathena/chathandler.h
@@ -26,10 +26,10 @@
#include "net/ea/chathandler.h"
#include "net/eathena/messagehandler.h"
-#include "net/eathena/messageout.h"
namespace EAthena
{
+class MessageOut;
class ChatHandler final : public MessageHandler, public Ea::ChatHandler
{
diff --git a/src/net/eathena/generalhandler.cpp b/src/net/eathena/generalhandler.cpp
index ebb5d46d7..3a18dede9 100644
--- a/src/net/eathena/generalhandler.cpp
+++ b/src/net/eathena/generalhandler.cpp
@@ -33,6 +33,7 @@
#include "net/ea/guildhandler.h"
+#include "net/ea/gui/guildtab.h"
#include "net/ea/gui/partytab.h"
#include "net/eathena/adminhandler.h"
diff --git a/src/net/eathena/messageout.cpp b/src/net/eathena/messageout.cpp
index 3ac6a417e..ff16f5dd0 100644
--- a/src/net/eathena/messageout.cpp
+++ b/src/net/eathena/messageout.cpp
@@ -96,7 +96,7 @@ void MessageOut::writeCoordinates(const uint16_t x,
mNetwork->mOutSize += 3;
mPos += 3;
- int16_t temp = x;
+ uint16_t temp = x;
temp <<= 6;
data[0] = 0;
data[1] = 1;
diff --git a/src/net/eathena/network.cpp b/src/net/eathena/network.cpp
index 56d4f5aae..0162d82e8 100644
--- a/src/net/eathena/network.cpp
+++ b/src/net/eathena/network.cpp
@@ -24,6 +24,7 @@
#include "logger.h"
+#include "net/eathena/messagehandler.h"
#include "net/eathena/messagein.h"
#include "net/eathena/protocol.h"
diff --git a/src/net/eathena/network.h b/src/net/eathena/network.h
index 4c9349f96..fae4f06d5 100644
--- a/src/net/eathena/network.h
+++ b/src/net/eathena/network.h
@@ -25,8 +25,6 @@
#include "net/ea/network.h"
-#include "net/eathena/messagehandler.h"
-
/**
* Protocol version, reported to the eAthena char and mapserver who can adjust
* the protocol accordingly.
@@ -35,6 +33,7 @@
namespace EAthena
{
+class MessageHandler;
class Network final : public Ea::Network
{
diff --git a/src/net/eathena/partyhandler.cpp b/src/net/eathena/partyhandler.cpp
index fcc650171..cfec2fe81 100644
--- a/src/net/eathena/partyhandler.cpp
+++ b/src/net/eathena/partyhandler.cpp
@@ -24,6 +24,7 @@
#include "actormanager.h"
#include "notifications.h"
#include "notifymanager.h"
+#include "party.h"
#include "being/localplayer.h"
diff --git a/src/net/loginhandler.h b/src/net/loginhandler.h
index 0c3fa27ff..91c2e4603 100644
--- a/src/net/loginhandler.h
+++ b/src/net/loginhandler.h
@@ -36,11 +36,6 @@ namespace Net
class LoginHandler
{
public:
- /**
- * This enum describes options specific to either eAthena or Manaserv.
- * By querying for these flags, the GUI can adapt to the current
- * server type dynamically.
- */
enum OptionalAction
{
Unregister = 0x1,
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index 9d9c68b94..121e1e58f 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -59,22 +59,6 @@ unsigned char MessageIn::readInt8()
return value;
}
-void MessageIn::readCoordinates(uint16_t &restrict x, uint16_t &restrict y)
-{
- if (mPos + 3 <= mLength)
- {
- const unsigned char *const p
- = reinterpret_cast<unsigned char const *const>(mData + mPos);
- x = static_cast<uint16_t>(p[0] | ((p[1] & 0x07) << 8));
- y = static_cast<uint16_t>((p[1] >> 3) | ((p[2] & 0x3F) << 5));
- }
- mPos += 3;
- PacketCounters::incInBytes(3);
- DEBUGLOG(std::string("readCoordinates: ").append(toString(
- static_cast<int>(x))).append(",").append(toString(
- static_cast<int>(y))));
-}
-
uint8_t MessageIn::fromServerDirection(const uint8_t serverDir)
{
// Translate from eAthena format
@@ -97,10 +81,7 @@ uint8_t MessageIn::fromServerDirection(const uint8_t serverDir)
case 7:
return 9;
case 8:
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() != ServerInfo::MANASERV)
-#endif
- return 8;
+ return 8;
default:
logger->log("incorrect direction: %d",
static_cast<int>(serverDir));
@@ -115,7 +96,7 @@ void MessageIn::readCoordinates(uint16_t &restrict x, uint16_t &restrict y,
if (mPos + 3 <= mLength)
{
const char *const data = mData + mPos;
- int16_t temp = MAKEWORD(data[1] & 0x00c0, data[0] & 0x00ff);
+ uint16_t temp = MAKEWORD(data[1] & 0x00c0, data[0] & 0x00ff);
x = static_cast<uint16_t>(temp >> 6);
temp = MAKEWORD(data[2] & 0x00f0, data[1] & 0x003f);
y = static_cast<uint16_t>(temp >> 4);
@@ -147,7 +128,7 @@ void MessageIn::readCoordinatePair(uint16_t &restrict srcX,
if (mPos + 5 <= mLength)
{
const char *const data = mData + mPos;
- int16_t temp = MAKEWORD(data[3], data[2] & 0x000f);
+ uint16_t temp = MAKEWORD(data[3], data[2] & 0x000f);
dstX = static_cast<uint16_t>(temp >> 2);
dstY = MAKEWORD(data[4], data[3] & 0x0003);
diff --git a/src/net/messagein.h b/src/net/messagein.h
index c3ed294c3..7b2b2400b 100644
--- a/src/net/messagein.h
+++ b/src/net/messagein.h
@@ -65,13 +65,6 @@ class MessageIn
virtual int readInt32() = 0; /**< Reads a long. */
/**
- * Reads a 3-byte block containing tile-based coordinates. Used by
- * manaserv.
- */
- virtual void readCoordinates(uint16_t &restrict x,
- uint16_t &restrict y);
-
- /**
* Reads a special 3 byte block used by eAthena, containing x and y
* coordinates and direction.
*/
diff --git a/src/net/net.cpp b/src/net/net.cpp
index c7a4f33f7..90cf9e16a 100644
--- a/src/net/net.cpp
+++ b/src/net/net.cpp
@@ -32,10 +32,6 @@
#include "net/eathena/generalhandler.h"
#endif
-#ifdef MANASERV_SUPPORT
-#include "net/manaserv/generalhandler.h"
-#endif
-
#include "debug.h"
Net::AdminHandler *adminHandler = nullptr;
@@ -162,13 +158,6 @@ void connectToServer(const ServerInfo &server)
new TmwAthena::GeneralHandler;
#endif
break;
- case ServerInfo::MANASERV:
-#ifdef MANASERV_SUPPORT
- new ManaServ::GeneralHandler;
-#else
- new TmwAthena::GeneralHandler;
-#endif
- break;
case ServerInfo::TMWATHENA:
case ServerInfo::UNKNOWN:
default:
diff --git a/src/net/serverinfo.h b/src/net/serverinfo.h
index 0b17184fd..48f216855 100644
--- a/src/net/serverinfo.h
+++ b/src/net/serverinfo.h
@@ -38,7 +38,6 @@ public:
enum Type
{
UNKNOWN = 0,
- MANASERV,
TMWATHENA,
EVOL,
EATHENA
@@ -139,10 +138,6 @@ public:
else if (compareStrI(serverType, "eathena") == 0)
return TMWATHENA;
#endif
-#ifdef MANASERV_SUPPORT
- else if (compareStrI(serverType, "manaserv") == 0)
- return MANASERV;
-#endif
return UNKNOWN;
}
};
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp
index af236f00b..d00f12dd3 100644
--- a/src/net/tmwa/chathandler.cpp
+++ b/src/net/tmwa/chathandler.cpp
@@ -24,8 +24,7 @@
#include "being/localplayer.h"
-#include "gui/widgets/tabs/chattab.h"
-
+#include "net/tmwa/messageout.h"
#include "net/tmwa/protocol.h"
#include <string>
diff --git a/src/net/tmwa/chathandler.h b/src/net/tmwa/chathandler.h
index a7226c52c..c4f51fec7 100644
--- a/src/net/tmwa/chathandler.h
+++ b/src/net/tmwa/chathandler.h
@@ -26,10 +26,10 @@
#include "net/ea/chathandler.h"
#include "net/tmwa/messagehandler.h"
-#include "net/tmwa/messageout.h"
namespace TmwAthena
{
+class MessageOut;
class ChatHandler final : public MessageHandler, public Ea::ChatHandler
{
diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
index 683eb0711..46d1d490f 100644
--- a/src/net/tmwa/generalhandler.cpp
+++ b/src/net/tmwa/generalhandler.cpp
@@ -33,6 +33,7 @@
#include "net/ea/guildhandler.h"
+#include "net/ea/gui/guildtab.h"
#include "net/ea/gui/partytab.h"
#include "net/tmwa/adminhandler.h"
diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp
index 8dfbf2bd7..8c3ecb5ec 100644
--- a/src/net/tmwa/messageout.cpp
+++ b/src/net/tmwa/messageout.cpp
@@ -98,7 +98,7 @@ void MessageOut::writeCoordinates(const uint16_t x,
mNetwork->mOutSize += 3;
mPos += 3;
- int16_t temp = x;
+ uint16_t temp = x;
temp <<= 6;
data[0] = 0;
data[1] = 1;
diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp
index c91387898..cc94b6161 100644
--- a/src/net/tmwa/network.cpp
+++ b/src/net/tmwa/network.cpp
@@ -24,6 +24,7 @@
#include "logger.h"
+#include "net/tmwa/messagehandler.h"
#include "net/tmwa/messagein.h"
#include "net/tmwa/protocol.h"
diff --git a/src/net/tmwa/network.h b/src/net/tmwa/network.h
index 6d05d0e48..bf9381227 100644
--- a/src/net/tmwa/network.h
+++ b/src/net/tmwa/network.h
@@ -25,8 +25,6 @@
#include "net/ea/network.h"
-#include "net/tmwa/messagehandler.h"
-
/**
* Protocol version, reported to the eAthena char and mapserver who can adjust
* the protocol accordingly.
@@ -36,6 +34,7 @@
namespace TmwAthena
{
+class MessageHandler;
class Network final : public Ea::Network
{
diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp
index 78d56f669..ba18a9efa 100644
--- a/src/net/tmwa/partyhandler.cpp
+++ b/src/net/tmwa/partyhandler.cpp
@@ -24,6 +24,7 @@
#include "actormanager.h"
#include "notifications.h"
#include "notifymanager.h"
+#include "party.h"
#include "being/localplayer.h"
diff --git a/src/net/tmwa/pethandler.cpp b/src/net/tmwa/pethandler.cpp
index 6b9e5adb7..3293b7edd 100644
--- a/src/net/tmwa/pethandler.cpp
+++ b/src/net/tmwa/pethandler.cpp
@@ -24,8 +24,7 @@
#include "net/net.h"
-#include "net/tmwa/chathandler.h"
-#include "net/tmwa/protocol.h"
+#include "net/chathandler.h"
#include "debug.h"
diff --git a/src/net/tradehandler.h b/src/net/tradehandler.h
index 823352239..21ca65e97 100644
--- a/src/net/tradehandler.h
+++ b/src/net/tradehandler.h
@@ -29,6 +29,8 @@
#include "localconsts.h"
+class Item;
+
namespace Net
{
class TradeHandler
diff --git a/src/particle/imageparticle.cpp b/src/particle/imageparticle.cpp
index e41c072b4..92f458e41 100644
--- a/src/particle/imageparticle.cpp
+++ b/src/particle/imageparticle.cpp
@@ -103,6 +103,6 @@ void ImageParticle::draw(Graphics *const graphics,
}
mImage->setAlpha(alphafactor);
- graphics->drawImage2(mImage, screenX, screenY);
+ graphics->drawImage(mImage, screenX, screenY);
return;
}
diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp
index a9cc9993f..c446fa177 100644
--- a/src/particle/particle.cpp
+++ b/src/particle/particle.cpp
@@ -414,8 +414,8 @@ Particle *Particle::addEffect(const std::string &particleEffectFile,
Particle *Particle::addTextSplashEffect(const std::string &text,
const int x, const int y,
- const gcn::Color *const color,
- gcn::Font *const font,
+ const Color *const color,
+ Font *const font,
const bool outline)
{
Particle *const newParticle = new TextParticle(text, color, font, outline);
@@ -438,8 +438,8 @@ Particle *Particle::addTextSplashEffect(const std::string &text,
Particle *Particle::addTextRiseFadeOutEffect(const std::string &text,
const int x, const int y,
- const gcn::Color *const color,
- gcn::Font *const font,
+ const Color *const color,
+ Font *const font,
const bool outline)
{
Particle *const newParticle = new TextParticle(text, color, font, outline);
diff --git a/src/particle/particle.h b/src/particle/particle.h
index f75803772..491232b17 100644
--- a/src/particle/particle.h
+++ b/src/particle/particle.h
@@ -30,15 +30,11 @@
#include <list>
#include <string>
+class Color;
+class Font;
class Particle;
class ParticleEmitter;
-namespace gcn
-{
- class Color;
- class Font;
-}
-
typedef std::list<Particle *> Particles;
typedef Particles::iterator ParticleIterator;
typedef Particles::const_iterator ParticleConstIterator;
@@ -135,8 +131,8 @@ class Particle : public Actor
*/
Particle *addTextSplashEffect(const std::string &text,
const int x, const int y,
- const gcn::Color *const color,
- gcn::Font *const font,
+ const Color *const color,
+ Font *const font,
const bool outline = false);
/**
@@ -144,8 +140,8 @@ class Particle : public Actor
*/
Particle *addTextRiseFadeOutEffect(const std::string &text,
const int x, const int y,
- const gcn::Color *const color,
- gcn::Font *const font,
+ const Color *const color,
+ Font *const font,
const bool outline = false);
/**
diff --git a/src/particle/textparticle.cpp b/src/particle/textparticle.cpp
index 54de26887..41ea683f6 100644
--- a/src/particle/textparticle.cpp
+++ b/src/particle/textparticle.cpp
@@ -26,14 +26,14 @@
#include "gui/theme.h"
-#include <guichan/color.hpp>
-#include <guichan/font.hpp>
+#include "gui/color.h"
+#include "gui/font.h"
#include "debug.h"
TextParticle::TextParticle(const std::string &text,
- const gcn::Color *const color,
- gcn::Font *const font, const bool outline) :
+ const Color *const color,
+ Font *const font, const bool outline) :
Particle(),
mText(text),
mTextFont(font),
@@ -74,7 +74,7 @@ void TextParticle::draw(Graphics *const graphics,
/ static_cast<float>(mFadeIn);
}
- gcn::Color color = *mColor;
+ Color color = *mColor;
color.a = static_cast<int>(alpha);
graphics->setColor(color);
diff --git a/src/particle/textparticle.h b/src/particle/textparticle.h
index eb8a160e1..ec586c3a9 100644
--- a/src/particle/textparticle.h
+++ b/src/particle/textparticle.h
@@ -32,8 +32,8 @@ class TextParticle final : public Particle
* Constructor.
*/
TextParticle(const std::string &text,
- const gcn::Color *const color,
- gcn::Font *const font, const bool outline = false);
+ const Color *const color,
+ Font *const font, const bool outline = false);
A_DELETE_COPY(TextParticle)
@@ -53,8 +53,8 @@ class TextParticle final : public Particle
private:
std::string mText; /**< Text of the particle. */
- gcn::Font *mTextFont; /**< Font used for drawing the text. */
- const gcn::Color *mColor; /**< Color used for drawing the text. */
+ Font *mTextFont; /**< Font used for drawing the text. */
+ const Color *mColor; /**< Color used for drawing the text. */
int mTextWidth;
bool mOutline; /**< Make the text better readable */
};
diff --git a/src/party.h b/src/party.h
index 79fdfcf9e..c839168c7 100644
--- a/src/party.h
+++ b/src/party.h
@@ -22,7 +22,7 @@
#ifndef PARTY_H
#define PARTY_H
-#include "gui/widgets/avatarlistbox.h"
+#include "gui/models/avatarlistmodel.h"
#include "utils/dtor.h"
#include "utils/stringvector.h"
diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp
index 7e3687006..17f444eb8 100644
--- a/src/render/graphics.cpp
+++ b/src/render/graphics.cpp
@@ -20,6 +20,49 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include "render/graphics.h"
#include "main.h"
@@ -48,11 +91,11 @@
Graphics *mainGraphics = nullptr;
Graphics::Graphics() :
- gcn::Graphics(),
mWidth(0),
mHeight(0),
mActualWidth(0),
mActualHeight(0),
+ mClipStack(),
mWindow(nullptr),
#ifdef USE_SDL2
mRenderer(nullptr),
@@ -503,3 +546,82 @@ void Graphics::setWindowSize(const int width A_UNUSED,
SDL_SetWindowSize(mWindow, width, height);
#endif
}
+
+bool Graphics::pushClipArea(Rect area)
+{
+ // Ignore area with a negate width or height
+ // by simple pushing an empty clip area
+ // to the stack.
+ if (area.width < 0 || area.height < 0)
+ {
+ ClipRect carea;
+ mClipStack.push(carea);
+ return true;
+ }
+
+ if (mClipStack.empty())
+ {
+ ClipRect carea;
+ carea.x = area.x;
+ carea.y = area.y;
+ carea.width = area.width;
+ carea.height = area.height;
+ carea.xOffset = area.x;
+ carea.yOffset = area.y;
+ mClipStack.push(carea);
+ return true;
+ }
+
+ const ClipRect &top = mClipStack.top();
+ ClipRect carea;
+ carea = area;
+ carea.xOffset = top.xOffset + carea.x;
+ carea.yOffset = top.yOffset + carea.y;
+ carea.x += top.xOffset;
+ carea.y += top.yOffset;
+
+ // Clamp the pushed clip rectangle.
+ if (carea.x < top.x)
+ carea.x = top.x;
+
+ if (carea.y < top.y)
+ carea.y = top.y;
+
+ if (carea.x + carea.width > top.x + top.width)
+ {
+ carea.width = top.x + top.width - carea.x;
+
+ if (carea.width < 0)
+ carea.width = 0;
+ }
+
+ if (carea.y + carea.height > top.y + top.height)
+ {
+ carea.height = top.y + top.height - carea.y;
+
+ if (carea.height < 0)
+ carea.height = 0;
+ }
+
+ const bool result = carea.isIntersecting(top);
+
+ mClipStack.push(carea);
+
+ return result;
+}
+
+void Graphics::popClipArea()
+{
+ if (mClipStack.empty())
+ return;
+
+ mClipStack.pop();
+}
+
+const ClipRect *Graphics::getCurrentClipArea() const
+{
+ if (mClipStack.empty())
+ return nullptr;
+
+ return &mClipStack.top();
+}
diff --git a/src/render/graphics.h b/src/render/graphics.h
index 0cb510195..75b26a241 100644
--- a/src/render/graphics.h
+++ b/src/render/graphics.h
@@ -20,6 +20,49 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#ifndef RENDER_GRAPHICS_H
#define RENDER_GRAPHICS_H
@@ -27,15 +70,18 @@
#include "sdlshared.h"
+#include "gui/color.h"
+
#include "render/renderers.h"
-#include <guichan/color.hpp>
-#include <guichan/graphics.hpp>
+#include "gui/cliprect.h"
#ifdef USE_SDL2
#include <SDL_render.h>
#endif
+#include <stack>
+
#include "localconsts.h"
class Image;
@@ -94,7 +140,7 @@ class ImageRect final
/**
* A central point of control for graphics.
*/
-class Graphics : public gcn::Graphics
+class Graphics
{
public:
A_DELETE_COPY(Graphics)
@@ -104,6 +150,16 @@ class Graphics : public gcn::Graphics
*/
virtual ~Graphics();
+ /**
+ * Alignments for text drawing.
+ */
+ enum Alignment
+ {
+ LEFT = 0,
+ CENTER,
+ RIGHT
+ };
+
void setWindow(SDL_Window *const window,
const int width, const int height)
{
@@ -145,14 +201,6 @@ class Graphics : public gcn::Graphics
*/
virtual bool resizeScreen(const int width, const int height);
- // override unused abstract function
- void drawImage(const gcn::Image* image A_UNUSED,
- int srcX A_UNUSED, int srcY A_UNUSED,
- int dstX A_UNUSED, int dstY A_UNUSED,
- int width A_UNUSED, int height A_UNUSED) override final
- {
- }
-
/**
* Draws a resclaled version of the image
*/
@@ -211,8 +259,7 @@ class Graphics : public gcn::Graphics
const int w, const int h,
const ImageRect &imgRect) = 0;
- virtual void fillRectangle(const gcn::Rectangle& rectangle)
- override = 0;
+ virtual void fillRectangle(const Rect& rectangle) = 0;
/**
* Updates the screen. This is done by either copying the buffer to the
@@ -246,10 +293,7 @@ class Graphics : public gcn::Graphics
const int x2, const int y2,
const int width, const int height);
- const gcn::Font *getFont() const A_WARN_UNUSED
- { return mFont; }
-
- gcn::ClipRectangle &getTopClip() A_WARN_UNUSED
+ ClipRect &getTopClip() A_WARN_UNUSED
{ return mClipStack.top(); }
void setRedraw(const bool n)
@@ -288,27 +332,27 @@ class Graphics : public gcn::Graphics
virtual void initArrays()
{ }
- void setColor(const gcn::Color &color) override
+ virtual void setColor(const Color &color)
{
mColor = color;
mColor2 = color;
mAlpha = (color.a != 255);
}
- void setColor2(const gcn::Color &color)
+ void setColor2(const Color &color)
{ mColor2 = color; }
- void setColorAll(const gcn::Color &color, const gcn::Color &color2)
+ void setColorAll(const Color &color, const Color &color2)
{
mColor = color;
mColor2 = color2;
mAlpha = (color.a != 255);
}
- const gcn::Color &getColor() const override
+ const Color &getColor() const
{ return mColor; }
- const gcn::Color &getColor2() const
+ const Color &getColor2() const
{ return mColor2; }
#ifdef DEBUG_DRAW_CALLS
@@ -333,8 +377,8 @@ class Graphics : public gcn::Graphics
* @return <code>true</code> if the image was blitted properly
* <code>false</code> otherwise.
*/
- virtual bool drawImage2(const Image *const image,
- int dstX, int dstY) = 0;
+ virtual bool drawImage(const Image *const image,
+ int dstX, int dstY) = 0;
virtual void drawImageCached(const Image *const image,
int srcX, int srcY) = 0;
@@ -353,6 +397,87 @@ class Graphics : public gcn::Graphics
void setScale(int scale);
+ /**
+ * Pushes a clip area onto the stack. The x and y coordinates in the
+ * rectangle is relative to the last pushed clip area.
+ * If the new area falls outside the current clip area, it will be
+ * clipped as necessary.
+ *
+ * If a clip area is outside of the top clip area a clip area with
+ * zero width and height will be pushed.
+ *
+ * @param area The clip area to be pushed onto the stack.
+ * @return False if the the new area lays outside the current clip
+ * area.
+ */
+ virtual bool pushClipArea(Rect area);
+
+ /**
+ * Removes the top most clip area from the stack.
+ *
+ * @throws Exception if the stack is empty.
+ */
+ virtual void popClipArea();
+
+ /**
+ * Ddraws a line.
+ *
+ * @param x1 The first x coordinate.
+ * @param y1 The first y coordinate.
+ * @param x2 The second x coordinate.
+ * @param y2 The second y coordinate.
+ */
+ virtual void drawLine(int x1, int y1, int x2, int y2) = 0;
+
+ /**
+ * Draws a simple, non-filled, rectangle with a one pixel width.
+ *
+ * @param rectangle The rectangle to draw.
+ */
+ virtual void drawRectangle(const Rect &rectangle) = 0;
+
+ /**
+ * Gets the current clip area. Usefull if you want to do drawing
+ * bypassing Graphics.
+ *
+ * @return The current clip area.
+ */
+ virtual const ClipRect *getCurrentClipArea() const;
+
+ /**
+ * Draws a single point/pixel.
+ *
+ * @param x The x coordinate.
+ * @param y The y coordinate.
+ */
+ virtual void drawPoint(int x, int y) = 0;
+
+ /**
+ * Initializes drawing. Called by the Gui when Gui::draw() is called.
+ * It is needed by some implementations of Graphics to perform
+ * preparations before drawing. An example of such an implementation
+ * is the OpenGLGraphics.
+ *
+ * NOTE: You will never need to call this function yourself, unless
+ * you use a Graphics object outside of Guichan.
+ *
+ * @see _endDraw, Gui::draw
+ */
+ virtual void _beginDraw()
+ { }
+
+ /**
+ * Deinitializes drawing. Called by the Gui when a Gui::draw() is done.
+ * done. It should reset any state changes made by _beginDraw().
+ *
+ * NOTE: You will never need to call this function yourself, unless
+ * you use a Graphics object outside of Guichan.
+ *
+ * @see _beginDraw, Gui::draw
+ */
+ virtual void _endDraw()
+ { }
+
int mWidth;
int mHeight;
int mActualWidth;
@@ -382,6 +507,11 @@ class Graphics : public gcn::Graphics
bool videoInfo();
+ /**
+ * Holds the clip area stack.
+ */
+ std::stack<ClipRect> mClipStack;
+
SDL_Window *mWindow;
#ifdef USE_SDL2
@@ -405,8 +535,8 @@ class Graphics : public gcn::Graphics
int mStartFreeMem;
bool mSync;
int mScale;
- gcn::Color mColor;
- gcn::Color mColor2;
+ Color mColor;
+ Color mColor2;
};
extern Graphics *mainGraphics;
diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp
index 82bf04dc8..86707fac8 100644
--- a/src/render/mobileopenglgraphics.cpp
+++ b/src/render/mobileopenglgraphics.cpp
@@ -219,8 +219,8 @@ static inline void drawRescaledQuad(const Image *const image,
}
}
-bool MobileOpenGLGraphics::drawImage2(const Image *const image,
- int dstX, int dstY)
+bool MobileOpenGLGraphics::drawImage(const Image *const image,
+ int dstX, int dstY)
{
return drawImageInline(image, dstX, dstY);
}
@@ -228,7 +228,7 @@ bool MobileOpenGLGraphics::drawImage2(const Image *const image,
bool MobileOpenGLGraphics::drawImageInline(const Image *const image,
int dstX, int dstY)
{
- FUNC_BLOCK("Graphics::drawImage2", 1)
+ FUNC_BLOCK("Graphics::drawImage", 1)
if (!image)
return false;
@@ -884,7 +884,7 @@ void MobileOpenGLGraphics::_beginDraw()
// glScalef(0.5F, 0.5F, 0.5F);
- pushClipArea(gcn::Rectangle(0, 0, mRect.w, mRect.h));
+ pushClipArea(Rect(0, 0, mRect.w, mRect.h));
}
void MobileOpenGLGraphics::_endDraw()
@@ -951,21 +951,21 @@ SDL_Surface* MobileOpenGLGraphics::getScreenshot()
return screenshot;
}
-bool MobileOpenGLGraphics::pushClipArea(gcn::Rectangle area)
+bool MobileOpenGLGraphics::pushClipArea(Rect area)
{
int transX = 0;
int transY = 0;
if (!mClipStack.empty())
{
- const gcn::ClipRectangle &clipArea = mClipStack.top();
+ const ClipRect &clipArea = mClipStack.top();
transX = -clipArea.xOffset;
transY = -clipArea.yOffset;
}
- const bool result = gcn::Graphics::pushClipArea(area);
+ const bool result = Graphics::pushClipArea(area);
- const gcn::ClipRectangle &clipArea = mClipStack.top();
+ const ClipRect &clipArea = mClipStack.top();
transX += clipArea.xOffset;
transY += clipArea.yOffset;
@@ -986,16 +986,16 @@ void MobileOpenGLGraphics::popClipArea()
if (mClipStack.empty())
return;
- const gcn::ClipRectangle &clipArea1 = mClipStack.top();
+ const ClipRect &clipArea1 = mClipStack.top();
int transX = -clipArea1.xOffset;
int transY = -clipArea1.yOffset;
- gcn::Graphics::popClipArea();
+ Graphics::popClipArea();
if (mClipStack.empty())
return;
- const gcn::ClipRectangle &clipArea = mClipStack.top();
+ const ClipRect &clipArea = mClipStack.top();
transX += clipArea.xOffset;
transY += clipArea.yOffset;
if (transX || transY)
@@ -1040,12 +1040,12 @@ void MobileOpenGLGraphics::drawLine(int x1, int y1, int x2, int y2)
drawLineArrays(4);
}
-void MobileOpenGLGraphics::drawRectangle(const gcn::Rectangle& rect)
+void MobileOpenGLGraphics::drawRectangle(const Rect& rect)
{
drawRectangle(rect, false);
}
-void MobileOpenGLGraphics::fillRectangle(const gcn::Rectangle& rect)
+void MobileOpenGLGraphics::fillRectangle(const Rect& rect)
{
drawRectangle(rect, true);
}
@@ -1090,7 +1090,7 @@ void MobileOpenGLGraphics::setTexturingAndBlending(const bool enable)
}
}
-void MobileOpenGLGraphics::drawRectangle(const gcn::Rectangle& rect,
+void MobileOpenGLGraphics::drawRectangle(const Rect& rect,
const bool filled)
{
BLOCK_START("Graphics::drawRectangle")
diff --git a/src/render/mobileopenglgraphics.h b/src/render/mobileopenglgraphics.h
index f665f743b..0b9cd83e2 100644
--- a/src/render/mobileopenglgraphics.h
+++ b/src/render/mobileopenglgraphics.h
@@ -127,7 +127,7 @@ class MobileOpenGLGraphics final : public Graphics
bool mTexture;
bool mIsByteColor;
- gcn::Color mByteColor;
+ Color mByteColor;
GLuint mImageCached;
float mFloatColor;
int mMaxVertices;
diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp
index e8e1a2116..6bc25be32 100644
--- a/src/render/normalopenglgraphics.cpp
+++ b/src/render/normalopenglgraphics.cpp
@@ -286,8 +286,8 @@ static inline void drawRescaledQuad(const Image *const image,
}
}
-bool NormalOpenGLGraphics::drawImage2(const Image *const image,
- int dstX, int dstY)
+bool NormalOpenGLGraphics::drawImage(const Image *const image,
+ int dstX, int dstY)
{
return drawImageInline(image, dstX, dstY);
}
@@ -295,7 +295,7 @@ bool NormalOpenGLGraphics::drawImage2(const Image *const image,
bool NormalOpenGLGraphics::drawImageInline(const Image *const image,
int dstX, int dstY)
{
- FUNC_BLOCK("Graphics::drawImage2", 1)
+ FUNC_BLOCK("Graphics::drawImage", 1)
if (!image)
return false;
@@ -1145,7 +1145,7 @@ void NormalOpenGLGraphics::_beginDraw()
#endif
#endif
- pushClipArea(gcn::Rectangle(0, 0, w, h));
+ pushClipArea(Rect(0, 0, w, h));
}
void NormalOpenGLGraphics::_endDraw()
@@ -1211,21 +1211,21 @@ SDL_Surface* NormalOpenGLGraphics::getScreenshot()
return screenshot;
}
-bool NormalOpenGLGraphics::pushClipArea(gcn::Rectangle area)
+bool NormalOpenGLGraphics::pushClipArea(Rect area)
{
int transX = 0;
int transY = 0;
if (!mClipStack.empty())
{
- const gcn::ClipRectangle &clipArea = mClipStack.top();
+ const ClipRect &clipArea = mClipStack.top();
transX = -clipArea.xOffset;
transY = -clipArea.yOffset;
}
- const bool result = gcn::Graphics::pushClipArea(area);
+ const bool result = Graphics::pushClipArea(area);
- const gcn::ClipRectangle &clipArea = mClipStack.top();
+ const ClipRect &clipArea = mClipStack.top();
transX += clipArea.xOffset;
transY += clipArea.yOffset;
@@ -1247,16 +1247,16 @@ void NormalOpenGLGraphics::popClipArea()
if (mClipStack.empty())
return;
- const gcn::ClipRectangle &clipArea1 = mClipStack.top();
+ const ClipRect &clipArea1 = mClipStack.top();
int transX = -clipArea1.xOffset;
int transY = -clipArea1.yOffset;
- gcn::Graphics::popClipArea();
+ Graphics::popClipArea();
if (mClipStack.empty())
return;
- const gcn::ClipRectangle &clipArea = mClipStack.top();
+ const ClipRect &clipArea = mClipStack.top();
transX += clipArea.xOffset;
transY += clipArea.yOffset;
if (transX || transY)
@@ -1297,12 +1297,12 @@ void NormalOpenGLGraphics::drawLine(int x1, int y1, int x2, int y2)
drawLineArrayf(4);
}
-void NormalOpenGLGraphics::drawRectangle(const gcn::Rectangle& rect)
+void NormalOpenGLGraphics::drawRectangle(const Rect& rect)
{
drawRectangle(rect, false);
}
-void NormalOpenGLGraphics::fillRectangle(const gcn::Rectangle& rect)
+void NormalOpenGLGraphics::fillRectangle(const Rect& rect)
{
drawRectangle(rect, true);
}
@@ -1347,7 +1347,7 @@ void NormalOpenGLGraphics::setTexturingAndBlending(const bool enable)
}
}
-void NormalOpenGLGraphics::drawRectangle(const gcn::Rectangle& rect,
+void NormalOpenGLGraphics::drawRectangle(const Rect& rect,
const bool filled)
{
BLOCK_START("Graphics::drawRectangle")
diff --git a/src/render/normalopenglgraphics.h b/src/render/normalopenglgraphics.h
index 882ff5ed8..214954e3c 100644
--- a/src/render/normalopenglgraphics.h
+++ b/src/render/normalopenglgraphics.h
@@ -143,7 +143,7 @@ class NormalOpenGLGraphics final : public Graphics
bool mTexture;
bool mIsByteColor;
- gcn::Color mByteColor;
+ Color mByteColor;
GLuint mImageCached;
float mFloatColor;
int mMaxVertices;
diff --git a/src/render/nullopenglgraphics.cpp b/src/render/nullopenglgraphics.cpp
index 3ea1e4182..d09d7b13b 100644
--- a/src/render/nullopenglgraphics.cpp
+++ b/src/render/nullopenglgraphics.cpp
@@ -139,8 +139,8 @@ static inline void drawRescaledQuad(const Image *const image A_UNUSED,
}
}
-bool NullOpenGLGraphics::drawImage2(const Image *const image,
- int dstX, int dstY)
+bool NullOpenGLGraphics::drawImage(const Image *const image,
+ int dstX, int dstY)
{
return drawImageInline(image, dstX, dstY);
}
@@ -148,7 +148,7 @@ bool NullOpenGLGraphics::drawImage2(const Image *const image,
bool NullOpenGLGraphics::drawImageInline(const Image *const image,
int dstX, int dstY)
{
- FUNC_BLOCK("Graphics::drawImage2", 1)
+ FUNC_BLOCK("Graphics::drawImage", 1)
if (!image)
return false;
@@ -918,7 +918,7 @@ void NullOpenGLGraphics::updateScreen()
void NullOpenGLGraphics::_beginDraw()
{
- pushClipArea(gcn::Rectangle(0, 0, 640, 480));
+ pushClipArea(Rect(0, 0, 640, 480));
}
void NullOpenGLGraphics::_endDraw()
@@ -935,21 +935,21 @@ SDL_Surface* NullOpenGLGraphics::getScreenshot()
return nullptr;
}
-bool NullOpenGLGraphics::pushClipArea(gcn::Rectangle area)
+bool NullOpenGLGraphics::pushClipArea(Rect area)
{
int transX = 0;
int transY = 0;
if (!mClipStack.empty())
{
- const gcn::ClipRectangle &clipArea = mClipStack.top();
+ const ClipRect &clipArea = mClipStack.top();
transX = -clipArea.xOffset;
transY = -clipArea.yOffset;
}
- const bool result = gcn::Graphics::pushClipArea(area);
+ const bool result = Graphics::pushClipArea(area);
- const gcn::ClipRectangle &clipArea = mClipStack.top();
+ const ClipRect &clipArea = mClipStack.top();
transX += clipArea.xOffset;
transY += clipArea.yOffset;
@@ -958,7 +958,7 @@ bool NullOpenGLGraphics::pushClipArea(gcn::Rectangle area)
void NullOpenGLGraphics::popClipArea()
{
- gcn::Graphics::popClipArea();
+ Graphics::popClipArea();
if (mClipStack.empty())
return;
@@ -984,12 +984,12 @@ void NullOpenGLGraphics::drawLine(int x1, int y1,
drawLineArrayf(4);
}
-void NullOpenGLGraphics::drawRectangle(const gcn::Rectangle& rect)
+void NullOpenGLGraphics::drawRectangle(const Rect& rect)
{
drawRectangle(rect, false);
}
-void NullOpenGLGraphics::fillRectangle(const gcn::Rectangle& rect)
+void NullOpenGLGraphics::fillRectangle(const Rect& rect)
{
drawRectangle(rect, true);
}
@@ -1017,7 +1017,7 @@ void NullOpenGLGraphics::setTexturingAndBlending(const bool enable)
}
}
-void NullOpenGLGraphics::drawRectangle(const gcn::Rectangle& rect A_UNUSED,
+void NullOpenGLGraphics::drawRectangle(const Rect& rect A_UNUSED,
const bool filled A_UNUSED)
{
BLOCK_START("Graphics::drawRectangle")
diff --git a/src/render/nullopenglgraphics.h b/src/render/nullopenglgraphics.h
index cbab0614d..ee2a5d189 100644
--- a/src/render/nullopenglgraphics.h
+++ b/src/render/nullopenglgraphics.h
@@ -130,7 +130,7 @@ class NullOpenGLGraphics final : public Graphics
bool mTexture;
bool mIsByteColor;
- gcn::Color mByteColor;
+ Color mByteColor;
float mFloatColor;
int mMaxVertices;
bool mColorAlpha;
diff --git a/src/render/openglgraphicsdef.hpp b/src/render/openglgraphicsdef.hpp
index 89f8e63a9..5e8e3390c 100644
--- a/src/render/openglgraphicsdef.hpp
+++ b/src/render/openglgraphicsdef.hpp
@@ -88,18 +88,18 @@
void _endDraw() override final;
- bool pushClipArea(gcn::Rectangle area) override final;
+ bool pushClipArea(Rect area) override final;
void popClipArea() override final;
- void setColor(const gcn::Color &color) override final
+ void setColor(const Color &color) override final
{
mColor = color;
mColor2 = color;
mColorAlpha = (color.a != 255);
}
- void setColorAll(const gcn::Color &color, const gcn::Color &color2)
+ void setColorAll(const Color &color, const Color &color2)
{
mColor = color;
mColor2 = color2;
@@ -110,12 +110,12 @@
void drawLine(int x1, int y1, int x2, int y2) override final;
- void drawRectangle(const gcn::Rectangle &rect,
+ void drawRectangle(const Rect &rect,
const bool filled);
- void drawRectangle(const gcn::Rectangle &rect) override final;
+ void drawRectangle(const Rect &rect) override final;
- void fillRectangle(const gcn::Rectangle &rect) override final;
+ void fillRectangle(const Rect &rect) override final;
static void dumpSettings();
@@ -130,8 +130,8 @@
void updateTextureFormat();
- bool drawImage2(const Image *const image,
- int dstX, int dstY) override final;
+ bool drawImage(const Image *const image,
+ int dstX, int dstY) override final;
void drawImageCached(const Image *const image,
int x, int y) override final;
diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp
index bf9334655..faf2de76e 100644
--- a/src/render/safeopenglgraphics.cpp
+++ b/src/render/safeopenglgraphics.cpp
@@ -142,8 +142,8 @@ static inline void drawRescaledQuad(const Image *const image,
}
}
-bool SafeOpenGLGraphics::drawImage2(const Image *const image,
- int dstX, int dstY)
+bool SafeOpenGLGraphics::drawImage(const Image *const image,
+ int dstX, int dstY)
{
return drawImageInline(image, dstX, dstY);
}
@@ -151,7 +151,7 @@ bool SafeOpenGLGraphics::drawImage2(const Image *const image,
bool SafeOpenGLGraphics::drawImageInline(const Image *const image,
int dstX, int dstY)
{
- FUNC_BLOCK("Graphics::drawImage2", 1)
+ FUNC_BLOCK("Graphics::drawImage", 1)
if (!image)
return false;
@@ -459,7 +459,7 @@ void SafeOpenGLGraphics::_beginDraw()
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- pushClipArea(gcn::Rectangle(0, 0, mRect.w, mRect.h));
+ pushClipArea(Rect(0, 0, mRect.w, mRect.h));
}
void SafeOpenGLGraphics::_endDraw()
@@ -523,21 +523,21 @@ SDL_Surface* SafeOpenGLGraphics::getScreenshot()
return screenshot;
}
-bool SafeOpenGLGraphics::pushClipArea(gcn::Rectangle area)
+bool SafeOpenGLGraphics::pushClipArea(Rect area)
{
int transX = 0;
int transY = 0;
if (!mClipStack.empty())
{
- const gcn::ClipRectangle &clipArea = mClipStack.top();
+ const ClipRect &clipArea = mClipStack.top();
transX = -clipArea.xOffset;
transY = -clipArea.yOffset;
}
- const bool result = gcn::Graphics::pushClipArea(area);
+ const bool result = Graphics::pushClipArea(area);
- const gcn::ClipRectangle &clipArea = mClipStack.top();
+ const ClipRect &clipArea = mClipStack.top();
glPushMatrix();
glTranslatef(static_cast<GLfloat>(transX + clipArea.xOffset),
@@ -551,13 +551,13 @@ bool SafeOpenGLGraphics::pushClipArea(gcn::Rectangle area)
void SafeOpenGLGraphics::popClipArea()
{
- gcn::Graphics::popClipArea();
+ Graphics::popClipArea();
if (mClipStack.empty())
return;
glPopMatrix();
- const gcn::ClipRectangle &clipArea = mClipStack.top();
+ const ClipRect &clipArea = mClipStack.top();
glScissor(clipArea.x * mScale,
(mRect.h - clipArea.y - clipArea.height) * mScale,
clipArea.width * mScale,
@@ -613,12 +613,12 @@ void SafeOpenGLGraphics::drawLine(int x1, int y1, int x2, int y2)
glEnd();
}
-void SafeOpenGLGraphics::drawRectangle(const gcn::Rectangle& rect)
+void SafeOpenGLGraphics::drawRectangle(const Rect& rect)
{
drawRectangle(rect, false);
}
-void SafeOpenGLGraphics::fillRectangle(const gcn::Rectangle& rect)
+void SafeOpenGLGraphics::fillRectangle(const Rect& rect)
{
drawRectangle(rect, true);
}
@@ -661,7 +661,7 @@ void SafeOpenGLGraphics::setTexturingAndBlending(const bool enable)
}
}
-void SafeOpenGLGraphics::drawRectangle(const gcn::Rectangle& rect,
+void SafeOpenGLGraphics::drawRectangle(const Rect& rect,
const bool filled)
{
BLOCK_START("Graphics::drawRectangle")
diff --git a/src/render/safeopenglgraphics.h b/src/render/safeopenglgraphics.h
index 28d61b59a..fbb156c6c 100644
--- a/src/render/safeopenglgraphics.h
+++ b/src/render/safeopenglgraphics.h
@@ -90,7 +90,7 @@ class SafeOpenGLGraphics final : public Graphics
bool mTexture;
bool mIsByteColor;
- gcn::Color mByteColor;
+ Color mByteColor;
float mFloatColor;
bool mColorAlpha;
FBOInfo mFbo;
diff --git a/src/render/sdl2graphics.cpp b/src/render/sdl2graphics.cpp
index 97f231d08..8c78c8cdd 100644
--- a/src/render/sdl2graphics.cpp
+++ b/src/render/sdl2graphics.cpp
@@ -20,6 +20,49 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#ifdef USE_SDL2
#include "render/sdl2graphics.h"
@@ -31,12 +74,13 @@
#include "graphicsvertexes.h"
#include "logger.h"
+#include "resources/image.h"
#include "resources/imagehelper.h"
#include "resources/sdl2imagehelper.h"
#include "utils/sdlcheckutils.h"
-#include <guichan/sdl/sdlpixel.hpp>
+#include "utils/sdlpixel.h"
#include "debug.h"
@@ -92,7 +136,7 @@ bool SDLGraphics::drawRescaledImage(const Image *const image,
if (!image->mTexture)
return false;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
const SDL_Rect &bounds = image->mBounds;
const SDL_Rect srcRect =
{
@@ -113,8 +157,8 @@ bool SDLGraphics::drawRescaledImage(const Image *const image,
&srcRect, &dstRect) < 0);
}
-bool SDLGraphics::drawImage2(const Image *const image,
- int dstX, int dstY)
+bool SDLGraphics::drawImage(const Image *const image,
+ int dstX, int dstY)
{
return drawImageInline(image, dstX, dstY);
}
@@ -122,12 +166,12 @@ bool SDLGraphics::drawImage2(const Image *const image,
bool SDLGraphics::drawImageInline(const Image *const image,
int dstX, int dstY)
{
- FUNC_BLOCK("Graphics::drawImage2", 1)
+ FUNC_BLOCK("Graphics::drawImage", 1)
// Check that preconditions for blitting are met.
if (!mWindow || !image || !image->mTexture)
return false;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
if (!top.width || !top.height)
return false;
@@ -159,7 +203,7 @@ void SDLGraphics::drawImageCached(const Image *const image,
if (!mWindow || !image || !image->mTexture)
return;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
if (!top.width || !top.height)
return;
@@ -194,7 +238,7 @@ void SDLGraphics::drawPatternCached(const Image *const image,
if (!image->mTexture)
return;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
if (!top.width || !top.height)
return;
@@ -252,7 +296,7 @@ void SDLGraphics::drawPatternInline(const Image *const image,
if (!image->mTexture)
return;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
if (!top.width || !top.height)
return;
@@ -303,7 +347,7 @@ void SDLGraphics::drawRescaledPattern(const Image *const image,
if (scaledHeight == 0 || scaledWidth == 0)
return;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
if (!top.width || !top.height)
return;
@@ -363,7 +407,7 @@ void SDLGraphics::calcPatternInline(ImageVertexes* const vert,
if (!vert || !mWindow || !image || !image->mTexture)
return;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
if (!top.width || !top.height)
return;
@@ -448,7 +492,7 @@ void SDLGraphics::calcTileSDL(ImageVertexes *const vert, int x, int y) const
if (!vert || !vert->image || !vert->image->mTexture)
return;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
if (!top.width || !top.height)
return;
@@ -594,9 +638,9 @@ void SDLGraphics::calcWindow(ImageCollection *const vertCol,
calcImageRect(vert, x, y, w, h, imgRect);
}
-void SDLGraphics::fillRectangle(const gcn::Rectangle &rectangle)
+void SDLGraphics::fillRectangle(const Rect &rectangle)
{
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
const SDL_Rect rect =
{
static_cast<int32_t>(rectangle.x + top.xOffset),
@@ -611,7 +655,7 @@ void SDLGraphics::fillRectangle(const gcn::Rectangle &rectangle)
void SDLGraphics::_beginDraw()
{
- pushClipArea(gcn::Rectangle(0, 0, mRect.w, mRect.h));
+ pushClipArea(Rect(0, 0, mRect.w, mRect.h));
}
void SDLGraphics::_endDraw()
@@ -619,11 +663,11 @@ void SDLGraphics::_endDraw()
popClipArea();
}
-bool SDLGraphics::pushClipArea(gcn::Rectangle area)
+bool SDLGraphics::pushClipArea(Rect area)
{
- const bool result = gcn::Graphics::pushClipArea(area);
+ const bool result = Graphics::pushClipArea(area);
- const gcn::ClipRectangle &carea = mClipStack.top();
+ const ClipRect &carea = mClipStack.top();
const SDL_Rect rect =
{
static_cast<int32_t>(carea.x),
@@ -637,12 +681,12 @@ bool SDLGraphics::pushClipArea(gcn::Rectangle area)
void SDLGraphics::popClipArea()
{
- gcn::Graphics::popClipArea();
+ Graphics::popClipArea();
if (mClipStack.empty())
return;
- const gcn::ClipRectangle &carea = mClipStack.top();
+ const ClipRect &carea = mClipStack.top();
const SDL_Rect rect =
{
static_cast<int32_t>(carea.x),
@@ -659,7 +703,7 @@ void SDLGraphics::drawPoint(int x, int y)
if (mClipStack.empty())
return;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
x += top.xOffset;
y += top.yOffset;
@@ -678,9 +722,9 @@ void SDLGraphics::drawPoint(int x, int y)
}
-void SDLGraphics::drawRectangle(const gcn::Rectangle &rectangle)
+void SDLGraphics::drawRectangle(const Rect &rectangle)
{
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
SDL_SetRenderDrawColor(mRenderer, mColor.r, mColor.g, mColor.b, mColor.a);
@@ -702,7 +746,7 @@ void SDLGraphics::drawRectangle(const gcn::Rectangle &rectangle)
void SDLGraphics::drawLine(int x1, int y1, int x2, int y2)
{
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
SDL_SetRenderDrawColor(mRenderer, mColor.r, mColor.g, mColor.b, mColor.a);
diff --git a/src/render/sdl2graphics.h b/src/render/sdl2graphics.h
index c4e0d74a7..9f604d9b5 100644
--- a/src/render/sdl2graphics.h
+++ b/src/render/sdl2graphics.h
@@ -20,6 +20,49 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#ifndef RENDER_SDL2GRAPHICS_H
#define RENDER_SDL2GRAPHICS_H
@@ -58,7 +101,7 @@ class SDLGraphics final : public Graphics
void _endDraw() override final;
- bool pushClipArea(gcn::Rectangle rect) override final;
+ bool pushClipArea(Rect rect) override final;
void popClipArea() override final;
@@ -120,9 +163,9 @@ class SDLGraphics final : public Graphics
const int w, const int h,
const ImageRect &imgRect) override final;
- void fillRectangle(const gcn::Rectangle &rect) override final;
+ void fillRectangle(const Rect &rect) override final;
- void drawRectangle(const gcn::Rectangle &rect) override final;
+ void drawRectangle(const Rect &rect) override final;
void drawPoint(int x, int y) override final;
@@ -139,8 +182,8 @@ class SDLGraphics final : public Graphics
void setRendererFlags(const uint32_t flags)
{ mRendererFlags = flags; }
- bool drawImage2(const Image *const image,
- int dstX, int dstY) override final;
+ bool drawImage(const Image *const image,
+ int dstX, int dstY) override final;
void drawImageCached(const Image *const image,
int x, int y) override final;
@@ -161,7 +204,7 @@ class SDLGraphics final : public Graphics
protected:
uint32_t mRendererFlags;
uint32_t mOldPixel;
- int mOldAlpha;
+ unsigned int mOldAlpha;
private:
void inline calcImageRect(ImageVertexes *const vert,
diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp
index 22a66a911..0844cd52e 100644
--- a/src/render/sdl2softwaregraphics.cpp
+++ b/src/render/sdl2softwaregraphics.cpp
@@ -31,12 +31,13 @@
#include "graphicsvertexes.h"
#include "logger.h"
+#include "resources/image.h"
#include "resources/imagehelper.h"
#include "resources/sdl2softwareimagehelper.h"
#include "utils/sdlcheckutils.h"
-#include <guichan/sdl/sdlpixel.hpp>
+#include "utils/sdlpixel.h"
#include "debug.h"
@@ -81,7 +82,7 @@ bool SDL2SoftwareGraphics::drawRescaledImage(const Image *const image,
if (!tmpImage->mSDLSurface)
return false;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
const SDL_Rect &bounds = image->mBounds;
SDL_Rect srcRect =
@@ -108,8 +109,8 @@ bool SDL2SoftwareGraphics::drawRescaledImage(const Image *const image,
return returnValue;
}
-bool SDL2SoftwareGraphics::drawImage2(const Image *const image,
- int dstX, int dstY)
+bool SDL2SoftwareGraphics::drawImage(const Image *const image,
+ int dstX, int dstY)
{
return drawImageInline(image, dstX, dstY);
}
@@ -117,12 +118,12 @@ bool SDL2SoftwareGraphics::drawImage2(const Image *const image,
bool SDL2SoftwareGraphics::drawImageInline(const Image *const image,
int dstX, int dstY)
{
- FUNC_BLOCK("Graphics::drawImage2", 1)
+ FUNC_BLOCK("Graphics::drawImage", 1)
// Check that preconditions for blitting are met.
if (!mSurface || !image || !image->mSDLSurface)
return false;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
const SDL_Rect &bounds = image->mBounds;
SDL_Surface *const src = image->mSDLSurface;
@@ -210,7 +211,7 @@ void SDL2SoftwareGraphics::drawImageCached(const Image *const image,
if (!mSurface || !image || !image->mSDLSurface)
return;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
const SDL_Rect &bounds = image->mBounds;
SDL_Surface *const src = image->mSDLSurface;
@@ -306,7 +307,7 @@ void SDL2SoftwareGraphics::drawPatternCached(const Image *const image,
if (iw == 0 || ih == 0)
return;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
const int xOffset = top.xOffset + x;
const int yOffset = top.yOffset + y;
const int srcX = bounds.x;
@@ -427,7 +428,7 @@ void SDL2SoftwareGraphics::drawPatternInline(const Image *const image,
if (iw == 0 || ih == 0)
return;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
const int xOffset = top.xOffset + x;
const int yOffset = top.yOffset + y;
const int srcX = bounds.x;
@@ -546,7 +547,7 @@ void SDL2SoftwareGraphics::drawRescaledPattern(const Image *const image,
if (iw == 0 || ih == 0)
return;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
const int xOffset = top.xOffset + x;
const int yOffset = top.yOffset + y;
const int srcX = bounds.x;
@@ -609,7 +610,7 @@ void SDL2SoftwareGraphics::calcPatternInline(ImageVertexes* const vert,
if (iw == 0 || ih == 0)
return;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
const int xOffset = top.xOffset + x;
const int yOffset = top.yOffset + y;
const int srcX = bounds.x;
@@ -694,7 +695,7 @@ void SDL2SoftwareGraphics::calcTileSDL(ImageVertexes *const vert,
return;
const Image *const image = vert->image;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
const SDL_Rect &bounds = image->mBounds;
DoubleRect *rect = new DoubleRect();
@@ -916,15 +917,15 @@ int SDL2SoftwareGraphics::SDL_FakeUpperBlit(const SDL_Surface *const src,
return 0;
}
-void SDL2SoftwareGraphics::fillRectangle(const gcn::Rectangle &rectangle)
+void SDL2SoftwareGraphics::fillRectangle(const Rect &rectangle)
{
FUNC_BLOCK("Graphics::fillRectangle", 1)
if (mClipStack.empty())
return;
- const gcn::ClipRectangle& top = mClipStack.top();
+ const ClipRect& top = mClipStack.top();
- gcn::Rectangle area = rectangle;
+ Rect area = rectangle;
area.x += top.xOffset;
area.y += top.yOffset;
@@ -967,7 +968,7 @@ void SDL2SoftwareGraphics::fillRectangle(const gcn::Rectangle &rectangle)
for (x = x1; x < x2; x++)
{
uint8_t *const p = p0 + x * 2;
- *reinterpret_cast<uint16_t *>(p) = gcn::SDLAlpha16(
+ *reinterpret_cast<uint16_t *>(p) = SDLAlpha16(
static_cast<uint16_t>(pixel),
*reinterpret_cast<uint16_t *>(p),
static_cast<uint8_t>(mColor.a), mSurface->format);
@@ -1116,7 +1117,7 @@ void SDL2SoftwareGraphics::fillRectangle(const gcn::Rectangle &rectangle)
void SDL2SoftwareGraphics::_beginDraw()
{
- pushClipArea(gcn::Rectangle(0, 0, mRect.w, mRect.h));
+ pushClipArea(Rect(0, 0, mRect.w, mRect.h));
}
void SDL2SoftwareGraphics::_endDraw()
@@ -1124,11 +1125,11 @@ void SDL2SoftwareGraphics::_endDraw()
popClipArea();
}
-bool SDL2SoftwareGraphics::pushClipArea(gcn::Rectangle area)
+bool SDL2SoftwareGraphics::pushClipArea(Rect area)
{
- const bool result = gcn::Graphics::pushClipArea(area);
+ const bool result = Graphics::pushClipArea(area);
- const gcn::ClipRectangle &carea = mClipStack.top();
+ const ClipRect &carea = mClipStack.top();
const SDL_Rect rect =
{
static_cast<int32_t>(carea.x),
@@ -1142,12 +1143,12 @@ bool SDL2SoftwareGraphics::pushClipArea(gcn::Rectangle area)
void SDL2SoftwareGraphics::popClipArea()
{
- gcn::Graphics::popClipArea();
+ Graphics::popClipArea();
if (mClipStack.empty())
return;
- const gcn::ClipRectangle &carea = mClipStack.top();
+ const ClipRect &carea = mClipStack.top();
const SDL_Rect rect =
{
static_cast<int32_t>(carea.x),
@@ -1164,7 +1165,7 @@ void SDL2SoftwareGraphics::drawPoint(int x, int y)
if (mClipStack.empty())
return;
- const gcn::ClipRectangle& top = mClipStack.top();
+ const ClipRect& top = mClipStack.top();
x += top.xOffset;
y += top.yOffset;
@@ -1183,7 +1184,7 @@ void SDL2SoftwareGraphics::drawHLine(int x1, int y, int x2)
if (mClipStack.empty())
return;
- const gcn::ClipRectangle& top = mClipStack.top();
+ const ClipRect& top = mClipStack.top();
const int xOffset = top.xOffset;
x1 += xOffset;
@@ -1309,7 +1310,7 @@ void SDL2SoftwareGraphics::drawVLine(int x, int y1, int y2)
if (mClipStack.empty())
return;
- const gcn::ClipRectangle& top = mClipStack.top();
+ const ClipRect& top = mClipStack.top();
const int yOffset = top.yOffset;
x += top.xOffset;
@@ -1439,7 +1440,7 @@ void SDL2SoftwareGraphics::drawVLine(int x, int y1, int y2)
SDL_UnlockSurface(mSurface);
}
-void SDL2SoftwareGraphics::drawRectangle(const gcn::Rectangle &rectangle)
+void SDL2SoftwareGraphics::drawRectangle(const Rect &rectangle)
{
const int x1 = rectangle.x;
const int x2 = x1 + rectangle.width - 1;
diff --git a/src/render/sdl2softwaregraphics.h b/src/render/sdl2softwaregraphics.h
index 3ac6cb212..6ef750dbd 100644
--- a/src/render/sdl2softwaregraphics.h
+++ b/src/render/sdl2softwaregraphics.h
@@ -58,7 +58,7 @@ class SDL2SoftwareGraphics final : public Graphics
void _endDraw();
- bool pushClipArea(gcn::Rectangle rect);
+ bool pushClipArea(Rect rect);
void popClipArea();
@@ -120,9 +120,9 @@ class SDL2SoftwareGraphics final : public Graphics
const int w, const int h,
const ImageRect &imgRect) override final;
- void fillRectangle(const gcn::Rectangle &rect) override final;
+ void fillRectangle(const Rect &rect) override final;
- void drawRectangle(const gcn::Rectangle &rect) override final;
+ void drawRectangle(const Rect &rect) override final;
void drawPoint(int x, int y) override final;
@@ -141,8 +141,8 @@ class SDL2SoftwareGraphics final : public Graphics
bool resizeScreen(const int width, const int height) override final;
- bool drawImage2(const Image *const image,
- int dstX, int dstY) override final;
+ bool drawImage(const Image *const image,
+ int dstX, int dstY) override final;
void drawImageCached(const Image *const image,
int x, int y) override final;
@@ -173,7 +173,7 @@ class SDL2SoftwareGraphics final : public Graphics
uint32_t mRendererFlags;
SDL_Surface *mSurface;
uint32_t mOldPixel;
- int mOldAlpha;
+ unsigned int mOldAlpha;
private:
void inline calcImageRect(ImageVertexes *const vert,
diff --git a/src/render/sdlgraphics.cpp b/src/render/sdlgraphics.cpp
index e0e22cac9..44dcc426d 100644
--- a/src/render/sdlgraphics.cpp
+++ b/src/render/sdlgraphics.cpp
@@ -31,7 +31,9 @@
#include "utils/sdlcheckutils.h"
-#include <guichan/sdl/sdlpixel.hpp>
+#include "utils/sdlpixel.h"
+
+#include "resources/image.h"
#include "debug.h"
@@ -74,7 +76,7 @@ bool SDLGraphics::drawRescaledImage(const Image *const image,
if (!tmpImage->mSDLSurface)
return false;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
const SDL_Rect &bounds = image->mBounds;
SDL_Rect srcRect =
@@ -101,8 +103,8 @@ bool SDLGraphics::drawRescaledImage(const Image *const image,
return returnValue;
}
-bool SDLGraphics::drawImage2(const Image *const image,
- int dstX, int dstY)
+bool SDLGraphics::drawImage(const Image *const image,
+ int dstX, int dstY)
{
return drawImageInline(image, dstX, dstY);
}
@@ -110,12 +112,12 @@ bool SDLGraphics::drawImage2(const Image *const image,
bool SDLGraphics::drawImageInline(const Image *const image,
int dstX, int dstY)
{
- FUNC_BLOCK("Graphics::drawImage2", 1)
+ FUNC_BLOCK("Graphics::drawImage", 1)
// Check that preconditions for blitting are met.
if (!mWindow || !image || !image->mSDLSurface)
return false;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
const SDL_Rect &bounds = image->mBounds;
SDL_Surface *const src = image->mSDLSurface;
@@ -203,7 +205,7 @@ void SDLGraphics::drawImageCached(const Image *const image,
if (!mWindow || !image || !image->mSDLSurface)
return;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
const SDL_Rect &bounds = image->mBounds;
SDL_Surface *const src = image->mSDLSurface;
@@ -299,7 +301,7 @@ void SDLGraphics::drawPatternCached(const Image *const image,
if (iw == 0 || ih == 0)
return;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
const int xOffset = top.xOffset + x;
const int yOffset = top.yOffset + y;
const int srcX = bounds.x;
@@ -420,7 +422,7 @@ void SDLGraphics::drawPatternInline(const Image *const image,
if (iw == 0 || ih == 0)
return;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
const int xOffset = top.xOffset + x;
const int yOffset = top.yOffset + y;
const int srcX = bounds.x;
@@ -539,7 +541,7 @@ void SDLGraphics::drawRescaledPattern(const Image *const image,
if (iw == 0 || ih == 0)
return;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
const int xOffset = top.xOffset + x;
const int yOffset = top.yOffset + y;
const int srcX = bounds.x;
@@ -602,7 +604,7 @@ void SDLGraphics::calcPatternInline(ImageVertexes* const vert,
if (iw == 0 || ih == 0)
return;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
const int xOffset = top.xOffset + x;
const int yOffset = top.yOffset + y;
const int srcX = bounds.x;
@@ -686,7 +688,7 @@ void SDLGraphics::calcTileSDL(ImageVertexes *const vert, int x, int y) const
return;
const Image *const image = vert->image;
- const gcn::ClipRectangle &top = mClipStack.top();
+ const ClipRect &top = mClipStack.top();
const SDL_Rect &bounds = image->mBounds;
DoubleRect *rect = new DoubleRect();
@@ -912,15 +914,15 @@ int SDLGraphics::SDL_FakeUpperBlit(const SDL_Surface *const src,
return 0;
}
-void SDLGraphics::fillRectangle(const gcn::Rectangle& rectangle)
+void SDLGraphics::fillRectangle(const Rect& rectangle)
{
FUNC_BLOCK("Graphics::fillRectangle", 1)
if (mClipStack.empty())
return;
- const gcn::ClipRectangle& top = mClipStack.top();
+ const ClipRect& top = mClipStack.top();
- gcn::Rectangle area = rectangle;
+ Rect area = rectangle;
area.x += top.xOffset;
area.y += top.yOffset;
@@ -963,7 +965,7 @@ void SDLGraphics::fillRectangle(const gcn::Rectangle& rectangle)
for (x = x1; x < x2; x++)
{
uint8_t *const p = p0 + x * 2;
- *reinterpret_cast<uint16_t *>(p) = gcn::SDLAlpha16(
+ *reinterpret_cast<uint16_t *>(p) = SDLAlpha16(
static_cast<uint16_t>(pixel),
*reinterpret_cast<uint16_t *>(p),
static_cast<uint8_t>(mColor.a), mWindow->format);
@@ -1112,7 +1114,7 @@ void SDLGraphics::fillRectangle(const gcn::Rectangle& rectangle)
void SDLGraphics::_beginDraw()
{
- pushClipArea(gcn::Rectangle(0, 0, mRect.w, mRect.h));
+ pushClipArea(Rect(0, 0, mRect.w, mRect.h));
}
void SDLGraphics::_endDraw()
@@ -1120,10 +1122,10 @@ void SDLGraphics::_endDraw()
popClipArea();
}
-bool SDLGraphics::pushClipArea(gcn::Rectangle area)
+bool SDLGraphics::pushClipArea(Rect area)
{
- const bool result = gcn::Graphics::pushClipArea(area);
- const gcn::ClipRectangle &carea = mClipStack.top();
+ const bool result = Graphics::pushClipArea(area);
+ const ClipRect &carea = mClipStack.top();
const SDL_Rect rect =
{
static_cast<int16_t>(carea.x),
@@ -1138,12 +1140,12 @@ bool SDLGraphics::pushClipArea(gcn::Rectangle area)
void SDLGraphics::popClipArea()
{
- gcn::Graphics::popClipArea();
+ Graphics::popClipArea();
if (mClipStack.empty())
return;
- const gcn::ClipRectangle &carea = mClipStack.top();
+ const ClipRect &carea = mClipStack.top();
const SDL_Rect rect =
{
static_cast<int16_t>(carea.x),
@@ -1160,7 +1162,7 @@ void SDLGraphics::drawPoint(int x, int y)
if (mClipStack.empty())
return;
- const gcn::ClipRectangle& top = mClipStack.top();
+ const ClipRect& top = mClipStack.top();
x += top.xOffset;
y += top.yOffset;
@@ -1179,7 +1181,7 @@ void SDLGraphics::drawHLine(int x1, int y, int x2)
if (mClipStack.empty())
return;
- const gcn::ClipRectangle& top = mClipStack.top();
+ const ClipRect& top = mClipStack.top();
const int xOffset = top.xOffset;
x1 += xOffset;
@@ -1305,7 +1307,7 @@ void SDLGraphics::drawVLine(int x, int y1, int y2)
if (mClipStack.empty())
return;
- const gcn::ClipRectangle& top = mClipStack.top();
+ const ClipRect& top = mClipStack.top();
const int yOffset = top.yOffset;
x += top.xOffset;
@@ -1435,7 +1437,7 @@ void SDLGraphics::drawVLine(int x, int y1, int y2)
SDL_UnlockSurface(mWindow);
}
-void SDLGraphics::drawRectangle(const gcn::Rectangle &rectangle)
+void SDLGraphics::drawRectangle(const Rect &rectangle)
{
const int x1 = rectangle.x;
const int x2 = x1 + rectangle.width - 1;
diff --git a/src/render/sdlgraphics.h b/src/render/sdlgraphics.h
index 17b54db92..170c0010b 100644
--- a/src/render/sdlgraphics.h
+++ b/src/render/sdlgraphics.h
@@ -58,7 +58,7 @@ class SDLGraphics final : public Graphics
void _endDraw() override final;
- bool pushClipArea(gcn::Rectangle rect) override final;
+ bool pushClipArea(Rect rect) override final;
void popClipArea() override final;
@@ -120,9 +120,9 @@ class SDLGraphics final : public Graphics
const int w, const int h,
const ImageRect &imgRect) override final;
- void fillRectangle(const gcn::Rectangle &rect) override final;
+ void fillRectangle(const Rect &rect) override final;
- void drawRectangle(const gcn::Rectangle &rect) override final;
+ void drawRectangle(const Rect &rect) override final;
void drawPoint(int x, int y) override final;
@@ -136,8 +136,8 @@ class SDLGraphics final : public Graphics
const bool resize,
const bool noFrame) override final;
- bool drawImage2(const Image *const image,
- int dstX, int dstY) override final;
+ bool drawImage(const Image *const image,
+ int dstX, int dstY) override final;
void drawImageCached(const Image *const image,
int x, int y) override final;
@@ -166,7 +166,7 @@ class SDLGraphics final : public Graphics
void drawVLine(int x, int y1, int y2);
uint32_t mOldPixel;
- int mOldAlpha;
+ unsigned int mOldAlpha;
private:
void inline calcImageRect(ImageVertexes *const vert,
diff --git a/src/render/surfacegraphics.cpp b/src/render/surfacegraphics.cpp
index 8834bb171..e6aee752f 100644
--- a/src/render/surfacegraphics.cpp
+++ b/src/render/surfacegraphics.cpp
@@ -42,10 +42,10 @@ SurfaceGraphics::~SurfaceGraphics()
{
}
-bool SurfaceGraphics::drawImage2(const Image *const image,
- int dstX, int dstY)
+bool SurfaceGraphics::drawImage(const Image *const image,
+ int dstX, int dstY)
{
- FUNC_BLOCK("Graphics::drawImage2", 1)
+ FUNC_BLOCK("Graphics::drawImage", 1)
// Check that preconditions for blitting are met.
if (!mTarget || !image || !image->mSDLSurface)
return false;
diff --git a/src/render/surfacegraphics.h b/src/render/surfacegraphics.h
index c3e6cb2ee..8e85356da 100644
--- a/src/render/surfacegraphics.h
+++ b/src/render/surfacegraphics.h
@@ -63,7 +63,7 @@ class SurfaceGraphics final : public Graphics
void _endDraw() override final
{ }
- bool pushClipArea(gcn::Rectangle rect A_UNUSED) override final
+ bool pushClipArea(Rect rect A_UNUSED) override final
{ return true; }
void popClipArea() override final
@@ -158,10 +158,10 @@ class SurfaceGraphics final : public Graphics
BlitMode getBlitMode() const A_WARN_UNUSED
{ return mBlitMode; }
- void fillRectangle(const gcn::Rectangle &rect A_UNUSED) override final
+ void fillRectangle(const Rect &rect A_UNUSED) override final
{ }
- void drawRectangle(const gcn::Rectangle &rect A_UNUSED) override final
+ void drawRectangle(const Rect &rect A_UNUSED) override final
{ }
void drawPoint(int x A_UNUSED, int y A_UNUSED) override final
@@ -179,8 +179,8 @@ class SurfaceGraphics final : public Graphics
const bool noFrame A_UNUSED) override final
{ return false; }
- bool drawImage2(const Image *const image,
- int dstX, int dstY) override final;
+ bool drawImage(const Image *const image,
+ int dstX, int dstY) override final;
void drawImageCached(const Image *const image,
int x, int y) override final;
diff --git a/src/resources/atlasmanager.cpp b/src/resources/atlasmanager.cpp
index 71a6382dc..870de40a9 100644
--- a/src/resources/atlasmanager.cpp
+++ b/src/resources/atlasmanager.cpp
@@ -250,7 +250,7 @@ SDL_Surface *AtlasManager::createSDLAtlas(TextureAtlas *const atlas)
#else
SDL_SetAlpha(image->mSDLSurface, 0, SDL_ALPHA_OPAQUE);
#endif
- graphics->drawImage2(image, item->x, item->y);
+ graphics->drawImage(image, item->x, item->y);
}
}
}
diff --git a/src/resources/db/monsterdb.cpp b/src/resources/db/monsterdb.cpp
index 9b9112f0f..7bdbeb33d 100644
--- a/src/resources/db/monsterdb.cpp
+++ b/src/resources/db/monsterdb.cpp
@@ -68,14 +68,8 @@ void MonsterDB::loadXmlFile(const std::string &fileName)
return;
}
-#ifdef MANASERV_SUPPORT
- const int offset = XML::getProperty(rootNode, "offset",
- Net::getNetworkType() != ServerInfo::MANASERV
- ? OLD_TMWATHENA_OFFSET : 0);
-#else
const int offset = XML::getProperty(rootNode,
"offset", OLD_TMWATHENA_OFFSET);
-#endif
// iterate <monster>s
for_each_xml_child_node(monsterNode, rootNode)
diff --git a/src/resources/db/weaponsdb.cpp b/src/resources/db/weaponsdb.cpp
new file mode 100644
index 000000000..6e8e4ce1f
--- /dev/null
+++ b/src/resources/db/weaponsdb.cpp
@@ -0,0 +1,76 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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/db/weaponsdb.h"
+
+#include "utils/xmlutils.h"
+
+#include "debug.h"
+
+namespace
+{
+ WeaponsInfos mBows;
+ WeaponsInfos mSwords;
+ WeaponsInfos mShields;
+ bool mLoaded = false;
+}
+
+static void loadDB(const std::string &name, WeaponsInfos &arr)
+{
+ readXmlIntVector("weapons.xml",
+ "weapons",
+ name,
+ "item",
+ "id",
+ arr);
+}
+
+void WeaponsDB::load()
+{
+ if (mLoaded)
+ unload();
+
+ loadDB("swords", mSwords);
+ loadDB("bows", mBows);
+ loadDB("shields", mShields);
+}
+
+void WeaponsDB::unload()
+{
+ mBows.clear();
+ mSwords.clear();
+ mShields.clear();
+ mLoaded = false;
+}
+
+const WeaponsInfos &WeaponsDB::getBows()
+{
+ return mBows;
+}
+
+const WeaponsInfos &WeaponsDB::getSwords()
+{
+ return mSwords;
+}
+
+const WeaponsInfos &WeaponsDB::getShields()
+{
+ return mShields;
+}
diff --git a/src/resources/db/weaponsdb.h b/src/resources/db/weaponsdb.h
new file mode 100644
index 000000000..33688b338
--- /dev/null
+++ b/src/resources/db/weaponsdb.h
@@ -0,0 +1,44 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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 RESOURCES_DB_WEAPONSDB_H
+#define RESOURCES_DB_WEAPONSDB_H
+
+#include <vector>
+
+#include "localconsts.h"
+
+typedef std::vector<int> WeaponsInfos;
+typedef WeaponsInfos::const_iterator WeaponsInfosIter;
+
+namespace WeaponsDB
+{
+ void load();
+
+ void unload();
+
+ const WeaponsInfos &getBows();
+
+ const WeaponsInfos &getSwords();
+
+ const WeaponsInfos &getShields();
+} // namespace WeaponsDB
+
+#endif // RESOURCES_DB_WEAPONSDB_H
diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp
index a1d925a1f..4f9e8a738 100644
--- a/src/resources/dye.cpp
+++ b/src/resources/dye.cpp
@@ -88,7 +88,7 @@ DyePalette::DyePalette(const std::string &description,
logger->log("Error, invalid embedded palette: %s", description.c_str());
}
-int DyePalette::hexDecode(const signed char c)
+unsigned int DyePalette::hexDecode(const signed char c)
{
if ('0' <= c && c <= '9')
return c - '0';
diff --git a/src/resources/dye.h b/src/resources/dye.h
index a68839e47..b6003624b 100644
--- a/src/resources/dye.h
+++ b/src/resources/dye.h
@@ -82,7 +82,7 @@ class DyePalette final
void replaceAOGLColor(uint32_t *restrict pixels,
const int bufSize) const;
- static int hexDecode(const signed char c) A_WARN_UNUSED;
+ static unsigned int hexDecode(const signed char c) A_WARN_UNUSED;
private:
std::vector<DyeColor> mColors;
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index e053e0035..4da901b09 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -214,6 +214,7 @@ void MapReader::addLayerToList(const std::string &fileName)
mKnownLayers[name] = childNode;
mKnownDocs.insert(doc);
}
+ delete doc;
}
Map *MapReader::readMap(const std::string &restrict filename,
diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp
index 63f15c18f..075c98c06 100644
--- a/src/simpleanimation.cpp
+++ b/src/simpleanimation.cpp
@@ -29,7 +29,6 @@
#include "resources/animation.h"
#include "resources/dye.h"
-#include "resources/image.h"
#include "resources/imageset.h"
#include "resources/resourcemanager.h"
@@ -79,8 +78,9 @@ void SimpleAnimation::draw(Graphics *const graphics,
if (!mCurrentFrame || !mCurrentFrame->image)
return;
- graphics->drawImage2(mCurrentFrame->image,
- posX + mCurrentFrame->offsetX, posY + mCurrentFrame->offsetY);
+ graphics->drawImage(mCurrentFrame->image,
+ posX + mCurrentFrame->offsetX,
+ posY + mCurrentFrame->offsetY);
}
void SimpleAnimation::reset()
diff --git a/src/soundmanager.h b/src/soundmanager.h
index 9eb1ea8a2..9a09f383d 100644
--- a/src/soundmanager.h
+++ b/src/soundmanager.h
@@ -25,7 +25,7 @@
#include <SDL_mixer.h>
-#include "configlistener.h"
+#include "listeners/configlistener.h"
#include <string>
diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp
index 049c010b3..647c6dd99 100644
--- a/src/statuseffect.cpp
+++ b/src/statuseffect.cpp
@@ -22,12 +22,15 @@
#include "statuseffect.h"
+#include "animatedsprite.h"
#include "configuration.h"
#include "logger.h"
#include "soundmanager.h"
#include "gui/widgets/tabs/chattab.h"
+#include "particle/particle.h"
+
#include "resources/beingcommon.h"
#include <map>
diff --git a/src/statuseffect.h b/src/statuseffect.h
index 6dda71cfc..8bb164820 100644
--- a/src/statuseffect.h
+++ b/src/statuseffect.h
@@ -23,12 +23,13 @@
#ifndef STATUSEFFECT_H
#define STATUSEFFECT_H
-#include "animatedsprite.h"
-
-#include "particle/particle.h"
+#include <string>
#include "localconsts.h"
+class AnimatedSprite;
+class Particle;
+
class StatusEffect final
{
public:
diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp
index a0e4f98dc..584bdb5cb 100644
--- a/src/test/testlauncher.cpp
+++ b/src/test/testlauncher.cpp
@@ -94,7 +94,7 @@ int TestLauncher::testBackend() const
for (int f = 0; f < cnt; f ++)
{
- mainGraphics->drawImage2(img, cnt * 7, cnt * 5);
+ mainGraphics->drawImage(img, cnt * 7, cnt * 5);
mainGraphics->updateScreen();
}
@@ -152,11 +152,11 @@ int TestLauncher::testFps()
{
for (int y = 0; y < 600; y += 50)
{
- mainGraphics->drawImage2(img[idx], x, y);
+ mainGraphics->drawImage(img[idx], x, y);
idx ++;
if (idx > sz)
idx = 0;
- mainGraphics->drawImage2(img[idx], x, y);
+ mainGraphics->drawImage(img[idx], x, y);
idx ++;
if (idx > sz)
idx = 0;
@@ -211,9 +211,9 @@ int TestLauncher::testInternal()
{
for (int y = 0; y < 600; y += 25)
{
- mainGraphics->drawImage2(img[idx], x, y);
- mainGraphics->drawImage2(img[idx], x + 1, y);
- mainGraphics->drawImage2(img[idx], x, y + 5);
+ mainGraphics->drawImage(img[idx], x, y);
+ mainGraphics->drawImage(img[idx], x + 1, y);
+ mainGraphics->drawImage(img[idx], x, y + 5);
idx ++;
if (idx > 3)
diff --git a/src/text.cpp b/src/text.cpp
index d0027b8ae..27d794d33 100644
--- a/src/text.cpp
+++ b/src/text.cpp
@@ -26,23 +26,21 @@
#include "configuration.h"
#include "textmanager.h"
+#include "gui/font.h"
#include "gui/gui.h"
-#include "gui/sdlfont.h"
#include "gui/theme.h"
#include "resources/image.h"
-#include <guichan/font.hpp>
-
#include "debug.h"
int Text::mInstances = 0;
ImageRect Text::mBubble;
Text::Text(const std::string &text, const int x, const int y,
- const gcn::Graphics::Alignment alignment,
- const gcn::Color *const color, const bool isSpeech,
- gcn::Font *const font) :
+ const Graphics::Alignment alignment,
+ const Color *const color, const bool isSpeech,
+ Font *const font) :
mFont(font ? font : (gui ? gui->getFont() : nullptr)),
mX(x),
mY(y),
@@ -78,13 +76,13 @@ Text::Text(const std::string &text, const int x, const int y,
switch (alignment)
{
- case gcn::Graphics::LEFT:
+ case Graphics::LEFT:
mXOffset = 0;
break;
- case gcn::Graphics::CENTER:
+ case Graphics::CENTER:
mXOffset = mWidth / 2;
break;
- case gcn::Graphics::RIGHT:
+ case Graphics::RIGHT:
mXOffset = mWidth;
break;
default:
@@ -114,7 +112,7 @@ Text::~Text()
}
}
-void Text::setColor(const gcn::Color *const color)
+void Text::setColor(const Color *const color)
{
mColor = color;
}
@@ -137,9 +135,11 @@ void Text::draw(Graphics *const graphics, const int xOff, const int yOff)
BLOCK_START("Text::draw")
if (mIsSpeech)
{
- static_cast<Graphics*>(graphics)->drawImageRect(
- mX - xOff - 5, mY - yOff - 5, mWidth + 10, mHeight + 10,
- mBubble);
+ graphics->drawImageRect(mX - xOff - 5,
+ mY - yOff - 5,
+ mWidth + 10,
+ mHeight + 10,
+ mBubble);
}
graphics->setColor(*mColor);
@@ -151,8 +151,8 @@ void Text::draw(Graphics *const graphics, const int xOff, const int yOff)
}
FlashText::FlashText(const std::string &text, const int x, const int y,
- const gcn::Graphics::Alignment alignment,
- const gcn::Color *const color, gcn::Font *const font) :
+ const Graphics::Alignment alignment,
+ const Color *const color, Font *const font) :
Text(text, x, y, alignment, color, false, font),
mTime(0)
{
diff --git a/src/text.h b/src/text.h
index 2c6b9b2b4..497792091 100644
--- a/src/text.h
+++ b/src/text.h
@@ -26,10 +26,12 @@
#include "render/graphics.h"
-#include <guichan/color.hpp>
+#include "gui/color.h"
#include "localconsts.h"
+class Font;
+
class Text
{
friend class TextManager;
@@ -39,9 +41,9 @@ class Text
* Constructor creates a text object to display on the screen.
*/
Text(const std::string &text, const int x, const int y,
- const gcn::Graphics::Alignment alignment,
- const gcn::Color *const color, const bool isSpeech = false,
- gcn::Font *const font = nullptr);
+ const Graphics::Alignment alignment,
+ const Color *const color, const bool isSpeech = false,
+ Font *const font = nullptr);
A_DELETE_COPY(Text)
@@ -50,7 +52,7 @@ class Text
*/
virtual ~Text();
- void setColor(const gcn::Color *const color);
+ void setColor(const Color *const color);
int getWidth() const A_WARN_UNUSED
{ return mWidth; }
@@ -70,7 +72,7 @@ class Text
const int xOff, const int yOff);
private:
- gcn::Font *mFont; /**< The font of the text */
+ Font *mFont; /**< The font of the text */
int mX; /**< Actual x-value of left of text written. */
int mY; /**< Actual y-value of top of text written. */
int mWidth; /**< The width of the text. */
@@ -78,8 +80,8 @@ class Text
int mXOffset; /**< The offset of mX from the desired x. */
static int mInstances; /**< Instances of text. */
std::string mText; /**< The text to display. */
- const gcn::Color *mColor; /**< The color of the text. */
- const gcn::Color mOutlineColor;
+ const Color *mColor; /**< The color of the text. */
+ const Color mOutlineColor;
bool mIsSpeech; /**< Is this text a speech bubble? */
protected:
@@ -90,9 +92,9 @@ class FlashText final : public Text
{
public:
FlashText(const std::string &text, const int x, const int y,
- const gcn::Graphics::Alignment alignment,
- const gcn::Color *const color,
- gcn::Font *const font = nullptr);
+ const Graphics::Alignment alignment,
+ const Color *const color,
+ Font *const font = nullptr);
A_DELETE_COPY(FlashText)
diff --git a/src/touchactions.cpp b/src/touchactions.cpp
index a79c14275..d4f7d9f6e 100644
--- a/src/touchactions.cpp
+++ b/src/touchactions.cpp
@@ -20,10 +20,10 @@
#include "touchactions.h"
-#include "mouseinput.h"
#include "touchmanager.h"
#include "input/inputmanager.h"
+#include "input/mouseinput.h"
#include "debug.h"
@@ -109,7 +109,7 @@ impHandler(padClick)
impHandler(padEvents)
{
- if (mouseInput.getType() == gcn::MouseInput::MOVED)
+ if (mouseInput.getType() == MouseInput::MOVED)
{
if (padClicked)
moveChar(mouseInput.getX(), mouseInput.getY());
diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp
index b7b926383..b1ed41fdc 100644
--- a/src/touchmanager.cpp
+++ b/src/touchmanager.cpp
@@ -22,11 +22,12 @@
#include "configuration.h"
#include "graphicsvertexes.h"
-#include "mouseinput.h"
#include "touchactions.h"
+#include "input/mouseinput.h"
+
+#include "gui/font.h"
#include "gui/gui.h"
-#include "gui/sdlfont.h"
#include "input/inputmanager.h"
@@ -34,6 +35,8 @@
#include "gui/theme.h"
+#include "resources/image.h"
+
#include "debug.h"
TouchManager touchManager;
@@ -160,7 +163,7 @@ void TouchManager::loadTouchItem(TouchItem **item, const std::string &name,
default:
break;
}
- *item = new TouchItem(text, gcn::Rectangle(x + diff, y + diff,
+ *item = new TouchItem(text, Rect(x + diff, y + diff,
width + border2, height + border2), type,
eventPressed, eventReleased, images, icon,
x + pad, y + pad, width, height,
@@ -229,7 +232,7 @@ void TouchManager::draw()
const Image *const icon = item->icon;
if (icon)
{
- mainGraphics->drawImage2(icon,
+ mainGraphics->drawImage(icon,
item->x + (item->width - icon->mBounds.w) / 2,
item->y + (item->height - icon->mBounds.h) / 2);
}
@@ -239,7 +242,7 @@ void TouchManager::draw()
if (!gui)
return;
- SDLFont *const font = boldFont;
+ Font *const font = boldFont;
mainGraphics->setColorAll(Theme::getThemeColor(Theme::TEXT),
Theme::getThemeColor(Theme::TEXT_OUTLINE));
FOR_EACH (TouchItemVectorCIter, it, mObjects)
@@ -267,7 +270,7 @@ bool TouchManager::processEvent(const MouseInput &mouseInput)
const TouchItem *const item = *it;
if (!item || (!mShow && (item != mKeyboard || !mShowKeyboard)))
continue;
- const gcn::Rectangle &rect = item->rect;
+ const Rect &rect = item->rect;
if (rect.isPointInRect(x, y))
{
MouseInput event = mouseInput;
@@ -278,13 +281,13 @@ bool TouchManager::processEvent(const MouseInput &mouseInput)
switch (mouseInput.getType())
{
- case gcn::MouseInput::PRESSED:
+ case MouseInput::PRESSED:
if (!item->eventPressed.empty())
executeAction(item->eventPressed);
else if (item->funcPressed)
item->funcPressed(event);
break;
- case gcn::MouseInput::RELEASED:
+ case MouseInput::RELEASED:
if (!item->eventReleased.empty())
executeAction(item->eventReleased);
else if (item->funcReleased)
diff --git a/src/touchmanager.h b/src/touchmanager.h
index 6f7b96a6d..d874ec452 100644
--- a/src/touchmanager.h
+++ b/src/touchmanager.h
@@ -21,19 +21,18 @@
#ifndef TOUCHMANAGER_H
#define TOUCHMANAGER_H
-#include "resources/image.h"
-
-#include "configlistener.h"
+#include "listeners/configlistener.h"
#include "input/keydata.h"
-#include <guichan/rectangle.hpp>
+#include "gui/rect.h"
#include <string>
#include <vector>
#include "localconsts.h"
+class Image;
class ImageCollection;
class ImageRect;
class MouseInput;
@@ -46,7 +45,7 @@ const int buttonsCount = 12;
struct TouchItem final
{
TouchItem(const std::string &text0,
- const gcn::Rectangle &rect0, const int type0,
+ const Rect &rect0, const int type0,
const std::string &eventPressed0,
const std::string &eventReleased0,
ImageRect *const images0, Image *const icon0,
@@ -74,7 +73,7 @@ struct TouchItem final
A_DELETE_COPY(TouchItem)
std::string text;
- gcn::Rectangle rect;
+ Rect rect;
int type;
std::string eventPressed;
std::string eventReleased;
diff --git a/src/utils/files.cpp b/src/utils/files.cpp
index 24ec9366e..d671cb0db 100644
--- a/src/utils/files.cpp
+++ b/src/utils/files.cpp
@@ -22,9 +22,10 @@
#if defined(ANDROID) || defined(__native_client__)
#include "resources/resourcemanager.h"
-#endif
#include "utils/mkdir.h"
+#endif
+
#include "utils/physfstools.h"
#include "localconsts.h"
diff --git a/src/utils/mathutils.h b/src/utils/mathutils.h
index 545a1cc4b..f5a3dc102 100644
--- a/src/utils/mathutils.h
+++ b/src/utils/mathutils.h
@@ -70,7 +70,7 @@ inline float fastSqrt(const float x) A_WARN_UNUSED;
constexpr inline float weightedAverage(const float n1, const float n2,
const float w) A_WARN_UNUSED;
constexpr inline int roundDouble(const double v) A_WARN_UNUSED;
-inline int powerOfTwo(const int input) A_WARN_UNUSED;
+inline int powerOfTwo(const unsigned int input) A_WARN_UNUSED;
inline uint16_t getCrc16(const std::string &str)
{
@@ -123,9 +123,9 @@ constexpr inline int roundDouble(const double v)
return (v > 0.0) ? static_cast<int>(v + 0.5) : static_cast<int>(v - 0.5);
}
-inline int powerOfTwo(const int input)
+inline int powerOfTwo(const unsigned int input)
{
- int value = 1;
+ unsigned int value = 1;
while (value < input)
value <<= 1;
return value;
diff --git a/src/utils/paths.cpp b/src/utils/paths.cpp
index a3f61bde3..96cd0ed29 100644
--- a/src/utils/paths.cpp
+++ b/src/utils/paths.cpp
@@ -28,7 +28,9 @@
#include "utils/physfstools.h"
#include "utils/stringutils.h"
+#ifdef USE_X11
#include "resources/resourcemanager.h"
+#endif
#ifdef __native_client__
#include <limits.h>
diff --git a/src/utils/sdlpixel.h b/src/utils/sdlpixel.h
new file mode 100644
index 000000000..282b90afb
--- /dev/null
+++ b/src/utils/sdlpixel.h
@@ -0,0 +1,236 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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/>.
+ */
+
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef UTILS_SDLPIXEL_H
+#define UTILS_SDLPIXEL_H
+
+#include "gui/color.h"
+
+#include "SDL.h"
+
+/**
+ * Puts a pixel on an SDL_Surface.
+ *
+ * @param x the x coordinate on the surface.
+ * @param y the y coordinate on the surface.
+ * @param color the color the pixel should be in.
+ */
+inline void SDLputPixel(SDL_Surface* surface, int x, int y,
+ const Color& color)
+{
+ if (!surface)
+ return;
+
+ const int bpp = surface->format->BytesPerPixel;
+
+ SDL_LockSurface(surface);
+
+ Uint8 *const p = static_cast<uint8_t*>(surface->pixels)
+ + y * surface->pitch + x * bpp;
+
+ const Uint32 pixel = SDL_MapRGB(surface->format,
+ static_cast<uint8_t>(color.r), static_cast<uint8_t>(color.g),
+ static_cast<uint8_t>(color.b));
+
+ switch (bpp)
+ {
+ case 1:
+ *p = static_cast<uint8_t>(pixel);
+ break;
+
+ case 2:
+ *reinterpret_cast<uint16_t*>(p) = static_cast<uint16_t>(pixel);
+ break;
+
+ case 3:
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+ p[0] = static_cast<uint8_t>((pixel >> 16) & 0xff);
+ p[1] = static_cast<uint8_t>((pixel >> 8) & 0xff);
+ p[2] = static_cast<uint8_t>((pixel) & 0xff);
+#else
+ p[0] = static_cast<uint8_t>((pixel) & 0xff);
+ p[1] = static_cast<uint8_t>((pixel >> 8) & 0xff);
+ p[2] = static_cast<uint8_t>((pixel >> 16) & 0xff);
+#endif
+ break;
+
+ case 4:
+ *reinterpret_cast<Uint32*>(p) = pixel;
+ break;
+
+ default:
+ break;
+ }
+
+ SDL_UnlockSurface(surface);
+}
+
+/**
+ * Blends two 32 bit colors together.
+ *
+ * @param src the source color.
+ * @param dst the destination color.
+ * @param a alpha.
+ */
+inline unsigned int SDLAlpha32(const unsigned int src,
+ const unsigned int dst,
+ const unsigned char a)
+{
+ const unsigned int b = ((src & 0xff) * a + (dst & 0xff) * (255 - a)) >> 8;
+ const unsigned int g = ((src & 0xff00) * a + (dst & 0xff00)
+ * (255 - a)) >> 8;
+ const unsigned int r = ((src & 0xff0000) * a + (dst & 0xff0000)
+ * (255 - a)) >> 8;
+
+ return (b & 0xff) | (g & 0xff00) | (r & 0xff0000);
+}
+
+/**
+ * Blends two 16 bit colors together.
+ *
+ * @param src the source color.
+ * @param dst the destination color.
+ * @param a alpha.
+ */
+inline unsigned short SDLAlpha16(const unsigned short src,
+ const unsigned short dst,
+ const unsigned char a,
+ const SDL_PixelFormat *const f)
+{
+ unsigned int b = ((src & f->Rmask) * a + (dst & f->Rmask)
+ * (255 - a)) >> 8;
+ unsigned int g = ((src & f->Gmask) * a + (dst & f->Gmask)
+ * (255 - a)) >> 8;
+ unsigned int r = ((src & f->Bmask) * a + (dst & f->Bmask)
+ * (255 - a)) >> 8;
+
+ return static_cast<unsigned short>((b & f->Rmask)
+ | (g & f->Gmask) | (r & f->Bmask));
+}
+
+/**
+ * Puts a pixel on an SDL_Surface with alpha
+ *
+ * @param x the x coordinate on the surface.
+ * @param y the y coordinate on the surface.
+ * @param color the color the pixel should be in.
+ */
+inline void SDLputPixelAlpha(SDL_Surface* surface, int x, int y,
+ const Color& color)
+{
+ const int bpp = surface->format->BytesPerPixel;
+
+ SDL_LockSurface(surface);
+
+ Uint8 *const p = static_cast<uint8_t*>(surface->pixels)
+ + y * surface->pitch + x * bpp;
+
+ const Uint32 pixel = SDL_MapRGB(surface->format,
+ static_cast<uint8_t>(color.r),
+ static_cast<uint8_t>(color.g),
+ static_cast<uint8_t>(color.b));
+
+ switch (bpp)
+ {
+ case 1:
+ *p = static_cast<uint8_t>(pixel);
+ break;
+
+ case 2:
+ *reinterpret_cast<Uint16*>(p) = SDLAlpha16(
+ static_cast<unsigned short>(pixel),
+ *reinterpret_cast<unsigned short*>(p),
+ static_cast<unsigned char>(color.a), surface->format);
+ break;
+
+ case 3:
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+ p[2] = static_cast<uint8_t>((p[2] * (255 - color.a)
+ + color.b * color.a) >> 8);
+ p[1] = static_cast<uint8_t>((p[1] * (255 - color.a)
+ + color.g * color.a) >> 8);
+ p[0] = static_cast<uint8_t>((p[0] * (255 - color.a)
+ + color.r * color.a) >> 8);
+#else
+ p[0] = static_cast<uint8_t>((p[0] * (255 - color.a)
+ + color.b * color.a) >> 8);
+ p[1] = static_cast<uint8_t>((p[1] * (255 - color.a)
+ + color.g * color.a) >> 8);
+ p[2] = static_cast<uint8_t>((p[2] * (255 - color.a)
+ + color.r * color.a) >> 8);
+#endif
+ break;
+
+ case 4:
+ *reinterpret_cast<Uint32*>(p) = SDLAlpha32(pixel,
+ *reinterpret_cast<Uint32*>(p),
+ static_cast<unsigned char>(color.a));
+ break;
+ default:
+ break;
+ }
+
+ SDL_UnlockSurface(surface);
+}
+
+#endif // UTILS_SDLPIXEL_H
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 224c2a8e8..f47f724a8 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -73,7 +73,7 @@ unsigned int atox(const std::string &str)
return value;
}
-const char *ipToString(const int address)
+const char *ipToString(const uint32_t address)
{
static char asciiIP[18];
diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h
index 4a73b3e58..7cf924d98 100644
--- a/src/utils/stringutils.h
+++ b/src/utils/stringutils.h
@@ -90,7 +90,7 @@ std::string toStringPrint(const unsigned int val);
* @param address the address to convert to a string
* @return the string representation of the address
*/
-const char *ipToString(const int address) A_WARN_UNUSED;
+const char *ipToString(const uint32_t address) A_WARN_UNUSED;
/**
* A safe version of sprintf that returns a std::string of the result.
diff --git a/src/utils/translation/poparser.cpp b/src/utils/translation/poparser.cpp
index f0ab95005..c105bf0da 100644
--- a/src/utils/translation/poparser.cpp
+++ b/src/utils/translation/poparser.cpp
@@ -24,6 +24,8 @@
#include "utils/stringutils.h"
+#include "utils/translation/podict.h"
+
#include "logger.h"
#include "debug.h"
diff --git a/src/utils/translation/poparser.h b/src/utils/translation/poparser.h
index 08a6ac7b1..41598442b 100644
--- a/src/utils/translation/poparser.h
+++ b/src/utils/translation/poparser.h
@@ -21,13 +21,13 @@
#ifndef UTILS_TRANSLATION_POPARSER_H
#define UTILS_TRANSLATION_POPARSER_H
-#include "utils/translation/podict.h"
-
#include "localconsts.h"
#include <sstream>
#include <string>
+class PoDict;
+
class PoParser final
{
public:
diff --git a/src/utils/xml.h b/src/utils/xml.h
index 48d60cda7..d8a281045 100644
--- a/src/utils/xml.h
+++ b/src/utils/xml.h
@@ -23,8 +23,8 @@
#ifndef UTILS_XML_H
#define UTILS_XML_H
-#include <libxml/xmlwriter.h>
#include <libxml/tree.h>
+#include <libxml/xmlwriter.h>
#include <string>
diff --git a/src/utils/xmlutils.cpp b/src/utils/xmlutils.cpp
new file mode 100644
index 000000000..7d19b1064
--- /dev/null
+++ b/src/utils/xmlutils.cpp
@@ -0,0 +1,63 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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 "utils/xmlutils.h"
+
+#include "logger.h"
+
+#include "utils/xml.h"
+
+#include "debug.h"
+
+void readXmlIntVector(const std::string &fileName,
+ const std::string &rootName,
+ const std::string &sectionName,
+ const std::string &itemName,
+ const std::string &attributeName,
+ std::vector<int> &arr)
+{
+ arr.clear();
+ XML::Document doc(fileName);
+ const XmlNodePtrConst rootNode = doc.rootNode();
+
+ if (!rootNode || !xmlNameEqual(rootNode, rootName.c_str()))
+ {
+ logger->log("Error while loading %s!", fileName.c_str());
+ return;
+ }
+
+ for_each_xml_child_node(sectionNode, rootNode)
+ {
+ if (!xmlNameEqual(sectionNode, sectionName.c_str()))
+ continue;
+ for_each_xml_child_node(childNode, sectionNode)
+ {
+ if (!xmlNameEqual(childNode, itemName.c_str()))
+ continue;
+
+ const int val = XML::getProperty(childNode,
+ attributeName.c_str(), -1);
+ if (val == -1)
+ continue;
+
+ arr.push_back(val);
+ }
+ }
+}
diff --git a/src/input/inputevent.cpp b/src/utils/xmlutils.h
index b87e4fe0a..3dbee5f95 100644
--- a/src/input/inputevent.cpp
+++ b/src/utils/xmlutils.h
@@ -1,6 +1,6 @@
/*
* The ManaPlus Client
- * Copyright (C) 2012-2014 The ManaPlus Developers
+ * Copyright (C) 2014 The ManaPlus Developers
*
* This file is part of The ManaPlus Client.
*
@@ -18,12 +18,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "input/inputevent.h"
+#ifndef UTILS_XMLUTILS_H
+#define UTILS_XMLUTILS_H
-#include "debug.h"
+#include <string>
+#include <vector>
-InputEvent::InputEvent(const int action0, const int mask0) :
- action(action0),
- mask(mask0)
-{
-}
+void readXmlIntVector(const std::string &fileName,
+ const std::string &rootName,
+ const std::string &sectionName,
+ const std::string &itemName,
+ const std::string &attributeName,
+ std::vector<int> &arr);
+
+#endif // UTILS_XMLUTILS_H
diff --git a/src/utils/xmlutils_unittest.cc b/src/utils/xmlutils_unittest.cc
new file mode 100644
index 000000000..5b3469805
--- /dev/null
+++ b/src/utils/xmlutils_unittest.cc
@@ -0,0 +1,70 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus 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 "utils/xmlutils.h"
+
+#include "client.h"
+#include "logger.h"
+
+#include "gtest/gtest.h"
+
+#include "utils/physfstools.h"
+#include "utils/xml.h"
+
+#include "resources/resourcemanager.h"
+
+#include <string>
+#include <vector>
+
+#include "debug.h"
+
+static void init()
+{
+ PHYSFS_init("manaplus");
+ dirSeparator = "/";
+ XML::initXML();
+ logger = new Logger();
+ ResourceManager *resman = ResourceManager::getInstance();
+ resman->addToSearchPath("data", false);
+ resman->addToSearchPath("../data", false);
+}
+
+TEST(xmlutils, readXmlIntVector1)
+{
+ Client::Options options;
+ client = new Client(options);
+ init();
+
+ std::vector<int> arr;
+
+ readXmlIntVector("graphics/gui/browserbox.xml",
+ "skinset",
+ "widget",
+ "option",
+ "value",
+ arr);
+
+ EXPECT_EQ(5, arr.size());
+ EXPECT_EQ(1, arr[0]);
+ EXPECT_EQ(15, arr[1]);
+ EXPECT_EQ(0, arr[2]);
+ EXPECT_EQ(1, arr[3]);
+ EXPECT_EQ(1, arr[4]);
+}