From aa3f63fd497558a02feb3ddbc44f31eac091f39b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 10 Oct 2017 22:14:45 +0300 Subject: Remove most unused files. --- src/gui/browserlink.h | 53 - src/gui/buttoninfo.h | 49 - src/gui/buttontext.h | 45 - src/gui/chatlog.h | 48 - src/gui/cliprect.h | 129 - src/gui/color.h | 253 -- src/gui/colorpair.h | 43 - src/gui/dialogsmanager.cpp | 222 -- src/gui/dialogsmanager.h | 65 - src/gui/focushandler.cpp | 621 ----- src/gui/focushandler.h | 410 --- src/gui/fonts/font.cpp | 499 ---- src/gui/fonts/font.h | 158 -- src/gui/fonts/textchunk.cpp | 203 -- src/gui/fonts/textchunk.h | 75 - src/gui/fonts/textchunklist.cpp | 153 -- src/gui/fonts/textchunklist.h | 60 - src/gui/fonts/textchunksmall.cpp | 83 - src/gui/fonts/textchunksmall.h | 49 - src/gui/gui.cpp | 1515 ----------- src/gui/gui.h | 527 ---- src/gui/mailmessage.h | 59 - src/gui/models/avatarlistmodel.h | 44 - src/gui/models/beingslistmodel.h | 66 - src/gui/models/colorlistmodel.h | 87 - src/gui/models/colormodel.cpp | 97 - src/gui/models/colormodel.h | 69 - src/gui/models/extendedlistmodel.h | 40 - src/gui/models/extendednamesmodel.cpp | 68 - src/gui/models/extendednamesmodel.h | 62 - src/gui/models/fontsizechoicelistmodel.h | 92 - src/gui/models/fontsmodel.h | 44 - src/gui/models/iconsmodel.h | 88 - src/gui/models/ignorechoiceslistmodel.h | 64 - src/gui/models/itemsmodel.h | 88 - src/gui/models/keylistmodel.h | 88 - src/gui/models/langlistmodel.h | 145 - src/gui/models/listmodel.h | 108 - src/gui/models/magicschoolmodel.h | 73 - src/gui/models/modelistmodel.cpp | 101 - src/gui/models/modelistmodel.h | 70 - src/gui/models/namesmodel.cpp | 68 - src/gui/models/namesmodel.h | 64 - src/gui/models/opengllistmodel.h | 53 - src/gui/models/playerrelationlistmodel.h | 75 - src/gui/models/playertablemodel.cpp | 148 - src/gui/models/playertablemodel.h | 68 - src/gui/models/questsmodel.h | 40 - src/gui/models/serverslistmodel.h | 119 - src/gui/models/shopitems.cpp | 206 -- src/gui/models/shopitems.h | 170 -- src/gui/models/skillmodel.cpp | 62 - src/gui/models/skillmodel.h | 58 - src/gui/models/sortlistmodelbuy.h | 71 - src/gui/models/sortlistmodelinv.h | 69 - src/gui/models/soundsmodel.h | 49 - src/gui/models/tablemodel.cpp | 182 -- src/gui/models/tablemodel.h | 153 -- src/gui/models/targettypemodel.h | 64 - src/gui/models/themesmodel.h | 49 - src/gui/models/touchactionmodel.cpp | 91 - src/gui/models/touchactionmodel.h | 49 - src/gui/models/typelistmodel.h | 74 - src/gui/models/updatelistmodel.h | 79 - src/gui/models/updatetypemodel.h | 63 - src/gui/models/worldlistmodel.h | 68 - src/gui/mouseoverlink.h | 51 - src/gui/onlineplayer.h | 90 - src/gui/palette.cpp | 199 -- src/gui/palette.h | 158 -- src/gui/popupmanager.cpp | 113 - src/gui/popupmanager.h | 71 - src/gui/popups/beingpopup.cpp | 337 --- src/gui/popups/beingpopup.h | 68 - src/gui/popups/itempopup.cpp | 465 ---- src/gui/popups/itempopup.h | 103 - src/gui/popups/popupmenu.cpp | 3613 ------------------------- src/gui/popups/popupmenu.h | 321 --- src/gui/popups/skillpopup.cpp | 250 -- src/gui/popups/skillpopup.h | 84 - src/gui/popups/speechbubble.cpp | 98 - src/gui/popups/speechbubble.h | 67 - src/gui/popups/spellpopup.cpp | 123 - src/gui/popups/spellpopup.h | 71 - src/gui/popups/statuspopup.cpp | 171 -- src/gui/popups/statuspopup.h | 72 - src/gui/popups/textboxpopup.cpp | 83 - src/gui/popups/textboxpopup.h | 64 - src/gui/popups/textpopup.cpp | 112 - src/gui/popups/textpopup.h | 83 - src/gui/rect.h | 226 -- src/gui/sdlinput.cpp | 405 --- src/gui/sdlinput.h | 391 --- src/gui/setupactiondata.h | 52 - src/gui/setupinputpages.cpp | 80 - src/gui/setupinputpages.h | 32 - src/gui/shortcut/dropshortcut.cpp | 171 -- src/gui/shortcut/dropshortcut.h | 69 - src/gui/shortcut/emoteshortcut.cpp | 115 - src/gui/shortcut/emoteshortcut.h | 133 - src/gui/shortcut/itemshortcut.cpp | 289 -- src/gui/shortcut/itemshortcut.h | 183 -- src/gui/shortcut/shortcutbase.cpp | 128 - src/gui/shortcut/shortcutbase.h | 141 - src/gui/shortcut/spellshortcut.cpp | 63 - src/gui/shortcut/spellshortcut.h | 88 - src/gui/skin.cpp | 152 -- src/gui/skin.h | 135 - src/gui/theme.cpp | 1283 --------- src/gui/theme.h | 207 -- src/gui/themecolorsidoperators.cpp | 30 - src/gui/themecolorsidoperators.h | 28 - src/gui/themeinfo.h | 64 - src/gui/touchactiondata.cpp | 38 - src/gui/touchactiondata.h | 28 - src/gui/userpalette.cpp | 649 ----- src/gui/userpalette.h | 250 -- src/gui/viewport.h | 32 - src/gui/widgets/attrs/attrdisplay.cpp | 67 - src/gui/widgets/attrs/attrdisplay.h | 82 - src/gui/widgets/attrs/changedisplay.cpp | 119 - src/gui/widgets/attrs/changedisplay.h | 61 - src/gui/widgets/attrs/derdisplay.cpp | 40 - src/gui/widgets/attrs/derdisplay.h | 44 - src/gui/widgets/avatarlistbox.cpp | 740 ----- src/gui/widgets/avatarlistbox.h | 64 - src/gui/widgets/basiccontainer.cpp | 439 --- src/gui/widgets/basiccontainer.h | 213 -- src/gui/widgets/basiccontainer2.cpp | 128 - src/gui/widgets/basiccontainer2.h | 153 -- src/gui/widgets/browserbox.cpp | 936 ------- src/gui/widgets/browserbox.h | 210 -- src/gui/widgets/browserbox.inc | 30 - src/gui/widgets/button.cpp | 934 ------- src/gui/widgets/button.h | 347 --- src/gui/widgets/characterdisplay.cpp | 160 -- src/gui/widgets/characterdisplay.h | 93 - src/gui/widgets/characterviewbase.h | 63 - src/gui/widgets/characterviewnormal.cpp | 121 - src/gui/widgets/characterviewnormal.h | 50 - src/gui/widgets/characterviewsmall.cpp | 136 - src/gui/widgets/characterviewsmall.h | 54 - src/gui/widgets/chatinput.h | 105 - src/gui/widgets/checkbox.cpp | 338 --- src/gui/widgets/checkbox.h | 216 -- src/gui/widgets/colorpage.cpp | 124 - src/gui/widgets/colorpage.h | 48 - src/gui/widgets/container.cpp | 60 - src/gui/widgets/container.h | 51 - src/gui/widgets/containerplacer.cpp | 44 - src/gui/widgets/containerplacer.h | 73 - src/gui/widgets/createwidget.h | 41 - src/gui/widgets/desktop.cpp | 229 -- src/gui/widgets/desktop.h | 88 - src/gui/widgets/dropdown.cpp | 580 ---- src/gui/widgets/dropdown.h | 166 -- src/gui/widgets/emotepage.cpp | 167 -- src/gui/widgets/emotepage.h | 67 - src/gui/widgets/emoteshortcutcontainer.cpp | 297 -- src/gui/widgets/emoteshortcutcontainer.h | 92 - src/gui/widgets/equipmentbox.h | 41 - src/gui/widgets/equipmentpage.h | 53 - src/gui/widgets/extendedlistbox.cpp | 257 -- src/gui/widgets/extendedlistbox.h | 61 - src/gui/widgets/extendedlistboxitem.h | 49 - src/gui/widgets/flowcontainer.cpp | 97 - src/gui/widgets/flowcontainer.h | 75 - src/gui/widgets/guitable.cpp | 675 ----- src/gui/widgets/guitable.h | 207 -- src/gui/widgets/horizontcontainer.cpp | 66 - src/gui/widgets/horizontcontainer.h | 62 - src/gui/widgets/icon.cpp | 105 - src/gui/widgets/icon.h | 83 - src/gui/widgets/inttextfield.cpp | 148 - src/gui/widgets/inttextfield.h | 85 - src/gui/widgets/itemcontainer.cpp | 1322 --------- src/gui/widgets/itemcontainer.h | 223 -- src/gui/widgets/itemlinkhandler.cpp | 223 -- src/gui/widgets/itemlinkhandler.h | 61 - src/gui/widgets/itemshortcutcontainer.cpp | 650 ----- src/gui/widgets/itemshortcutcontainer.h | 89 - src/gui/widgets/label.cpp | 292 -- src/gui/widgets/label.h | 195 -- src/gui/widgets/layout.cpp | 46 - src/gui/widgets/layout.h | 66 - src/gui/widgets/layoutarray.cpp | 313 --- src/gui/widgets/layoutarray.h | 127 - src/gui/widgets/layoutcell.cpp | 136 - src/gui/widgets/layoutcell.h | 196 -- src/gui/widgets/layouthelper.cpp | 79 - src/gui/widgets/layouthelper.h | 91 - src/gui/widgets/linepart.cpp | 33 - src/gui/widgets/linepart.h | 102 - src/gui/widgets/linkhandler.h | 49 - src/gui/widgets/listbox.cpp | 446 --- src/gui/widgets/listbox.h | 296 -- src/gui/widgets/passwordfield.cpp | 55 - src/gui/widgets/passwordfield.h | 55 - src/gui/widgets/playerbox.cpp | 190 -- src/gui/widgets/playerbox.h | 112 - src/gui/widgets/popup.cpp | 273 -- src/gui/widgets/popup.h | 193 -- src/gui/widgets/popuplist.cpp | 188 -- src/gui/widgets/popuplist.h | 84 - src/gui/widgets/progressbar.cpp | 376 --- src/gui/widgets/progressbar.h | 166 -- src/gui/widgets/progressindicator.cpp | 98 - src/gui/widgets/progressindicator.h | 54 - src/gui/widgets/radiobutton.cpp | 373 --- src/gui/widgets/radiobutton.h | 247 -- src/gui/widgets/radiogroup.cpp | 41 - src/gui/widgets/radiogroup.h | 41 - src/gui/widgets/scrollarea.cpp | 1460 ---------- src/gui/widgets/scrollarea.h | 598 ---- src/gui/widgets/selldialog.cpp | 397 --- src/gui/widgets/selldialog.h | 156 -- src/gui/widgets/serverslistbox.h | 159 -- src/gui/widgets/setupbuttonitem.cpp | 95 - src/gui/widgets/setupbuttonitem.h | 69 - src/gui/widgets/setupitem.cpp | 1338 --------- src/gui/widgets/setupitem.h | 613 ----- src/gui/widgets/setupquickitem.cpp | 117 - src/gui/widgets/setupquickitem.h | 80 - src/gui/widgets/setuptouchitem.cpp | 132 - src/gui/widgets/setuptouchitem.h | 67 - src/gui/widgets/shoplistbox.cpp | 310 --- src/gui/widgets/shoplistbox.h | 113 - src/gui/widgets/shortcutcontainer.cpp | 159 -- src/gui/widgets/shortcutcontainer.h | 120 - src/gui/widgets/skilllistbox.h | 290 -- src/gui/widgets/skillrectanglelistbox.h | 418 --- src/gui/widgets/slider.cpp | 517 ---- src/gui/widgets/slider.h | 337 --- src/gui/widgets/sliderlist.cpp | 240 -- src/gui/widgets/sliderlist.h | 89 - src/gui/widgets/spellshortcutcontainer.cpp | 371 --- src/gui/widgets/spellshortcutcontainer.h | 86 - src/gui/widgets/staticbrowserbox.cpp | 781 ------ src/gui/widgets/staticbrowserbox.h | 194 -- src/gui/widgets/statspage.cpp | 88 - src/gui/widgets/statspage.h | 61 - src/gui/widgets/statspagebasic.cpp | 163 -- src/gui/widgets/statspagebasic.h | 67 - src/gui/widgets/tabbedarea.cpp | 827 ------ src/gui/widgets/tabbedarea.h | 299 -- src/gui/widgets/tabs/chat/battletab.cpp | 44 - src/gui/widgets/tabs/chat/battletab.h | 43 - src/gui/widgets/tabs/chat/channeltab.cpp | 77 - src/gui/widgets/tabs/chat/channeltab.h | 51 - src/gui/widgets/tabs/chat/chattab.cpp | 563 ---- src/gui/widgets/tabs/chat/chattab.h | 216 -- src/gui/widgets/tabs/chat/emulateguildtab.cpp | 108 - src/gui/widgets/tabs/chat/emulateguildtab.h | 59 - src/gui/widgets/tabs/chat/gmtab.cpp | 57 - src/gui/widgets/tabs/chat/gmtab.h | 49 - src/gui/widgets/tabs/chat/guildtab.cpp | 125 - src/gui/widgets/tabs/chat/guildtab.h | 56 - src/gui/widgets/tabs/chat/langtab.cpp | 38 - src/gui/widgets/tabs/chat/langtab.h | 39 - src/gui/widgets/tabs/chat/partytab.cpp | 151 -- src/gui/widgets/tabs/chat/partytab.h | 58 - src/gui/widgets/tabs/chat/tradetab.cpp | 50 - src/gui/widgets/tabs/chat/tradetab.h | 46 - src/gui/widgets/tabs/chat/whispertab.cpp | 130 - src/gui/widgets/tabs/chat/whispertab.h | 73 - src/gui/widgets/tabs/debugwindowtabs.cpp | 492 ---- src/gui/widgets/tabs/debugwindowtabs.h | 129 - src/gui/widgets/tabs/setup_audio.cpp | 214 -- src/gui/widgets/tabs/setup_audio.h | 47 - src/gui/widgets/tabs/setup_chat.cpp | 347 --- src/gui/widgets/tabs/setup_chat.h | 40 - src/gui/widgets/tabs/setup_colors.cpp | 491 ---- src/gui/widgets/tabs/setup_colors.h | 91 - src/gui/widgets/tabs/setup_input.cpp | 399 --- src/gui/widgets/tabs/setup_input.h | 105 - src/gui/widgets/tabs/setup_joystick.cpp | 184 -- src/gui/widgets/tabs/setup_joystick.h | 62 - src/gui/widgets/tabs/setup_misc.cpp | 518 ---- src/gui/widgets/tabs/setup_misc.h | 52 - src/gui/widgets/tabs/setup_mods.cpp | 129 - src/gui/widgets/tabs/setup_mods.h | 50 - src/gui/widgets/tabs/setup_perfomance.cpp | 209 -- src/gui/widgets/tabs/setup_perfomance.h | 46 - src/gui/widgets/tabs/setup_players.cpp | 211 -- src/gui/widgets/tabs/setup_players.h | 49 - src/gui/widgets/tabs/setup_quick.cpp | 118 - src/gui/widgets/tabs/setup_quick.h | 45 - src/gui/widgets/tabs/setup_relations.cpp | 266 -- src/gui/widgets/tabs/setup_relations.h | 79 - src/gui/widgets/tabs/setup_theme.cpp | 415 --- src/gui/widgets/tabs/setup_theme.h | 113 - src/gui/widgets/tabs/setup_touch.cpp | 134 - src/gui/widgets/tabs/setup_touch.h | 44 - src/gui/widgets/tabs/setup_video.cpp | 534 ---- src/gui/widgets/tabs/setup_video.h | 88 - src/gui/widgets/tabs/setup_visual.cpp | 252 -- src/gui/widgets/tabs/setup_visual.h | 51 - src/gui/widgets/tabs/setuptab.cpp | 44 - src/gui/widgets/tabs/setuptab.h | 74 - src/gui/widgets/tabs/setuptabscroll.cpp | 163 -- src/gui/widgets/tabs/setuptabscroll.h | 81 - src/gui/widgets/tabs/shortcuttab.h | 47 - src/gui/widgets/tabs/skilltab.h | 88 - src/gui/widgets/tabs/socialattacktab.h | 77 - src/gui/widgets/tabs/socialfriendsfunctor.h | 59 - src/gui/widgets/tabs/socialfriendstab.h | 127 - src/gui/widgets/tabs/socialguildtab.h | 179 -- src/gui/widgets/tabs/socialguildtab2.h | 106 - src/gui/widgets/tabs/socialnavigationtab.h | 308 --- src/gui/widgets/tabs/socialpartytab.h | 171 -- src/gui/widgets/tabs/socialpickuptab.h | 75 - src/gui/widgets/tabs/socialplayerstab.h | 198 -- src/gui/widgets/tabs/socialtab.h | 143 - src/gui/widgets/tabs/socialtabbase.h | 84 - src/gui/widgets/tabs/tab.cpp | 488 ---- src/gui/widgets/tabs/tab.h | 245 -- src/gui/widgets/tabstrip.cpp | 124 - src/gui/widgets/tabstrip.h | 57 - src/gui/widgets/textbox.cpp | 647 ----- src/gui/widgets/textbox.h | 329 --- src/gui/widgets/textfield.cpp | 837 ------ src/gui/widgets/textfield.h | 293 -- src/gui/widgets/textpreview.cpp | 151 -- src/gui/widgets/textpreview.h | 144 - src/gui/widgets/vertcontainer.cpp | 89 - src/gui/widgets/vertcontainer.h | 66 - src/gui/widgets/virtshortcutcontainer.cpp | 383 --- src/gui/widgets/virtshortcutcontainer.h | 92 - src/gui/widgets/widget.cpp | 526 ---- src/gui/widgets/widget.h | 1181 -------- src/gui/widgets/widget2.h | 117 - src/gui/widgets/widgetgroup.cpp | 87 - src/gui/widgets/widgetgroup.h | 69 - src/gui/widgets/window.cpp | 1499 ---------- src/gui/widgets/window.h | 725 ----- src/gui/widgets/windowcontainer.cpp | 105 - src/gui/widgets/windowcontainer.h | 74 - src/gui/windowmanager.cpp | 498 ---- src/gui/windowmanager.h | 87 - src/gui/windowmenu.cpp | 493 ---- src/gui/windowmenu.h | 118 - src/gui/windows/bankwindow.cpp | 102 - src/gui/windows/bankwindow.h | 64 - src/gui/windows/buydialog.cpp | 794 ------ src/gui/windows/buydialog.h | 207 -- src/gui/windows/buyingstoreselldialog.cpp | 70 - src/gui/windows/buyingstoreselldialog.h | 55 - src/gui/windows/buyselldialog.cpp | 167 -- src/gui/windows/buyselldialog.h | 86 - src/gui/windows/changeemaildialog.cpp | 186 -- src/gui/windows/changeemaildialog.h | 81 - src/gui/windows/changepassworddialog.cpp | 177 -- src/gui/windows/changepassworddialog.h | 76 - src/gui/windows/charcreatedialog.cpp | 885 ------ src/gui/windows/charcreatedialog.h | 171 -- src/gui/windows/chardeleteconfirm.h | 65 - src/gui/windows/charselectdialog.cpp | 644 ----- src/gui/windows/charselectdialog.h | 136 - src/gui/windows/chatwindow.cpp | 2181 --------------- src/gui/windows/chatwindow.h | 406 --- src/gui/windows/confirmdialog.cpp | 120 - src/gui/windows/confirmdialog.h | 71 - src/gui/windows/connectiondialog.cpp | 90 - src/gui/windows/connectiondialog.h | 69 - src/gui/windows/cutinwindow.cpp | 153 -- src/gui/windows/cutinwindow.h | 61 - src/gui/windows/debugwindow.cpp | 173 -- src/gui/windows/debugwindow.h | 78 - src/gui/windows/didyouknowwindow.cpp | 188 -- src/gui/windows/didyouknowwindow.h | 76 - src/gui/windows/editdialog.cpp | 80 - src/gui/windows/editdialog.h | 72 - src/gui/windows/editserverdialog.cpp | 297 -- src/gui/windows/editserverdialog.h | 86 - src/gui/windows/eggselectiondialog.cpp | 67 - src/gui/windows/eggselectiondialog.h | 45 - src/gui/windows/emotewindow.cpp | 278 -- src/gui/windows/emotewindow.h | 89 - src/gui/windows/equipmentwindow.cpp | 848 ------ src/gui/windows/equipmentwindow.h | 167 -- src/gui/windows/helpwindow.cpp | 220 -- src/gui/windows/helpwindow.h | 92 - src/gui/windows/insertcarddialog.cpp | 79 - src/gui/windows/insertcarddialog.h | 49 - src/gui/windows/inventorywindow.cpp | 1083 -------- src/gui/windows/inventorywindow.h | 210 -- src/gui/windows/itemamountwindow.cpp | 504 ---- src/gui/windows/itemamountwindow.h | 123 - src/gui/windows/killstats.cpp | 479 ---- src/gui/windows/killstats.h | 116 - src/gui/windows/logindialog.cpp | 402 --- src/gui/windows/logindialog.h | 113 - src/gui/windows/maileditwindow.cpp | 278 -- src/gui/windows/maileditwindow.h | 92 - src/gui/windows/mailviewwindow.cpp | 269 -- src/gui/windows/mailviewwindow.h | 80 - src/gui/windows/mailwindow.cpp | 393 --- src/gui/windows/mailwindow.h | 108 - src/gui/windows/minimap.cpp | 540 ---- src/gui/windows/minimap.h | 95 - src/gui/windows/ministatuswindow.cpp | 594 ---- src/gui/windows/ministatuswindow.h | 151 -- src/gui/windows/npcdialog.cpp | 1395 ---------- src/gui/windows/npcdialog.h | 324 --- src/gui/windows/npcselldialog.cpp | 154 -- src/gui/windows/npcselldialog.h | 59 - src/gui/windows/okdialog.cpp | 94 - src/gui/windows/okdialog.h | 72 - src/gui/windows/outfitwindow.cpp | 749 ----- src/gui/windows/outfitwindow.h | 133 - src/gui/windows/questswindow.cpp | 483 ---- src/gui/windows/questswindow.h | 105 - src/gui/windows/quitdialog.cpp | 260 -- src/gui/windows/quitdialog.h | 84 - src/gui/windows/registerdialog.cpp | 317 --- src/gui/windows/registerdialog.h | 95 - src/gui/windows/serverdialog.cpp | 902 ------ src/gui/windows/serverdialog.h | 150 - src/gui/windows/serverinfowindow.cpp | 184 -- src/gui/windows/serverinfowindow.h | 68 - src/gui/windows/setupwindow.cpp | 335 --- src/gui/windows/setupwindow.h | 96 - src/gui/windows/shopselldialog.cpp | 60 - src/gui/windows/shopselldialog.h | 54 - src/gui/windows/shopwindow.cpp | 1175 -------- src/gui/windows/shopwindow.h | 207 -- src/gui/windows/shortcutwindow.cpp | 269 -- src/gui/windows/shortcutwindow.h | 100 - src/gui/windows/skilldialog.cpp | 1432 ---------- src/gui/windows/skilldialog.h | 237 -- src/gui/windows/socialwindow.cpp | 659 ----- src/gui/windows/socialwindow.h | 171 -- src/gui/windows/statuswindow.cpp | 652 ----- src/gui/windows/statuswindow.h | 119 - src/gui/windows/textcommandeditor.cpp | 344 --- src/gui/windows/textcommandeditor.h | 116 - src/gui/windows/textdialog.cpp | 135 - src/gui/windows/textdialog.h | 85 - src/gui/windows/textselectdialog.cpp | 192 -- src/gui/windows/textselectdialog.h | 104 - src/gui/windows/tradewindow.cpp | 553 ---- src/gui/windows/tradewindow.h | 214 -- src/gui/windows/updaterwindow.cpp | 1217 --------- src/gui/windows/updaterwindow.h | 252 -- src/gui/windows/whoisonline.cpp | 909 ------- src/gui/windows/whoisonline.h | 182 -- src/gui/windows/worldselectdialog.cpp | 134 - src/gui/windows/worldselectdialog.h | 77 - 448 files changed, 100884 deletions(-) delete mode 100644 src/gui/browserlink.h delete mode 100644 src/gui/buttoninfo.h delete mode 100644 src/gui/buttontext.h delete mode 100644 src/gui/chatlog.h delete mode 100644 src/gui/cliprect.h delete mode 100644 src/gui/color.h delete mode 100644 src/gui/colorpair.h delete mode 100644 src/gui/dialogsmanager.cpp delete mode 100644 src/gui/dialogsmanager.h delete mode 100644 src/gui/focushandler.cpp delete mode 100644 src/gui/focushandler.h delete mode 100644 src/gui/fonts/font.cpp delete mode 100644 src/gui/fonts/font.h delete mode 100644 src/gui/fonts/textchunk.cpp delete mode 100644 src/gui/fonts/textchunk.h delete mode 100644 src/gui/fonts/textchunklist.cpp delete mode 100644 src/gui/fonts/textchunklist.h delete mode 100644 src/gui/fonts/textchunksmall.cpp delete mode 100644 src/gui/fonts/textchunksmall.h delete mode 100644 src/gui/gui.cpp delete mode 100644 src/gui/gui.h delete mode 100644 src/gui/mailmessage.h delete mode 100644 src/gui/models/avatarlistmodel.h delete mode 100644 src/gui/models/beingslistmodel.h delete mode 100644 src/gui/models/colorlistmodel.h delete mode 100644 src/gui/models/colormodel.cpp delete mode 100644 src/gui/models/colormodel.h delete mode 100644 src/gui/models/extendedlistmodel.h delete mode 100644 src/gui/models/extendednamesmodel.cpp delete mode 100644 src/gui/models/extendednamesmodel.h delete mode 100644 src/gui/models/fontsizechoicelistmodel.h delete mode 100644 src/gui/models/fontsmodel.h delete mode 100644 src/gui/models/iconsmodel.h delete mode 100644 src/gui/models/ignorechoiceslistmodel.h delete mode 100644 src/gui/models/itemsmodel.h delete mode 100644 src/gui/models/keylistmodel.h delete mode 100644 src/gui/models/langlistmodel.h delete mode 100644 src/gui/models/listmodel.h delete mode 100644 src/gui/models/magicschoolmodel.h delete mode 100644 src/gui/models/modelistmodel.cpp delete mode 100644 src/gui/models/modelistmodel.h delete mode 100644 src/gui/models/namesmodel.cpp delete mode 100644 src/gui/models/namesmodel.h delete mode 100644 src/gui/models/opengllistmodel.h delete mode 100644 src/gui/models/playerrelationlistmodel.h delete mode 100644 src/gui/models/playertablemodel.cpp delete mode 100644 src/gui/models/playertablemodel.h delete mode 100644 src/gui/models/questsmodel.h delete mode 100644 src/gui/models/serverslistmodel.h delete mode 100644 src/gui/models/shopitems.cpp delete mode 100644 src/gui/models/shopitems.h delete mode 100644 src/gui/models/skillmodel.cpp delete mode 100644 src/gui/models/skillmodel.h delete mode 100644 src/gui/models/sortlistmodelbuy.h delete mode 100644 src/gui/models/sortlistmodelinv.h delete mode 100644 src/gui/models/soundsmodel.h delete mode 100644 src/gui/models/tablemodel.cpp delete mode 100644 src/gui/models/tablemodel.h delete mode 100644 src/gui/models/targettypemodel.h delete mode 100644 src/gui/models/themesmodel.h delete mode 100644 src/gui/models/touchactionmodel.cpp delete mode 100644 src/gui/models/touchactionmodel.h delete mode 100644 src/gui/models/typelistmodel.h delete mode 100644 src/gui/models/updatelistmodel.h delete mode 100644 src/gui/models/updatetypemodel.h delete mode 100644 src/gui/models/worldlistmodel.h delete mode 100644 src/gui/mouseoverlink.h delete mode 100644 src/gui/onlineplayer.h delete mode 100644 src/gui/palette.cpp delete mode 100644 src/gui/palette.h delete mode 100644 src/gui/popupmanager.cpp delete mode 100644 src/gui/popupmanager.h delete mode 100644 src/gui/popups/beingpopup.cpp delete mode 100644 src/gui/popups/beingpopup.h delete mode 100644 src/gui/popups/itempopup.cpp delete mode 100644 src/gui/popups/itempopup.h delete mode 100644 src/gui/popups/popupmenu.cpp delete mode 100644 src/gui/popups/popupmenu.h delete mode 100644 src/gui/popups/skillpopup.cpp delete mode 100644 src/gui/popups/skillpopup.h delete mode 100644 src/gui/popups/speechbubble.cpp delete mode 100644 src/gui/popups/speechbubble.h delete mode 100644 src/gui/popups/spellpopup.cpp delete mode 100644 src/gui/popups/spellpopup.h delete mode 100644 src/gui/popups/statuspopup.cpp delete mode 100644 src/gui/popups/statuspopup.h delete mode 100644 src/gui/popups/textboxpopup.cpp delete mode 100644 src/gui/popups/textboxpopup.h delete mode 100644 src/gui/popups/textpopup.cpp delete mode 100644 src/gui/popups/textpopup.h delete mode 100644 src/gui/rect.h delete mode 100644 src/gui/sdlinput.cpp delete mode 100644 src/gui/sdlinput.h delete mode 100644 src/gui/setupactiondata.h delete mode 100644 src/gui/setupinputpages.cpp delete mode 100644 src/gui/setupinputpages.h delete mode 100644 src/gui/shortcut/dropshortcut.cpp delete mode 100644 src/gui/shortcut/dropshortcut.h delete mode 100644 src/gui/shortcut/emoteshortcut.cpp delete mode 100644 src/gui/shortcut/emoteshortcut.h delete mode 100644 src/gui/shortcut/itemshortcut.cpp delete mode 100644 src/gui/shortcut/itemshortcut.h delete mode 100644 src/gui/shortcut/shortcutbase.cpp delete mode 100644 src/gui/shortcut/shortcutbase.h delete mode 100644 src/gui/shortcut/spellshortcut.cpp delete mode 100644 src/gui/shortcut/spellshortcut.h delete mode 100644 src/gui/skin.cpp delete mode 100644 src/gui/skin.h delete mode 100644 src/gui/theme.cpp delete mode 100644 src/gui/theme.h delete mode 100644 src/gui/themecolorsidoperators.cpp delete mode 100644 src/gui/themecolorsidoperators.h delete mode 100644 src/gui/themeinfo.h delete mode 100644 src/gui/touchactiondata.cpp delete mode 100644 src/gui/touchactiondata.h delete mode 100644 src/gui/userpalette.cpp delete mode 100644 src/gui/userpalette.h delete mode 100644 src/gui/viewport.h delete mode 100644 src/gui/widgets/attrs/attrdisplay.cpp delete mode 100644 src/gui/widgets/attrs/attrdisplay.h delete mode 100644 src/gui/widgets/attrs/changedisplay.cpp delete mode 100644 src/gui/widgets/attrs/changedisplay.h delete mode 100644 src/gui/widgets/attrs/derdisplay.cpp delete mode 100644 src/gui/widgets/attrs/derdisplay.h delete mode 100644 src/gui/widgets/avatarlistbox.cpp delete mode 100644 src/gui/widgets/avatarlistbox.h delete mode 100644 src/gui/widgets/basiccontainer.cpp delete mode 100644 src/gui/widgets/basiccontainer.h delete mode 100644 src/gui/widgets/basiccontainer2.cpp delete mode 100644 src/gui/widgets/basiccontainer2.h delete mode 100644 src/gui/widgets/browserbox.cpp delete mode 100644 src/gui/widgets/browserbox.h delete mode 100644 src/gui/widgets/browserbox.inc delete mode 100644 src/gui/widgets/button.cpp delete mode 100644 src/gui/widgets/button.h delete mode 100644 src/gui/widgets/characterdisplay.cpp delete mode 100644 src/gui/widgets/characterdisplay.h delete mode 100644 src/gui/widgets/characterviewbase.h delete mode 100644 src/gui/widgets/characterviewnormal.cpp delete mode 100644 src/gui/widgets/characterviewnormal.h delete mode 100644 src/gui/widgets/characterviewsmall.cpp delete mode 100644 src/gui/widgets/characterviewsmall.h delete mode 100644 src/gui/widgets/chatinput.h delete mode 100644 src/gui/widgets/checkbox.cpp delete mode 100644 src/gui/widgets/checkbox.h delete mode 100644 src/gui/widgets/colorpage.cpp delete mode 100644 src/gui/widgets/colorpage.h delete mode 100644 src/gui/widgets/container.cpp delete mode 100644 src/gui/widgets/container.h delete mode 100644 src/gui/widgets/containerplacer.cpp delete mode 100644 src/gui/widgets/containerplacer.h delete mode 100644 src/gui/widgets/createwidget.h delete mode 100644 src/gui/widgets/desktop.cpp delete mode 100644 src/gui/widgets/desktop.h delete mode 100644 src/gui/widgets/dropdown.cpp delete mode 100644 src/gui/widgets/dropdown.h delete mode 100644 src/gui/widgets/emotepage.cpp delete mode 100644 src/gui/widgets/emotepage.h delete mode 100644 src/gui/widgets/emoteshortcutcontainer.cpp delete mode 100644 src/gui/widgets/emoteshortcutcontainer.h delete mode 100644 src/gui/widgets/equipmentbox.h delete mode 100644 src/gui/widgets/equipmentpage.h delete mode 100644 src/gui/widgets/extendedlistbox.cpp delete mode 100644 src/gui/widgets/extendedlistbox.h delete mode 100644 src/gui/widgets/extendedlistboxitem.h delete mode 100644 src/gui/widgets/flowcontainer.cpp delete mode 100644 src/gui/widgets/flowcontainer.h delete mode 100644 src/gui/widgets/guitable.cpp delete mode 100644 src/gui/widgets/guitable.h delete mode 100644 src/gui/widgets/horizontcontainer.cpp delete mode 100644 src/gui/widgets/horizontcontainer.h delete mode 100644 src/gui/widgets/icon.cpp delete mode 100644 src/gui/widgets/icon.h delete mode 100644 src/gui/widgets/inttextfield.cpp delete mode 100644 src/gui/widgets/inttextfield.h delete mode 100644 src/gui/widgets/itemcontainer.cpp delete mode 100644 src/gui/widgets/itemcontainer.h delete mode 100644 src/gui/widgets/itemlinkhandler.cpp delete mode 100644 src/gui/widgets/itemlinkhandler.h delete mode 100644 src/gui/widgets/itemshortcutcontainer.cpp delete mode 100644 src/gui/widgets/itemshortcutcontainer.h delete mode 100644 src/gui/widgets/label.cpp delete mode 100644 src/gui/widgets/label.h delete mode 100644 src/gui/widgets/layout.cpp delete mode 100644 src/gui/widgets/layout.h delete mode 100644 src/gui/widgets/layoutarray.cpp delete mode 100644 src/gui/widgets/layoutarray.h delete mode 100644 src/gui/widgets/layoutcell.cpp delete mode 100644 src/gui/widgets/layoutcell.h delete mode 100644 src/gui/widgets/layouthelper.cpp delete mode 100644 src/gui/widgets/layouthelper.h delete mode 100644 src/gui/widgets/linepart.cpp delete mode 100644 src/gui/widgets/linepart.h delete mode 100644 src/gui/widgets/linkhandler.h delete mode 100644 src/gui/widgets/listbox.cpp delete mode 100644 src/gui/widgets/listbox.h delete mode 100644 src/gui/widgets/passwordfield.cpp delete mode 100644 src/gui/widgets/passwordfield.h delete mode 100644 src/gui/widgets/playerbox.cpp delete mode 100644 src/gui/widgets/playerbox.h delete mode 100644 src/gui/widgets/popup.cpp delete mode 100644 src/gui/widgets/popup.h delete mode 100644 src/gui/widgets/popuplist.cpp delete mode 100644 src/gui/widgets/popuplist.h delete mode 100644 src/gui/widgets/progressbar.cpp delete mode 100644 src/gui/widgets/progressbar.h delete mode 100644 src/gui/widgets/progressindicator.cpp delete mode 100644 src/gui/widgets/progressindicator.h delete mode 100644 src/gui/widgets/radiobutton.cpp delete mode 100644 src/gui/widgets/radiobutton.h delete mode 100644 src/gui/widgets/radiogroup.cpp delete mode 100644 src/gui/widgets/radiogroup.h delete mode 100644 src/gui/widgets/scrollarea.cpp delete mode 100644 src/gui/widgets/scrollarea.h delete mode 100644 src/gui/widgets/selldialog.cpp delete mode 100644 src/gui/widgets/selldialog.h delete mode 100644 src/gui/widgets/serverslistbox.h delete mode 100644 src/gui/widgets/setupbuttonitem.cpp delete mode 100644 src/gui/widgets/setupbuttonitem.h delete mode 100644 src/gui/widgets/setupitem.cpp delete mode 100644 src/gui/widgets/setupitem.h delete mode 100644 src/gui/widgets/setupquickitem.cpp delete mode 100644 src/gui/widgets/setupquickitem.h delete mode 100644 src/gui/widgets/setuptouchitem.cpp delete mode 100644 src/gui/widgets/setuptouchitem.h delete mode 100644 src/gui/widgets/shoplistbox.cpp delete mode 100644 src/gui/widgets/shoplistbox.h delete mode 100644 src/gui/widgets/shortcutcontainer.cpp delete mode 100644 src/gui/widgets/shortcutcontainer.h delete mode 100644 src/gui/widgets/skilllistbox.h delete mode 100644 src/gui/widgets/skillrectanglelistbox.h delete mode 100644 src/gui/widgets/slider.cpp delete mode 100644 src/gui/widgets/slider.h delete mode 100644 src/gui/widgets/sliderlist.cpp delete mode 100644 src/gui/widgets/sliderlist.h delete mode 100644 src/gui/widgets/spellshortcutcontainer.cpp delete mode 100644 src/gui/widgets/spellshortcutcontainer.h delete mode 100644 src/gui/widgets/staticbrowserbox.cpp delete mode 100644 src/gui/widgets/staticbrowserbox.h delete mode 100644 src/gui/widgets/statspage.cpp delete mode 100644 src/gui/widgets/statspage.h delete mode 100644 src/gui/widgets/statspagebasic.cpp delete mode 100644 src/gui/widgets/statspagebasic.h delete mode 100644 src/gui/widgets/tabbedarea.cpp delete mode 100644 src/gui/widgets/tabbedarea.h delete mode 100644 src/gui/widgets/tabs/chat/battletab.cpp delete mode 100644 src/gui/widgets/tabs/chat/battletab.h delete mode 100644 src/gui/widgets/tabs/chat/channeltab.cpp delete mode 100644 src/gui/widgets/tabs/chat/channeltab.h delete mode 100644 src/gui/widgets/tabs/chat/chattab.cpp delete mode 100644 src/gui/widgets/tabs/chat/chattab.h delete mode 100644 src/gui/widgets/tabs/chat/emulateguildtab.cpp delete mode 100644 src/gui/widgets/tabs/chat/emulateguildtab.h delete mode 100644 src/gui/widgets/tabs/chat/gmtab.cpp delete mode 100644 src/gui/widgets/tabs/chat/gmtab.h delete mode 100644 src/gui/widgets/tabs/chat/guildtab.cpp delete mode 100644 src/gui/widgets/tabs/chat/guildtab.h delete mode 100644 src/gui/widgets/tabs/chat/langtab.cpp delete mode 100644 src/gui/widgets/tabs/chat/langtab.h delete mode 100644 src/gui/widgets/tabs/chat/partytab.cpp delete mode 100644 src/gui/widgets/tabs/chat/partytab.h delete mode 100644 src/gui/widgets/tabs/chat/tradetab.cpp delete mode 100644 src/gui/widgets/tabs/chat/tradetab.h delete mode 100644 src/gui/widgets/tabs/chat/whispertab.cpp delete mode 100644 src/gui/widgets/tabs/chat/whispertab.h delete mode 100644 src/gui/widgets/tabs/debugwindowtabs.cpp delete mode 100644 src/gui/widgets/tabs/debugwindowtabs.h delete mode 100644 src/gui/widgets/tabs/setup_audio.cpp delete mode 100644 src/gui/widgets/tabs/setup_audio.h delete mode 100644 src/gui/widgets/tabs/setup_chat.cpp delete mode 100644 src/gui/widgets/tabs/setup_chat.h delete mode 100644 src/gui/widgets/tabs/setup_colors.cpp delete mode 100644 src/gui/widgets/tabs/setup_colors.h delete mode 100644 src/gui/widgets/tabs/setup_input.cpp delete mode 100644 src/gui/widgets/tabs/setup_input.h delete mode 100644 src/gui/widgets/tabs/setup_joystick.cpp delete mode 100644 src/gui/widgets/tabs/setup_joystick.h delete mode 100644 src/gui/widgets/tabs/setup_misc.cpp delete mode 100644 src/gui/widgets/tabs/setup_misc.h delete mode 100644 src/gui/widgets/tabs/setup_mods.cpp delete mode 100644 src/gui/widgets/tabs/setup_mods.h delete mode 100644 src/gui/widgets/tabs/setup_perfomance.cpp delete mode 100644 src/gui/widgets/tabs/setup_perfomance.h delete mode 100644 src/gui/widgets/tabs/setup_players.cpp delete mode 100644 src/gui/widgets/tabs/setup_players.h delete mode 100644 src/gui/widgets/tabs/setup_quick.cpp delete mode 100644 src/gui/widgets/tabs/setup_quick.h delete mode 100644 src/gui/widgets/tabs/setup_relations.cpp delete mode 100644 src/gui/widgets/tabs/setup_relations.h delete mode 100644 src/gui/widgets/tabs/setup_theme.cpp delete mode 100644 src/gui/widgets/tabs/setup_theme.h delete mode 100644 src/gui/widgets/tabs/setup_touch.cpp delete mode 100644 src/gui/widgets/tabs/setup_touch.h delete mode 100644 src/gui/widgets/tabs/setup_video.cpp delete mode 100644 src/gui/widgets/tabs/setup_video.h delete mode 100644 src/gui/widgets/tabs/setup_visual.cpp delete mode 100644 src/gui/widgets/tabs/setup_visual.h delete mode 100644 src/gui/widgets/tabs/setuptab.cpp delete mode 100644 src/gui/widgets/tabs/setuptab.h delete mode 100644 src/gui/widgets/tabs/setuptabscroll.cpp delete mode 100644 src/gui/widgets/tabs/setuptabscroll.h delete mode 100644 src/gui/widgets/tabs/shortcuttab.h delete mode 100644 src/gui/widgets/tabs/skilltab.h delete mode 100644 src/gui/widgets/tabs/socialattacktab.h delete mode 100644 src/gui/widgets/tabs/socialfriendsfunctor.h delete mode 100644 src/gui/widgets/tabs/socialfriendstab.h delete mode 100644 src/gui/widgets/tabs/socialguildtab.h delete mode 100644 src/gui/widgets/tabs/socialguildtab2.h delete mode 100644 src/gui/widgets/tabs/socialnavigationtab.h delete mode 100644 src/gui/widgets/tabs/socialpartytab.h delete mode 100644 src/gui/widgets/tabs/socialpickuptab.h delete mode 100644 src/gui/widgets/tabs/socialplayerstab.h delete mode 100644 src/gui/widgets/tabs/socialtab.h delete mode 100644 src/gui/widgets/tabs/socialtabbase.h delete mode 100644 src/gui/widgets/tabs/tab.cpp delete mode 100644 src/gui/widgets/tabs/tab.h delete mode 100644 src/gui/widgets/tabstrip.cpp delete mode 100644 src/gui/widgets/tabstrip.h delete mode 100644 src/gui/widgets/textbox.cpp delete mode 100644 src/gui/widgets/textbox.h delete mode 100644 src/gui/widgets/textfield.cpp delete mode 100644 src/gui/widgets/textfield.h delete mode 100644 src/gui/widgets/textpreview.cpp delete mode 100644 src/gui/widgets/textpreview.h delete mode 100644 src/gui/widgets/vertcontainer.cpp delete mode 100644 src/gui/widgets/vertcontainer.h delete mode 100644 src/gui/widgets/virtshortcutcontainer.cpp delete mode 100644 src/gui/widgets/virtshortcutcontainer.h delete mode 100644 src/gui/widgets/widget.cpp delete mode 100644 src/gui/widgets/widget.h delete mode 100644 src/gui/widgets/widget2.h delete mode 100644 src/gui/widgets/widgetgroup.cpp delete mode 100644 src/gui/widgets/widgetgroup.h delete mode 100644 src/gui/widgets/window.cpp delete mode 100644 src/gui/widgets/window.h delete mode 100644 src/gui/widgets/windowcontainer.cpp delete mode 100644 src/gui/widgets/windowcontainer.h delete mode 100644 src/gui/windowmanager.cpp delete mode 100644 src/gui/windowmanager.h delete mode 100644 src/gui/windowmenu.cpp delete mode 100644 src/gui/windowmenu.h delete mode 100644 src/gui/windows/bankwindow.cpp delete mode 100644 src/gui/windows/bankwindow.h delete mode 100644 src/gui/windows/buydialog.cpp delete mode 100644 src/gui/windows/buydialog.h delete mode 100644 src/gui/windows/buyingstoreselldialog.cpp delete mode 100644 src/gui/windows/buyingstoreselldialog.h delete mode 100644 src/gui/windows/buyselldialog.cpp delete mode 100644 src/gui/windows/buyselldialog.h delete mode 100644 src/gui/windows/changeemaildialog.cpp delete mode 100644 src/gui/windows/changeemaildialog.h delete mode 100644 src/gui/windows/changepassworddialog.cpp delete mode 100644 src/gui/windows/changepassworddialog.h delete mode 100644 src/gui/windows/charcreatedialog.cpp delete mode 100644 src/gui/windows/charcreatedialog.h delete mode 100644 src/gui/windows/chardeleteconfirm.h delete mode 100644 src/gui/windows/charselectdialog.cpp delete mode 100644 src/gui/windows/charselectdialog.h delete mode 100644 src/gui/windows/chatwindow.cpp delete mode 100644 src/gui/windows/chatwindow.h delete mode 100644 src/gui/windows/confirmdialog.cpp delete mode 100644 src/gui/windows/confirmdialog.h delete mode 100644 src/gui/windows/connectiondialog.cpp delete mode 100644 src/gui/windows/connectiondialog.h delete mode 100644 src/gui/windows/cutinwindow.cpp delete mode 100644 src/gui/windows/cutinwindow.h delete mode 100644 src/gui/windows/debugwindow.cpp delete mode 100644 src/gui/windows/debugwindow.h delete mode 100644 src/gui/windows/didyouknowwindow.cpp delete mode 100644 src/gui/windows/didyouknowwindow.h delete mode 100644 src/gui/windows/editdialog.cpp delete mode 100644 src/gui/windows/editdialog.h delete mode 100644 src/gui/windows/editserverdialog.cpp delete mode 100644 src/gui/windows/editserverdialog.h delete mode 100644 src/gui/windows/eggselectiondialog.cpp delete mode 100644 src/gui/windows/eggselectiondialog.h delete mode 100644 src/gui/windows/emotewindow.cpp delete mode 100644 src/gui/windows/emotewindow.h delete mode 100644 src/gui/windows/equipmentwindow.cpp delete mode 100644 src/gui/windows/equipmentwindow.h delete mode 100644 src/gui/windows/helpwindow.cpp delete mode 100644 src/gui/windows/helpwindow.h delete mode 100644 src/gui/windows/insertcarddialog.cpp delete mode 100644 src/gui/windows/insertcarddialog.h delete mode 100644 src/gui/windows/inventorywindow.cpp delete mode 100644 src/gui/windows/inventorywindow.h delete mode 100644 src/gui/windows/itemamountwindow.cpp delete mode 100644 src/gui/windows/itemamountwindow.h delete mode 100644 src/gui/windows/killstats.cpp delete mode 100644 src/gui/windows/killstats.h delete mode 100644 src/gui/windows/logindialog.cpp delete mode 100644 src/gui/windows/logindialog.h delete mode 100644 src/gui/windows/maileditwindow.cpp delete mode 100644 src/gui/windows/maileditwindow.h delete mode 100644 src/gui/windows/mailviewwindow.cpp delete mode 100644 src/gui/windows/mailviewwindow.h delete mode 100644 src/gui/windows/mailwindow.cpp delete mode 100644 src/gui/windows/mailwindow.h delete mode 100644 src/gui/windows/minimap.cpp delete mode 100644 src/gui/windows/minimap.h delete mode 100644 src/gui/windows/ministatuswindow.cpp delete mode 100644 src/gui/windows/ministatuswindow.h delete mode 100644 src/gui/windows/npcdialog.cpp delete mode 100644 src/gui/windows/npcdialog.h delete mode 100644 src/gui/windows/npcselldialog.cpp delete mode 100644 src/gui/windows/npcselldialog.h delete mode 100644 src/gui/windows/okdialog.cpp delete mode 100644 src/gui/windows/okdialog.h delete mode 100644 src/gui/windows/outfitwindow.cpp delete mode 100644 src/gui/windows/outfitwindow.h delete mode 100644 src/gui/windows/questswindow.cpp delete mode 100644 src/gui/windows/questswindow.h delete mode 100644 src/gui/windows/quitdialog.cpp delete mode 100644 src/gui/windows/quitdialog.h delete mode 100644 src/gui/windows/registerdialog.cpp delete mode 100644 src/gui/windows/registerdialog.h delete mode 100644 src/gui/windows/serverdialog.cpp delete mode 100644 src/gui/windows/serverdialog.h delete mode 100644 src/gui/windows/serverinfowindow.cpp delete mode 100644 src/gui/windows/serverinfowindow.h delete mode 100644 src/gui/windows/setupwindow.cpp delete mode 100644 src/gui/windows/setupwindow.h delete mode 100644 src/gui/windows/shopselldialog.cpp delete mode 100644 src/gui/windows/shopselldialog.h delete mode 100644 src/gui/windows/shopwindow.cpp delete mode 100644 src/gui/windows/shopwindow.h delete mode 100644 src/gui/windows/shortcutwindow.cpp delete mode 100644 src/gui/windows/shortcutwindow.h delete mode 100644 src/gui/windows/skilldialog.cpp delete mode 100644 src/gui/windows/skilldialog.h delete mode 100644 src/gui/windows/socialwindow.cpp delete mode 100644 src/gui/windows/socialwindow.h delete mode 100644 src/gui/windows/statuswindow.cpp delete mode 100644 src/gui/windows/statuswindow.h delete mode 100644 src/gui/windows/textcommandeditor.cpp delete mode 100644 src/gui/windows/textcommandeditor.h delete mode 100644 src/gui/windows/textdialog.cpp delete mode 100644 src/gui/windows/textdialog.h delete mode 100644 src/gui/windows/textselectdialog.cpp delete mode 100644 src/gui/windows/textselectdialog.h delete mode 100644 src/gui/windows/tradewindow.cpp delete mode 100644 src/gui/windows/tradewindow.h delete mode 100644 src/gui/windows/updaterwindow.cpp delete mode 100644 src/gui/windows/updaterwindow.h delete mode 100644 src/gui/windows/whoisonline.cpp delete mode 100644 src/gui/windows/whoisonline.h delete mode 100644 src/gui/windows/worldselectdialog.cpp delete mode 100644 src/gui/windows/worldselectdialog.h (limited to 'src/gui') diff --git a/src/gui/browserlink.h b/src/gui/browserlink.h deleted file mode 100644 index a8dc0cb6f..000000000 --- a/src/gui/browserlink.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * Copyright (C) 2009 Aethyra Development Team - * - * 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 . - */ - -#ifndef GUI_BROWSERLINK_H -#define GUI_BROWSERLINK_H - -#include - -#include "localconsts.h" - -struct BrowserLink final -{ - BrowserLink() : - x1(0), - x2(0), - y1(0), - y2(0), - link(), - caption() - { - } - - A_DEFAULT_COPY(BrowserLink) - - int x1; - int x2; - int y1; - int y2; - std::string link; - std::string caption; -}; - -#endif // GUI_BROWSERLINK_H diff --git a/src/gui/buttoninfo.h b/src/gui/buttoninfo.h deleted file mode 100644 index d6039e08f..000000000 --- a/src/gui/buttoninfo.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_BUTTONINFO_H -#define GUI_BUTTONINFO_H - -#include "enums/input/inputaction.h" - -#include "enums/simpletypes/visible.h" - -#include "localconsts.h" - -class Button; - -struct ButtonInfo final -{ - ButtonInfo(Button *const button0, - const InputActionT key0, - const Visible visible0) : - button(button0), - key(key0), - visible(visible0) - { - } - - A_DELETE_COPY(ButtonInfo) - - Button *button; - InputActionT key; - Visible visible; -}; -#endif // GUI_BUTTONINFO_H diff --git a/src/gui/buttontext.h b/src/gui/buttontext.h deleted file mode 100644 index f827859b6..000000000 --- a/src/gui/buttontext.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_BUTTONTEXT_H -#define GUI_BUTTONTEXT_H - -#include "enums/input/inputaction.h" - -#include "localconsts.h" - -#include - -struct ButtonText final -{ - ButtonText(const std::string &text0, - const InputActionT key0) : - text(text0), - key(key0) - { - } - - A_DELETE_COPY(ButtonText) - - std::string text; - InputActionT key; -}; - -#endif // GUI_BUTTONTEXT_H diff --git a/src/gui/chatlog.h b/src/gui/chatlog.h deleted file mode 100644 index 20820ad13..000000000 --- a/src/gui/chatlog.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_CHATLOG_H -#define GUI_CHATLOG_H - -#include "enums/gui/chatmsgtype.h" - -#include - -#include "localconsts.h" - -/** One item in the chat log */ -struct CHATLOG final -{ - CHATLOG() : - nick(), - text(), - own(ChatMsgType::BY_UNKNOWN) - { - } - - A_DELETE_COPY(CHATLOG) - - std::string nick; - std::string text; - ChatMsgTypeT own; -}; -#endif // GUI_CHATLOG_H diff --git a/src/gui/cliprect.h b/src/gui/cliprect.h deleted file mode 100644 index 149420b8c..000000000 --- a/src/gui/cliprect.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 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 . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * 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_CLIPRECT_H -#define GUI_CLIPRECT_H - -#include "gui/rect.h" - -#include "localconsts.h" - -/** - * 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 -{ - public: - /** - * Constructor. - */ - ClipRect() : - Rect(0, 0, 0, 0), - xOffset(0), - yOffset(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) : - Rect(x0, y0, width0, height0), - xOffset(xOffset0), - yOffset(yOffset0) - { - } - - A_DELETE_COPY(ClipRect) - - /** - * Holds the x offset of the x coordinate. - */ - int xOffset; - - /** - * Holds the y offset of the y coordinate. - */ - int yOffset; -}; - -#endif // GUI_CLIPRECT_H diff --git a/src/gui/color.h b/src/gui/color.h deleted file mode 100644 index c4a1aab01..000000000 --- a/src/gui/color.h +++ /dev/null @@ -1,253 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 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 . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * 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_COLOR_H -#define GUI_COLOR_H - -#include "utils/cast.h" - -#include "localconsts.h" - -/** - * Represents a color with red, green, blue and alpha components. - */ -class Color final -{ - public: - /** - * Constructor. Initializes the color to black. - */ - constexpr Color() : - r(0U), - g(0U), - b(0U), - a(255U) - { - } - - /** - * 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 constexpr Color(const unsigned int color) : - r((color >> 16) & 0xFFU), - g((color >> 8) & 0xFFU), - b(color & 0xFFU), - a(255U) - { - } - - /** - * Constructor. The default alpha value is 255. - * - * @param ar Red color component (range 0-255). - * @param ag Green color component (range 0-255). - * @param ab Blue color component (range 0-255). - * @param aa Alpha, used for transparency. A value of 0 means - * totaly transparent, 255 is totaly opaque. - */ - constexpr Color(const unsigned int ar, - const unsigned int ag, - const unsigned int ab, - const unsigned int aa = 255) : - r(ar), - g(ag), - b(ab), - a(aa) - { - } - - - A_DEFAULT_COPY(Color) - - /** - * 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. - */ - constexpr2 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; - } - - /** - * 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. - */ - constexpr2 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; - } - - /** - * 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. - */ - constexpr2 Color operator*(const float value) const - { - Color result(CAST_U32(static_cast(r) * value), - CAST_U32(static_cast(g) * value), - CAST_U32(static_cast(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; - } - - /** - * Compares two colors. - * - * @return True if the two colors have the same RGBA components - * false otherwise. - */ - constexpr bool operator==(const Color& color) const - { - return r == color.r && - g == color.g && - b == color.b && - a == color.a; - } - - /** - * Compares two colors. - * - * @return True if the two colors have different RGBA components, - * false otherwise. - */ - constexpr bool operator!=(const Color& color) const - { - return !(r == color.r && - g == color.g && - b == color.b && - a == color.a); - } - - /** - * Holds the red color component (range 0-255). - */ - unsigned int r; - - /** - * Holds the green color component (range 0-255). - */ - unsigned int g; - - /** - * 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. - */ - unsigned int a; -}; - -#endif // GUI_COLOR_H diff --git a/src/gui/colorpair.h b/src/gui/colorpair.h deleted file mode 100644 index f3089868e..000000000 --- a/src/gui/colorpair.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 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 . - */ - -#ifndef GUI_COLORPAIR_H -#define GUI_COLORPAIR_H - -#include "localconsts.h" - -class Color; - -struct ColorPair final -{ - constexpr ColorPair(const Color *const c1, - const Color *const c2) : - color1(c1), - color2(c2) - { - } - - A_DEFAULT_COPY(ColorPair) - - const Color *color1; - const Color *color2; -}; - -#endif // GUI_COLORPAIR_H diff --git a/src/gui/dialogsmanager.cpp b/src/gui/dialogsmanager.cpp deleted file mode 100644 index f24352a43..000000000 --- a/src/gui/dialogsmanager.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#include "gui/dialogsmanager.h" - -#include "configuration.h" -#include "settings.h" - -#include "being/playerinfo.h" - -#include "gui/widgets/createwidget.h" - -#include "gui/windows/confirmdialog.h" - -#ifndef DYECMD -#include "gui/widgets/selldialog.h" - -#include "gui/windows/buyselldialog.h" -#include "gui/windows/buydialog.h" -#include "gui/windows/updaterwindow.h" - -#include "listeners/playerpostdeathlistener.h" -#endif // DYECMD - -#include "listeners/weightlistener.h" - -#include "net/inventoryhandler.h" - -#include "resources/db/deaddb.h" - -#include "utils/gettext.h" - -#include "debug.h" - -#ifdef WIN32 -#undef ERROR -#endif // WIN32 - -OkDialog *deathNotice = nullptr; -DialogsManager *dialogsManager = nullptr; -OkDialog *weightNotice = nullptr; -time_t weightNoticeTime = 0; - -#ifndef DYECMD -namespace -{ - PlayerPostDeathListener postDeathListener; - WeightListener weightListener; -} // namespace -#endif // DYECMD - -DialogsManager::DialogsManager() : - AttributeListener(), - PlayerDeathListener() -{ -} - -void DialogsManager::closeDialogs() -{ -#ifndef DYECMD - NpcDialog::clearDialogs(); - BuyDialog::closeAll(); - BuySellDialog::closeAll(); - NpcDialog::closeAll(); - SellDialog::closeAll(); - if (inventoryHandler != nullptr) - inventoryHandler->destroyStorage(); -#endif // DYECMD - - if (deathNotice != nullptr) - { - deathNotice->scheduleDelete(); - deathNotice = nullptr; - } -} - -void DialogsManager::createUpdaterWindow() -{ -#ifndef DYECMD - CREATEWIDGETV(updaterWindow, UpdaterWindow, - settings.updateHost, - settings.oldUpdates, - false, - UpdateType::Normal); -#endif // DYECMD -} - -Window *DialogsManager::openErrorDialog(const std::string &header, - const std::string &message, - const Modal modal) -{ - if (settings.supportUrl.empty() || config.getBoolValue("hidesupport")) - { - OkDialog *const dialog = CREATEWIDGETR(OkDialog, - header, - message, - // TRANSLATORS: ok dialog button - _("Close"), - DialogType::ERROR, - modal, - ShowCenter_true, - nullptr, - 260); - return dialog; - } - ConfirmDialog *const dialog = CREATEWIDGETR(ConfirmDialog, - header, - strprintf("%s %s", message.c_str(), - // TRANSLATORS: error message question - _("Do you want to open support page?")), - SOUND_ERROR, - false, - modal); - return dialog; -} - -void DialogsManager::playerDeath() -{ -#ifndef DYECMD - if (deathNotice == nullptr) - { - CREATEWIDGETV(deathNotice, OkDialog, - // TRANSLATORS: message header - _("Message"), - DeadDB::getRandomString(), - // TRANSLATORS: ok dialog button - _("Revive"), - DialogType::OK, - Modal_false, - ShowCenter_true, - nullptr, - 260); - deathNotice->addActionListener(&postDeathListener); - } -#endif // DYECMD -} - -#ifndef DYECMD -void DialogsManager::attributeChanged(const AttributesT id, - const int64_t oldVal, - const int64_t newVal) -{ - if (id == Attributes::TOTAL_WEIGHT) - { - if ((weightNotice == nullptr) && config.getBoolValue("weightMsg")) - { - int percent = settings.overweightPercent; - if (percent < 1) - percent = 50; - const int max = PlayerInfo::getAttribute( - Attributes::MAX_WEIGHT) * percent / 100; - const int total = CAST_S32(oldVal); - if (newVal >= max && total < max) - { - weightNoticeTime = cur_time + 5; - CREATEWIDGETV(weightNotice, OkDialog, - // TRANSLATORS: message header - _("Message"), - // TRANSLATORS: weight message - _("You are carrying more than " - "half your weight. You are " - "unable to regain health."), - // TRANSLATORS: ok dialog button - _("OK"), - DialogType::OK, - Modal_false, - ShowCenter_true, - nullptr, - 260); - weightNotice->addActionListener( - &weightListener); - } - else if (newVal < max && total >= max) - { - weightNoticeTime = cur_time + 5; - CREATEWIDGETV(weightNotice, OkDialog, - // TRANSLATORS: message header - _("Message"), - // TRANSLATORS: weight message - _("You are carrying less than " - "half your weight. You " - "can regain health."), - // TRANSLATORS: ok dialog button - _("OK"), - DialogType::OK, - Modal_false, - ShowCenter_true, - nullptr, - 260); - weightNotice->addActionListener( - &weightListener); - } - } - } -} -#else // DYECMD - -void DialogsManager::attributeChanged(const AttributesT id A_UNUSED, - const int64_t oldVal A_UNUSED, - const int64_t newVal A_UNUSED) -{ -} -#endif // DYECMD diff --git a/src/gui/dialogsmanager.h b/src/gui/dialogsmanager.h deleted file mode 100644 index 04ace68e2..000000000 --- a/src/gui/dialogsmanager.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_DIALOGSMANAGER_H -#define GUI_DIALOGSMANAGER_H - -#include "enums/simpletypes/modal.h" - -#include "listeners/attributelistener.h" -#include "listeners/playerdeathlistener.h" - -#include - -#include "localconsts.h" - -class Window; - -class DialogsManager final : public AttributeListener, - public PlayerDeathListener -{ - public: - DialogsManager(); - - virtual ~DialogsManager() - { } - - A_DELETE_COPY(DialogsManager) - - static void closeDialogs(); - - static void createUpdaterWindow(); - - static Window *openErrorDialog(const std::string &header, - const std::string &message, - const Modal modal) RETURNS_NONNULL; - - void playerDeath() override final; - - void attributeChanged(const AttributesT id, - const int64_t oldVal, - const int64_t newVal) override final; -}; - -extern DialogsManager *dialogsManager; - -#endif // GUI_DIALOGSMANAGER_H diff --git a/src/gui/focushandler.cpp b/src/gui/focushandler.cpp deleted file mode 100644 index ebfc988ac..000000000 --- a/src/gui/focushandler.cpp +++ /dev/null @@ -1,621 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * 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 "utils/foreach.h" - -#include "debug.h" - -FocusHandler::FocusHandler() : - mWidgets(), - mFocusedWidget(nullptr), - mModalFocusedWidget(nullptr), - mModalMouseInputFocusedWidget(nullptr), - mDraggedWidget(nullptr), - mLastWidgetWithMouse(nullptr), - mLastWidgetWithModalFocus(nullptr), - mLastWidgetWithModalMouseInputFocus(nullptr), - mLastWidgetPressed(nullptr), - mModalStack() -{ -} - -void FocusHandler::requestModalFocus(Widget *const widget) -{ - /* If there is another widget with modal focus, remove its modal focus - * and put it on the modal widget stack. - */ - if ((mModalFocusedWidget != nullptr) && mModalFocusedWidget != widget) - { - mModalStack.push_front(mModalFocusedWidget); - mModalFocusedWidget = nullptr; - } - - mModalFocusedWidget = widget; - if ((mFocusedWidget != nullptr) && !mFocusedWidget->isModalFocused()) - focusNone(); -} - -void FocusHandler::releaseModalFocus(Widget *const widget) -{ - mModalStack.remove(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()) - { - requestModalFocus(mModalStack.front()); - mModalStack.pop_front(); - } - } -} - -void FocusHandler::remove(Widget *const widget) -{ - releaseModalFocus(widget); - - if (isFocused(widget)) - mFocusedWidget = nullptr; - - FOR_EACH (WidgetIterator, iter, mWidgets) - { - 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() -{ - if (mFocusedWidget != nullptr) - { - if (!mFocusedWidget->isTabOutEnabled()) - return; - } - - if (mWidgets.empty()) - { - mFocusedWidget = nullptr; - return; - } - - int i; - int focusedWidget = -1; - const int sz = CAST_S32(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 == nullptr) || 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() -{ - if (mFocusedWidget != nullptr) - { - if (!mFocusedWidget->isTabOutEnabled()) - return; - } - - if (mWidgets.empty()) - { - mFocusedWidget = nullptr; - return; - } - - int i; - int focusedWidget = -1; - const int sz = CAST_S32(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 == nullptr) || 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::checkForWindow() const -{ - if (mFocusedWidget != nullptr) - { - Widget *widget = mFocusedWidget->getParent(); - - while (widget != nullptr) - { - Window *const window = dynamic_cast(widget); - - if (window != nullptr) - { - window->requestMoveToTop(); - break; - } - - widget = widget->getParent(); - } - } -} - -void FocusHandler::distributeFocusGainedEvent(const Event &focusEvent) -{ - if (gui != nullptr) - gui->distributeGlobalFocusGainedEvent(focusEvent); - - const Widget *const sourceWidget = focusEvent.getSource(); - - if (sourceWidget == nullptr) - return; - std::list focusListeners - = sourceWidget->getFocusListeners(); - - // Send the event to all focus listeners of the widget. - for (std::list::const_iterator - it = focusListeners.begin(); - it != focusListeners.end(); - ++ it) - { - (*it)->focusGained(focusEvent); - } -} - -void FocusHandler::requestFocus(const Widget *const widget) -{ - if ((widget == nullptr) || widget == mFocusedWidget) - return; - - int toBeFocusedIndex = -1; - for (unsigned int i = 0, fsz = CAST_U32( - mWidgets.size()); i < fsz; ++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 != nullptr) - { - Event focusEvent(oldFocused); - distributeFocusLostEvent(focusEvent); - } - - Event focusEvent(mWidgets.at(toBeFocusedIndex)); - distributeFocusGainedEvent(focusEvent); - } -} - -void FocusHandler::requestModalMouseInputFocus(Widget *const widget) -{ - if ((mModalMouseInputFocusedWidget != nullptr) - && mModalMouseInputFocusedWidget != widget) - { - return; - } - - mModalMouseInputFocusedWidget = widget; -} - -void FocusHandler::releaseModalMouseInputFocus(const Widget *const 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 = CAST_S32(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 = CAST_S32(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 *const widget) const -{ - return mFocusedWidget == widget; -} - -void FocusHandler::add(Widget *const widget) -{ - mWidgets.push_back(widget); -} - -void FocusHandler::focusNone() -{ - if (mFocusedWidget != nullptr) - { - Widget *const focused = mFocusedWidget; - mFocusedWidget = nullptr; - - Event focusEvent(focused); - distributeFocusLostEvent(focusEvent); - } -} - -void FocusHandler::distributeFocusLostEvent(const Event& focusEvent) -{ - const Widget *const sourceWidget = focusEvent.getSource(); - if (sourceWidget == nullptr) - return; - - std::list focusListeners - = sourceWidget->getFocusListeners(); - - // Send the event to all focus listeners of the widget. - for (std::list::const_iterator - it = focusListeners.begin(); - it != focusListeners.end(); - ++ it) - { - (*it)->focusLost(focusEvent); - } -} - -Widget* FocusHandler::getDraggedWidget() const -{ - return mDraggedWidget; -} - -void FocusHandler::setDraggedWidget(Widget *const draggedWidget) -{ - mDraggedWidget = draggedWidget; -} - -Widget* FocusHandler::getLastWidgetWithMouse() const -{ - return mLastWidgetWithMouse; -} - -void FocusHandler::setLastWidgetWithMouse(Widget *const lastWidgetWithMouse) -{ - mLastWidgetWithMouse = lastWidgetWithMouse; -} - -Widget* FocusHandler::getLastWidgetWithModalFocus() const -{ - return mLastWidgetWithModalFocus; -} - -void FocusHandler::setLastWidgetWithModalFocus(Widget *const widget) -{ - mLastWidgetWithModalFocus = widget; -} - -Widget* FocusHandler::getLastWidgetWithModalMouseInputFocus() const -{ - return mLastWidgetWithModalMouseInputFocus; -} - -void FocusHandler::setLastWidgetWithModalMouseInputFocus(Widget *const widget) -{ - mLastWidgetWithModalMouseInputFocus = widget; -} - -Widget* FocusHandler::getLastWidgetPressed() const -{ - return mLastWidgetPressed; -} - -void FocusHandler::setLastWidgetPressed(Widget *const lastWidgetPressed) -{ - mLastWidgetPressed = lastWidgetPressed; -} diff --git a/src/gui/focushandler.h b/src/gui/focushandler.h deleted file mode 100644 index 248ae8f71..000000000 --- a/src/gui/focushandler.h +++ /dev/null @@ -1,410 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * 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 "utils/vector.h" - -#include - -#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: - FocusHandler(); - - A_DELETE_COPY(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 - */ - void requestFocus(const Widget *const 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 - */ - void requestModalFocus(Widget *const 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 - */ - void requestModalMouseInputFocus(Widget *const 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 - */ - void releaseModalFocus(Widget *const 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(const Widget *const 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 *const 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 *const widget); - - /** - * Removes a widget from the focus handler. - * - * @param widget The widget to remove. - * @see add - */ - void remove(Widget *const 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() const 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 *const 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() const 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 *const lastWidgetWithMouse); - - /** - * Gets the last widget with modal focus. - * - * @return The last widget with modal focus. - * @see setLastWidgetWithModalFocus - */ - Widget* getLastWidgetWithModalFocus() const A_WARN_UNUSED; - - /** - * Sets the last widget with modal focus. - * - * @param widget The last widget with modal focus. - * @see getLastWidgetWithModalFocus - */ - void setLastWidgetWithModalFocus(Widget *const widget); - - /** - * Gets the last widget with modal mouse input focus. - * - * @return The last widget with modal mouse input focus. - * @see setLastWidgetWithModalMouseInputFocus - */ - Widget* getLastWidgetWithModalMouseInputFocus() const 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 *const 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() const 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 - */ - void setLastWidgetPressed(Widget *const lastWidgetPressed); - - private: - /** - * Checks to see if the widget tabbed to is in a window, and if it is, - * it requests the window be moved to the top. - */ - void checkForWindow() const; - - /** - * Distributes a focus lost event. - * - * @param focusEvent the event to distribute. - */ - static void distributeFocusLostEvent(const Event& focusEvent); - - /** - * Distributes a focus gained event. - * - * @param focusEvent the event to distribute. - */ - static void distributeFocusGainedEvent(const Event& focusEvent); - - /** - * Typedef. - */ - typedef STD_VECTOR 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 mModalStack; -}; - -#endif // GUI_FOCUSHANDLER_H diff --git a/src/gui/fonts/font.cpp b/src/gui/fonts/font.cpp deleted file mode 100644 index 2ac2bcb4a..000000000 --- a/src/gui/fonts/font.cpp +++ /dev/null @@ -1,499 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2009 Aethyra Development Team - * Copyright (C) 2011-2017 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 . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * 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/fonts/font.h" - -#include "fs/files.h" -#include "fs/paths.h" - -#include "fs/virtfs/tools.h" -#ifdef USE_SDL2 -#include "fs/virtfs/rwops.h" -#endif // USE_SDL2 - -#include "gui/fonts/textchunk.h" - -#include "render/graphics.h" - -#include "resources/imagehelper.h" - -#include "resources/image/image.h" - -#include "utils/checkutils.h" -#include "utils/delete2.h" -#include "utils/sdlcheckutils.h" -#include "utils/stringutils.h" -#include "utils/timer.h" - -#include "debug.h" - -const unsigned int CACHE_SIZE = 256; -const unsigned int CACHE_SIZE_SMALL1 = 2; -const unsigned int CACHE_SIZE_SMALL2 = 50; -const unsigned int CACHE_SIZE_SMALL3 = 170; -const unsigned int CLEAN_TIME = 7; - -bool Font::mSoftMode(false); - -extern char *strBuf; - -static int fontCounter; - -Font::Font(std::string filename, - int size, - const int style) : - mFont(nullptr), - mCreateCounter(0), - mDeleteCounter(0), - mCleanTime(cur_time + CLEAN_TIME) -{ - if (fontCounter == 0) - { - mSoftMode = imageHelper->useOpenGL() == RENDER_SOFTWARE; - if (TTF_Init() == -1) - { - logger->error("Unable to initialize SDL_ttf: " + - std::string(SDL_GetError())); - } - } - - if (size < 4) - { - reportAlways("Error: requested load font %s with size %d", - filename.c_str(), - size); - size = 4; - } - - if (fontCounter == 0) - { - strBuf = new char[65535]; - memset(strBuf, 0, 65535); - } - - ++fontCounter; - - fixDirSeparators(filename); - logger->log("Attempt to load font: %s", - filename.c_str()); - mFont = openFont(filename.c_str(), size); - - if (mFont == nullptr) - { - logger->log("Error normal loading font " + filename); - - filename = "fonts/dejavusans.ttf"; - mFont = openFont(fixDirSeparators(filename).c_str(), size); - if (mFont == nullptr) - { -#ifdef UNITTESTS - reportAlways("Font load failed %s", - filename.c_str()); -#endif // UNITTESTS - logger->error("Font::Font: " + - std::string(SDL_GetError())); - } - else - { - logger->log("Loaded fallback font %s, %d", - filename.c_str(), - size); - } - } - else - { - logger->log("Loaded font %s, %d", - filename.c_str(), - size); - } - - TTF_SetFontStyle(mFont, style); -} - -Font::~Font() -{ - TTF_CloseFont(mFont); - mFont = nullptr; - --fontCounter; - clear(); - - if (fontCounter == 0) - { - TTF_Quit(); - delete []strBuf; - } -} - -TTF_Font *Font::openFont(const char *const name, - const int size) -{ -#ifdef USE_SDL2 - SDL_RWops *const rw = VirtFs::rwopsOpenRead(name); - if (rw) - { - logger->log("Loading virtfs font file: %s", - name); - return TTF_OpenFontIndexRW(rw, 1, size, 0); - } -#endif - const std::string path = VirtFs::getPath(name); - if (Files::existsLocal(path) == false) - { -#ifndef UNITTESTS - // +++ in future need trigger assert in unit tests here too - reportAlways("Font::openFont font not exists: %s", - path.c_str()); -#endif // UNITTESTS - return nullptr; - } - logger->log("Loading physical font file: %s", - path.c_str()); - return TTF_OpenFontIndex(path.c_str(), - size, 0); -} - -void Font::loadFont(std::string filename, - const int size, - const int style) -{ - if (fontCounter == 0 && TTF_Init() == -1) - { - logger->log("Unable to initialize SDL_ttf: " + - std::string(SDL_GetError())); - return; - } - - fixDirSeparators(filename); - TTF_Font *const font = openFont(filename.c_str(), size); - - if (font == nullptr) - { - logger->log("Font::Font: " + - std::string(SDL_GetError())); - return; - } - - if (mFont != nullptr) - TTF_CloseFont(mFont); - - mFont = font; - TTF_SetFontStyle(mFont, style); - clear(); -} - -void Font::clear() -{ - for (size_t f = 0; f < CACHES_NUMBER; f ++) - mCache[f].clear(); -} - -void Font::drawString(Graphics *const graphics, - Color col, - const Color &col2, - const std::string &text, - const int x, const int y) -{ - BLOCK_START("Font::drawString") - if (text.empty()) - { - BLOCK_END("Font::drawString") - return; - } - -// Color col = graphics->getColor(); -// const Color &col2 = graphics->getColor2(); - const float alpha = static_cast(col.a) / 255.0F; - - /* The alpha value is ignored at string generation so avoid caching the - * same text with different alpha values. - */ - col.a = 255; - - const unsigned char chr = text[0]; - TextChunkList *const cache = &mCache[chr]; - - std::map &search = cache->search; - std::map::iterator i - = search.find(TextChunkSmall(text, col, col2)); - if (i != search.end()) - { - TextChunk *const chunk2 = (*i).second; - cache->moveToFirst(chunk2); - Image *const image = chunk2->img; - if (image != nullptr) - { - image->setAlpha(alpha); - graphics->drawImage(image, x, y); - } - } - else - { - if (cache->size >= CACHE_SIZE) - { -#ifdef DEBUG_FONT_COUNTERS - mDeleteCounter ++; -#endif // DEBUG_FONT_COUNTERS - - cache->removeBack(); - } -#ifdef DEBUG_FONT_COUNTERS - mCreateCounter ++; -#endif // DEBUG_FONT_COUNTERS - - TextChunk *chunk2 = new TextChunk(text, col, col2, this); - - chunk2->generate(mFont, alpha); - cache->insertFirst(chunk2); - - const Image *const image = chunk2->img; - if (image != nullptr) - graphics->drawImage(image, x, y); - } - BLOCK_END("Font::drawString") -} - -void Font::slowLogic(const int rnd) -{ - BLOCK_START("Font::slowLogic") - if (mCleanTime == 0) - { - mCleanTime = cur_time + CLEAN_TIME + rnd; - } - else if (mCleanTime < cur_time) - { - doClean(); - mCleanTime = cur_time + CLEAN_TIME + rnd; - } - BLOCK_END("Font::slowLogic") -} - -int Font::getWidth(const std::string &text) const -{ - if (text.empty()) - return 0; - - const unsigned char chr = text[0]; - TextChunkList *const cache = &mCache[chr]; - - std::map &search = cache->searchWidth; - std::map::iterator i = search.find(text); - if (i != search.end()) - { - TextChunk *const chunk = (*i).second; - cache->moveToFirst(chunk); - const Image *const image = chunk->img; - if (image != nullptr) - return image->getWidth(); - return 0; - } - - // if string was not drawed - int w, h; - getSafeUtf8String(text, strBuf); - TTF_SizeUTF8(mFont, strBuf, &w, &h); - return w; -} - -int Font::getHeight() const -{ - return TTF_FontHeight(mFont); -} - -void Font::doClean() -{ - for (unsigned int f = 0; f < CACHES_NUMBER; f ++) - { - TextChunkList *const cache = &mCache[f]; - const size_t size = CAST_SIZE(cache->size); -#ifdef DEBUG_FONT_COUNTERS - logger->log("ptr: %u, size: %ld", f, size); -#endif // DEBUG_FONT_COUNTERS - - if (size > CACHE_SIZE_SMALL3) - { -#ifdef DEBUG_FONT_COUNTERS - mDeleteCounter += 100; -#endif // DEBUG_FONT_COUNTERS - - cache->removeBack(100); -#ifdef DEBUG_FONT_COUNTERS - logger->log("delete3"); -#endif // DEBUG_FONT_COUNTERS - } - else if (size > CACHE_SIZE_SMALL2) - { -#ifdef DEBUG_FONT_COUNTERS - mDeleteCounter += 20; -#endif // DEBUG_FONT_COUNTERS - - cache->removeBack(20); -#ifdef DEBUG_FONT_COUNTERS - logger->log("delete2"); -#endif // DEBUG_FONT_COUNTERS - } - else if (size > CACHE_SIZE_SMALL1) - { -#ifdef DEBUG_FONT_COUNTERS - mDeleteCounter ++; -#endif // DEBUG_FONT_COUNTERS - - cache->removeBack(); -#ifdef DEBUG_FONT_COUNTERS - logger->log("delete1"); -#endif // DEBUG_FONT_COUNTERS - } - } -} - -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 CAST_S32(i); - } - - return CAST_S32(sz); -} - -const TextChunkList *Font::getCache() const noexcept2 -{ - return mCache; -} - -void Font::generate(TextChunk &chunk) -{ - const std::string &text = chunk.text; - if (text.empty()) - return; - - const unsigned char chr = text[0]; - TextChunkList *const cache = &mCache[chr]; - Color &col = chunk.color; - Color &col2 = chunk.color2; - const int oldAlpha = col.a; - col.a = 255; - - TextChunkSmall key(text, col, col2); - std::map &search = cache->search; - std::map::iterator i = search.find(key); - if (i != search.end()) - { - TextChunk *const chunk2 = (*i).second; - cache->moveToFirst(chunk2); -// search.erase(key); - cache->remove(chunk2); - chunk.img = chunk2->img; - chunk2->img = nullptr; - delete chunk2; -// logger->log("cached image: " + chunk.text); - } - else - { - if (cache->size >= CACHE_SIZE) - { -#ifdef DEBUG_FONT_COUNTERS - mDeleteCounter ++; -#endif // DEBUG_FONT_COUNTERS - - cache->removeBack(); - } -#ifdef DEBUG_FONT_COUNTERS - mCreateCounter ++; -#endif // DEBUG_FONT_COUNTERS - - const float alpha = static_cast(chunk.color.a) / 255.0F; - chunk.generate(mFont, alpha); -// logger->log("generate image: " + chunk.text); - } - col.a = oldAlpha; -} - -void Font::insertChunk(TextChunk *const chunk) -{ - if ((chunk == nullptr) || chunk->text.empty() || (chunk->img == nullptr)) - return; -// logger->log("insert chunk: text=%s, color: %d,%d,%d", -// chunk->text.c_str(), chunk->color.r, chunk->color.g, chunk->color.b); - const unsigned char chr = chunk->text[0]; - TextChunkList *const cache = &mCache[chr]; - - std::map &search = cache->search; - std::map::iterator i - = search.find(TextChunkSmall(chunk->text, - chunk->color, chunk->color2)); - if (i != search.end()) - { - delete2(chunk->img); - return; - } - - TextChunk *const chunk2 = new TextChunk(chunk->text, - chunk->color, chunk->color2, chunk->textFont); - chunk2->img = chunk->img; - cache->insertFirst(chunk2); -} diff --git a/src/gui/fonts/font.h b/src/gui/fonts/font.h deleted file mode 100644 index 4f3670374..000000000 --- a/src/gui/fonts/font.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * Copyright (C) 2009 Aethyra Development Team - * - * 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 . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * 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_FONTS_FONT_H -#define GUI_FONTS_FONT_H - -#include "gui/fonts/textchunklist.h" - -PRAGMA48(GCC diagnostic push) -PRAGMA48(GCC diagnostic ignored "-Wshadow") -#include -PRAGMA48(GCC diagnostic pop) - -#include "localconsts.h" - -class Graphics; - -const unsigned int CACHES_NUMBER = 256; - -/** - * A wrapper around SDL_ttf for allowing the use of TrueType fonts. - * - * NOTE: This class initializes SDL_ttf as necessary. - */ -class Font final -{ - public: - Font(std::string filename, - int size, - const int style); - - A_DELETE_COPY(Font) - - ~Font(); - - void loadFont(std::string filename, - const int size, - const int style) restrict2; - - int getWidth(const std::string &text) const restrict2 A_WARN_UNUSED; - - int getHeight() const restrict2 A_WARN_UNUSED; - - const TextChunkList *getCache() const restrict2 noexcept2 - A_CONST A_WARN_UNUSED; - - /** - * @see Font::drawString - */ - void drawString(Graphics *restrict const graphics, - Color col, - const Color &restrict col2, - const std::string &restrict text, - const int x, - const int y) restrict2 A_NONNULL(2); - - void clear() restrict2; - - void doClean() restrict2; - - void slowLogic(const int rnd) restrict2; - - unsigned int getCreateCounter() const restrict2 noexcept2 A_WARN_UNUSED - { return mCreateCounter; } - - unsigned int getDeleteCounter() const restrict2 noexcept2 A_WARN_UNUSED - { return mDeleteCounter; } - - int getStringIndexAt(const std::string &restrict text, - const int x) const restrict2 A_WARN_UNUSED; - - void generate(TextChunk &restrict chunk) restrict2; - - void insertChunk(TextChunk *const chunk) restrict2; - - static bool mSoftMode; - - private: - static TTF_Font *openFont(const char *restrict const name, - const int size); - - TTF_Font *restrict mFont; - unsigned int mCreateCounter; - unsigned int mDeleteCounter; - - // Word surfaces cache - time_t mCleanTime; - mutable TextChunkList mCache[CACHES_NUMBER]; -}; - -#ifdef UNITTESTS -extern int textChunkCnt; -#endif // UNITTESTS - -#endif // GUI_FONTS_FONT_H diff --git a/src/gui/fonts/textchunk.cpp b/src/gui/fonts/textchunk.cpp deleted file mode 100644 index 22dcd18dc..000000000 --- a/src/gui/fonts/textchunk.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2009 Aethyra Development Team - * Copyright (C) 2011-2017 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 . - */ - -#include "gui/fonts/textchunk.h" - -#include "sdlshared.h" - -#include "gui/fonts/font.h" - -#include "resources/surfaceimagehelper.h" - -#include "resources/image/image.h" - -#include "utils/delete2.h" -#include "utils/sdlcheckutils.h" -#include "utils/stringutils.h" - -#include "debug.h" - -namespace -{ - const int OUTLINE_SIZE = 1; -} // namespace - -char *restrict strBuf = nullptr; - -#ifdef UNITTESTS -int textChunkCnt = 0; -#endif // UNITTESTS - -TextChunk::TextChunk() : - img(nullptr), - textFont(nullptr), - text(), - color(), - color2(), - prev(nullptr), - next(nullptr) -{ -#ifdef UNITTESTS - textChunkCnt ++; -#endif // UNITTESTS -} - -TextChunk::TextChunk(const std::string &restrict text0, - const Color &restrict color0, - const Color &restrict color1, - Font *restrict const font) : - img(nullptr), - textFont(font), - text(text0), - color(color0), - color2(color1), - prev(nullptr), - next(nullptr) -{ -#ifdef UNITTESTS - textChunkCnt ++; -#endif // UNITTESTS -} - -TextChunk::~TextChunk() -{ - delete2(img); -#ifdef UNITTESTS - textChunkCnt --; -#endif // UNITTESTS -} - -bool TextChunk::operator==(const TextChunk &restrict chunk) const -{ - return chunk.text == text && chunk.color == color - && chunk.color2 == color2; -} - -void TextChunk::generate(TTF_Font *restrict const font, - const float alpha) -{ - BLOCK_START("TextChunk::generate") - SDL_Color sdlCol; - sdlCol.b = CAST_U8(color.b); - sdlCol.r = CAST_U8(color.r); - sdlCol.g = CAST_U8(color.g); -#ifdef USE_SDL2 - sdlCol.a = 255; -#else // USE_SDL2 - - sdlCol.unused = 0; -#endif // USE_SDL2 - - getSafeUtf8String(text, strBuf); - - SDL_Surface *surface = MTTF_RenderUTF8_Blended( - font, strBuf, sdlCol); - - if (surface == nullptr) - { - img = nullptr; - BLOCK_END("TextChunk::generate") - return; - } - - const int width = surface->w; - const int height = surface->h; - - if (color.r != color2.r || color.g != color2.g - || color.b != color2.b) - { // outlining - SDL_Color sdlCol2; - SDL_Surface *const background = imageHelper->create32BitSurface( - width, height); - if (background == nullptr) - { - img = nullptr; - MSDL_FreeSurface(surface); - BLOCK_END("TextChunk::generate") - return; - } - sdlCol2.b = CAST_U8(color2.b); - sdlCol2.r = CAST_U8(color2.r); - sdlCol2.g = CAST_U8(color2.g); -#ifdef USE_SDL2 - sdlCol2.a = 255; -#else // USE_SDL2 - - sdlCol2.unused = 0; -#endif // USE_SDL2 - - SDL_Surface *const surface2 = MTTF_RenderUTF8_Blended( - font, strBuf, sdlCol2); - if (surface2 == nullptr) - { - img = nullptr; - MSDL_FreeSurface(surface); - BLOCK_END("TextChunk::generate") - return; - } - SDL_Rect rect = - { - OUTLINE_SIZE, - 0, - static_cast(surface->w), - static_cast(surface->h) - }; - SurfaceImageHelper::combineSurface(surface2, nullptr, - background, &rect); - rect.x = -OUTLINE_SIZE; - SurfaceImageHelper::combineSurface(surface2, nullptr, - background, &rect); - rect.x = 0; - rect.y = -OUTLINE_SIZE; - SurfaceImageHelper::combineSurface(surface2, nullptr, - background, &rect); - rect.y = OUTLINE_SIZE; - SurfaceImageHelper::combineSurface(surface2, nullptr, - background, &rect); - rect.x = 0; - rect.y = 0; - SurfaceImageHelper::combineSurface(surface, nullptr, - background, &rect); - MSDL_FreeSurface(surface); - MSDL_FreeSurface(surface2); - surface = background; - } - img = imageHelper->createTextSurface( - surface, width, height, alpha); - MSDL_FreeSurface(surface); - - BLOCK_END("TextChunk::generate") -} - -void TextChunk::deleteImage() -{ - if (textFont != nullptr) - { - textFont->insertChunk(this); - img = nullptr; - } - else - { - delete2(img); - } -} diff --git a/src/gui/fonts/textchunk.h b/src/gui/fonts/textchunk.h deleted file mode 100644 index bbd50fdff..000000000 --- a/src/gui/fonts/textchunk.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * Copyright (C) 2009 Aethyra Development Team - * - * 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 . - */ - -#ifndef GUI_FONTS_TEXTCHUNK_H -#define GUI_FONTS_TEXTCHUNK_H - -#include "gui/color.h" - -#include - -PRAGMA48(GCC diagnostic push) -PRAGMA48(GCC diagnostic ignored "-Wshadow") -#include -PRAGMA48(GCC diagnostic pop) - -#include "localconsts.h" - -class Font; -class Image; - -class TextChunk final -{ - public: - TextChunk(); - - TextChunk(const std::string &restrict text0, - const Color &restrict color0, - const Color &restrict color1, - Font *restrict const font); - - A_DELETE_COPY(TextChunk) - - ~TextChunk(); - - bool operator==(const TextChunk &restrict chunk) const restrict2; - - void generate(TTF_Font *restrict const font, - const float alpha) restrict2; - - void deleteImage() restrict2; - - Image *restrict img; - Font *restrict textFont; - std::string text; - Color color; - Color color2; - TextChunk *restrict prev; - TextChunk *restrict next; -}; - -#ifdef UNITTESTS -extern int textChunkCnt; -#endif // UNITTESTS - -#endif // GUI_FONTS_TEXTCHUNK_H diff --git a/src/gui/fonts/textchunklist.cpp b/src/gui/fonts/textchunklist.cpp deleted file mode 100644 index 4ce39406b..000000000 --- a/src/gui/fonts/textchunklist.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 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 . - */ - -#include "gui/fonts/textchunklist.h" - -#include "gui/fonts/textchunk.h" - -#include "debug.h" - -TextChunkList::TextChunkList() : - start(nullptr), - end(nullptr), - size(0), - search(), - searchWidth() -{ -} - -void TextChunkList::insertFirst(TextChunk *restrict const item) -{ - TextChunk *restrict const oldFirst = start; - if (start != nullptr) - start->prev = item; - item->prev = nullptr; - if (oldFirst != nullptr) - item->next = oldFirst; - else - end = item; - start = item; - size ++; - search[TextChunkSmall(item->text, item->color, item->color2)] = item; - searchWidth[item->text] = item; -} - -void TextChunkList::moveToFirst(TextChunk *restrict const item) -{ - if (item == start) - return; - - TextChunk *restrict const oldPrev = item->prev; - if (oldPrev != nullptr) - oldPrev->next = item->next; - TextChunk *restrict const oldNext = item->next; - if (oldNext != nullptr) - oldNext->prev = item->prev; - else - end = oldPrev; - TextChunk *restrict const oldFirst = start; - if (start != nullptr) - start->prev = item; - item->prev = nullptr; - item->next = oldFirst; - start = item; -} - -void TextChunkList::remove(const TextChunk *restrict const item) -{ - if (item == nullptr) - return; - - TextChunk *restrict const oldPrev = item->prev; - TextChunk *restrict const oldNext = item->next; - if (oldPrev != nullptr) - oldPrev->next = item->next; - else - start = oldNext; - if (oldNext != nullptr) - oldNext->prev = item->prev; - else - end = oldPrev; - - search.erase(TextChunkSmall(item->text, - item->color, item->color2)); - searchWidth.erase(item->text); - size --; -} - -void TextChunkList::removeBack() -{ - TextChunk *restrict oldEnd = end; - if (oldEnd != nullptr) - { - end = oldEnd->prev; - if (end != nullptr) - end->next = nullptr; - else - start = nullptr; - search.erase(TextChunkSmall(oldEnd->text, - oldEnd->color, oldEnd->color2)); - searchWidth.erase(oldEnd->text); - delete oldEnd; - size --; - } -} - -void TextChunkList::removeBack(int n) -{ - TextChunk *restrict item = end; - while ((n != 0) && (item != nullptr)) - { - n --; - TextChunk *oldEnd = item; - item = item->prev; - search.erase(TextChunkSmall(oldEnd->text, - oldEnd->color, oldEnd->color2)); - searchWidth.erase(oldEnd->text); - delete oldEnd; - size --; - } - if (item != nullptr) - { - item->next = nullptr; - end = item; - } - else - { - start = nullptr; - end = nullptr; - } -} - -void TextChunkList::clear() -{ - search.clear(); - searchWidth.clear(); - TextChunk *restrict item = start; - while (item != nullptr) - { - TextChunk *restrict const item2 = item->next; - delete item; - item = item2; - } - start = nullptr; - end = nullptr; - size = 0; -} diff --git a/src/gui/fonts/textchunklist.h b/src/gui/fonts/textchunklist.h deleted file mode 100644 index fff198445..000000000 --- a/src/gui/fonts/textchunklist.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_FONTS_TEXTCHUNKLIST_H -#define GUI_FONTS_TEXTCHUNKLIST_H - -#include "gui/fonts/textchunksmall.h" - -#include - -#include "localconsts.h" - -class TextChunk; - -class TextChunkList final -{ - public: - TextChunkList(); - - A_DELETE_COPY(TextChunkList) - - void insertFirst(TextChunk *restrict const item) - restrict2 A_NONNULL(2); - - void moveToFirst(TextChunk *restrict const item) - restrict2 A_NONNULL(2); - - void remove(const TextChunk *restrict const item) restrict2; - - void removeBack() restrict2; - - void removeBack(int n) restrict2; - - void clear() restrict2; - - TextChunk *restrict start; - TextChunk *restrict end; - uint32_t size; - std::map search; - std::map searchWidth; -}; - -#endif // GUI_FONTS_TEXTCHUNKLIST_H diff --git a/src/gui/fonts/textchunksmall.cpp b/src/gui/fonts/textchunksmall.cpp deleted file mode 100644 index 73e8ad386..000000000 --- a/src/gui/fonts/textchunksmall.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 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 . - */ - -#include "gui/fonts/textchunksmall.h" - -#include "gui/fonts/font.h" - -#include "debug.h" - -TextChunkSmall::TextChunkSmall(const std::string &text0, - const Color &color0, - const Color &color1) : - text(text0), - color(color0), - color2(color1) -{ -} - -TextChunkSmall::TextChunkSmall(const TextChunkSmall &old) : - text(old.text), - color(old.color), - color2(old.color2) -{ -} - -TextChunkSmall &TextChunkSmall::operator=(const TextChunkSmall &chunk) -{ - text = chunk.text; - color = chunk.color; - color2 = chunk.color2; - return *this; -} - -bool TextChunkSmall::operator==(const TextChunkSmall &chunk) const -{ - return chunk.text == text && - chunk.color == color && - chunk.color2 == color2; -} - -bool TextChunkSmall::operator<(const TextChunkSmall &chunk) const -{ - if (chunk.text != text) - return chunk.text > text; - - const Color &restrict c = chunk.color; - if (c.r != color.r) - return c.r > color.r; - if (c.g != color.g) - return c.g > color.g; - if (c.b != color.b) - return c.b > color.b; - - const Color &restrict c2 = chunk.color2; - if (c2.r != color2.r) - return c2.r > color2.r; - if (c2.g != color2.g) - return c2.g > color2.g; - if (c2.b != color2.b) - return c2.b > color2.b; - - if (c.a != color.a && Font::mSoftMode) - return c.a > color.a; - - return false; -} diff --git a/src/gui/fonts/textchunksmall.h b/src/gui/fonts/textchunksmall.h deleted file mode 100644 index 0896c3591..000000000 --- a/src/gui/fonts/textchunksmall.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_FONTS_TEXTCHUNKSMALL_H -#define GUI_FONTS_TEXTCHUNKSMALL_H - -#include "gui/color.h" - -#include - -#include "localconsts.h" - -class TextChunkSmall final -{ - public: - A_DEFAULT_COPY(TextChunkSmall) - - TextChunkSmall(const std::string &restrict text0, - const Color &restrict color0, - const Color &restrict color1); - - TextChunkSmall(const TextChunkSmall &restrict old); - - bool operator==(const TextChunkSmall &restrict chunk) const restrict2; - bool operator<(const TextChunkSmall &restrict chunk) const restrict2; - TextChunkSmall &operator=(const TextChunkSmall &restrict chunk) - restrict2; - std::string text; - Color color; - Color color2; -}; -#endif // GUI_FONTS_TEXTCHUNKSMALL_H diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp deleted file mode 100644 index 3fab73d0a..000000000 --- a/src/gui/gui.cpp +++ /dev/null @@ -1,1515 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * 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/gui.h" - -#include "gui/focushandler.h" -#include "gui/sdlinput.h" -#include "gui/viewport.h" - -#include "gui/fonts/font.h" - -#include "gui/widgets/label.h" -#include "gui/widgets/window.h" - -#include "gui/widgets/tabs/tab.h" - -#ifndef DYECMD -#include "dragdrop.h" -#else // DYECMD -#include "resources/image/image.h" -#endif // DYECMD -#include "settings.h" - -#include "listeners/focuslistener.h" -#include "listeners/guiconfiglistener.h" -#include "listeners/keylistener.h" - -#include "input/inputmanager.h" - -#include "input/touch/touchmanager.h" - -#include "render/renderers.h" - -#include "resources/imageset.h" - -#include "resources/resourcemanager/resourcemanager.h" - -#include "utils/delete2.h" -#include "utils/foreach.h" -#include "utils/langs.h" -#include "utils/sdlsharedhelper.h" -#include "utils/timer.h" - -#include "net/ipc.h" - -#include "debug.h" - -Gui *gui = nullptr; -Font *boldFont = nullptr; - -Gui::Gui() : - mTop(nullptr), - mGraphics(nullptr), - mInput(nullptr), - mFocusHandler(new FocusHandler), - mKeyListeners(), - mLastMousePressButton(MouseButton::EMPTY), - mLastMousePressTimeStamp(0U), - mLastMouseX(0), - mLastMouseY(0), - mClickCount(1), - mLastMouseDragButton(MouseButton::EMPTY), - mWidgetWithMouseQueue(), - mConfigListener(new GuiConfigListener(this)), - mGuiFont(nullptr), - mInfoParticleFont(nullptr), - mHelpFont(nullptr), - mSecureFont(nullptr), - mNpcFont(nullptr), - mMouseCursors(nullptr), - mMouseCursorAlpha(1.0F), - mMouseInactivityTimer(0), - mCursorType(Cursor::CURSOR_POINTER), -#ifdef ANDROID - mLastMouseRealX(0), - mLastMouseRealY(0), -#endif // ANDROID - mFocusListeners(), - mForegroundColor(theme->getColor(ThemeColorId::TEXT, 255)), - mForegroundColor2(theme->getColor(ThemeColorId::TEXT_OUTLINE, 255)), - mTime(0), - mTime10(0), - mCustomCursor(false), - mDoubleClick(true) -{ -} - -void Gui::postInit(Graphics *const graphics) -{ - logger->log1("Initializing GUI..."); - // Set graphics - setGraphics(graphics); - - // Set input - guiInput = new SDLInput; - setInput(guiInput); - - // Set focus handler - delete mFocusHandler; - mFocusHandler = new FocusHandler; - - // Initialize top GUI widget - WindowContainer *const guiTop = new WindowContainer(nullptr); - guiTop->setFocusable(true); - guiTop->setSize(graphics->mWidth, graphics->mHeight); - guiTop->setOpaque(Opaque_false); - Window::setWindowContainer(guiTop); - setTop(guiTop); - - const StringVect langs = getLang(); - const bool isJapan = (!langs.empty() && langs[0].size() > 3 - && langs[0].substr(0, 3) == "ja_"); - const bool isChinese = (!langs.empty() && langs[0].size() > 3 - && langs[0].substr(0, 3) == "zh_"); - - // Set global font - const int fontSize = config.getIntValue("fontSize"); - std::string fontFile = config.getValue("font", ""); - if (isJapan) - { - fontFile = config.getValue("japanFont", ""); - if (fontFile.empty()) - fontFile = branding.getStringValue("japanFont"); - } - else if (isChinese) - { - fontFile = config.getValue("chinaFont", ""); - if (fontFile.empty()) - fontFile = branding.getStringValue("chinaFont"); - } - if (fontFile.empty()) - fontFile = branding.getStringValue("font"); - - mGuiFont = new Font(fontFile, fontSize, TTF_STYLE_NORMAL); - - // Set particle font - fontFile = config.getValue("particleFont", ""); - if (isJapan) - { - fontFile = config.getValue("japanFont", ""); - if (fontFile.empty()) - fontFile = branding.getStringValue("japanFont"); - } - else if (isChinese) - { - fontFile = config.getValue("chinaFont", ""); - if (fontFile.empty()) - fontFile = branding.getStringValue("chinaFont"); - } - if (fontFile.empty()) - fontFile = branding.getStringValue("particleFont"); - - mInfoParticleFont = new Font(fontFile, fontSize, TTF_STYLE_BOLD); - - // Set bold font - fontFile = config.getValue("boldFont", ""); - if (fontFile.empty()) - fontFile = branding.getStringValue("boldFont"); - - boldFont = new Font(fontFile, fontSize, TTF_STYLE_NORMAL); - - // Set help font - fontFile = config.getValue("helpFont", ""); - if (fontFile.empty()) - fontFile = branding.getStringValue("helpFont"); - - mHelpFont = new Font(fontFile, fontSize, TTF_STYLE_NORMAL); - - // Set secure font - fontFile = config.getValue("secureFont", ""); - if (fontFile.empty()) - fontFile = branding.getStringValue("secureFont"); - - mSecureFont = new Font(fontFile, fontSize, TTF_STYLE_NORMAL); - - // Set npc font - const int npcFontSize = config.getIntValue("npcfontSize"); - fontFile = config.getValue("npcFont", ""); - if (isJapan) - { - fontFile = config.getValue("japanFont", ""); - if (fontFile.empty()) - fontFile = branding.getStringValue("japanFont"); - } - else if (isChinese) - { - fontFile = config.getValue("chinaFont", ""); - if (fontFile.empty()) - fontFile = branding.getStringValue("chinaFont"); - } - if (fontFile.empty()) - fontFile = branding.getStringValue("npcFont"); - - mNpcFont = new Font(fontFile, npcFontSize, TTF_STYLE_NORMAL); - - Widget::setGlobalFont(mGuiFont); - - // Initialize mouse cursor and listen for changes to the option - setUseCustomCursor(config.getBoolValue("customcursor")); - setDoubleClick(config.getBoolValue("doubleClick")); - config.addListener("customcursor", mConfigListener); - config.addListener("doubleClick", mConfigListener); -} - -Gui::~Gui() -{ - config.removeListeners(mConfigListener); - delete2(mConfigListener); - - if (mMouseCursors != nullptr) - { - mMouseCursors->decRef(); - mMouseCursors = nullptr; - } - - if (windowContainer != nullptr) - windowContainer->slowLogic(); - Widget *top = mTop; - if (Widget::widgetExists(mTop)) - setTop(nullptr); - Window::setWindowContainer(nullptr); - delete top; - - delete2(mGuiFont); - delete2(boldFont); - delete2(mHelpFont); - delete2(mSecureFont); - delete2(mInfoParticleFont); - delete2(mNpcFont); - delete2(guiInput); - delete2(theme); - - delete2(mFocusHandler); - Label::finalCleanup(); - Tab::finalCleanup(); - Widget::cleanGlobalFont(); -} - -void Gui::logic() -{ - BLOCK_START("Gui::logic") - ResourceManager::clearScheduled(); - - if (mTop == nullptr) - { - BLOCK_END("Gui::logic") - return; - } - - handleModalFocus(); - handleModalMouseInputFocus(); - - if (guiInput != nullptr) - handleMouseInput(); - - mTop->logic(); - BLOCK_END("Gui::logic") -} - -void Gui::slowLogic() -{ - BLOCK_START("Gui::slowLogic") - Palette::advanceGradients(); - - // Fade out mouse cursor after extended inactivity - if (mMouseInactivityTimer < 100 * 15) - { - ++mMouseInactivityTimer; - mMouseCursorAlpha = std::min(1.0F, mMouseCursorAlpha + 0.05F); - } - else - { - mMouseCursorAlpha = std::max(0.0F, mMouseCursorAlpha - 0.005F); - } - if (mGuiFont != nullptr) - mGuiFont->slowLogic(0); - if (mInfoParticleFont != nullptr) - mInfoParticleFont->slowLogic(1); - if (mHelpFont != nullptr) - mHelpFont->slowLogic(2); - if (mSecureFont != nullptr) - mSecureFont->slowLogic(3); - if (boldFont != nullptr) - boldFont->slowLogic(4); - if (mNpcFont != nullptr) - mNpcFont->slowLogic(5); - if (windowContainer != nullptr) - windowContainer->slowLogic(); - - const time_t time = cur_time; - if (mTime != time) - { - logger->flush(); - if (ipc != nullptr) - ipc->flush(); - mTime = time; - - if (time > mTime10 || mTime10 - time > 10) - { - mTime10 = time + 10; - ResourceManager::cleanOrphans(); - guiInput->simulateMouseMove(); - } - } - - BLOCK_END("Gui::slowLogic") -} - -void Gui::clearFonts() -{ - if (mGuiFont != nullptr) - mGuiFont->clear(); - if (mInfoParticleFont != nullptr) - mInfoParticleFont->clear(); - if (mHelpFont != nullptr) - mHelpFont->clear(); - if (mSecureFont != nullptr) - mSecureFont->clear(); - if (boldFont != nullptr) - boldFont->clear(); - if (mNpcFont != nullptr) - mNpcFont->clear(); -} - -bool Gui::handleInput() -{ - if (mInput != nullptr) - return handleKeyInput(); - return false; -} - -bool Gui::handleKeyInput() -{ - if (guiInput == nullptr) - return false; - - BLOCK_START("Gui::handleKeyInput") - bool consumed(false); - - while (!mInput->isKeyQueueEmpty()) - { - const KeyInput keyInput = guiInput->dequeueKeyInput(); - - KeyEvent eventToGlobalKeyListeners(nullptr, - keyInput.getType(), - keyInput.getActionId(), keyInput.getKey()); - -#ifdef USE_SDL2 - if (!keyInput.getText().empty()) - eventToGlobalKeyListeners.setText(keyInput.getText()); -#endif // USE_SDL2 - - distributeKeyEventToGlobalKeyListeners( - eventToGlobalKeyListeners); - - // If a global key listener consumes the event it will not be - // sent further to the source of the event. - if (eventToGlobalKeyListeners.isConsumed()) - { - consumed = true; - continue; - } - - if (mFocusHandler != nullptr) - { - bool eventConsumed = false; - - // Send key inputs to the focused widgets - if (mFocusHandler->getFocused() != nullptr) - { - KeyEvent event(getKeyEventSource(), - keyInput.getType(), - keyInput.getActionId(), keyInput.getKey()); -#ifdef USE_SDL2 - if (!keyInput.getText().empty()) - event.setText(keyInput.getText()); -#endif // USE_SDL2 - - if (!mFocusHandler->getFocused()->isFocusable()) - mFocusHandler->focusNone(); - else - distributeKeyEvent(event); - - eventConsumed = event.isConsumed(); - if (eventConsumed) - consumed = true; - } - - // If the key event hasn't been consumed and - // tabbing is enable check for tab press and - // change focus. - if (!eventConsumed && keyInput.getActionId() - == InputAction::GUI_TAB && - keyInput.getType() == KeyEventType::PRESSED) - { - if (inputManager.isActionActive(InputAction::GUI_MOD)) - mFocusHandler->tabPrevious(); - else - mFocusHandler->tabNext(); - } - } - } // end while - BLOCK_END("Gui::handleKeyInput") - return consumed; -} - -void Gui::draw() -{ - BLOCK_START("Gui::draw 1") - Widget *const top = getTop(); - if (top == nullptr) - return; - mGraphics->pushClipArea(top->getDimension()); - - if (isBatchDrawRenders(openGLMode)) - { - top->draw(mGraphics); - touchManager.draw(); - } - else - { - top->safeDraw(mGraphics); - touchManager.safeDraw(); - } - - int mouseX; - int mouseY; - const MouseStateType button = getMouseState(mouseX, mouseY); - - if ((settings.mouseFocused || - ((button & SDL_BUTTON(1)) != 0)) && - mMouseCursors != nullptr && - mCustomCursor && - mMouseCursorAlpha > 0.0F) - { -#ifndef DYECMD - const Image *const image = dragDrop.getItemImage(); - if (mGuiFont != nullptr) - { - const std::string &str = dragDrop.getText(); - if (!str.empty()) - { - const int posX = mouseX - mGuiFont->getWidth(str) / 2; - const int posY = mouseY + - (image != nullptr ? image->mBounds.h / 2 : 0); - mGuiFont->drawString(mGraphics, - mForegroundColor, mForegroundColor2, - str, - posX, posY); - } - } - if (image != nullptr) - { - const int posX = mouseX - (image->mBounds.w / 2); - const int posY = mouseY - (image->mBounds.h / 2); - mGraphics->drawImage(image, posX, posY); - } -#endif // DYECMD - - Image *const mouseCursor = mMouseCursors->get( - CAST_SIZE(mCursorType)); - if (mouseCursor != nullptr) - { - mouseCursor->setAlpha(mMouseCursorAlpha); - mGraphics->drawImage(mouseCursor, mouseX - 15, mouseY - 17); - } - } - - mGraphics->popClipArea(); - BLOCK_END("Gui::draw 1") -} - -void Gui::videoResized() const -{ - WindowContainer *const top = static_cast(getTop()); - - if (top != nullptr) - { - const int oldWidth = top->getWidth(); - const int oldHeight = top->getHeight(); - - top->setSize(mainGraphics->mWidth, mainGraphics->mHeight); - top->adjustAfterResize(oldWidth, oldHeight); - } - - if (viewport != nullptr) - viewport->videoResized(); - Widget::distributeWindowResizeEvent(); -} - -void Gui::setUseCustomCursor(const bool customCursor) -{ - if (settings.options.hideCursor) - { - SDL::showCursor(false); - return; - } - if (customCursor != mCustomCursor) - { - mCustomCursor = customCursor; - - if (mCustomCursor) - { - // Hide the SDL mouse cursor - SDL::showCursor(false); - - // Load the mouse cursor - if (mMouseCursors != nullptr) - mMouseCursors->decRef(); - mMouseCursors = Theme::getImageSetFromTheme("mouse.png", 40, 40); - - if (mMouseCursors == nullptr) - logger->log("Error: Unable to load mouse cursors."); - } - else - { - // Show the SDL mouse cursor - SDL::showCursor(true); - - // Unload the mouse cursor - if (mMouseCursors != nullptr) - { - mMouseCursors->decRef(); - mMouseCursors = nullptr; - } - } - } -} - -void Gui::handleMouseMoved(const MouseInput &mouseInput) -{ - // Check if the mouse leaves the application window. - if (mTop != nullptr && - !mWidgetWithMouseQueue.empty() && - (mouseInput.getX() < 0 || - mouseInput.getY() < 0 || - !mTop->getDimension().isPointInRect(mouseInput.getX(), - mouseInput.getY()))) - { - // Distribute an event to all widgets in the - // "widget with mouse" queue. - while (!mWidgetWithMouseQueue.empty()) - { - Widget *const widget = mWidgetWithMouseQueue.front(); - - if (Widget::widgetExists(widget)) - { - distributeMouseEvent(widget, - MouseEventType::EXITED, - mouseInput.getButton(), - mouseInput.getX(), - mouseInput.getY(), - true, - true); - } - - mWidgetWithMouseQueue.pop_front(); - } - - mMouseInactivityTimer = 0; - return; - } - - const int mouseX = mouseInput.getX(); - const int mouseY = mouseInput.getY(); - const MouseButtonT button = mouseInput.getButton(); - - // Check if there is a need to send mouse exited events by - // traversing the "widget with mouse" queue. - bool widgetWithMouseQueueCheckDone = mWidgetWithMouseQueue.empty(); - while (!widgetWithMouseQueueCheckDone) - { - unsigned int iterations = 0; - for (std::deque::iterator - iter = mWidgetWithMouseQueue.begin(); - iter != mWidgetWithMouseQueue.end(); - ++ iter) - { - Widget *const widget = *iter; - - // If a widget in the "widget with mouse queue" doesn't - // exists anymore it should be removed from the queue. - if (!Widget::widgetExists(widget)) - { - mWidgetWithMouseQueue.erase(iter); - break; - } - else - { - int x; - int y; - widget->getAbsolutePosition(x, y); - - if (x > mouseX - || y > mouseY - || x + widget->getWidth() <= mouseX - || y + widget->getHeight() <= mouseY - || !widget->isVisible()) - { - distributeMouseEvent(widget, - MouseEventType::EXITED, - button, - mouseX, - mouseY, - true, - true); - mClickCount = 1; - mLastMousePressTimeStamp = 0U; - mWidgetWithMouseQueue.erase(iter); - break; - } - } - - iterations++; - } - - widgetWithMouseQueueCheckDone = - (CAST_SIZE(iterations) == mWidgetWithMouseQueue.size()); - } - - // Check all widgets below the mouse to see if they are - // present in the "widget with mouse" queue. If a widget - // is not then it should be added and an entered event should - // be sent to it. - Widget* parent = getMouseEventSource(mouseX, mouseY); - Widget* widget = parent; - - // If a widget has modal mouse input focus then it will - // always be returned from getMouseEventSource, but we only wan't to - // send mouse entered events if the mouse has actually entered the - // widget with modal mouse input focus, hence we need to check if - // that's the case. If it's not we should simply ignore to send any - // mouse entered events. - if ((mFocusHandler->getModalMouseInputFocused() != nullptr) - && widget == mFocusHandler->getModalMouseInputFocused() - && Widget::widgetExists(widget) && - (widget != nullptr)) - { - int x, y; - widget->getAbsolutePosition(x, y); - - if (x > mouseX || y > mouseY - || x + widget->getWidth() <= mouseX - || y + widget->getHeight() <= mouseY) - { - parent = nullptr; - } - } - - while (parent != nullptr) - { - parent = widget->getParent(); - - // Check if the widget is present in the "widget with mouse" queue. - bool widgetIsPresentInQueue = false; - FOR_EACH (std::deque::const_iterator, - iter, mWidgetWithMouseQueue) - { - if (*iter == widget) - { - widgetIsPresentInQueue = true; - break; - } - } - - // Widget is not present, send an entered event and add - // it to the "widget with mouse" queue. - if (!widgetIsPresentInQueue - && Widget::widgetExists(widget)) - { - distributeMouseEvent(widget, - MouseEventType::ENTERED, - button, - mouseX, - mouseY, - true, - true); - mWidgetWithMouseQueue.push_front(widget); - } - - const Widget *const swap = widget; - widget = parent; - parent = swap->getParent(); - } - - if (mFocusHandler->getDraggedWidget() != nullptr) - { - distributeMouseEvent(mFocusHandler->getDraggedWidget(), - MouseEventType::DRAGGED, - mLastMouseDragButton, - mouseX, - mouseY); - } - else - { - Widget *const sourceWidget = getMouseEventSource(mouseX, mouseY); - distributeMouseEvent(sourceWidget, - MouseEventType::MOVED, - button, - mouseX, - mouseY); - } - mMouseInactivityTimer = 0; -} - -void Gui::handleMousePressed(const MouseInput &mouseInput) -{ - const int x = mouseInput.getX(); - const int y = mouseInput.getY(); - const MouseButtonT button = mouseInput.getButton(); - const unsigned int timeStamp = mouseInput.getTimeStamp(); - - Widget *sourceWidget = getMouseEventSource(x, y); - - if (mFocusHandler->getDraggedWidget() != nullptr) - sourceWidget = mFocusHandler->getDraggedWidget(); - - if (sourceWidget == nullptr) - return; - int sourceWidgetX; - int sourceWidgetY; - sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY); - - if (((mFocusHandler->getModalFocused() != nullptr) - && sourceWidget->isModalFocused()) - || (mFocusHandler->getModalFocused() == nullptr)) - { - sourceWidget->requestFocus(); - } - - if (mDoubleClick && - timeStamp - mLastMousePressTimeStamp < 250U && - mLastMousePressButton == button) - { - mClickCount ++; - } - else - { - mClickCount = 1; - } - - distributeMouseEvent(sourceWidget, MouseEventType::PRESSED, button, x, y); - mFocusHandler->setLastWidgetPressed(sourceWidget); - mFocusHandler->setDraggedWidget(sourceWidget); - mLastMouseDragButton = button; - mLastMousePressButton = button; - mLastMousePressTimeStamp = timeStamp; -} - -void Gui::updateFonts() -{ - const int fontSize = config.getIntValue("fontSize"); - std::string fontFile = config.getValue("font", ""); - if (fontFile.empty()) - fontFile = branding.getStringValue("font"); - - mGuiFont->loadFont(fontFile, fontSize, TTF_STYLE_NORMAL); - - fontFile = config.getValue("particleFont", ""); - if (fontFile.empty()) - fontFile = branding.getStringValue("particleFont"); - - mInfoParticleFont->loadFont(fontFile, fontSize, TTF_STYLE_BOLD); - - fontFile = config.getValue("boldFont", ""); - if (fontFile.empty()) - fontFile = branding.getStringValue("boldFont"); - - boldFont->loadFont(fontFile, fontSize, TTF_STYLE_NORMAL); - - const int npcFontSize = config.getIntValue("npcfontSize"); - - fontFile = config.getValue("npcFont", ""); - if (fontFile.empty()) - fontFile = branding.getStringValue("npcFont"); - - mNpcFont->loadFont(fontFile, npcFontSize, TTF_STYLE_NORMAL); -} - -void Gui::distributeMouseEvent(Widget *const source, - const MouseEventTypeT type, - const MouseButtonT button, - const int x, const int y, - const bool force, - const bool toSourceOnly) -{ - if ((source == nullptr) || (mFocusHandler == nullptr)) - return; - - Widget *widget = source; - - if (!force) - { - if (mFocusHandler->getModalFocused() != nullptr - && !widget->isModalFocused()) - { - return; - } - if (mFocusHandler->getModalMouseInputFocused() != nullptr - && !widget->isModalMouseInputFocused()) - { - return; - } - } - - MouseEvent event(source, - type, button, - x, y, mClickCount); - - Widget* parent = source; - while (parent != nullptr) - { - // If the widget has been removed due to input - // cancel the distribution. - if (!Widget::widgetExists(widget)) - break; - - parent = widget->getParent(); - - if (widget->isEnabled() || force) - { - int widgetX; - int widgetY; - widget->getAbsolutePosition(widgetX, widgetY); - - event.setX(x - widgetX); - event.setY(y - widgetY); - - std::list mouseListeners - = widget->getMouseListeners(); - - const MouseEventTypeT mouseType = event.getType(); - // Send the event to all mouse listeners of the widget. - FOR_EACH (std::list::const_iterator, - it, mouseListeners) - { - switch (mouseType) - { - case MouseEventType::ENTERED: - (*it)->mouseEntered(event); - break; - case MouseEventType::EXITED: - (*it)->mouseExited(event); - break; - case MouseEventType::MOVED: - (*it)->mouseMoved(event); - break; - case MouseEventType::PRESSED: - (*it)->mousePressed(event); - break; - case MouseEventType::RELEASED: - case MouseEventType::RELEASED2: - (*it)->mouseReleased(event); - break; - case MouseEventType::WHEEL_MOVED_UP: - (*it)->mouseWheelMovedUp(event); - break; - case MouseEventType::WHEEL_MOVED_DOWN: - (*it)->mouseWheelMovedDown(event); - break; - case MouseEventType::DRAGGED: - (*it)->mouseDragged(event); - break; - case MouseEventType::CLICKED: - (*it)->mouseClicked(event); - break; - default: - break; - } - } - - if (toSourceOnly) - break; - } - - const Widget *const swap = widget; - widget = parent; - parent = swap->getParent(); - -#ifndef DYECMD - if (type == MouseEventType::RELEASED) - dragDrop.clear(); -#endif // DYECMD - - if ((widget == nullptr) || event.isConsumed()) - break; - - // If a non modal focused widget has been reach - // and we have modal focus cancel the distribution. - if ((mFocusHandler->getModalFocused() != nullptr) - && !widget->isModalFocused()) - { - break; - } - - // If a non modal mouse input focused widget has been reach - // and we have modal mouse input focus cancel the distribution. - if ((mFocusHandler->getModalMouseInputFocused() != nullptr) - && !widget->isModalMouseInputFocused()) - { - break; - } - } -} - -void Gui::resetClickCount() -{ - mClickCount = 1; - mLastMousePressTimeStamp = 0; -} - -MouseEvent *Gui::createMouseEvent(Window *const widget) -{ - if ((viewport == nullptr) || (widget == nullptr)) - return nullptr; - - int x = 0; - int y = 0; - int mouseX = 0; - int mouseY = 0; - - getAbsolutePosition(widget, x, y); - getMouseState(mouseX, mouseY); - - return new MouseEvent(widget, - MouseEventType::MOVED, - MouseButton::EMPTY, - mouseX - x, - mouseY - y, - mClickCount); -} - -void Gui::getAbsolutePosition(Widget *restrict widget, - int &restrict x, - int &restrict y) -{ - if (widget == nullptr) - return; - x = 0; - y = 0; - while (widget->getParent() != nullptr) - { - x += widget->getX(); - y += widget->getY(); - widget = widget->getParent(); - } -} - -void Gui::handleMouseInput() -{ - BLOCK_START("Gui::handleMouseInput") - while (!mInput->isMouseQueueEmpty()) - { - const MouseInput mouseInput = guiInput->dequeueMouseInput(); - - if (touchManager.processEvent(mouseInput)) - { -#ifdef ANDROID -#ifndef USE_SDL2 - SDL_WarpMouse(mLastMouseX, mLastMouseY, - mLastMouseRealX, mLastMouseRealY); -#endif // USE_SDL2 -#endif // ANDROID - - mMouseInactivityTimer = 0; - continue; - } - - // Save the current mouse state. It will be needed if modal focus - // changes or modal mouse input focus changes. - mLastMouseX = mouseInput.getX(); - mLastMouseY = mouseInput.getY(); -#ifdef ANDROID - mLastMouseRealX = mouseInput.getRealX(); - mLastMouseRealY = mouseInput.getRealY(); -#endif // ANDROID - - switch (mouseInput.getType()) - { - case MouseEventType::PRESSED: - handleMousePressed(mouseInput); - break; - case MouseEventType::RELEASED: - handleMouseReleased(mouseInput); - break; - case MouseEventType::MOVED: - handleMouseMoved(mouseInput); - break; - case MouseEventType::WHEEL_MOVED_DOWN: - handleMouseWheelMovedDown(mouseInput); - break; - case MouseEventType::WHEEL_MOVED_UP: - handleMouseWheelMovedUp(mouseInput); - break; - case MouseEventType::CLICKED: - case MouseEventType::ENTERED: - case MouseEventType::EXITED: - case MouseEventType::DRAGGED: - case MouseEventType::RELEASED2: - default: - break; - } - } - BLOCK_END("Gui::handleMouseInput") -} - -void Gui::handleMouseReleased(const MouseInput &mouseInput) -{ - Widget *sourceWidget = getMouseEventSource( - mouseInput.getX(), mouseInput.getY()); - - int sourceWidgetX; - int sourceWidgetY; - if (mFocusHandler->getDraggedWidget() != nullptr) - { - if (sourceWidget != mFocusHandler->getLastWidgetPressed()) - mFocusHandler->setLastWidgetPressed(nullptr); - - Widget *const oldWidget = sourceWidget; - sourceWidget = mFocusHandler->getDraggedWidget(); - if ((oldWidget != nullptr) && oldWidget != sourceWidget) - { - oldWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY); - distributeMouseEvent(oldWidget, - MouseEventType::RELEASED2, - mouseInput.getButton(), - mouseInput.getX(), - mouseInput.getY()); - } - } - - if (sourceWidget == nullptr) - return; - sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY); - distributeMouseEvent(sourceWidget, - MouseEventType::RELEASED, - mouseInput.getButton(), - mouseInput.getX(), - mouseInput.getY()); - - if (mouseInput.getButton() == mLastMousePressButton - && mFocusHandler->getLastWidgetPressed() == sourceWidget) - { - distributeMouseEvent(sourceWidget, - MouseEventType::CLICKED, - mouseInput.getButton(), - mouseInput.getX(), - mouseInput.getY()); - - mFocusHandler->setLastWidgetPressed(nullptr); - } - else - { - mLastMousePressButton = MouseButton::EMPTY; - mClickCount = 0; - } - - if (mFocusHandler->getDraggedWidget() != nullptr) - mFocusHandler->setDraggedWidget(nullptr); -} - -void Gui::addGlobalFocusListener(FocusListener* focusListener) -{ - mFocusListeners.push_back(focusListener); -} - -void Gui::removeGlobalFocusListener(FocusListener* focusListener) -{ - mFocusListeners.remove(focusListener); -} - -void Gui::distributeGlobalFocusGainedEvent(const Event &focusEvent) -{ - for (FocusListenerIterator iter = mFocusListeners.begin(); - iter != mFocusListeners.end(); - ++ iter) - { - (*iter)->focusGained(focusEvent); - } -} - -void Gui::removeDragged(const Widget *const widget) -{ - if (mFocusHandler == nullptr) - return; - - if (mFocusHandler->getDraggedWidget() == widget) - mFocusHandler->setDraggedWidget(nullptr); -} - -MouseStateType Gui::getMouseState(int &x, int &y) -{ - const MouseStateType res = SDL_GetMouseState(&x, &y); - const int scale = mainGraphics->getScale(); - x /= scale; - y /= scale; - return res; -} - -void Gui::setTop(Widget *const top) -{ - if (mTop != nullptr) - mTop->setFocusHandler(nullptr); - if (top != nullptr) - top->setFocusHandler(mFocusHandler); - - mTop = top; -} - -void Gui::setGraphics(Graphics *const graphics) -{ - mGraphics = graphics; -} - -Graphics* Gui::getGraphics() const -{ - return mGraphics; -} - -void Gui::setInput(SDLInput *const input) -{ - mInput = input; -} - -SDLInput* Gui::getInput() const -{ - return mInput; -} - -void Gui::addGlobalKeyListener(KeyListener *const keyListener) -{ - mKeyListeners.push_back(keyListener); -} - -void Gui::removeGlobalKeyListener(KeyListener *const keyListener) -{ - mKeyListeners.remove(keyListener); -} - -void Gui::handleMouseWheelMovedDown(const MouseInput& mouseInput) -{ - Widget* sourceWidget = getMouseEventSource( - mouseInput.getX(), mouseInput.getY()); - - if (mFocusHandler->getDraggedWidget() != nullptr) - sourceWidget = mFocusHandler->getDraggedWidget(); - - if (sourceWidget != nullptr) - { - int sourceWidgetX = 0; - int sourceWidgetY = 0; - - sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY); - distributeMouseEvent(sourceWidget, - MouseEventType::WHEEL_MOVED_DOWN, - mouseInput.getButton(), - mouseInput.getX(), - mouseInput.getY()); - } -} - -void Gui::handleMouseWheelMovedUp(const MouseInput& mouseInput) -{ - Widget* sourceWidget = getMouseEventSource( - mouseInput.getX(), mouseInput.getY()); - - if (mFocusHandler->getDraggedWidget() != nullptr) - sourceWidget = mFocusHandler->getDraggedWidget(); - - if (sourceWidget != nullptr) - { - int sourceWidgetX; - int sourceWidgetY; - - sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY); - distributeMouseEvent(sourceWidget, - MouseEventType::WHEEL_MOVED_UP, - mouseInput.getButton(), - mouseInput.getX(), - mouseInput.getY()); - } -} - -Widget* Gui::getWidgetAt(const int x, const int y) const -{ - // If the widget's parent has no child then we have found the widget.. - Widget* parent = mTop; - Widget* child = mTop; - Widget* selectable = mTop; - - while (child != nullptr) - { - Widget *const swap = child; - int parentX, parentY; - parent->getAbsolutePosition(parentX, parentY); - child = parent->getWidgetAt(x - parentX, y - parentY); - parent = swap; - if (parent->isSelectable()) - selectable = parent; - } - - return selectable; -} - -Widget* Gui::getMouseEventSource(const int x, const int y) const -{ - Widget *const widget = getWidgetAt(x, y); - if (widget == nullptr) - return nullptr; - - if (mFocusHandler != nullptr && - mFocusHandler->getModalMouseInputFocused() != nullptr && - !widget->isModalMouseInputFocused()) - { - return mFocusHandler->getModalMouseInputFocused(); - } - - return widget; -} - -Widget* Gui::getKeyEventSource() const -{ - Widget* widget = mFocusHandler->getFocused(); - - while (widget != nullptr && - widget->getInternalFocusHandler() != nullptr && - widget->getInternalFocusHandler()->getFocused() != nullptr) - { - widget = widget->getInternalFocusHandler()->getFocused(); - } - - return widget; -} - -void Gui::distributeKeyEvent(KeyEvent &event) const -{ - Widget* parent = event.getSource(); - Widget* widget = parent; - - if (parent == nullptr) - return; - if (mFocusHandler->getModalFocused() != nullptr && - !widget->isModalFocused()) - { - return; - } - if (mFocusHandler->getModalMouseInputFocused() != nullptr && - !widget->isModalMouseInputFocused()) - { - return; - } - - while (parent != nullptr) - { - // If the widget has been removed due to input - // cancel the distribution. - if (!Widget::widgetExists(widget)) - break; - - parent = widget->getParent(); - - if (widget->isEnabled()) - { - std::list keyListeners - = widget->getKeyListeners(); - - const KeyEventTypeT eventType = event.getType(); - // Send the event to all key listeners of the source widget. - FOR_EACH (std::list::const_iterator, - it, keyListeners) - { - switch (eventType) - { - case KeyEventType::PRESSED: - (*it)->keyPressed(event); - break; - case KeyEventType::RELEASED: - (*it)->keyReleased(event); - break; - default: - break; - } - } - } - - const Widget *const swap = widget; - widget = parent; - parent = swap->getParent(); - - // If a non modal focused widget has been reach - // and we have modal focus cancel the distribution. - if ((widget != nullptr) && - (mFocusHandler->getModalFocused() != nullptr) && - !widget->isModalFocused()) - { - break; - } - } -} - -void Gui::distributeKeyEventToGlobalKeyListeners(KeyEvent& event) -{ - BLOCK_START("Gui::distributeKeyEventToGlobalKeyListeners") - const KeyEventTypeT eventType = event.getType(); - FOR_EACH (KeyListenerListIterator, it, mKeyListeners) - { - switch (eventType) - { - case KeyEventType::PRESSED: - (*it)->keyPressed(event); - break; - case KeyEventType::RELEASED: - (*it)->keyReleased(event); - break; - default: - break; - } - - if (event.isConsumed()) - break; - } - BLOCK_END("Gui::distributeKeyEventToGlobalKeyListeners") -} - -void Gui::handleModalMouseInputFocus() -{ - BLOCK_START("Gui::handleModalMouseInputFocus") - Widget *const lastModalWidget - = mFocusHandler->getLastWidgetWithModalMouseInputFocus(); - Widget *const modalWidget = mFocusHandler->getModalMouseInputFocused(); - if (lastModalWidget != modalWidget) - { - // Check if modal mouse input focus has been gained by a widget. - if (lastModalWidget == nullptr) - { - handleModalFocusGained(); - mFocusHandler->setLastWidgetWithModalMouseInputFocus(modalWidget); - } - // Check if modal mouse input focus has been released. - else - { - handleModalFocusReleased(); - mFocusHandler->setLastWidgetWithModalMouseInputFocus(nullptr); - } - } - BLOCK_END("Gui::handleModalMouseInputFocus") -} - -void Gui::handleModalFocus() -{ - BLOCK_START("Gui::handleModalFocus") - Widget *const lastModalWidget - = mFocusHandler->getLastWidgetWithModalFocus(); - Widget *const modalWidget = mFocusHandler->getModalFocused(); - - if (lastModalWidget != modalWidget) - { - // Check if modal focus has been gained by a widget. - if (lastModalWidget == nullptr) - { - handleModalFocusGained(); - mFocusHandler->setLastWidgetWithModalFocus(modalWidget); - } - // Check if modal focus has been released. - else - { - handleModalFocusReleased(); - mFocusHandler->setLastWidgetWithModalFocus(nullptr); - } - } - BLOCK_END("Gui::handleModalFocus") -} - -void Gui::handleModalFocusGained() -{ - // Distribute an event to all widgets in the "widget with mouse" queue. - while (!mWidgetWithMouseQueue.empty()) - { - Widget *const widget = mWidgetWithMouseQueue.front(); - - if (Widget::widgetExists(widget)) - { - distributeMouseEvent(widget, - MouseEventType::EXITED, - mLastMousePressButton, - mLastMouseX, - mLastMouseY, - true, - true); - } - - mWidgetWithMouseQueue.pop_front(); - } - - mFocusHandler->setLastWidgetWithModalMouseInputFocus( - mFocusHandler->getModalMouseInputFocused()); -} - -void Gui::handleModalFocusReleased() -{ - // Check all widgets below the mouse to see if they are - // present in the "widget with mouse" queue. If a widget - // is not then it should be added and an entered event should - // be sent to it. - Widget* widget = getMouseEventSource(mLastMouseX, mLastMouseY); - Widget* parent = widget; - - while (parent != nullptr && - widget != nullptr) - { - parent = widget->getParent(); - - // Check if the widget is present in the "widget with mouse" queue. - bool widgetIsPresentInQueue = false; - FOR_EACH (std::deque::const_iterator, - iter, mWidgetWithMouseQueue) - { - if (*iter == widget) - { - widgetIsPresentInQueue = true; - break; - } - } - - // Widget is not present, send an entered event and add - // it to the "widget with mouse" queue. - if (!widgetIsPresentInQueue && Widget::widgetExists(widget)) - { - distributeMouseEvent(widget, - MouseEventType::ENTERED, - mLastMousePressButton, - mLastMouseX, - mLastMouseY, - false, - true); - mWidgetWithMouseQueue.push_front(widget); - } - - const Widget *const swap = widget; - widget = parent; - parent = swap->getParent(); - } -} - -int Gui::getMousePressLength() const -{ - if (mLastMousePressTimeStamp == 0u) - return 0; - unsigned int ticks = SDL_GetTicks(); - if (ticks > mLastMousePressTimeStamp) - return ticks - mLastMousePressTimeStamp; - return mLastMousePressTimeStamp - ticks; -} diff --git a/src/gui/gui.h b/src/gui/gui.h deleted file mode 100644 index a846f1a5d..000000000 --- a/src/gui/gui.h +++ /dev/null @@ -1,527 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * 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_GUI_H -#define GUI_GUI_H - -#include "gui/color.h" - -#include "enums/events/mousebutton.h" -#include "enums/events/mouseeventtype.h" - -#include "enums/resources/cursor.h" - -#include -#include - -#include "localconsts.h" - -class Event; -class FocusHandler; -class FocusListener; -class Graphics; -class GuiConfigListener; -class ImageSet; -class KeyEvent; -class KeyListener; -class MouseEvent; -class MouseInput; -class Font; -class SDLInput; -class Widget; -class Window; - -#ifdef USE_SDL2 -#define MouseStateType uint32_t -#else // USE_SDL2 -#define MouseStateType uint8_t -#endif // USE_SDL2 - -/** - * \defgroup GUI Core GUI related classes (widgets) - */ - -/** - * \defgroup Interface User interface related classes (windows, dialogs) - */ - -/** - * Main GUI class. - * - * \ingroup GUI - */ -class Gui final -{ - public: - /** - * Constructor. - */ - Gui(); - - A_DELETE_COPY(Gui) - - /** - * Destructor. - */ - ~Gui(); - - void postInit(Graphics *const graphics) A_NONNULL(2); - - /** - * Performs logic of the GUI. Overridden to track mouse pointer - * activity. - */ - void logic(); - - void slowLogic(); - - void clearFonts(); - - /** - * Draws the whole Gui by calling draw functions down in the - * Gui hierarchy. It also draws the mouse pointer. - */ - void draw(); - - /** - * Called when the application window has been resized. - */ - void videoResized() const; - - FocusHandler *getFocusHandler() const noexcept2 A_WARN_UNUSED - { return mFocusHandler; } - - /** - * Return game font. - */ - Font *getFont() const RETURNS_NONNULL A_WARN_UNUSED - { return mGuiFont; } - - /** - * Return help font. - */ - Font *getHelpFont() const RETURNS_NONNULL A_WARN_UNUSED - { return mHelpFont; } - - /** - * Return secure font. - */ - Font *getSecureFont() const RETURNS_NONNULL A_WARN_UNUSED - { return mSecureFont; } - - /** - * Return npc font. - */ - Font *getNpcFont() const RETURNS_NONNULL A_WARN_UNUSED - { return mNpcFont; } - - /** - * Return the Font used for "Info Particles", i.e. ones showing, what - * you picked up, etc. - */ - Font *getInfoParticleFont() const RETURNS_NONNULL A_WARN_UNUSED - { return mInfoParticleFont; } - - /** - * Sets whether a custom cursor should be rendered. - */ - void setUseCustomCursor(const bool customCursor); - - /** - * Sets which cursor should be used. - */ - void setCursorType(const CursorT index) - { mCursorType = index; } - - void setDoubleClick(const bool b) - { mDoubleClick = b; } - - void updateFonts(); - - bool handleInput(); - - bool handleKeyInput(); - - void resetClickCount(); - - MouseEvent *createMouseEvent(Window *const widget) A_WARN_UNUSED; - - static void getAbsolutePosition(Widget *restrict widget, - int &restrict x, - int &restrict y); - - void addGlobalFocusListener(FocusListener* focusListener); - - void removeGlobalFocusListener(FocusListener* focusListener); - - void distributeGlobalFocusGainedEvent(const Event &focusEvent); - - void removeDragged(const Widget *const widget); - - int getLastMouseX() const - { return mLastMouseX; } - - int getLastMouseY() const - { return mLastMouseY; } - - static MouseStateType getMouseState(int &x, int &y); - - /** - * Sets the top widget. The top widget is the root widget - * of the GUI. If you want a GUI to be able to contain more - * than one widget the top widget should be a container. - * - * @param top The top widget. - * @see Container - */ - void setTop(Widget *const top); - - /** - * Gets the top widget. The top widget is the root widget - * of the GUI. - * - * @return The top widget. NULL if no top widget has been set. - */ - Widget* getTop() const noexcept2 A_WARN_UNUSED - { return mTop; } - - /** - * Sets the graphics object to use for drawing. - * - * @param graphics The graphics object to use for drawing. - * @see getGraphics, AllegroGraphics, HGEGraphics, - * OpenLayerGraphics, OpenGLGraphics, SDLGraphics - */ - void setGraphics(Graphics *const graphics) A_NONNULL(2); - - /** - * Gets the graphics object used for drawing. - * - * @return The graphics object used for drawing. NULL if no - * graphics object has been set. - * @see setGraphics, AllegroGraphics, HGEGraphics, - * OpenLayerGraphics, OpenGLGraphics, SDLGraphics - */ - Graphics* getGraphics() const RETURNS_NONNULL A_WARN_UNUSED; - - /** - * Sets the input object to use for input handling. - * - * @param input The input object to use for input handling. - * @see getInput, AllegroInput, HGEInput, OpenLayerInput, - * SDLInput - */ - void setInput(SDLInput *const input) A_NONNULL(2); - - /** - * Gets the input object being used for input handling. - * - * @return The input object used for handling input. NULL if no - * input object has been set. - * @see setInput, AllegroInput, HGEInput, OpenLayerInput, - * SDLInput - */ - SDLInput* getInput() const A_WARN_UNUSED; - - /** - * Adds a global key listener to the Gui. A global key listener - * will receive all key events generated from the GUI and global - * key listeners will receive the events before key listeners - * of widgets. - * - * @param keyListener The key listener to add. - * @see removeGlobalKeyListener - */ - void addGlobalKeyListener(KeyListener *const keyListener); - - /** - * Removes global key listener from the Gui. - * - * @param keyListener The key listener to remove. - * @throws Exception if the key listener hasn't been added. - * @see addGlobalKeyListener - */ - void removeGlobalKeyListener(KeyListener *const keyListener); - - bool isLongPress() const - { return getMousePressLength() > 250; } - - int getMousePressLength() const; - - protected: - void handleMouseMoved(const MouseInput &mouseInput); - - void handleMouseReleased(const MouseInput &mouseInput); - - void handleMousePressed(const MouseInput &mouseInput); - - void handleMouseInput(); - - void distributeMouseEvent(Widget *const source, - const MouseEventTypeT type, - const MouseButtonT button, - const int x, const int y, - const bool force = false, - const bool toSourceOnly = false); - - /** - * - * Handles mouse wheel moved down input. - * - * @param mouseInput The mouse input to handle. - */ - void handleMouseWheelMovedDown(const MouseInput& mouseInput); - - /** - * Handles mouse wheel moved up input. - * - * @param mouseInput The mouse input to handle. - */ - void handleMouseWheelMovedUp(const MouseInput& mouseInput); - - /** - * Gets the widget at a certain position. - * - * @return The widget at a certain position. - */ - Widget* getWidgetAt(const int x, const int y) const A_WARN_UNUSED; - - /** - * Gets the source of the mouse event. - * - * @return The source widget of the mouse event. - */ - Widget* getMouseEventSource(const int x, - const int y) const A_WARN_UNUSED; - - /** - * Gets the source of the key event. - * - * @return The source widget of the key event. - */ - Widget* getKeyEventSource() const A_WARN_UNUSED; - - /** - * Distributes a key event. - * - * @param event The key event to distribute. - - */ - void distributeKeyEvent(KeyEvent &event) const; - - /** - * Distributes a key event to the global key listeners. - * - * @param event The key event to distribute. - * - */ - void distributeKeyEventToGlobalKeyListeners(KeyEvent& event); - - /** - * Handles modal mouse input focus. Modal mouse input focus needs - * to be checked at each logic iteration as it might be necessary to - * distribute mouse entered or mouse exited events. - * - */ - void handleModalMouseInputFocus(); - - /** - * Handles modal focus. Modal focus needs to be checked at - * each logic iteration as it might be necessary to distribute - * mouse entered or mouse exited events. - * - */ - void handleModalFocus(); - - /** - * Handles modal focus gained. If modal focus has been gained it might - * be necessary to distribute mouse entered or mouse exited events. - * - */ - void handleModalFocusGained(); - - /** - * Handles modal mouse input focus gained. If modal focus has been - * gained it might be necessary to distribute mouse entered or mouse - * exited events. - * - */ - void handleModalFocusReleased(); - - private: - /** - * Holds the top widget. - */ - Widget* mTop; - - /** - * Holds the graphics implementation used. - */ - Graphics* mGraphics A_NONNULLPOINTER; - - /** - * Holds the input implementation used. - */ - SDLInput* mInput A_NONNULLPOINTER; - - /** - * Holds the focus handler for the Gui. - */ - FocusHandler* mFocusHandler A_NONNULLPOINTER; - - /** - * Typedef. - */ - typedef std::list KeyListenerList; - - /** - * Typedef. - */ - typedef KeyListenerList::iterator KeyListenerListIterator; - - /** - * Holds the global key listeners of the Gui. - */ - KeyListenerList mKeyListeners; - - /** - * Holds the last mouse button pressed. - */ - MouseButtonT mLastMousePressButton; - - /** - * Holds the last mouse press time stamp. - */ - unsigned int mLastMousePressTimeStamp; - - /** - * Holds the last mouse x coordinate. - */ - int mLastMouseX; - - /** - * Holds the last mouse y coordinate. - */ - int mLastMouseY; - - /** - * Holds the current click count. Used to keep track - * of clicks for a the last pressed button. - */ - int mClickCount; - - /** - * Holds the last button used when a drag of a widget - * was initiated. Used to be able to release a drag - * when the same button is released. - */ - MouseButtonT mLastMouseDragButton; - - /** - * Holds a stack with all the widgets with the mouse. - * Used to properly distribute mouse events. - */ - std::deque mWidgetWithMouseQueue; - - GuiConfigListener *mConfigListener; - /** The global GUI font */ - Font *mGuiFont A_NONNULLPOINTER; - /** Font for Info Particles */ - Font *mInfoParticleFont A_NONNULLPOINTER; - /** Font for Help Window */ - Font *mHelpFont A_NONNULLPOINTER; - /** Font for secure labels */ - Font *mSecureFont A_NONNULLPOINTER; - /** Font for npc text */ - Font *mNpcFont A_NONNULLPOINTER; - /** Mouse cursor images */ - ImageSet *mMouseCursors; - float mMouseCursorAlpha; - int mMouseInactivityTimer; - CursorT mCursorType; -#ifdef ANDROID - uint16_t mLastMouseRealX; - uint16_t mLastMouseRealY; -#endif // ANDROID - - typedef std::list FocusListenerList; - typedef FocusListenerList::iterator FocusListenerIterator; - FocusListenerList mFocusListeners; - Color mForegroundColor; - Color mForegroundColor2; - time_t mTime; - time_t mTime10; - bool mCustomCursor; /**< Show custom cursor */ - bool mDoubleClick; -}; - -extern Gui *gui; /**< The GUI system */ - -/** - * Bolded text font - */ -extern Font *boldFont A_NONNULLPOINTER; - -#endif // GUI_GUI_H diff --git a/src/gui/mailmessage.h b/src/gui/mailmessage.h deleted file mode 100644 index f96a6d675..000000000 --- a/src/gui/mailmessage.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2015-2017 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 . - */ - -#ifndef GUI_MAILMESSAGE_H -#define GUI_MAILMESSAGE_H - -#include "enums/net/mailmessagetype.h" - -#include - -#include "localconsts.h" - -struct MailMessage final -{ - MailMessage() : - title(), - sender(), - strTime(), - text(), - id(0), - time(0), - expireTime(0), - money(0), - type(MailMessageType::Text), - read(false) - { - } - - A_DELETE_COPY(MailMessage) - - std::string title; - std::string sender; - std::string strTime; - std::string text; - int64_t id; - int time; - int expireTime; - int64_t money; - MailMessageType::Type type; - bool read; -}; -#endif // GUI_MAILMESSAGE_H diff --git a/src/gui/models/avatarlistmodel.h b/src/gui/models/avatarlistmodel.h deleted file mode 100644 index 67ec6846a..000000000 --- a/src/gui/models/avatarlistmodel.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_MODELS_AVATARLISTMODEL_H -#define GUI_MODELS_AVATARLISTMODEL_H - -#include "avatar.h" - -#include "gui/models/listmodel.h" - -class AvatarListModel notfinal : public ListModel -{ - public: - AvatarListModel() : - ListModel() - { } - - A_DELETE_COPY(AvatarListModel) - - 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 deleted file mode 100644 index a0a9d2920..000000000 --- a/src/gui/models/beingslistmodel.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_MODELS_BEINGSLISTMODEL_H -#define GUI_MODELS_BEINGSLISTMODEL_H - -#include "gui/models/avatarlistmodel.h" - -#include "utils/cast.h" -#include "utils/dtor.h" -#include "utils/vector.h" - -class BeingsListModel final : public AvatarListModel -{ - public: - BeingsListModel() : - AvatarListModel(), - mMembers() - { - } - - A_DELETE_COPY(BeingsListModel) - - ~BeingsListModel() - { - delete_all(mMembers); - mMembers.clear(); - } - - STD_VECTOR *getMembers() RETURNS_NONNULL A_WARN_UNUSED - { - return &mMembers; - } - - Avatar *getAvatarAt(int index) override final - { - return mMembers[index]; - } - - int getNumberOfElements() override final - { - return CAST_S32(mMembers.size()); - } - - STD_VECTOR mMembers; -}; - -#endif // GUI_MODELS_BEINGSLISTMODEL_H diff --git a/src/gui/models/colorlistmodel.h b/src/gui/models/colorlistmodel.h deleted file mode 100644 index bb2d413c2..000000000 --- a/src/gui/models/colorlistmodel.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#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() : - ListModel() - { } - - A_DELETE_COPY(ColorListModel) - - ~ColorListModel() - { } - - int getNumberOfElements() override final - { - return 14; - } - - std::string getElementAt(int i) override final - { - if (i >= getNumberOfElements() || i < 0) - return "???"; - return gettext(COLOR_NAME[i]); - } -}; - -#endif // GUI_MODELS_COLORLISTMODEL_H diff --git a/src/gui/models/colormodel.cpp b/src/gui/models/colormodel.cpp deleted file mode 100644 index 3bbded2e2..000000000 --- a/src/gui/models/colormodel.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 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 . - */ - -#include "gui/models/colormodel.h" - -#include "gui/widgets/widget2.h" - -#include "utils/gettext.h" - -#include "debug.h" - -ColorModel::ColorModel() : - ListModel(), - mNames(), - mColors() -{ -} - -ColorModel::~ColorModel() -{ -} - -int ColorModel::getNumberOfElements() -{ - return CAST_S32(mNames.size()); -} - -std::string ColorModel::getElementAt(int i) -{ - if (i >= getNumberOfElements() || i < 0) - return "???"; - return mNames[CAST_SIZE(i)]; -} - -const ColorPair *ColorModel::getColorAt(const int i) const -{ - if (i >= CAST_S32(mColors.size()) || i < 0) - return &mColors[0]; - - return &mColors[CAST_SIZE(i)]; -} - -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)); -} - -#define addColor(name, color) \ - model->add(name, &widget->getThemeColor(ThemeColorId::color), \ - &widget->getThemeColor(ThemeColorId::color##_OUTLINE)); - -ColorModel *ColorModel::createDefault(const Widget2 *const widget) -{ - ColorModel *const model = new ColorModel; - if (widget == nullptr) - return model; - // TRANSLATORS: color name - addColor(_("black"), BLACK); - // TRANSLATORS: color name - addColor(_("red"), RED); - // TRANSLATORS: color name - addColor(_("green"), GREEN); - // TRANSLATORS: color name - addColor(_("blue"), BLUE); - // TRANSLATORS: color name - addColor(_("gold"), ORANGE); - // TRANSLATORS: color name - addColor(_("yellow"), YELLOW); - // TRANSLATORS: color name - addColor(_("pink"), PINK); - // TRANSLATORS: color name - addColor(_("purple"), PURPLE); - // TRANSLATORS: color name - addColor(_("grey"), GRAY); - // TRANSLATORS: color name - addColor(_("brown"), BROWN); - return model; -} diff --git a/src/gui/models/colormodel.h b/src/gui/models/colormodel.h deleted file mode 100644 index 9d621dfbe..000000000 --- a/src/gui/models/colormodel.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 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 . - */ - -#ifndef GUI_MODELS_COLORMODEL_H -#define GUI_MODELS_COLORMODEL_H - -#include "utils/stringvector.h" - -#include "gui/colorpair.h" - -#include "gui/models/listmodel.h" - -#include "localconsts.h" - -class Color; -class Widget2; - -class ColorModel final : public ListModel -{ - public: - ColorModel(); - - A_DELETE_COPY(ColorModel) - - virtual ~ColorModel(); - - int getNumberOfElements() override final A_WARN_UNUSED; - - std::string getElementAt(int i) override final A_WARN_UNUSED; - - const ColorPair *getColorAt(const int i) - const RETURNS_NONNULL A_WARN_UNUSED; - - StringVect &getNames() A_WARN_UNUSED - { return mNames; } - - size_t size() A_WARN_UNUSED - { return mNames.size(); } - - void add(const std::string &name, - const Color *const color1, - const Color *const color2); - - static ColorModel *createDefault(const Widget2 *const widget) - RETURNS_NONNULL; - - protected: - StringVect mNames; - STD_VECTOR mColors; -}; - -#endif // GUI_MODELS_COLORMODEL_H diff --git a/src/gui/models/extendedlistmodel.h b/src/gui/models/extendedlistmodel.h deleted file mode 100644 index 981a96897..000000000 --- a/src/gui/models/extendedlistmodel.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 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 . - */ - -#ifndef GUI_MODELS_EXTENDEDLISTMODEL_H -#define GUI_MODELS_EXTENDEDLISTMODEL_H - -#include "gui/models/listmodel.h" - -#include "resources/image/image.h" - -class ExtendedListModel notfinal : public ListModel -{ - public: - ExtendedListModel() : - ListModel() - { } - - A_DELETE_COPY(ExtendedListModel) - - virtual const Image *getImageAt(int i) A_WARN_UNUSED = 0; -}; - -#endif // GUI_MODELS_EXTENDEDLISTMODEL_H diff --git a/src/gui/models/extendednamesmodel.cpp b/src/gui/models/extendednamesmodel.cpp deleted file mode 100644 index 76191ae5a..000000000 --- a/src/gui/models/extendednamesmodel.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 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 . - */ - -#include "gui/models/extendednamesmodel.h" - -#include "utils/cast.h" -#include "utils/foreach.h" - -#include "debug.h" - -ExtendedNamesModel::ExtendedNamesModel() : - mNames(), - mImages() -{ -} - -ExtendedNamesModel::~ExtendedNamesModel() -{ - clear(); -} - -int ExtendedNamesModel::getNumberOfElements() -{ - return CAST_S32(mNames.size()); -} - -std::string ExtendedNamesModel::getElementAt(int i) -{ - if (i >= getNumberOfElements() || i < 0) - return "???"; - return mNames[CAST_SIZE(i)]; -} - -const Image *ExtendedNamesModel::getImageAt(int i) -{ - if (i >= CAST_S32(mImages.size()) || i < 0) - return nullptr; - - return mImages[CAST_SIZE(i)]; -} - -void ExtendedNamesModel::clear() -{ - mNames.clear(); - FOR_EACH (STD_VECTOR::iterator, it, mImages) - { - if (*it != nullptr) - (*it)->decRef(); - } - mImages.clear(); -} diff --git a/src/gui/models/extendednamesmodel.h b/src/gui/models/extendednamesmodel.h deleted file mode 100644 index 2e85a4b2b..000000000 --- a/src/gui/models/extendednamesmodel.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 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 . - */ - -#ifndef GUI_MODELS_EXTENDEDNAMESMODEL_H -#define GUI_MODELS_EXTENDEDNAMESMODEL_H - -#include "utils/stringvector.h" - -#include "gui/models/extendedlistmodel.h" - -class ExtendedNamesModel notfinal : public ExtendedListModel -{ - public: - ExtendedNamesModel(); - - A_DELETE_COPY(ExtendedNamesModel) - - virtual ~ExtendedNamesModel(); - - int getNumberOfElements() override final A_WARN_UNUSED; - - std::string getElementAt(int i) override final A_WARN_UNUSED; - - const Image *getImageAt(int i) override final A_WARN_UNUSED; - - StringVect &getNames() A_WARN_UNUSED - { return mNames; } - - STD_VECTOR &getImages() A_WARN_UNUSED - { return mImages; } - - size_t size() A_WARN_UNUSED - { return mNames.size(); } - - void add(const std::string &str) - { mNames.push_back(str); } - - void clear(); - - protected: - StringVect mNames; - STD_VECTOR mImages; -}; - -#endif // GUI_MODELS_EXTENDEDNAMESMODEL_H diff --git a/src/gui/models/fontsizechoicelistmodel.h b/src/gui/models/fontsizechoicelistmodel.h deleted file mode 100644 index 79aecf2fb..000000000 --- a/src/gui/models/fontsizechoicelistmodel.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_MODELS_FONTSIZECHOICELISTMODEL_H -#define GUI_MODELS_FONTSIZECHOICELISTMODEL_H - -#include "gui/models/listmodel.h" - -#include "utils/gettext.h" - -#include "localconsts.h" - -const int maxFontSizes = 16; - -const char *SIZE_NAME[maxFontSizes] = -{ - // TRANSLATORS: font size - N_("Very small (8)"), - // TRANSLATORS: font size - N_("Very small (9)"), - // TRANSLATORS: font size - N_("Tiny (10)"), - // TRANSLATORS: font size - N_("Small (11)"), - // TRANSLATORS: font size - N_("Medium (12)"), - // TRANSLATORS: font size - N_("Normal (13)"), - // TRANSLATORS: font size - N_("Large (14)"), - // TRANSLATORS: font size - N_("Large (15)"), - // TRANSLATORS: font size - N_("Large (16)"), - // TRANSLATORS: font size - N_("Big (17)"), - // TRANSLATORS: font size - N_("Big (18)"), - // TRANSLATORS: font size - N_("Big (19)"), - // TRANSLATORS: font size - N_("Very big (20)"), - // TRANSLATORS: font size - N_("Very big (21)"), - // TRANSLATORS: font size - N_("Very big (22)"), - // TRANSLATORS: font size - N_("Huge (23)") -}; - -class FontSizeChoiceListModel final : public ListModel -{ - public: - FontSizeChoiceListModel() : - ListModel() - { } - - A_DELETE_COPY(FontSizeChoiceListModel) - - ~FontSizeChoiceListModel() - { } - - int getNumberOfElements() override final A_WARN_UNUSED - { return maxFontSizes; } - - std::string getElementAt(int i) override final A_WARN_UNUSED - { - if (i >= getNumberOfElements() || i < 0) - return "???"; - - return gettext(SIZE_NAME[i]); - } -}; - -#endif // GUI_MODELS_FONTSIZECHOICELISTMODEL_H diff --git a/src/gui/models/fontsmodel.h b/src/gui/models/fontsmodel.h deleted file mode 100644 index b7f5fc4be..000000000 --- a/src/gui/models/fontsmodel.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_MODELS_FONTSMODEL_H -#define GUI_MODELS_FONTSMODEL_H - -#include "gui/theme.h" - -#include "gui/models/namesmodel.h" - -#include "localconsts.h" - -class FontsModel final : public NamesModel -{ - public: - FontsModel() : - NamesModel() - { Theme::fillFontsList(mNames); } - - A_DELETE_COPY(FontsModel) - - ~FontsModel() - { } -}; - -#endif // GUI_MODELS_FONTSMODEL_H diff --git a/src/gui/models/iconsmodel.h b/src/gui/models/iconsmodel.h deleted file mode 100644 index 4028895fb..000000000 --- a/src/gui/models/iconsmodel.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009 The Mana World Development Team - * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_MODELS_ICONSMODEL_H -#define GUI_MODELS_ICONSMODEL_H - -#include "gui/models/listmodel.h" - -#include "utils/foreach.h" - -#include "resources/iteminfo.h" - -#include "resources/db/itemdb.h" - -#include - -#include "localconsts.h" - -class IconsModel final : public ListModel -{ - public: - IconsModel() : - mStrings() - { - const std::map &items = ItemDB::getItemInfos(); - std::list tempStrings; - - for (std::map::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::const_iterator, i, tempStrings) - mStrings.push_back(*i); - } - - A_DELETE_COPY(IconsModel) - - ~IconsModel() - { } - - int getNumberOfElements() override final - { - return CAST_S32(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 deleted file mode 100644 index 6cd8bbe87..000000000 --- a/src/gui/models/ignorechoiceslistmodel.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_MODELS_IGNORECHOICESLISTMODEL_H -#define GUI_MODELS_IGNORECHOICESLISTMODEL_H - -#include "gui/models/playerrelationlistmodel.h" - -#include "being/playerignorestrategy.h" -#include "being/playerrelations.h" - -#include "utils/cast.h" - -/** - * Class for choosing one of the various `what to do when ignoring a player' options - */ -class IgnoreChoicesListModel final : public ListModel -{ - public: - IgnoreChoicesListModel() : - ListModel() - { } - - A_DELETE_COPY(IgnoreChoicesListModel) - - ~IgnoreChoicesListModel() - { } - - int getNumberOfElements() override final - { - return CAST_S32(playerRelations. - getPlayerIgnoreStrategies()->size()); - } - - std::string getElementAt(int i) override final - { - if (i >= getNumberOfElements() || i < 0) - return "???"; - - return (*playerRelations.getPlayerIgnoreStrategies()) - [i]->mDescription; - } -}; - -#endif // GUI_MODELS_IGNORECHOICESLISTMODEL_H diff --git a/src/gui/models/itemsmodel.h b/src/gui/models/itemsmodel.h deleted file mode 100644 index a49a7cfc5..000000000 --- a/src/gui/models/itemsmodel.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#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/foreach.h" - -#include - -#include "localconsts.h" - -class ItemsModal final : public ListModel -{ - public: - ItemsModal() : - mStrings() - { - const std::map &items = ItemDB::getItemInfos(); - std::list tempStrings; - - for (std::map::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::const_iterator, i, tempStrings) - mStrings.push_back(*i); - } - - A_DELETE_COPY(ItemsModal) - - ~ItemsModal() - { } - - int getNumberOfElements() override final - { - return CAST_S32(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/gui/models/keylistmodel.h b/src/gui/models/keylistmodel.h deleted file mode 100644 index 601426f8a..000000000 --- a/src/gui/models/keylistmodel.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2007 Joshua Langley - * Copyright (C) 2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_MODELS_KEYLISTMODEL_H -#define GUI_MODELS_KEYLISTMODEL_H - -#include "gui/setupactiondata.h" - -#include "gui/models/listmodel.h" - -#include "localconsts.h" - -extern SetupActionData *const setupActionData[]; - -/** - * The list model for key function list. - * - * \ingroup Interface - */ -class KeyListModel final : public ListModel -{ - public: - KeyListModel() : - mDataNum(0), - mSelectedData(0), - mSize(0) - { - } - - A_DELETE_COPY(KeyListModel) - - /** - * Returns the number of elements in container. - */ - int getNumberOfElements() override final - { return mSize; } - - /** - * Returns element from container. - */ - std::string getElementAt(int i) override final - { return setupActionData[mSelectedData][i].text; } - - /** - * Sets element from container. - */ - void setElementAt(const int i, const std::string &caption) - { setupActionData[mSelectedData][i].text = caption; } - - void setSize(const int size) noexcept2 - { mSize = size; } - - void setDataNum(const int num) noexcept2 - { mDataNum = num; } - - void setSelectedData(const int i) noexcept2 - { mSelectedData = i; } - - int getSelectedData() const noexcept2 A_WARN_UNUSED - { return mSelectedData; } - - private: - int mDataNum; - int mSelectedData; - int mSize; -}; - -#endif // GUI_MODELS_KEYLISTMODEL_H diff --git a/src/gui/models/langlistmodel.h b/src/gui/models/langlistmodel.h deleted file mode 100644 index f8c67ad30..000000000 --- a/src/gui/models/langlistmodel.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_MODELS_LANGLISTMODEL_H -#define GUI_MODELS_LANGLISTMODEL_H - -#include "gui/models/extendedlistmodel.h" - -#include "resources/loaders/imageloader.h" - -#include "utils/gettext.h" - -#include "localconsts.h" - -struct Language final -{ - A_DEFAULT_COPY(Language) - - std::string name; - std::string value; - std::string icon; -}; - -const int langs_count = 22; - -const Language LANG_NAME[langs_count] = -{ - // TRANSLATORS: language - {N_("(default)"), "", ""}, - // TRANSLATORS: language - {N_("Catalan"), "ca_ES", "ca.png"}, - // TRANSLATORS: language - {N_("Chinese (China)"), "zh_CN", "cn.png"}, - // TRANSLATORS: language - {N_("Chinese (Hong Kong)"), "zh_HK", "hk.png"}, - // TRANSLATORS: language - {N_("Czech"), "cs_CZ", "cz.png"}, - // TRANSLATORS: language - {N_("Dutch (Belgium/Flemish)"), "nl_BE", "nl_BE.png"}, - // TRANSLATORS: language - {N_("English"), "C", "en.png"}, - // TRANSLATORS: language - {N_("Finnish"), "fi_FI", "fi.png"}, - // TRANSLATORS: language - {N_("French"), "fr_FR", "fr.png"}, - // TRANSLATORS: language - {N_("German"), "de_DE", "de.png"}, - // TRANSLATORS: language - {N_("Indonesian"), "id_ID", "id.png"}, - // TRANSLATORS: language - {N_("Italian"), "it_IT", "it.png"}, - // TRANSLATORS: language - {N_("Japanese"), "ja_JP", "jp.png"}, - // TRANSLATORS: language - {N_("Polish"), "pl_PL", "pl.png"}, - // TRANSLATORS: language - {N_("Portuguese"), "pt_PT", "pt.png"}, - // TRANSLATORS: language - {N_("Portuguese (Brazilian)"), "pt_BR", "pt_BR.png"}, - // TRANSLATORS: language - {N_("Russian"), "ru_RU", "ru.png"}, - // TRANSLATORS: language - {N_("Spanish (Castilian)"), "es_ES", "es.png"}, - // TRANSLATORS: language - {N_("Swedish (Sweden)"), "sv_SE", "se.png"}, - // TRANSLATORS: language - {N_("Turkish"), "tr_TR", "tr.png"}, - // TRANSLATORS: language - {N_("Ukrainian"), "uk_UA", "ua.png"}, - // TRANSLATORS: language - {N_("Esperanto"), "eo", "eo.png"} -}; - -class LangListModel final : public ExtendedListModel -{ - public: - LangListModel() - { - for (int f = 0; f < langs_count; f ++) - { - const std::string icon = LANG_NAME[f].icon; - if (!icon.empty()) - { - mIcons[f] = Loader::getImage("graphics/flags/" - + icon); - } - else - { - mIcons[f] = nullptr; - } - } - } - - A_DELETE_COPY(LangListModel) - - ~LangListModel() - { - for (int f = 0; f < langs_count; f ++) - { - Image *const img = mIcons[f]; - if (img != nullptr) - img->decRef(); - } - } - - int getNumberOfElements() override final A_WARN_UNUSED - { return langs_count; } - - std::string getElementAt(int i) override final A_WARN_UNUSED - { - if (i >= getNumberOfElements() || i < 0) - return "???"; - - return gettext(LANG_NAME[i].name.c_str()); - } - - const Image *getImageAt(int i) override final A_WARN_UNUSED - { - if (i >= getNumberOfElements() || i < 0) - return nullptr; - return mIcons[i]; - } - - Image *mIcons[langs_count] A_NONNULLPOINTER; -}; - -#endif // GUI_MODELS_LANGLISTMODEL_H diff --git a/src/gui/models/listmodel.h b/src/gui/models/listmodel.h deleted file mode 100644 index df8db8b54..000000000 --- a/src/gui/models/listmodel.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 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 . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * 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_MODELS_LISTMODEL_H -#define GUI_MODELS_LISTMODEL_H - -#include - -#include "localconsts.h" - -/** - * 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 notfinal -{ - public: - ListModel() - { } - - A_DELETE_COPY(ListModel) - - /** - * Destructor. - */ - virtual ~ListModel() - { } - - /** - * 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. - */ - virtual std::string getElementAt(int i) A_WARN_UNUSED = 0; -}; - -#endif // GUI_MODELS_LISTMODEL_H diff --git a/src/gui/models/magicschoolmodel.h b/src/gui/models/magicschoolmodel.h deleted file mode 100644 index 2dcd01880..000000000 --- a/src/gui/models/magicschoolmodel.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009 The Mana World Development Team - * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011-2017 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 . - */ - -#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() : - ListModel() - { } - - A_DELETE_COPY(MagicSchoolModel) - - ~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/models/modelistmodel.cpp b/src/gui/models/modelistmodel.cpp deleted file mode 100644 index d1253b9f1..000000000 --- a/src/gui/models/modelistmodel.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#include "render/graphics.h" - -#include "utils/sdlhelper.h" -#include "utils/stringutils.h" - -#include "gui/models/modelistmodel.h" - -#include - -#include "debug.h" - -#ifndef ANDROID -static bool modeSorter(const std::string &mode1, const std::string &mode2) -{ - const int width1 = atoi(mode1.substr(0, mode1.find('x')).c_str()); - const int height1 = atoi(mode1.substr(mode1.find('x') + 1).c_str()); - if ((width1 == 0) || (height1 == 0)) - return false; - - const int width2 = atoi(mode2.substr(0, mode2.find('x')).c_str()); - const int height2 = atoi(mode2.substr(mode2.find('x') + 1).c_str()); - if ((width2 == 0) || (height2 == 0)) - return false; - if (width1 != width2) - return width1 < width2; - - if (height1 != height2) - return height1 < height2; - - return false; -} -#endif // ANDROID - -ModeListModel::ModeListModel() : - ListModel(), - mVideoModes() -{ - SDL::getAllVideoModes(mVideoModes); -#ifndef ANDROID - addCustomMode("640x480"); - addCustomMode("800x600"); - addCustomMode("1024x768"); - addCustomMode("1280x1024"); - addCustomMode("1400x900"); - addCustomMode("1500x990"); - addCustomMode(toString(mainGraphics->mActualWidth).append("x") - .append(toString(mainGraphics->mActualHeight))); - - std::sort(mVideoModes.begin(), mVideoModes.end(), &modeSorter); - mVideoModes.push_back("custom"); -#endif // ANDROID -} - -#ifndef ANDROID -void ModeListModel::addCustomMode(const std::string &mode) -{ - StringVectCIter it = mVideoModes.begin(); - const StringVectCIter it_end = mVideoModes.end(); - while (it != it_end) - { - if (*it == mode) - return; - ++ it; - } - mVideoModes.push_back(mode); -} -#endif // ANDROID - -int ModeListModel::getIndexOf(const std::string &widthXHeightMode) -{ - std::string currentMode; - for (int i = 0; i < getNumberOfElements(); i++) - { - currentMode = getElementAt(i); - if (currentMode == widthXHeightMode) - return i; - } - return -1; -} diff --git a/src/gui/models/modelistmodel.h b/src/gui/models/modelistmodel.h deleted file mode 100644 index ed4d449d7..000000000 --- a/src/gui/models/modelistmodel.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_MODELS_MODELISTMODEL_H -#define GUI_MODELS_MODELISTMODEL_H - -#include "gui/models/listmodel.h" - -#include "utils/cast.h" -#include "utils/stringvector.h" - -#include "localconsts.h" - -class ModeListModel final : public ListModel -{ - public: - ModeListModel(); - - A_DELETE_COPY(ModeListModel) - - ~ModeListModel() - { } - - /** - * Returns the number of elements in container. - */ - int getNumberOfElements() override final - { return CAST_S32(mVideoModes.size()); } - - /** - * Returns element from container. - */ - std::string getElementAt(int i) override final - { return mVideoModes[CAST_SIZE(i)]; } - - /** - * Returns the index corresponding to the given video mode. - * E.g.: "800x600". - * or -1 if not found. - */ - int getIndexOf(const std::string &widthXHeightMode); - - private: -#ifndef ANDROID - void addCustomMode(const std::string &mode); -#endif // ANDROID - - StringVect mVideoModes; -}; - -#endif // GUI_MODELS_MODELISTMODEL_H diff --git a/src/gui/models/namesmodel.cpp b/src/gui/models/namesmodel.cpp deleted file mode 100644 index 5344a7a7d..000000000 --- a/src/gui/models/namesmodel.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 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 . - */ - -#include "gui/models/namesmodel.h" - -#include "utils/cast.h" -#include "utils/foreach.h" -#include "utils/gettext.h" - -#include "debug.h" - -NamesModel::NamesModel() : - ListModel(), - mNames() -{ -} - -NamesModel::~NamesModel() -{ -} - -int NamesModel::getNumberOfElements() -{ - return CAST_S32(mNames.size()); -} - -std::string NamesModel::getElementAt(int i) -{ - if (i >= getNumberOfElements() || i < 0) - return "???"; - return mNames[CAST_SIZE(i)]; -} - -void NamesModel::fillFromArray(const char *const *const arr, - const std::size_t sz) -{ - if (arr == nullptr) - return; - for (size_t f = 0; f < sz; f ++) - mNames.push_back(gettext(arr[f])); -} - -void NamesModel::fillFromVector(const StringVect &vect) -{ - FOR_EACH(StringVectCIter, it, vect) - { - const std::string str = *it; - if (!str.empty()) - mNames.push_back(str); - } -} diff --git a/src/gui/models/namesmodel.h b/src/gui/models/namesmodel.h deleted file mode 100644 index a239bd9aa..000000000 --- a/src/gui/models/namesmodel.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 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 . - */ - -#ifndef GUI_MODELS_NAMESMODEL_H -#define GUI_MODELS_NAMESMODEL_H - -#include "utils/stringvector.h" - -#include "gui/models/listmodel.h" - -#include "localconsts.h" - -class NamesModel notfinal : public ListModel -{ - public: - NamesModel(); - - A_DELETE_COPY(NamesModel) - - virtual ~NamesModel(); - - int getNumberOfElements() override final A_WARN_UNUSED; - - std::string getElementAt(int i) override final A_WARN_UNUSED; - - StringVect &getNames() noexcept2 A_WARN_UNUSED - { return mNames; } - - size_t size() const noexcept2 A_WARN_UNUSED - { return mNames.size(); } - - void clear() - { mNames.clear(); } - - void add(const std::string &str) - { mNames.push_back(str); } - - void fillFromArray(const char *const *const arr, - const std::size_t size); - - void fillFromVector(const StringVect &vect); - - protected: - StringVect mNames; -}; - -#endif // GUI_MODELS_NAMESMODEL_H diff --git a/src/gui/models/opengllistmodel.h b/src/gui/models/opengllistmodel.h deleted file mode 100644 index 085dd17a5..000000000 --- a/src/gui/models/opengllistmodel.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_MODELS_OPENGLLISTMODEL_H -#define GUI_MODELS_OPENGLLISTMODEL_H - -#include "gui/models/listmodel.h" - -#include "render/rendererslistsdl.h" - -#include "localconsts.h" - -class OpenGLListModel final : public ListModel -{ - public: - OpenGLListModel() : - ListModel() - { } - - A_DELETE_COPY(OpenGLListModel) - - ~OpenGLListModel() - { } - - int getNumberOfElements() override final - { return renderModesListSize; } - - std::string getElementAt(int i) override final - { - if (i >= getNumberOfElements() || i < 0) - return "???"; - return gettext(OPENGL_NAME[i]); - } -}; - -#endif // GUI_MODELS_OPENGLLISTMODEL_H diff --git a/src/gui/models/playerrelationlistmodel.h b/src/gui/models/playerrelationlistmodel.h deleted file mode 100644 index 5e58d4905..000000000 --- a/src/gui/models/playerrelationlistmodel.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_MODELS_PLAYERRELATIONLISTMODEL_H -#define GUI_MODELS_PLAYERRELATIONLISTMODEL_H - -#include "being/playerrelation.h" - -#include "gui/models/listmodel.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() : - ListModel() - { } - - A_DELETE_COPY(PlayerRelationListModel) - - ~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/gui/models/playertablemodel.cpp b/src/gui/models/playertablemodel.cpp deleted file mode 100644 index 271b6a5bb..000000000 --- a/src/gui/models/playertablemodel.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#include "gui/models/playertablemodel.h" - -#include "being/playerrelations.h" - -#include "gui/widgets/dropdown.h" -#include "gui/widgets/label.h" - -#include "gui/models/playerrelationlistmodel.h" - -#include "utils/delete2.h" -#include "utils/dtor.h" - -#include "debug.h" - -static const int COLUMNS_NR = 2; // name plus listbox -static const int NAME_COLUMN = 0; -static const unsigned int RELATION_CHOICE_COLUMN = 1; - -static const unsigned int ROW_HEIGHT = 12; -// The following column widths really shouldn't be hardcoded -// but should scale with the size of the widget... except -// that, right now, the widget doesn't exactly scale either. -static const unsigned int NAME_COLUMN_WIDTH = 230; -static const unsigned int RELATION_CHOICE_COLUMN_WIDTH = 80; - -#define WIDGET_AT(row, column) (((row) * COLUMNS_NR) + column) - -PlayerTableModel::PlayerTableModel(const Widget2 *const widget) : - Widget2(widget), - TableModel(), - mPlayers(nullptr), - mWidgets(), - mListModel(new PlayerRelationListModel) -{ - playerRelationsUpdated(); -} - -PlayerTableModel::~PlayerTableModel() -{ - freeWidgets(); - delete2(mListModel) - delete2(mPlayers) -} - -int PlayerTableModel::getRows() const -{ - if (mPlayers != nullptr) - return CAST_S32(mPlayers->size()); - return 0; -} - -int PlayerTableModel::getColumns() const -{ - return COLUMNS_NR; -} - -int PlayerTableModel::getRowHeight() const -{ - return ROW_HEIGHT; -} - -int PlayerTableModel::getColumnWidth(const int index) const -{ - if (index == NAME_COLUMN) - return NAME_COLUMN_WIDTH; - return RELATION_CHOICE_COLUMN_WIDTH; -} - -void PlayerTableModel::playerRelationsUpdated() -{ - signalBeforeUpdate(); - - freeWidgets(); - StringVect *const player_names = playerRelations.getPlayers(); - delete mPlayers; - mPlayers = player_names; - - // set up widgets - for (unsigned int r = 0, fsz = CAST_U32( - player_names->size()); r < fsz; ++r) - { - const std::string name = (*player_names)[r]; - Widget *const widget = new Label(this, name); - mWidgets.push_back(widget); - - DropDown *const choicebox = new DropDown(this, mListModel); - choicebox->setSelected(CAST_S32( - playerRelations.getRelation(name))); - mWidgets.push_back(choicebox); - } - - signalAfterUpdate(); -} - -void PlayerTableModel::updateModelInRow(const int row) const -{ - const DropDown *const choicebox = static_cast( - getElementAt(row, RELATION_CHOICE_COLUMN)); - if (choicebox == nullptr) - return; - playerRelations.setRelation(getPlayerAt(row), - static_cast( - choicebox->getSelected())); -} - -Widget *PlayerTableModel::getElementAt(int row, int column) const -{ - return mWidgets[WIDGET_AT(row, column)]; -} - -void PlayerTableModel::freeWidgets() -{ - delete2(mPlayers) - delete_all(mWidgets); - mWidgets.clear(); -} - -std::string PlayerTableModel::getPlayerAt(const int index) const -{ - if ((mPlayers == nullptr) || index < 0 - || index >= CAST_S32(mPlayers->size())) - { - return std::string(); - } - return (*mPlayers)[index]; -} diff --git a/src/gui/models/playertablemodel.h b/src/gui/models/playertablemodel.h deleted file mode 100644 index dfb00eeb4..000000000 --- a/src/gui/models/playertablemodel.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_MODELS_PLAYERTABLEMODEL_H -#define GUI_MODELS_PLAYERTABLEMODEL_H - -#include "gui/widgets/widget2.h" - -#include "gui/models/tablemodel.h" - -#include "localconsts.h" - -class PlayerRelationListModel; - -class PlayerTableModel final : public Widget2, - public TableModel -{ - public: - explicit PlayerTableModel(const Widget2 *const widget); - - A_DELETE_COPY(PlayerTableModel) - - ~PlayerTableModel(); - - int getRows() const override final; - - int getColumns() const override final A_CONST; - - int getRowHeight() const override final A_CONST; - - int getColumnWidth(const int index) const override final A_CONST; - - void playerRelationsUpdated(); - - void updateModelInRow(const int row) const; - - Widget *getElementAt(int row, int column) const override final; - - void freeWidgets(); - - std::string getPlayerAt(const int index) const; - - protected: - StringVect *mPlayers; - STD_VECTOR mWidgets; - PlayerRelationListModel *mListModel; -}; - -#endif // GUI_MODELS_PLAYERTABLEMODEL_H diff --git a/src/gui/models/questsmodel.h b/src/gui/models/questsmodel.h deleted file mode 100644 index f80e7a32d..000000000 --- a/src/gui/models/questsmodel.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 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 . - */ - -#ifndef GUI_MODELS_QUESTSMODEL_H -#define GUI_MODELS_QUESTSMODEL_H - -#include "gui/models/extendednamesmodel.h" - -class QuestsModel final : public ExtendedNamesModel -{ - public: - QuestsModel() : - ExtendedNamesModel() - { - } - - A_DELETE_COPY(QuestsModel) - - ~QuestsModel() - { } -}; - -#endif // GUI_MODELS_QUESTSMODEL_H diff --git a/src/gui/models/serverslistmodel.h b/src/gui/models/serverslistmodel.h deleted file mode 100644 index 8e236ebe0..000000000 --- a/src/gui/models/serverslistmodel.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_MODELS_SERVERSLISTMODEL_H -#define GUI_MODELS_SERVERSLISTMODEL_H - -#include "gui/gui.h" - -#include "gui/fonts/font.h" - -#include "gui/windows/serverdialog.h" - -#include "gui/models/listmodel.h" - -#include "utils/gettext.h" - -/** - * Server and Port List Model - */ -class ServersListModel final : public ListModel -{ - public: - typedef std::pair VersionString; - - ServersListModel(ServerInfos *const servers, - ServerDialog *const parent) : - mServers(servers), - mVersionStrings(servers != nullptr ? servers->size() : 0, - 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 CAST_S32(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; - if (server.freeType == ServerFreeType::NonFree) - { - // TRANSLATORS: server license comment - myServer.append(_("(NON FREE)")); - myServer.append(" "); - } - else if (server.freeType == ServerFreeType::Unknown) - { - // TRANSLATORS: server license comment - myServer.append(_("(UNKNOWN)")); - myServer.append(" "); - } - 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 >= CAST_S32(mVersionStrings.size())) - return; - - if (version.empty() || (gui == nullptr)) - { - mVersionStrings[index] = VersionString(0, ""); - } - else - { - mVersionStrings[index] = VersionString( - gui->getFont()->getWidth(version), version); - } - } - - private: - typedef STD_VECTOR VersionStrings; - - ServerInfos *mServers; - VersionStrings mVersionStrings; - ServerDialog *mParent; -}; - -#endif // GUI_MODELS_SERVERSLISTMODEL_H diff --git a/src/gui/models/shopitems.cpp b/src/gui/models/shopitems.cpp deleted file mode 100644 index 27e05ff12..000000000 --- a/src/gui/models/shopitems.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#include "gui/models/shopitems.h" - -#include "resources/item/shopitem.h" - -#include "utils/dtor.h" -#include "utils/foreach.h" - -#include "debug.h" - -ShopItems::ShopItems(const bool mergeDuplicates, - const std::string ¤cy) : - ListModel(), - mAllShopItems(), - mShopItems(), - mCurrency(currency), - mMergeDuplicates(mergeDuplicates) -{ -} - -ShopItems::~ShopItems() -{ - clear(); -} - -std::string ShopItems::getElementAt(int i) -{ - if (i < 0 || CAST_U32(i) - >= CAST_U32(mShopItems.size()) || (mShopItems.at(i) == nullptr)) - { - return ""; - } - - return mShopItems.at(i)->getDisplayName(); -} - -ShopItem *ShopItems::addItem(const int id, - const ItemTypeT type, - const ItemColor color, - const int amount, - const int price) -{ - ShopItem *const item = new ShopItem(-1, - id, - type, - color, - amount, - price, - mCurrency); - mShopItems.push_back(item); - mAllShopItems.push_back(item); - return item; -} - -ShopItem *ShopItems::addItemNoDup(const int id, - const ItemTypeT type, - const ItemColor color, - const int amount, - const int price) -{ - ShopItem *item = findItem(id, color); - if (item == nullptr) - { - item = new ShopItem(-1, - id, - type, - color, - amount, - price, - mCurrency); - mShopItems.push_back(item); - mAllShopItems.push_back(item); - } - return item; -} - -ShopItem *ShopItems::addItem2(const int inventoryIndex, - const int id, - const ItemTypeT type, - const ItemColor color, - const int quantity, - const int price) -{ - ShopItem *item = nullptr; - if (mMergeDuplicates) - item = findItem(id, color); - - if (item != nullptr) - { - item->addDuplicate(inventoryIndex, quantity); - } - else - { - item = new ShopItem(inventoryIndex, - id, - type, - color, - quantity, - price, - mCurrency); - mShopItems.push_back(item); - mAllShopItems.push_back(item); - } - return item; -} - -ShopItem *ShopItems::at(const size_t i) const -{ - if (i >= mShopItems.size()) - return nullptr; - - return mShopItems.at(i); -} - -bool ShopItems::findInAllItems(STD_VECTOR::iterator &it, - const ShopItem *const item) -{ - const STD_VECTOR::iterator it_end = mAllShopItems.end(); - for (it = mAllShopItems.begin(); it != it_end; ++ it) - { - if (*it == item) - return true; - } - return false; -} - -void ShopItems::erase(const unsigned int i) -{ - if (i >= CAST_U32(mShopItems.size())) - return; - - const ShopItem *const item = *(mShopItems.begin() + i); - STD_VECTOR::iterator it; - if (findInAllItems(it, item)) - mAllShopItems.erase(it); - mShopItems.erase(mShopItems.begin() + i); -} - -void ShopItems::del(const unsigned int i) -{ - if (i >= CAST_U32(mShopItems.size())) - return; - - ShopItem *item = *(mShopItems.begin() + i); - STD_VECTOR::iterator it; - if (findInAllItems(it, item)) - mAllShopItems.erase(it); - mShopItems.erase(mShopItems.begin() + i); - delete item; -} - -void ShopItems::clear() -{ - delete_all(mAllShopItems); - mAllShopItems.clear(); - mShopItems.clear(); -} - -ShopItem *ShopItems::findItem(const int id, - const ItemColor color) const -{ - STD_VECTOR::const_iterator it = mShopItems.begin(); - const STD_VECTOR::const_iterator e = mShopItems.end(); - while (it != e) - { - ShopItem *const item = *it; - if (item->getId() == id && item->getColor() == color) - return item; - - ++it; - } - - return nullptr; -} - -void ShopItems::updateList() -{ - mShopItems.clear(); - FOR_EACH (STD_VECTOR::iterator, it, mAllShopItems) - { - ShopItem *const item = *it; - if ((item != nullptr) && item->isVisible()) - mShopItems.push_back(item); - } -} diff --git a/src/gui/models/shopitems.h b/src/gui/models/shopitems.h deleted file mode 100644 index 26c5a94e4..000000000 --- a/src/gui/models/shopitems.h +++ /dev/null @@ -1,170 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_MODELS_SHOPITEMS_H -#define GUI_MODELS_SHOPITEMS_H - -#include "enums/resources/item/itemtype.h" - -#include "enums/simpletypes/itemcolor.h" - -#include "gui/models/listmodel.h" - -#include "utils/cast.h" -#include "utils/vector.h" - -#include "localconsts.h" - -class ShopItem; - -/** - * This class handles the list of items available in a shop. - * - * The addItem routine can automatically check, if an item already exists and - * only adds duplicates to the old item, if one is found. The original - * distribution of the duplicates can be retrieved from the item. - * - * This functionality can be enabled in the constructor. - */ -class ShopItems final : public ListModel -{ - public: - /** - * Constructor. - * - * @param mergeDuplicates lets the Shop look for duplicate entries and - * merges them to one item. - */ - ShopItems(const bool mergeDuplicates, - const std::string ¤cy); - - A_DELETE_COPY(ShopItems) - - ~ShopItems(); - - /** - * Adds an item to the list. - */ - ShopItem *addItem(const int id, - const ItemTypeT type, - const ItemColor color, - const int amount, - const int price); - - /** - * Adds an item to the list (used by sell dialog). Looks for - * duplicate entries, if mergeDuplicates was turned on. - * - * @param inventoryIndex the inventory index of the item - * @param id the id of the item - * @param amount number of available copies of the item - * @param price price of the item - */ - ShopItem *addItem2(const int inventoryIndex, - const int id, - const ItemTypeT type, - const ItemColor color, - const int amount, - const int price); - - ShopItem *addItemNoDup(const int id, - const ItemTypeT type, - const ItemColor color, - const int amount, - const int price); - - /** - * Returns the number of items in the shop. - */ - int getNumberOfElements() override final A_WARN_UNUSED - { return CAST_S32(mShopItems.size()); } - - bool empty() const noexcept2 A_WARN_UNUSED - { return mShopItems.empty(); } - - /** - * Returns the name of item number i in the shop. - * - * @param i the index to retrieve - */ - std::string getElementAt(int i) override final A_WARN_UNUSED; - - /** - * Returns the item number i in the shop. - */ - ShopItem *at(const size_t i) const A_WARN_UNUSED; - - /** - * Removes an element from the shop. - * - * @param i index to remove - */ - void erase(const unsigned int i); - - /** - * Removes an element from the shop and destroy it. - * - * @param i index to remove - */ - void del(const unsigned int i); - - /** - * Clears the list of items in the shop. - */ - void clear(); - - STD_VECTOR &items() A_WARN_UNUSED - { return mShopItems; } - - STD_VECTOR &allItems() A_WARN_UNUSED - { return mAllShopItems; } - - void setMergeDuplicates(const bool b) - { mMergeDuplicates = b; } - - void updateList(); - - private: - /** - * Searches the current items in the shop for the specified - * id and returns the item if found, or 0 else. - * - * @return the item found or 0 - */ - ShopItem *findItem(const int id, - const ItemColor color) const A_WARN_UNUSED; - - bool findInAllItems(STD_VECTOR::iterator &it, - const ShopItem *const item); - - /** The list of items in the shop. */ - STD_VECTOR mAllShopItems; - - STD_VECTOR mShopItems; - - std::string mCurrency; - - /** Look for duplicate entries on addition. */ - bool mMergeDuplicates; -}; - -#endif // GUI_MODELS_SHOPITEMS_H diff --git a/src/gui/models/skillmodel.cpp b/src/gui/models/skillmodel.cpp deleted file mode 100644 index 4d22280d8..000000000 --- a/src/gui/models/skillmodel.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#include "gui/models/skillmodel.h" - -#include "utils/foreach.h" - -#include "resources/skill/skilldata.h" - -#include "debug.h" - -SkillModel::SkillModel() : - ListModel(), - mSkills(), - mVisibleSkills() -{ -} - -SkillInfo *SkillModel::getSkillAt(const int i) const -{ - if (i < 0 || i >= CAST_S32(mVisibleSkills.size())) - return nullptr; - return mVisibleSkills.at(i); -} - -std::string SkillModel::getElementAt(int i) -{ - const SkillInfo *const info = getSkillAt(i); - if (info != nullptr) - return info->data->name; - return std::string(); -} - -void SkillModel::updateVisibilities() -{ - mVisibleSkills.clear(); - - FOR_EACH (SkillList::const_iterator, it, mSkills) - { - if (((*it) != nullptr) && (*it)->visible == Visible_true) - mVisibleSkills.push_back((*it)); - } -} diff --git a/src/gui/models/skillmodel.h b/src/gui/models/skillmodel.h deleted file mode 100644 index 6c7792508..000000000 --- a/src/gui/models/skillmodel.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_MODELS_SKILLMODEL_H -#define GUI_MODELS_SKILLMODEL_H - -#include "gui/models/listmodel.h" - -#include "utils/cast.h" - -#include "resources/skill/skillinfo.h" - -#include "localconsts.h" - -class SkillModel final : public ListModel -{ - public: - SkillModel(); - - A_DELETE_COPY(SkillModel) - - SkillInfo *getSkillAt(const int i) const; - - std::string getElementAt(int i) override final; - - int getNumberOfElements() override final - { return CAST_S32(mVisibleSkills.size()); } - - void addSkill(SkillInfo *const info) - { mSkills.push_back(info); } - - void updateVisibilities(); - - private: - SkillList mSkills; - SkillList mVisibleSkills; -}; - -#endif // GUI_MODELS_SKILLMODEL_H diff --git a/src/gui/models/sortlistmodelbuy.h b/src/gui/models/sortlistmodelbuy.h deleted file mode 100644 index 3af489222..000000000 --- a/src/gui/models/sortlistmodelbuy.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#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() : - ListModel() - { } - - A_DELETE_COPY(SortListModelBuy) - - ~SortListModelBuy() - { } - - int getNumberOfElements() override final - { return 7; } - - std::string getElementAt(int i) override final - { - 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 deleted file mode 100644 index 3561d2621..000000000 --- a/src/gui/models/sortlistmodelinv.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_MODELS_SORTLISTMODELINV_H -#define GUI_MODELS_SORTLISTMODELINV_H - -#include "gui/models/listmodel.h" - -#include "utils/gettext.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 ListModel -{ - public: - SortListModelInv() : - ListModel() - { } - - A_DELETE_COPY(SortListModelInv) - - ~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/models/soundsmodel.h b/src/gui/models/soundsmodel.h deleted file mode 100644 index ad66049a3..000000000 --- a/src/gui/models/soundsmodel.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_MODELS_SOUNDSMODEL_H -#define GUI_MODELS_SOUNDSMODEL_H - -#include "gui/theme.h" - -#include "gui/models/namesmodel.h" - -#include "utils/gettext.h" - -#include "localconsts.h" - -class SoundsModel final : public NamesModel -{ - public: - SoundsModel() : - NamesModel() - { - mNames.push_back(gettext("(no sound)")); - Theme::fillSoundsList(mNames); - } - - A_DELETE_COPY(SoundsModel) - - ~SoundsModel() - { } -}; - -#endif // GUI_MODELS_SOUNDSMODEL_H diff --git a/src/gui/models/tablemodel.cpp b/src/gui/models/tablemodel.cpp deleted file mode 100644 index 08cfb6d83..000000000 --- a/src/gui/models/tablemodel.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#include "gui/models/tablemodel.h" - -#include "utils/dtor.h" - -#include "gui/widgets/widget.h" - -#include "listeners/tablemodellistener.h" - -#include "debug.h" - -void TableModel::installListener(TableModelListener *const listener) -{ - if (listener != nullptr) - listeners.insert(listener); -} - -void TableModel::removeListener(TableModelListener *const listener) -{ - if (listener != nullptr) - listeners.erase(listener); -} - -void TableModel::signalBeforeUpdate() -{ - for (std::set::const_iterator it = listeners.begin(); - it != listeners.end(); ++it) - { - (*it)->modelUpdated(false); - } -} - -void TableModel::signalAfterUpdate() -{ - for (std::set::const_iterator it = listeners.begin(); - it != listeners.end(); ++it) - { - if (*it != nullptr) - (*it)->modelUpdated(true); - } -} - - -#define WIDGET_AT(row, column) (((row) * mColumns) + (column)) -#define DYN_SIZE(h) ((h) >= 0) - -StaticTableModel::StaticTableModel(const int row, const int column) : - TableModel(), - mRows(row), - mColumns(column), - mHeight(1), - mTableModel(), - mWidths() -{ - mTableModel.resize(row * column, nullptr); - mWidths.resize(column, 1); -} - -StaticTableModel::~StaticTableModel() -{ - delete_all(mTableModel); - mTableModel.clear(); -} - -void StaticTableModel::resize() -{ - mRows = getRows(); - mColumns = getColumns(); - mTableModel.resize(mRows * mColumns, nullptr); -} - -void StaticTableModel::set(const int row, const int column, - Widget *const widget) -{ - if ((widget == nullptr) || row >= mRows || row < 0 - || column >= mColumns || column < 0) - { - // raise exn? - return; - } - - if (DYN_SIZE(mHeight) - && widget->getHeight() > mHeight) - { - mHeight = widget->getHeight(); - } - - if (DYN_SIZE(mWidths[column]) - && widget->getWidth() > mWidths[column]) - { - mWidths[column] = widget->getWidth(); - } - - signalBeforeUpdate(); - - delete mTableModel[WIDGET_AT(row, column)]; - - mTableModel[WIDGET_AT(row, column)] = widget; - - signalAfterUpdate(); -} - -Widget *StaticTableModel::getElementAt(const int row, - const int column) const -{ - return mTableModel[WIDGET_AT(row, column)]; -} - -void StaticTableModel::fixColumnWidth(const int column, const int width) -{ - if (width < 0 || column < 0 || column >= mColumns) - return; - - mWidths[column] = -width; // Negate to tag as fixed -} - -void StaticTableModel::fixRowHeight(const int height) -{ - if (height < 0) - return; - - mHeight = -height; -} - -int StaticTableModel::getRowHeight() const -{ - return abs(mHeight); -} - -int StaticTableModel::getColumnWidth(const int column) const -{ - if (column < 0 || column >= mColumns) - return 0; - - return abs(mWidths[column]); -} - -int StaticTableModel::getRows() const -{ - return mRows; -} - -int StaticTableModel::getColumns() const -{ - return mColumns; -} - -int StaticTableModel::getWidth() const -{ - int width = 0; - - for (size_t i = 0, sz = mWidths.size(); i < sz; i++) - width += mWidths[i]; - - return width; -} - -int StaticTableModel::getHeight() const -{ - return mColumns * mHeight; -} diff --git a/src/gui/models/tablemodel.h b/src/gui/models/tablemodel.h deleted file mode 100644 index 23f286c2e..000000000 --- a/src/gui/models/tablemodel.h +++ /dev/null @@ -1,153 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_MODELS_TABLEMODEL_H -#define GUI_MODELS_TABLEMODEL_H - -#include "utils/vector.h" - -#include - -#include "localconsts.h" - -class Widget; - -class TableModelListener; - -/** - * A model for a regular table of widgets. - */ -class TableModel notfinal -{ - public: - A_DELETE_COPY(TableModel) - - virtual ~TableModel() - { } - - /** - * Determines the number of rows (lines) in the table - */ - virtual int getRows() const A_WARN_UNUSED = 0; - - /** - * Determines the number of columns in each row - */ - virtual int getColumns() const A_WARN_UNUSED = 0; - - /** - * Determines the height for each row - */ - virtual int getRowHeight() const A_WARN_UNUSED = 0; - - /** - * Determines the width of each individual column - */ - virtual int getColumnWidth(const int index) const A_WARN_UNUSED = 0; - - /** - * Retrieves the widget stored at the specified location - * within the table. - */ - virtual Widget *getElementAt(const int row, const int column) - const A_WARN_UNUSED = 0; - - virtual void installListener(TableModelListener *const listener); - - virtual void removeListener(TableModelListener *const listener); - - protected: - TableModel() : - listeners() - { - } - - /** - * Tells all listeners that the table is about to see an update - */ - virtual void signalBeforeUpdate(); - - /** - * Tells all listeners that the table has seen an update - */ - virtual void signalAfterUpdate(); - - private: - std::set listeners; -}; - - -class StaticTableModel final : public TableModel -{ - public: - StaticTableModel(const int width, const int height); - - A_DELETE_COPY(StaticTableModel) - - ~StaticTableModel(); - - /** - * Inserts a widget into the table model. - * 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, Widget *const widget); - - /** - * Fixes the column width for a given column; this overrides dynamic - * width inference. - * - * Semantics are undefined for width 0. - */ - void fixColumnWidth(const int column, const int width); - - /** - * Fixes the row height; this overrides dynamic height inference. - * - * Semantics are undefined for width 0. - */ - void fixRowHeight(const int height); - - /** - * Resizes the table model - */ - void resize(); - - int getRows() const override final A_WARN_UNUSED; - int getColumns() const override final A_WARN_UNUSED; - int getRowHeight() const override final A_WARN_UNUSED; - int getWidth() const A_WARN_UNUSED; - int getHeight() const A_WARN_UNUSED; - int getColumnWidth(const int index) const override final A_WARN_UNUSED; - Widget *getElementAt(const int row, - const int column) const override final - A_WARN_UNUSED; - - protected: - int mRows; - int mColumns; - int mHeight; - STD_VECTOR mTableModel; - STD_VECTOR mWidths; -}; - -#endif // GUI_MODELS_TABLEMODEL_H diff --git a/src/gui/models/targettypemodel.h b/src/gui/models/targettypemodel.h deleted file mode 100644 index ec049bf66..000000000 --- a/src/gui/models/targettypemodel.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011-2017 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 . - */ - -#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() : - ListModel() - { } - - A_DELETE_COPY(TargetTypeModel) - - ~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 deleted file mode 100644 index c68cc0a2f..000000000 --- a/src/gui/models/themesmodel.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011-2017 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 . - */ - -#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); - } - - A_DELETE_COPY(ThemesModel) - - ~ThemesModel() - { } -}; - -#endif // GUI_MODELS_THEMESMODEL_H diff --git a/src/gui/models/touchactionmodel.cpp b/src/gui/models/touchactionmodel.cpp deleted file mode 100644 index 1998d2752..000000000 --- a/src/gui/models/touchactionmodel.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 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 . - */ - -#include "gui/setupactiondata.h" -#include "gui/touchactiondata.h" - -#include "gui/models/touchactionmodel.h" - -#include "utils/foreach.h" - -#include - -#include "debug.h" - -const int touchActionDataSize = 5; - -static class SortTouchActionFunctor final -{ - public: - A_DEFAULT_COPY(SortTouchActionFunctor) - - bool operator() (const SetupActionData *const data1, - const SetupActionData *const data2) const - { - if ((data1 == nullptr) || (data2 == nullptr)) - return false; - return data1->name < data2->name; - } -} touchActionSorter; - -TouchActionsModel::TouchActionsModel() : - NamesModel(), - mActionId(), - mActionToSelection() -{ - STD_VECTOR data; - - for (int f = 0, fsz = touchActionDataSize; f < fsz; 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::iterator, it, data) - { - const SetupActionData *const data1 = *it; - mNames.push_back(data1->name); - mActionId.push_back(data1->actionId); - mActionToSelection[data1->actionId] = cnt; - cnt ++; - } -} - -InputActionT TouchActionsModel::getActionFromSelection(const int sel) const -{ - if (sel < 0 || sel > static_cast(mActionId.size())) - return InputAction::NO_VALUE; - return mActionId[sel]; -} - -int TouchActionsModel::getSelectionFromAction(const InputActionT action) const -{ - const std::map::const_iterator it - = mActionToSelection.find(action); - if (it == mActionToSelection.end()) - return 0; - return (*it).second; -} diff --git a/src/gui/models/touchactionmodel.h b/src/gui/models/touchactionmodel.h deleted file mode 100644 index 2d8cff02a..000000000 --- a/src/gui/models/touchactionmodel.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 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 . - */ - -#ifndef GUI_MODELS_TOUCHACTIONMODEL_H -#define GUI_MODELS_TOUCHACTIONMODEL_H - -#include "enums/input/inputaction.h" - -#include "gui/models/namesmodel.h" - -#include - -class TouchActionsModel final : public NamesModel -{ - public: - TouchActionsModel(); - - A_DELETE_COPY(TouchActionsModel) - - ~TouchActionsModel() - { } - - InputActionT getActionFromSelection(const int sel) const; - - int getSelectionFromAction(const InputActionT action) const; - - private: - STD_VECTOR mActionId; - std::map mActionToSelection; -}; - -#endif // GUI_MODELS_TOUCHACTIONMODEL_H diff --git a/src/gui/models/typelistmodel.h b/src/gui/models/typelistmodel.h deleted file mode 100644 index 681e019fc..000000000 --- a/src/gui/models/typelistmodel.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2012 The Mana Developers - * Copyright (C) 2012-2017 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 . - */ - -#ifndef GUI_MODELS_TYPELISTMODEL_H -#define GUI_MODELS_TYPELISTMODEL_H - -#include "gui/models/listmodel.h" - -/** - * Server Type List Model - */ -class TypeListModel final : public ListModel -{ - public: - TypeListModel() : - ListModel() - { } - - A_DELETE_COPY(TypeListModel) - - /** - * Used to get number of line in the list - */ - int getNumberOfElements() override final A_WARN_UNUSED -#if defined(TMWA_SUPPORT) - { return 3; } -#else // defined(TMWA_SUPPORT) - { return 2; } -#endif // defined(TMWA_SUPPORT) - - /** - * Used to get an element from the list - */ - std::string getElementAt(int elementIndex) - override final A_WARN_UNUSED - { -#ifdef TMWA_SUPPORT - if (elementIndex == 0) - return "TmwAthena"; - else if (elementIndex == 1) - return "Hercules"; - else if (elementIndex == 2) - return "Evol2"; - else -#else // TMWA_SUPPORT - if (elementIndex == 0) - return "Hercules"; - else if (elementIndex == 1) - return "Evol2"; - else -#endif // TMWA_SUPPORT - return "Unknown"; - } -}; - -#endif // GUI_MODELS_TYPELISTMODEL_H diff --git a/src/gui/models/updatelistmodel.h b/src/gui/models/updatelistmodel.h deleted file mode 100644 index cd4ba50c3..000000000 --- a/src/gui/models/updatelistmodel.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_MODELS_UPDATELISTMODEL_H -#define GUI_MODELS_UPDATELISTMODEL_H - -#include "gui/models/listmodel.h" - -#include "net/serverinfo.h" - -#include "utils/cast.h" -#include "utils/foreach.h" - -#include "localconsts.h" - -class UpdateListModel final : public ListModel -{ - public: - explicit UpdateListModel(ServerInfo *const server) : - ListModel(), - mNames(), - mServer(server) - { - FOR_EACH(STD_VECTOR::const_iterator, - it, - server->updateHosts) - { - const HostsGroup &group = *it; - mNames.push_back(group.name); - } - } - - A_DELETE_COPY(UpdateListModel) - - ~UpdateListModel() - { } - - int getNumberOfElements() override final - { - return CAST_S32(mNames.size()); - } - - std::string getElementAt(int i) override final - { - if (i >= getNumberOfElements() || i < 0) - return "???"; - return mNames[i]; - } - - bool empty() const - { - return mNames.empty(); - } - - protected: - StringVect mNames; - ServerInfo *mServer; -}; - -#endif // GUI_MODELS_UPDATELISTMODEL_H diff --git a/src/gui/models/updatetypemodel.h b/src/gui/models/updatetypemodel.h deleted file mode 100644 index 232be8223..000000000 --- a/src/gui/models/updatetypemodel.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#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 deleted file mode 100644 index 3be179c61..000000000 --- a/src/gui/models/worldlistmodel.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_MODELS_WORLDLISTMODEL_H -#define GUI_MODELS_WORLDLISTMODEL_H - -#include "gui/models/listmodel.h" - -#include "utils/cast.h" -#include "utils/stringutils.h" - -#include "net/worldinfo.h" - -/** - * The list model for the server list. - */ -class WorldListModel final : public ListModel -{ - public: - explicit WorldListModel(const Worlds &worlds) : - mWorlds(worlds) - { - } - - A_DELETE_COPY(WorldListModel) - - ~WorldListModel() - { } - - int getNumberOfElements() override final - { - return CAST_S32(mWorlds.size()); - } - - std::string getElementAt(int i) override final - { - const WorldInfo *const si = mWorlds[i]; - if (si != nullptr) - { - return std::string(si->name).append(" (").append( - toString(si->online_users)).append(")"); - } - return "???"; - } - private: - Worlds mWorlds; -}; - -#endif // GUI_MODELS_WORLDLISTMODEL_H diff --git a/src/gui/mouseoverlink.h b/src/gui/mouseoverlink.h deleted file mode 100644 index 758d02b6e..000000000 --- a/src/gui/mouseoverlink.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_MOUSEOVERLINK_H -#define GUI_MOUSEOVERLINK_H - -#include "gui/browserlink.h" - -#include "localconsts.h" - -struct MouseOverLink final -{ - MouseOverLink(const int x, - const int y) : - mX(x), - mY(y) - { } - - A_DEFAULT_COPY(MouseOverLink) - - bool operator() (const BrowserLink &link) const - { - return mX >= link.x1 && - mX < link.x2 && - mY >= link.y1 && - mY < link.y2; - } - const int mX; - const int mY; -}; - -#endif // GUI_MOUSEOVERLINK_H diff --git a/src/gui/onlineplayer.h b/src/gui/onlineplayer.h deleted file mode 100644 index 43ebb5c5f..000000000 --- a/src/gui/onlineplayer.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_ONLINEPLAYER_H -#define GUI_ONLINEPLAYER_H - -#include "enums/being/gender.h" - -#include - -#include "localconsts.h" - -class OnlinePlayer final -{ - public: - OnlinePlayer(const std::string &nick, - const unsigned char status, - const signed char level, - const GenderT gender, - const signed char version) : - mNick(nick), - mText(), - mStatus(status), - mLevel(level), - mVersion(version), - mGender(gender), - mIsGM(false) - { - } - - A_DELETE_COPY(OnlinePlayer) - - const std::string getNick() const noexcept2 A_WARN_UNUSED - { return mNick; } - - unsigned char getStaus() const noexcept2 A_WARN_UNUSED - { return mStatus; } - - void setIsGM(const bool b) - { mIsGM = b; } - - char getVersion() const noexcept2 A_WARN_UNUSED - { return mVersion; } - - char getLevel() const noexcept2 A_WARN_UNUSED - { return mLevel; } - - const std::string getText() const noexcept2 A_WARN_UNUSED - { return mText; } - - void setText(std::string str); - - void setLevel(const char level) noexcept2 - { mLevel = level; } - - private: - std::string mNick; - - std::string mText; - - unsigned char mStatus; - - signed char mLevel; - - signed char mVersion; - - GenderT mGender; - - bool mIsGM; -}; - -#endif // GUI_ONLINEPLAYER_H diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp deleted file mode 100644 index 7fcf153fe..000000000 --- a/src/gui/palette.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008 Douglas Boffey - * Copyright (C) 2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#include "gui/palette.h" - -#include "utils/foreach.h" -#include "utils/timer.h" - -#ifndef USE_SDL2 -#include -#endif // USE_SDL2 - -#include "debug.h" - -const Color Palette::BLACK = Color(0, 0, 0); -Palette::Palettes Palette::mInstances; - -const Color Palette::RAINBOW_COLORS[7] = -{ - 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; - -Palette::Palette(const int size) : - mRainbowTime(tick_time), - mColors(Colors(size)), - mCharColors(), - mGradVector() -{ - mInstances.insert(this); -} - -Palette::~Palette() -{ - mInstances.erase(this); -} - -const Color& Palette::getCharColor(const signed char c, bool &valid) const -{ - const CharColors::const_iterator it = mCharColors.find(c); - if (it != mCharColors.end()) - { - valid = true; - return mColors[(*it).second].color; - } - - valid = false; - return BLACK; -} - -void Palette::advanceGradients() -{ - FOR_EACH (Palettes::const_iterator, it, mInstances) - (*it)->advanceGradient(); -} - -void Palette::advanceGradient() -{ - const int time = get_elapsed_time(mRainbowTime); - if (time > 5) - { - // For slower systems, advance can be greater than one (advance > 1 - // skips advance-1 steps). Should make gradient look the same - // independent of the framerate. - const int advance = time / 5; - - for (size_t i = 0, sz = mGradVector.size(); i < sz; i++) - { - ColorElem *const elem A_NONNULLPOINTER = mGradVector[i]; - if (elem == nullptr) - continue; - - int delay = elem->delay; - const GradientTypeT &grad = elem->grad; - - if (grad == GradientType::PULSE) - delay = delay / 20; - - const int numOfColors = (elem->grad == GradientType::SPECTRUM ? 6 : - grad == GradientType::PULSE ? 127 : - RAINBOW_COLOR_COUNT); - - elem->gradientIndex = (elem->gradientIndex + advance) - % (delay * numOfColors); - - const int gradIndex = elem->gradientIndex; - const int pos = delay != 0 ? (gradIndex % delay) : gradIndex; - int colIndex; - if (delay != 0) - colIndex = gradIndex / delay; - else - colIndex = gradIndex; - - Color &color = elem->color; - int colVal; - - if (grad == GradientType::PULSE) - { - colVal = CAST_S32(255.0 * - sin(M_PI * colIndex / numOfColors)); - - const Color &col = elem->testColor; - - color.r = ((colVal * col.r) / 255) % (col.r + 1); - color.g = ((colVal * col.g) / 255) % (col.g + 1); - color.b = ((colVal * col.b) / 255) % (col.b + 1); - } - else if (grad == GradientType::SPECTRUM) - { - if ((colIndex % 2) != 0) - { // falling curve - if (delay != 0) - { - colVal = CAST_S32(255.0 * - (cos(M_PI * pos / delay) + 1) / 2); - } - else - { - colVal = CAST_S32(255.0 * - (cos(M_PI * pos) + 1) / 2); - } - } - else - { // ascending curve - if (delay != 0) - { - colVal = CAST_S32(255.0 * (cos(M_PI * - (delay - pos) / delay) + 1) / 2); - } - else - { - colVal = CAST_S32(255.0 * (cos(M_PI * - (delay - pos)) + 1) / 2); - } - } - - color.r = (colIndex == 0 || colIndex == 5) ? 255 : - (colIndex == 1 || colIndex == 4) ? colVal : 0; - color.g = (colIndex == 1 || colIndex == 2) ? 255 : - (colIndex == 0 || colIndex == 3) ? colVal : 0; - color.b = (colIndex == 3 || colIndex == 4) ? 255 : - (colIndex == 2 || colIndex == 5) ? colVal : 0; - } - else if (elem->grad == GradientType::RAINBOW) - { - const Color &startCol = RAINBOW_COLORS[colIndex]; - const Color &destCol - = RAINBOW_COLORS[(colIndex + 1) % numOfColors]; - double startColVal; - double destColVal; - - if (delay != 0) - startColVal = (cos(M_PI * pos / delay) + 1) / 2; - else - startColVal = 0; - - destColVal = 1 - startColVal; - - color.r = CAST_S32(startColVal - * startCol.r + destColVal * destCol.r); - - color.g = CAST_S32(startColVal - * startCol.g + destColVal * destCol.g); - - color.b = CAST_S32(startColVal - * startCol.b + destColVal * destCol.b); - } - } - - mRainbowTime = tick_time; - } -} diff --git a/src/gui/palette.h b/src/gui/palette.h deleted file mode 100644 index 048dacf54..000000000 --- a/src/gui/palette.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008 Douglas Boffey - * Copyright (C) 2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_PALETTE_H -#define GUI_PALETTE_H - -#include "enums/gui/gradienttype.h" - -#include "gui/color.h" - -#include "utils/vector.h" - -#include -#include -#include - -// Default Gradient Delay -#define GRADIENT_DELAY 40 - -/** - * Class controlling the game's color palette. - */ -class Palette notfinal -{ - public: - /** Black Color Constant */ - static const Color BLACK; - - A_DELETE_COPY(Palette) - - /** - * Returns the color associated with a character, if it exists. Returns - * Palette::BLACK if the character is not found. - * - * @param c character requested - * @param valid indicate whether character is known - * - * @return the requested color or Palette::BLACK - */ - const Color &getCharColor(const signed char c, - bool &valid) const A_WARN_UNUSED; - - /** - * Get the character used by the specified color. - * - * @param type the color type of the color - * - * @return the color char of the color with the given index - */ - inline char getColorChar(const int type) const A_WARN_UNUSED - { return mColors[CAST_SIZE(type)].ch; } - - /** - * Updates all colors, that are non-static. - */ - static void advanceGradients(); - - protected: - /** Colors used for the rainbow gradient */ - static const Color RAINBOW_COLORS[7]; - static const int RAINBOW_COLOR_COUNT; - - /** Time tick, that gradient-type colors were updated the last time. */ - int mRainbowTime; - - typedef std::set Palettes; - static Palettes mInstances; - - /** - * Constructor - */ - explicit Palette(const int size); - - /** - * Destructor - */ - virtual ~Palette(); - - void advanceGradient(); - - struct ColorElem final - { - ColorElem() : - type(0), - color(0), - testColor(0), - committedColor(0), - text(), - ch(0), - grad(GradientType::STATIC), - committedGrad(GradientType::STATIC), - gradientIndex(0), - delay(0), - committedDelay(0) - { - } - - A_DEFAULT_COPY(ColorElem) - - int type; - Color color; - Color testColor; - Color committedColor; - std::string text; - signed char ch; - GradientTypeT grad; - GradientTypeT committedGrad; - int gradientIndex; - int delay; - int committedDelay; - - void set(const int type0, - const Color &color0, - const GradientTypeT grad0, - const int delay0) - { - type = type0; - color = color0; - testColor = color0; - grad = grad0; - delay = delay0; - gradientIndex = rand(); - } - - inline unsigned int getRGB() const noexcept2 A_WARN_UNUSED - { - return (committedColor.r << 16) | (committedColor.g << 8) | - committedColor.b; - } - }; - typedef STD_VECTOR Colors; - typedef std::map CharColors; - Colors mColors; - CharColors mCharColors; - STD_VECTOR mGradVector; -}; - -#endif // GUI_PALETTE_H diff --git a/src/gui/popupmanager.cpp b/src/gui/popupmanager.cpp deleted file mode 100644 index 134aaac7b..000000000 --- a/src/gui/popupmanager.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#include "gui/popupmanager.h" - -#include "sdlshared.h" - -#ifndef DYECMD -#include "gui/popups/beingpopup.h" -#include "gui/popups/itempopup.h" -#include "gui/popups/popupmenu.h" -#endif // DYECMD -#include "gui/popups/textpopup.h" - -#include "debug.h" - -PopupManager *popupManager = nullptr; - -PopupManager::PopupManager() -{ -} - -PopupManager::~PopupManager() -{ -} - -void PopupManager::closePopupMenu() -{ -#ifndef DYECMD - if (popupMenu != nullptr) - popupMenu->handleLink("cancel", nullptr); -#endif // DYECMD -} - -void PopupManager::hideBeingPopup() -{ -#ifndef DYECMD - if (beingPopup != nullptr) - beingPopup->setVisible(Visible_false); -#endif // DYECMD -} - -void PopupManager::hideTextPopup() -{ - if (textPopup != nullptr) - textPopup->setVisible(Visible_false); -} - -void PopupManager::hidePopupMenu() -{ -#ifndef DYECMD - if (popupMenu != nullptr) - popupMenu->setVisible(Visible_false); -#endif // DYECMD -} - -void PopupManager::hideItemPopup() -{ -#ifndef DYECMD - if (itemPopup != nullptr) - itemPopup->hide(); -#endif // DYECMD -} - -bool PopupManager::isPopupMenuVisible() -{ -#ifndef DYECMD - return popupMenu != nullptr ? popupMenu->isPopupVisible() : false; -#else - return false; -#endif // DYECMD -} - -void PopupManager::clearPopup() -{ -#ifndef DYECMD - if (popupMenu != nullptr) - popupMenu->clear(); -#endif // DYECMD -} - -bool PopupManager::isTextPopupVisible() -{ - return textPopup != nullptr ? textPopup->isPopupVisible() : false; -} - -bool PopupManager::isBeingPopupVisible() -{ -#ifndef DYECMD - return beingPopup != nullptr ? beingPopup->isPopupVisible() : false; -#else // DYECMD - return false; -#endif // DYECMD -} diff --git a/src/gui/popupmanager.h b/src/gui/popupmanager.h deleted file mode 100644 index a3dd08a54..000000000 --- a/src/gui/popupmanager.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_POPUPMANAGER_H -#define GUI_POPUPMANAGER_H - -#include "localconsts.h" - -class PopupManager final -{ - public: - /** - * Constructor. - */ - PopupManager() A_CONST; - - A_DELETE_COPY(PopupManager) - - /** - * Destructor. - */ - ~PopupManager() A_CONST; - - static bool isBeingPopupVisible() A_WARN_UNUSED; - - static bool isTextPopupVisible() A_WARN_UNUSED; - - /** - * Closes the popup menu. Needed for when the player dies or switching - * maps. - */ - static void closePopupMenu(); - - /** - * Hides the BeingPopup. - */ - static void hideBeingPopup(); - - static void hideTextPopup(); - - static void hideItemPopup(); - - static bool isPopupMenuVisible() A_WARN_UNUSED; - - static void clearPopup(); - - static void hidePopupMenu(); -}; - -extern PopupManager *popupManager; - -#endif // GUI_POPUPMANAGER_H diff --git a/src/gui/popups/beingpopup.cpp b/src/gui/popups/beingpopup.cpp deleted file mode 100644 index 299683f6d..000000000 --- a/src/gui/popups/beingpopup.cpp +++ /dev/null @@ -1,337 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#include "gui/popups/beingpopup.h" - -#include "being/being.h" -#include "being/homunculusinfo.h" -#include "being/petinfo.h" -#include "being/playerinfo.h" -#include "being/playerrelations.h" - -#include "gui/gui.h" - -#include "gui/fonts/font.h" - -#include "gui/widgets/label.h" - -#include "resources/chatobject.h" - -#include "resources/db/groupdb.h" - -#include "utils/gettext.h" -#include "utils/foreach.h" -#include "utils/stringutils.h" - -#include "debug.h" - -BeingPopup *beingPopup = nullptr; - -BeingPopup::BeingPopup() : - Popup("BeingPopup", "beingpopup.xml"), - mBeingName(new Label(this, "A")), - mLabels() -{ - // Being Name - mBeingName->setFont(boldFont); - mBeingName->setPosition(0, 0); - - const int fontHeight = mBeingName->getHeight(); - setMinHeight(fontHeight); - addLabels(fontHeight); -} - -BeingPopup::~BeingPopup() -{ -} - -void BeingPopup::postInit() -{ - Popup::postInit(); - add(mBeingName); - FOR_EACH (STD_VECTOR::iterator, it, mLabels) - { - add(*it); - } -} - -void BeingPopup::addLabels(const int fontHeight) -{ - for (int f = 0; f < 11; f ++) - { - Label *const label = new Label(this, "A"); - label->setPosition(0, fontHeight * (f + 1)); - label->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP), - getThemeColor(ThemeColorId::POPUP_OUTLINE)); - mLabels.push_back(label); - } -} - -void BeingPopup::show(const int x, const int y, Being *const b) -{ - if (b == nullptr) - { - setVisible(Visible_false); - return; - } - - int num = 0; - Label *ptr = nullptr; - b->updateComment(); - - if (b->getType() == ActorType::Npc && b->getComment().empty()) - { - setVisible(Visible_false); - return; - } - - mBeingName->setCaption(b->getName() + b->getGenderSignWithSpace()); - if (gui != nullptr) - { - if (playerRelations.isGoodName(b)) - mBeingName->setFont(boldFont); - else - mBeingName->setFont(gui->getSecureFont()); - } - if (b->isAdvanced()) - { - mBeingName->setForegroundColorAll(getThemeColor( - ThemeColorId::PLAYER_ADVANCED), getThemeColor( - ThemeColorId::PLAYER_ADVANCED_OUTLINE)); - } - else - { - mBeingName->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP), - getThemeColor(ThemeColorId::POPUP_OUTLINE)); - } - - mBeingName->adjustSize(); - FOR_EACH (STD_VECTOR::iterator, it, mLabels) - { - (*it)->setCaption(std::string()); - } - - const ActorTypeT type = b->getType(); - if (type == ActorType::Pet) - { - const PetInfo *const info = PlayerInfo::getPet(); - if ((info != nullptr) && info->id == b->getId()) - { - ptr = mLabels[num]; - // TRANSLATORS: being popup label - ptr->setCaption(strprintf(_("Hungry: %d"), - info->hungry)); - ptr->adjustSize(); - num ++; - ptr = mLabels[num]; - // TRANSLATORS: being popup label - ptr->setCaption(strprintf(_("Intimacy: %d"), - info->intimacy)); - ptr->adjustSize(); - num ++; - } - } - else if (type == ActorType::Homunculus) - { - const HomunculusInfo *const info = PlayerInfo::getHomunculus(); - if ((info != nullptr) && info->id == b->getId()) - { - ptr = mLabels[num]; - // TRANSLATORS: being popup label - ptr->setCaption(strprintf(_("Hungry: %d"), - info->hungry)); - ptr->adjustSize(); - num ++; - ptr = mLabels[num]; - // TRANSLATORS: being popup label - ptr->setCaption(strprintf(_("Intimacy: %d"), - info->intimacy)); - ptr->adjustSize(); - num ++; - } - } - else - { - const int groupId = b->getGroupId(); - const std::string &groupName = GroupDb::getLongName(groupId); - if (!groupName.empty()) - { - ptr = mLabels[num]; - // TRANSLATORS: being popup label - ptr->setCaption(strprintf(_("Group: %s (%d)"), - groupName.c_str(), - groupId)); - ptr->adjustSize(); - num ++; - } - - if (!(b->getPartyName().empty())) - { - ptr = mLabels[num]; - // TRANSLATORS: being popup label - ptr->setCaption(strprintf(_("Party: %s"), - b->getPartyName().c_str())); - ptr->adjustSize(); - num ++; - } - - if (!(b->getGuildName().empty())) - { - ptr = mLabels[num]; - // TRANSLATORS: being popup label - ptr->setCaption(strprintf(_("Guild: %s"), - b->getGuildName().c_str())); - ptr->adjustSize(); - num ++; - } - - if (b->getPvpRank() > 0) - { - ptr = mLabels[num]; - // TRANSLATORS: being popup label - ptr->setCaption(strprintf(_("Pvp rank: %u"), - b->getPvpRank())); - ptr->adjustSize(); - num ++; - } - - if (!b->getBuyBoard().empty()) - { - ptr = mLabels[num]; - // TRANSLATORS: being popup label - ptr->setCaption(strprintf(_("Buy shop: %s"), - b->getBuyBoard().c_str())); - ptr->adjustSize(); - num ++; - } - - if (!b->getSellBoard().empty()) - { - ptr = mLabels[num]; - // TRANSLATORS: being popup label - ptr->setCaption(strprintf(_("Sell shop: %s"), - b->getSellBoard().c_str())); - ptr->adjustSize(); - num ++; - } - - if (!b->getComment().empty()) - { - ptr = mLabels[num]; - // TRANSLATORS: being popup label - ptr->setCaption(strprintf(_("Comment: %s"), - b->getComment().c_str())); - ptr->adjustSize(); - num ++; - } - - const std::string effects = b->getStatusEffectsString(); - if (!effects.empty()) - { - ptr = mLabels[num]; - // TRANSLATORS: being popup label - ptr->setCaption(strprintf(_("Effects: %s"), - effects.c_str())); - ptr->adjustSize(); - num ++; - } - - const ChatObject *const chat = b->getChat(); - if (chat != nullptr) - { - ptr = mLabels[num]; - // TRANSLATORS: being popup label - ptr->setCaption(strprintf(_("Chat room: %s"), - chat->title.c_str())); - ptr->adjustSize(); - num ++; - } - } - - const int level = b->getLevel(); - if (level > 1) - { - ptr = mLabels[num]; - // TRANSLATORS: being popup label - ptr->setCaption(strprintf(_("Level: %d"), - level)); - ptr->adjustSize(); - num ++; - } - - const int maxHp = b->getMaxHP(); - if (maxHp > 0) - { - int hp = b->getHP(); - if (hp == 0) - hp = maxHp - b->getDamageTaken(); - if (hp > 0) - { - ptr = mLabels[num]; - // TRANSLATORS: being popup label - ptr->setCaption(strprintf(_("Hp: %d/%d"), - hp, - maxHp)); - ptr->adjustSize(); - num ++; - } - } - - ptr = mLabels[num]; - // TRANSLATORS: being popup label - ptr->setCaption(strprintf(_("Particles: %u"), - CAST_U32(b->getParticlesCount()))); - ptr->adjustSize(); - num ++; - - const size_t sz = mLabels.size(); - for (size_t f = num; f < sz; f ++) - { - mLabels[f]->setCaption(std::string()); - } - - int minWidth = mBeingName->getWidth(); - const int height1 = getFont()->getHeight(); - int height = height1; - FOR_EACH (STD_VECTOR::iterator, it, mLabels) - { - const Label *const label = *it; - if (label != nullptr) - { - if (label->getWidth() > minWidth) - minWidth = label->getWidth(); - if (!label->getCaption().empty()) - height += height1; - } - } - - setContentSize(minWidth, height); - position(x, y); -} - -#ifdef USE_PROFILER -void BeingPopup::logic() -{ - BLOCK_START("BeingPopup::logic") - logicChildren(); - BLOCK_END("BeingPopup::logic") -} -#endif // USE_PROFILER diff --git a/src/gui/popups/beingpopup.h b/src/gui/popups/beingpopup.h deleted file mode 100644 index a14f44568..000000000 --- a/src/gui/popups/beingpopup.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_POPUPS_BEINGPOPUP_H -#define GUI_POPUPS_BEINGPOPUP_H - -#include "gui/widgets/popup.h" - -class Being; -class Label; - -/** - * A popup that displays information about a being. - */ -class BeingPopup final : public Popup -{ - public: - /** - * Constructor. Initializes the being popup. - */ - BeingPopup(); - - A_DELETE_COPY(BeingPopup) - - /** - * Destructor. Cleans up the being popup on deletion. - */ - ~BeingPopup(); - - /** - * Sets the info to be displayed given a particular player. - */ - void show(const int x, const int y, Being *const b); - - void postInit() override final; - -#ifdef USE_PROFILER - void logic(); -#endif // USE_PROFILER - - private: - void addLabels(const int fontHeight); - - Label *mBeingName A_NONNULLPOINTER; - STD_VECTOR mLabels; -}; - -extern BeingPopup *beingPopup; - -#endif // GUI_POPUPS_BEINGPOPUP_H diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp deleted file mode 100644 index 28de3b641..000000000 --- a/src/gui/popups/itempopup.cpp +++ /dev/null @@ -1,465 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008 The Legend of Mazzeroth Development Team - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#include "gui/popups/itempopup.h" - -#include "actormanager.h" -#include "configuration.h" - -#include "gui/gui.h" - -#include "gui/fonts/font.h" - -#include "gui/widgets/icon.h" -#include "gui/widgets/label.h" -#include "gui/widgets/textbox.h" - -#include "net/beinghandler.h" -#ifdef TMWA_SUPPORT -#include "net/net.h" -#endif // TMWA_SUPPORT - -#include "utils/foreach.h" -#include "utils/gettext.h" -#include "utils/stdmove.h" - -#include "utils/translation/podict.h" - -#include "resources/iteminfo.h" - -#include "resources/db/itemoptiondb.h" -#include "resources/db/unitsdb.h" - -#include "resources/image/image.h" - -#include "resources/item/item.h" -#include "resources/item/itemfieldtype.h" -#include "resources/item/itemoptionslist.h" - -#include "resources/loaders/imageloader.h" - -#include "debug.h" - -ItemPopup *itemPopup = nullptr; - -ItemPopup::ItemPopup() : - Popup("ItemPopup", "itempopup.xml"), - mItemName(new Label(this)), - mItemDesc(new TextBox(this)), - mItemEffect(new TextBox(this)), - mItemWeight(new TextBox(this)), - mItemCards(new TextBox(this)), - mItemOptions(new TextBox(this)), - mItemType(ItemDbType::UNUSABLE), - mIcon(new Icon(this, nullptr)), - mLastName(), - mCardsStr(), - mItemOptionsStr(), - mLastId(0), - mLastColor(ItemColor_one) -{ - // Item name - mItemName->setFont(boldFont); - mItemName->setPosition(0, 0); - - const int fontHeight = getFont()->getHeight(); - - // Item description - mItemDesc->setEditable(false); - mItemDesc->setPosition(0, fontHeight); - mItemDesc->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP), - getThemeColor(ThemeColorId::POPUP_OUTLINE)); - - // Item effect - mItemEffect->setEditable(false); - mItemEffect->setPosition(0, 2 * fontHeight); - mItemEffect->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP), - getThemeColor(ThemeColorId::POPUP_OUTLINE)); - - // Item weight - mItemWeight->setEditable(false); - mItemWeight->setPosition(0, 3 * fontHeight); - mItemWeight->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP), - getThemeColor(ThemeColorId::POPUP_OUTLINE)); - - // Item cards - mItemCards->setEditable(false); - mItemCards->setPosition(0, 4 * fontHeight); - mItemCards->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP), - getThemeColor(ThemeColorId::POPUP_OUTLINE)); - - // Item options - mItemOptions->setEditable(false); - mItemOptions->setPosition(0, 5 * fontHeight); - mItemOptions->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP), - getThemeColor(ThemeColorId::POPUP_OUTLINE)); -} - -void ItemPopup::postInit() -{ - Popup::postInit(); - add(mItemName); - add(mItemDesc); - add(mItemEffect); - add(mItemWeight); - add(mItemCards); - add(mItemOptions); - add(mIcon); - - addMouseListener(this); -} - -ItemPopup::~ItemPopup() -{ - if (mIcon != nullptr) - { - Image *const image = mIcon->getImage(); - if (image != nullptr) - image->decRef(); - } -} - -void ItemPopup::setItem(const Item *const item, - const bool showImage) -{ - if (item == nullptr) - return; - - const ItemInfo &ii = item->getInfo(); - setItem(ii, - item->getColor(), - showImage, - item->getId(), - item->getCards(), - item->getOptions()); - if (item->getRefine() > 0) - { - mLastName = ii.getName(); - mLastColor = item->getColor(); - mLastId = item->getId(); -#ifdef TMWA_SUPPORT - if (Net::getNetworkType() == ServerType::TMWATHENA) - { - mItemName->setCaption(strprintf("%s (+%u), %d", - ii.getName().c_str(), - CAST_U32(item->getRefine()), - ii.getId())); - } - else -#endif // TMWA_SUPPORT - { - mItemName->setCaption(strprintf("%s (+%u), %d", - ii.getName(item->getColor()).c_str(), - CAST_U32(item->getRefine()), - ii.getId())); - } - mItemName->adjustSize(); - const unsigned minWidth = mItemName->getWidth() + 8; - if (CAST_U32(getWidth()) < minWidth) - setWidth(minWidth); - } -} - -void ItemPopup::setItem(const ItemInfo &item, - const ItemColor color, - const bool showImage, - int id, - const int *const cards, - const ItemOptionsList *const options) -{ - if (mIcon == nullptr) - return; - - std::string cardsStr; - std::string optionsStr; - - if (item.getName() == mLastName && - color == mLastColor && - id == mLastId) - { - cardsStr = getCardsString(cards); - optionsStr = getOptionsString(options); - if (mItemOptionsStr == optionsStr && - mCardsStr == cardsStr) - { - return; - } - } - else - { - cardsStr = getCardsString(cards); - optionsStr = getOptionsString(options); - } - mItemOptionsStr = STD_MOVE(optionsStr); - mCardsStr = STD_MOVE(cardsStr); - - if (id == -1) - id = item.getId(); - - int space = 0; - - Image *const oldImage = mIcon->getImage(); - if (oldImage != nullptr) - oldImage->decRef(); - - if (showImage) - { - Image *const image = Loader::getImage(combineDye2( - pathJoin(paths.getStringValue("itemIcons"), - item.getDisplay().image), - item.getDyeIconColorsString(color))); - - mIcon->setImage(image); - if (image != nullptr) - { - mIcon->setPosition(0, 0); - space = mIcon->getWidth(); - } - } - else - { - mIcon->setImage(nullptr); - } - - mItemType = item.getType(); - - mLastName = item.getName(); - mLastColor = color; - mLastId = id; - -#ifdef TMWA_SUPPORT - if (Net::getNetworkType() == ServerType::TMWATHENA) - { - mItemName->setCaption(strprintf("%s, %d", - item.getName().c_str(), id)); - mItemDesc->setTextWrapped(item.getDescription(), 196); - } - else -#endif // TMWA_SUPPORT - { - mItemName->setCaption(strprintf("%s, %d", - item.getName(color).c_str(), id)); - mItemDesc->setTextWrapped(item.getDescription(color), 196); - } - - mItemName->adjustSize(); - setLabelColor(mItemName, mItemType); - mItemName->setPosition(space, 0); - - mItemEffect->setTextWrapped(item.getEffect(), 196); - // TRANSLATORS: popup label - mItemWeight->setTextWrapped(strprintf(_("Weight: %s"), - UnitsDb::formatWeight(item.getWeight()).c_str()), 196); - mItemCards->setTextWrapped(mCardsStr, 196); - mItemOptions->setTextWrapped(mItemOptionsStr, 196); - - int minWidth = mItemName->getWidth() + space; - - if (mItemName->getWidth() + space > minWidth) - minWidth = mItemName->getWidth() + space; - if (mItemDesc->getMinWidth() > minWidth) - minWidth = mItemDesc->getMinWidth(); - if (mItemEffect->getMinWidth() > minWidth) - minWidth = mItemEffect->getMinWidth(); - if (mItemWeight->getMinWidth() > minWidth) - minWidth = mItemWeight->getMinWidth(); - if (mItemCards->getMinWidth() > minWidth) - minWidth = mItemCards->getMinWidth(); - if (mItemOptions->getMinWidth() > minWidth) - minWidth = mItemOptions->getMinWidth(); - - const int numRowsDesc = mItemDesc->getNumberOfRows(); - const int numRowsEffect = mItemEffect->getNumberOfRows(); - const int numRowsWeight = mItemWeight->getNumberOfRows(); - const int numRowsCards = mItemCards->getNumberOfRows(); - const int numRowsOptions = mItemOptions->getNumberOfRows(); - const int height = getFont()->getHeight(); - - if (item.getEffect().empty()) - { - setContentSize(minWidth, - (numRowsDesc + 2 + numRowsWeight + numRowsCards + numRowsOptions) * - height); - mItemWeight->setPosition(0, (numRowsDesc + 2) * height); - mItemCards->setPosition(0, (numRowsDesc + numRowsWeight + 2) * height); - mItemOptions->setPosition(0, - (numRowsDesc + numRowsWeight + numRowsCards + 2) * height); - } - else - { - setContentSize(minWidth, (numRowsDesc + numRowsEffect + 2 - + numRowsWeight + numRowsCards + numRowsOptions) * height); - mItemEffect->setPosition(0, (numRowsDesc + 2) * height); - mItemWeight->setPosition(0, (numRowsDesc + numRowsEffect + 2) - * height); - mItemCards->setPosition(0, (numRowsDesc + numRowsEffect - + numRowsWeight + 2) * height); - mItemOptions->setPosition(0, (numRowsDesc + numRowsEffect - + numRowsWeight + numRowsCards + 2) * height); - } - - mItemDesc->setPosition(0, 2 * height); -} - -std::string ItemPopup::getCardsString(const int *const cards) -{ - if (cards == nullptr) - return std::string(); - - std::string label; - - switch (cards[0]) - { - case 0xfe: // named item - { - const int32_t charId = cards[2] + 65536 * cards[3]; - std::string name = actorManager->findCharById(charId); - if (name.empty()) - { - name = toString(charId); - beingHandler->requestNameByCharId(charId); - mLastId = 0; // allow recreate popup with same data - } - // TRANSLATORS: named item description - label.append(strprintf(_("Item named: %s"), name.c_str())); - return label; - } - case 0x00FFU: // forged item - { - return label; - } - case 0xFF00U: - { - return label; - } - default: - { - for (int f = 0; f < maxCards; f ++) - { - const int id = cards[f]; - if (id != 0) - { - if (!label.empty()) - label.append(" / "); - const ItemInfo &info = ItemDB::get(id); - label.append(info.getName()); - } - } - if (label.empty()) - return label; - // TRANSLATORS: popup label - return _("Cards: ") + label; - } - } -} - -std::string ItemPopup::getOptionsString(const ItemOptionsList *const options) -{ - if (options == nullptr || translator == nullptr) - return std::string(); - const size_t sz = options->size(); - std::string effect; - for (size_t f = 0; f < sz; f ++) - { - const ItemOption &option = options->get(f); - if (option.index == 0) - continue; - const STD_VECTOR &fields = ItemOptionDb::getFields( - option.index); - if (fields.empty()) - continue; - const std::string valueStr = toString(option.value); - FOR_EACH (STD_VECTOR::const_iterator, it, fields) - { - const ItemFieldType *const field = *it; - std::string value = valueStr; - if (!effect.empty()) - effect.append(" / "); - if (field->sign && value[0] != '-') - value = std::string("+").append(value); - const std::string format = translator->getStr(field->description); - effect.append(strprintf(format.c_str(), - value.c_str())); - } - } - if (effect.empty()) - return effect; - // TRANSLATORS: popup label - return _("Options: ") + effect; -} - -#define caseSetColor(name1, name2) \ - case name1: \ - { \ - return label->setForegroundColorAll(getThemeColor(name2), \ - getThemeColor(name2##_OUTLINE)); \ - } -void ItemPopup::setLabelColor(Label *label, - const ItemDbTypeT type) const -{ - switch (type) - { - caseSetColor(ItemDbType::UNUSABLE, ThemeColorId::GENERIC) - caseSetColor(ItemDbType::USABLE, ThemeColorId::USABLE) - caseSetColor(ItemDbType::EQUIPMENT_ONE_HAND_WEAPON, - ThemeColorId::ONEHAND) - caseSetColor(ItemDbType::EQUIPMENT_TWO_HANDS_WEAPON, - ThemeColorId::TWOHAND) - caseSetColor(ItemDbType::EQUIPMENT_TORSO, ThemeColorId::TORSO) - caseSetColor(ItemDbType::EQUIPMENT_ARMS, ThemeColorId::ARMS) - caseSetColor(ItemDbType::EQUIPMENT_HEAD, ThemeColorId::HEAD) - caseSetColor(ItemDbType::EQUIPMENT_LEGS, ThemeColorId::LEGS) - caseSetColor(ItemDbType::EQUIPMENT_SHIELD, ThemeColorId::SHIELD) - caseSetColor(ItemDbType::EQUIPMENT_RING, ThemeColorId::RING) - caseSetColor(ItemDbType::EQUIPMENT_NECKLACE, ThemeColorId::NECKLACE) - caseSetColor(ItemDbType::EQUIPMENT_FEET, ThemeColorId::FEET) - caseSetColor(ItemDbType::EQUIPMENT_AMMO, ThemeColorId::AMMO) - caseSetColor(ItemDbType::EQUIPMENT_CHARM, ThemeColorId::CHARM) - caseSetColor(ItemDbType::SPRITE_RACE, ThemeColorId::UNKNOWN_ITEM) - caseSetColor(ItemDbType::SPRITE_HAIR, ThemeColorId::UNKNOWN_ITEM) - caseSetColor(ItemDbType::CARD, ThemeColorId::CARD) - default: - { - return label->setForegroundColorAll(getThemeColor( - ThemeColorId::UNKNOWN_ITEM), getThemeColor( - ThemeColorId::UNKNOWN_ITEM_OUTLINE)); - } - } -} -#undef caseSetColor - -void ItemPopup::mouseMoved(MouseEvent &event) -{ - Popup::mouseMoved(event); - - // When the mouse moved on top of the popup, hide it - setVisible(Visible_false); - resetPopup(); -} - -void ItemPopup::resetPopup() -{ - mLastName.clear(); - mLastColor = ItemColor_one; - mLastId = 0; -} diff --git a/src/gui/popups/itempopup.h b/src/gui/popups/itempopup.h deleted file mode 100644 index fff3b817d..000000000 --- a/src/gui/popups/itempopup.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008 The Legend of Mazzeroth Development Team - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#ifndef GUI_POPUPS_ITEMPOPUP_H -#define GUI_POPUPS_ITEMPOPUP_H - -#include "enums/resources/item/itemdbtype.h" - -#include "enums/simpletypes/itemcolor.h" - -#include "gui/widgets/popup.h" - -class Icon; -class Item; -class ItemInfo; -class Label; -class TextBox; - -struct ItemOptionsList; - -/** - * A popup that displays information about an item. - */ -class ItemPopup final : public Popup -{ - public: - /** - * Constructor. Initializes the item popup. - */ - ItemPopup(); - - A_DELETE_COPY(ItemPopup) - - /** - * Destructor. Cleans up the item popup on deletion. - */ - ~ItemPopup(); - - void postInit() override final; - - /** - * Sets the info to be displayed given a particular item. - */ - void setItem(const ItemInfo &item, - const ItemColor color, - const bool showImage, - int id, - const int *const cards, - const ItemOptionsList *const options); - - void setItem(const Item *const item, - const bool showImage); - - void mouseMoved(MouseEvent &event) override final; - - void resetPopup(); - - private: - std::string getCardsString(const int *const cards); - - std::string getOptionsString(const ItemOptionsList *const options); - - Label *mItemName A_NONNULLPOINTER; - TextBox *mItemDesc A_NONNULLPOINTER; - TextBox *mItemEffect A_NONNULLPOINTER; - TextBox *mItemWeight A_NONNULLPOINTER; - TextBox *mItemCards A_NONNULLPOINTER; - TextBox *mItemOptions A_NONNULLPOINTER; - ItemDbTypeT mItemType; - Icon *mIcon A_NONNULLPOINTER; - std::string mLastName; - std::string mCardsStr; - std::string mItemOptionsStr; - int mLastId; - ItemColor mLastColor; - - void setLabelColor(Label *label, - const ItemDbTypeT type) const A_NONNULL(2); -}; - -extern ItemPopup *itemPopup; - -#endif // GUI_POPUPS_ITEMPOPUP_H diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp deleted file mode 100644 index 752caff72..000000000 --- a/src/gui/popups/popupmenu.cpp +++ /dev/null @@ -1,3613 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 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 . - */ - -#include "gui/popups/popupmenu.h" - -#include "actormanager.h" -#include "configuration.h" -#include "party.h" -#include "settings.h" - -#include "being/flooritem.h" -#include "being/localplayer.h" -#include "being/playerinfo.h" -#include "being/playerrelation.h" -#include "being/playerrelations.h" - -#include "const/spells.h" - -#include "enums/resources/map/mapitemtype.h" - -#include "input/inputmanager.h" - -#include "gui/buttontext.h" -#include "gui/gui.h" -#include "gui/popupmanager.h" -#include "gui/viewport.h" -#include "gui/windowmenu.h" - -#include "gui/windows/chatwindow.h" -#include "gui/windows/inventorywindow.h" -#include "gui/windows/minimap.h" -#include "gui/windows/ministatuswindow.h" -#include "gui/windows/npcdialog.h" -#include "gui/windows/outfitwindow.h" -#include "gui/windows/socialwindow.h" -#include "gui/windows/textcommandeditor.h" -#include "gui/windows/textdialog.h" -#include "gui/windows/tradewindow.h" - -#include "gui/widgets/button.h" -#include "gui/widgets/createwidget.h" -#include "gui/widgets/progressbar.h" -#include "gui/widgets/scrollarea.h" -#include "gui/widgets/staticbrowserbox.h" -#include "gui/widgets/textfield.h" - -#include "gui/widgets/tabs/chat/whispertab.h" - -#include "net/adminhandler.h" -#include "net/chathandler.h" -#include "net/guildhandler.h" -#include "net/npchandler.h" -#include "net/net.h" - -#ifdef TMWA_SUPPORT -#include "net/tmwa/guildmanager.h" -#endif // TMWA_SUPPORT - -#include "resources/chatobject.h" -#include "resources/groupinfo.h" -#include "resources/iteminfo.h" -#include "resources/itemmenuitem.h" - -#include "resources/db/groupdb.h" -#include "resources/db/npcdb.h" - -#include "resources/item/item.h" - -#include "resources/map/map.h" -#include "resources/map/mapitem.h" -#include "resources/map/speciallayer.h" - -#include "resources/skill/skillinfo.h" - -#include "utils/checkutils.h" -#include "utils/foreach.h" -#include "utils/gettext.h" - -#include "debug.h" - -std::string tradePartnerName; - -PopupMenu *popupMenu = nullptr; - -PopupMenu::PopupMenu() : - Popup("PopupMenu", "popupmenu.xml"), - mBrowserBox(new StaticBrowserBox(this, Opaque_true, - "popupbrowserbox.xml")), - mScrollArea(nullptr), - mBeingId(BeingId_zero), - mFloorItemId(BeingId_zero), - mItemId(0), - mItemIndex(-1), - mItemColor(ItemColor_one), - mMapItem(nullptr), - mTab(nullptr), - mSpell(nullptr), - mCallerWindow(nullptr), - mRenameListener(), - mPlayerListener(), - mDialog(nullptr), - mButton(nullptr), - mGroup(nullptr), - mName(), - mExtName(), - mTextField(nullptr), - mType(ActorType::Unknown), - mSubType(BeingTypeId_zero), - mX(0), - mY(0), - mAllowCleanMenu(true) -{ - mBrowserBox->setOpaque(Opaque_false); - mBrowserBox->setLinkHandler(this); - mRenameListener.setMapItem(nullptr); - mRenameListener.setDialog(nullptr); - mPlayerListener.setNick(""); - mPlayerListener.setDialog(nullptr); - mPlayerListener.setType(ActorType::Unknown); - mScrollArea = new ScrollArea(this, mBrowserBox, Opaque_false); - mScrollArea->setVerticalScrollPolicy(ScrollArea::SHOW_AUTO); - addMouseListener(this); -} - -void PopupMenu::postInit() -{ - Popup::postInit(); - add(mScrollArea); -} - -void PopupMenu::initPopup() -{ - if (localPlayer == nullptr) - return; - const int groupId = localPlayer->getGroupId(); - mGroup = GroupDb::getGroup(groupId); -} - -bool PopupMenu::isAllowCommand(const ServerCommandTypeT command) -{ - if (mGroup == nullptr) - return false; -#ifdef TMWA_SUPPORT - // allow any commands for legacy if group > 0 - if (Net::getNetworkType() == ServerType::TMWATHENA && - localPlayer != nullptr && - localPlayer->isGM()) - { - return true; - } -#endif - if (mGroup->mPermissions[CAST_SIZE(ServerPermissionType::all_commands)] == - Enable_true) - { - return true; - } - const ServerCommandEnable::Type enabled = - mGroup->mCommands[CAST_SIZE(command)]; - return (enabled & ServerCommandEnable::Self) != 0; -} - -bool PopupMenu::isAllowOtherCommand(const ServerCommandTypeT command) -{ - if (mGroup == nullptr || - localPlayer == nullptr) - return false; -#ifdef TMWA_SUPPORT - // allow any commands for legacy if group > 0 - if (Net::getNetworkType() == ServerType::TMWATHENA && - localPlayer->isGM()) - { - return true; - } -#endif - const ServerCommandEnable::Type enabled = - mGroup->mCommands[CAST_SIZE(command)]; - if (mName == localPlayer->getName()) - return (enabled & ServerCommandEnable::Self) != 0; - return (enabled & ServerCommandEnable::Other) != 0; -} - -void PopupMenu::showPopup(const int x, const int y, const Being *const being) -{ - if (being == nullptr || - localPlayer == nullptr || - actorManager == nullptr) - { - return; - } - - initPopup(); - mBeingId = being->getId(); - mName = being->getName(); - mExtName = being->getExtName(); - mType = being->getType(); - mSubType = being->getSubType(); - mBrowserBox->clearRows(); - mX = x; - mY = y; - - const std::string &name = mName; - if (being->getType() != ActorType::SkillUnit) - { - mBrowserBox->addRow(name + being->getGenderSignWithSpace()); - } - - switch (being->getType()) - { - case ActorType::Player: - { - // TRANSLATORS: popup menu item - // TRANSLATORS: trade with player - mBrowserBox->addRow("/trade 'NAME'", _("Trade")); - // TRANSLATORS: popup menu item - // TRANSLATORS: trade attack player - mBrowserBox->addRow("/attack 'NAME'", _("Attack")); - // TRANSLATORS: popup menu item - // TRANSLATORS: send whisper to player - mBrowserBox->addRow("/whispertext 'NAME'", _("Whisper")); - addMailCommands(); - addGmCommands(); - mBrowserBox->addSeparator("##3---"); - -#ifdef TMWA_SUPPORT - if (Net::getNetworkType() == ServerType::TMWATHENA) - { - // TRANSLATORS: popup menu item - // TRANSLATORS: heal player - mBrowserBox->addRow("/heal :'BEINGID'", _("Heal")); - mBrowserBox->addSeparator("##3---"); - } -#endif // TMWA_SUPPORT - - addPlayerRelation(name); - mBrowserBox->addSeparator("##3---"); - - addFollow(); - addPartyName(being->getPartyName()); - - const Guild *const guild1 = being->getGuild(); - const Guild *const guild2 = localPlayer->getGuild(); - if (guild2 != nullptr) - { - if (guild1 != nullptr) - { - if (guild1->getId() == guild2->getId()) - { - mBrowserBox->addRow("/kickguild 'NAME'", - // TRANSLATORS: popup menu item - // TRANSLATORS: kick player from guild - _("Kick from guild")); - if (guild2->getServerGuild()) - { - mBrowserBox->addRow(strprintf( - "@@guild-pos|%s >@@", - // TRANSLATORS: popup menu item - // TRANSLATORS: change player position in guild - _("Change pos in guild"))); - } - } - } - else if (guild2->getMember(mName) != nullptr) - { - mBrowserBox->addRow("/kickguild 'NAME'", - // TRANSLATORS: popup menu item - // TRANSLATORS: kick player from guild - _("Kick from guild")); - if (guild2->getServerGuild()) - { - mBrowserBox->addRow(strprintf( - "@@guild-pos|%s >@@", - // TRANSLATORS: popup menu item - // TRANSLATORS: change player position in guild - _("Change pos in guild"))); - } - } - else - { -#ifdef TMWA_SUPPORT - if (guild2->getServerGuild() || - (guildManager != nullptr && guildManager->havePower())) -#endif // TMWA_SUPPORT - { - mBrowserBox->addRow("/guild 'NAME'", - // TRANSLATORS: popup menu item - // TRANSLATORS: invite player to guild - _("Invite to guild")); - } - } - } - - // TRANSLATORS: popup menu item - // TRANSLATORS: set player invisible for self by id - mBrowserBox->addRow("/nuke 'NAME'", _("Nuke")); - // TRANSLATORS: popup menu item - // TRANSLATORS: move to player location - mBrowserBox->addRow("/navigateto 'NAME'", _("Move")); - addPlayerMisc(); - addBuySell(being); - addChat(being); - break; - } - - case ActorType::Npc: - if (!addBeingMenu()) - { - // TRANSLATORS: popup menu item - // TRANSLATORS: talk with npc - mBrowserBox->addRow("/talk 'NAME'", _("Talk")); -#ifdef TMWA_SUPPORT - if (Net::getNetworkType() != ServerType::TMWATHENA) -#endif - { - mBrowserBox->addRow("/whispertext NPC:'NAME'", - // TRANSLATORS: popup menu item - // TRANSLATORS: whisper to npc - _("Whisper")); - } - // TRANSLATORS: popup menu item - // TRANSLATORS: buy from npc - mBrowserBox->addRow("/buy 'NAME'", _("Buy")); - // TRANSLATORS: popup menu item - // TRANSLATORS: sell to npc - mBrowserBox->addRow("/sell 'NAME'", _("Sell")); - } - - addGmCommands(); - mBrowserBox->addSeparator("##3---"); - // TRANSLATORS: popup menu item - // TRANSLATORS: move to npc location - mBrowserBox->addRow("/navigateto 'NAME'", _("Move")); - // TRANSLATORS: popup menu item - // TRANSLATORS: add comment to npc - mBrowserBox->addRow("addcomment", _("Add comment")); - addChat(being); - break; - - case ActorType::Monster: - { - // Monsters can be attacked - // TRANSLATORS: popup menu item - // TRANSLATORS: attack monster - mBrowserBox->addRow("/attack :'BEINGID'", _("Attack")); - addCatchPetCommands(); - addGmCommands(); - mBrowserBox->addSeparator("##3---"); - - if (config.getBoolValue("enableAttackFilter")) - { - mBrowserBox->addSeparator("##3---"); - if (actorManager->isInAttackList(name) - || actorManager->isInIgnoreAttackList(name) - || actorManager->isInPriorityAttackList(name)) - { - mBrowserBox->addRow("/removeattack 'NAME'", - // TRANSLATORS: remove monster from attack list - // TRANSLATORS: popup menu item - _("Remove from attack list")); - } - else - { - mBrowserBox->addRow("/addpriorityattack 'NAME'", - // TRANSLATORS: popup menu item - // TRANSLATORS: add monster to priotiry attack list - _("Add to priority attack list")); - mBrowserBox->addRow("/addattack 'NAME'", - // TRANSLATORS: popup menu item - // TRANSLATORS: add monster to attack list - _("Add to attack list")); - mBrowserBox->addRow("/addignoreattack 'NAME'", - // TRANSLATORS: popup menu item - // TRANSLATORS: add monster to ignore list - _("Add to ignore list")); - } - } - break; - } - - case ActorType::Mercenary: - // TRANSLATORS: popup menu item - // TRANSLATORS: Mercenary move to master - mBrowserBox->addRow("/mercenarytomaster", _("Move to master")); - addGmCommands(); - mBrowserBox->addSeparator("##3---"); - // TRANSLATORS: popup menu item - // TRANSLATORS: fire mercenary - mBrowserBox->addRow("/firemercenary", _("Fire")); - mBrowserBox->addSeparator("##3---"); - break; - - case ActorType::Homunculus: - { - const HomunculusInfo *const info = PlayerInfo::getHomunculus(); - if (info != nullptr) - { - mBrowserBox->addRow("/homunculustomaster", - // TRANSLATORS: popup menu item - // TRANSLATORS: homunculus move to master - _("Move to master")); - // TRANSLATORS: popup menu item - // TRANSLATORS: feed homunculus - mBrowserBox->addRow("/homunculusfeed", _("Feed")); - mBrowserBox->addSeparator("##3---"); - // TRANSLATORS: popup menu item - // TRANSLATORS: pet rename item - mBrowserBox->addRow("/sethomunname", _("Rename")); - mBrowserBox->addSeparator("##3---"); - // TRANSLATORS: popup menu item - // TRANSLATORS: delete homunculus - mBrowserBox->addRow("/homunculusfire", _("Kill")); - mBrowserBox->addSeparator("##3---"); - } - addGmCommands(); - break; - } - case ActorType::Pet: - if (being->getOwner() == localPlayer) - { - // TRANSLATORS: popup menu item - // TRANSLATORS: feed pet - mBrowserBox->addRow("/petfeed", _("Feed")); - // TRANSLATORS: popup menu item - // TRANSLATORS: pet drop loot - mBrowserBox->addRow("/petdroploot", _("Drop loot")); - // TRANSLATORS: popup menu item - // TRANSLATORS: pet unequip item - mBrowserBox->addRow("/petunequip", _("Unequip")); - addGmCommands(); - mBrowserBox->addSeparator("##3---"); - // TRANSLATORS: popup menu item - // TRANSLATORS: pet rename item - mBrowserBox->addRow("/setpetname", _("Rename")); - mBrowserBox->addSeparator("##3---"); - const BeingInfo *const info = being->getInfo(); - std::string msg; - if (info != nullptr) - msg = info->getString(0); - if (!msg.empty()) - { - mBrowserBox->addRow("/petreturnegg", msg.c_str()); - } - else - { - mBrowserBox->addRow("/petreturnegg", - // TRANSLATORS: popup menu item - // TRANSLATORS: pet return to egg - _("Return to egg")); - } - mBrowserBox->addSeparator("##3---"); - } - else - { - addCatchPetCommands(); - } - break; - case ActorType::SkillUnit: - { - const BeingId id = being->getCreatorId(); - std::string creatorName; - Being *const creator = actorManager->findBeing(id); - if (creator != nullptr) - creatorName = creator->getName(); - else - creatorName = actorManager->getSeenPlayerById(id); - - if (creatorName.empty()) - creatorName = strprintf("?%d", CAST_S32(id)); - - mBrowserBox->addRow(strprintf("%s, %d (%s)", - name.c_str(), - CAST_S32(being->getSubType()), - creatorName.c_str())); - break; - } - case ActorType::Avatar: - case ActorType::Unknown: - case ActorType::FloorItem: - case ActorType::Portal: - case ActorType::Elemental: - default: - break; - } - // TRANSLATORS: popup menu item - // TRANSLATORS: add being name to chat - mBrowserBox->addRow("/addtext 'NAME'", _("Add name to chat")); - mBrowserBox->addSeparator("##3---"); - - // TRANSLATORS: popup menu item - // TRANSLATORS: close menu - mBrowserBox->addRow("cancel", _("Cancel")); - - showPopup(x, y); -} - -bool PopupMenu::addBeingMenu() -{ - Being *being = actorManager->findBeing(mBeingId); - if (being == nullptr) - return false; - - BeingInfo *const info = NPCDB::get(fromInt( - being->getSubType(), BeingTypeId)); - if (info == nullptr) - return false; - - const STD_VECTOR &menu = info->getMenu(); - FOR_EACH (STD_VECTOR::const_iterator, it, menu) - { - const BeingMenuItem &item = *it; - mBrowserBox->addRow("/" + item.command, item.name.c_str()); - } - return true; -} - -void PopupMenu::setMousePos() -{ - if (viewport != nullptr) - { - mX = viewport->mMouseX; - mY = viewport->mMouseY; - } - else - { - Gui::getMouseState(mX, mY); - } -} - -void PopupMenu::setMousePos2() -{ - if (mX == 0 && mY == 0) - { - if (viewport != nullptr) - { - mX = viewport->mMouseX; - mY = viewport->mMouseY; - } - else - { - Gui::getMouseState(mX, mY); - } - } -} - -void PopupMenu::showPopup(const int x, const int y, - const STD_VECTOR &beings) -{ - initPopup(); - mX = x; - mY = y; - mBrowserBox->clearRows(); - // TRANSLATORS: popup menu header - mBrowserBox->addRow(_("Players")); - FOR_EACH (STD_VECTOR::const_iterator, it, beings) - { - const Being *const being = dynamic_cast(*it); - const ActorSprite *const actor = *it; - if ((being != nullptr) && !being->getName().empty()) - { - mBrowserBox->addRow(strprintf("@@player_%u|%s >@@", - CAST_U32(being->getId()), (being->getName() - + being->getGenderSignWithSpace()).c_str())); - } - else if (actor->getType() == ActorType::FloorItem) - { - const FloorItem *const floorItem - = static_cast(actor); - mBrowserBox->addRow(strprintf("@@flooritem_%u|%s >@@", - CAST_U32(actor->getId()), - floorItem->getName().c_str())); - } - } - mBrowserBox->addSeparator("##3---"); - // TRANSLATORS: popup menu item - // TRANSLATORS: close menu - mBrowserBox->addRow("cancel", _("Cancel")); - showPopup(x, y); -} - -void PopupMenu::showPlayerPopup(const std::string &nick) -{ - if (nick.empty() || (localPlayer == nullptr)) - return; - - initPopup(); - setMousePos(); - mName = nick; - mExtName = nick; - mBeingId = BeingId_zero; - mType = ActorType::Player; - mSubType = BeingTypeId_zero; - mBrowserBox->clearRows(); - - const std::string &name = mName; - - mBrowserBox->addRow(name); - - // TRANSLATORS: popup menu item - // TRANSLATORS: send whisper to player - mBrowserBox->addRow("/whispertext 'NAME'", _("Whisper")); - addMailCommands(); - addGmCommands(); - mBrowserBox->addSeparator("##3---"); - - addPlayerRelation(name); - mBrowserBox->addSeparator("##3---"); - - addFollow(); - // TRANSLATORS: popup menu item - // TRANSLATORS: add comment to player - mBrowserBox->addRow("addcomment", _("Add comment")); - - if (localPlayer->isInParty()) - { - const Party *const party = localPlayer->getParty(); - if (party != nullptr) - { - const PartyMember *const member = party->getMember(mName); - if (member != nullptr) - { - // TRANSLATORS: popup menu item - // TRANSLATORS: kick player from party - mBrowserBox->addRow("/kickparty 'NAME'", _("Kick from party")); - mBrowserBox->addSeparator("##3---"); - const PartyMember *const o = party->getMember( - localPlayer->getName()); - showAdoptCommands(); - if ((o != nullptr) && member->getMap() == o->getMap()) - { - // TRANSLATORS: popup menu item - // TRANSLATORS: move to player position - mBrowserBox->addRow("/navigate 'X' 'Y'", _("Move")); - } - } - } - } - - const Guild *const guild2 = localPlayer->getGuild(); - if (guild2 != nullptr) - { - if (guild2->getMember(mName) != nullptr) - { -#ifdef TMWA_SUPPORT - if (guild2->getServerGuild() || (guildManager != nullptr - && guildManager->havePower())) -#endif // TMWA_SUPPORT - { - mBrowserBox->addRow("/kickguild 'NAME'", - // TRANSLATORS: popup menu item - // TRANSLATORS: kick player from guild - _("Kick from guild")); - } - if (guild2->getServerGuild()) - { - mBrowserBox->addRow(strprintf( - // TRANSLATORS: popup menu item - // TRANSLATORS: change player position in guild - "@@guild-pos|%s >@@", _("Change pos in guild"))); - } - } - else - { -#ifdef TMWA_SUPPORT - if (guild2->getServerGuild() || (guildManager != nullptr - && guildManager->havePower())) -#endif // TMWA_SUPPORT - { - // TRANSLATORS: popup menu item - // TRANSLATORS: invite player to guild - mBrowserBox->addRow("/guild 'NAME'", _("Invite to guild")); - } - } - } - - addBuySellDefault(); - // TRANSLATORS: popup menu item - // TRANSLATORS: add player name to chat - mBrowserBox->addRow("/addtext 'NAME'", _("Add name to chat")); - mBrowserBox->addSeparator("##3---"); - // TRANSLATORS: popup menu item - // TRANSLATORS: close menu - mBrowserBox->addRow("cancel", _("Cancel")); - - showPopup(mX, mY); -} - -void PopupMenu::showPopup(const int x, const int y, - const FloorItem *const floorItem) -{ - if (floorItem == nullptr) - return; - - initPopup(); - mX = x; - mY = y; - mFloorItemId = floorItem->getId(); - mItemId = floorItem->getItemId(); - mType = ActorType::FloorItem; - mSubType = BeingTypeId_zero; - for (int f = 0; f < maxCards; f ++) - mItemCards[f] = floorItem->getCard(f); - mBrowserBox->clearRows(); - const std::string name = floorItem->getName(); - mName = name; - mExtName = name; - - mBrowserBox->addRow(name); - - if (config.getBoolValue("enablePickupFilter")) - { - if (actorManager->isInPickupList(name) - || (actorManager->isInPickupList("") - && !actorManager->isInIgnorePickupList(name))) - { - // TRANSLATORS: popup menu item - // TRANSLATORS: pickup item from ground - mBrowserBox->addRow("/pickup 'FLOORID'", _("Pick up")); - mBrowserBox->addSeparator("##3---"); - } - addPickupFilter(name); - } - else - { - // TRANSLATORS: popup menu item - // TRANSLATORS: pickup item from ground - mBrowserBox->addRow("/pickup 'FLOORID'", _("Pick up")); - } - addProtection(); - // TRANSLATORS: popup menu item - // TRANSLATORS: add item name to chat - mBrowserBox->addRow("/addchat 'FLOORID''CARDS'", _("Add to chat")); - mBrowserBox->addSeparator("##3---"); - addGmCommands(); - - // TRANSLATORS: popup menu item - // TRANSLATORS: close menu - mBrowserBox->addRow("cancel", _("Cancel")); - - showPopup(mX, mY); -} - -void PopupMenu::showPopup(const int x, const int y, MapItem *const mapItem) -{ - if (mapItem == nullptr) - return; - - initPopup(); - mMapItem = mapItem; - mX = x; - mY = y; - - mBrowserBox->clearRows(); - - // TRANSLATORS: popup menu header - mBrowserBox->addRow(_("Map Item")); - // TRANSLATORS: popup menu item - // TRANSLATORS: rename map item - mBrowserBox->addRow("rename map", _("Rename")); - // TRANSLATORS: popup menu item - // TRANSLATORS: remove map item - mBrowserBox->addRow("remove map", _("Remove")); - - if (isAllowCommand(ServerCommandType::slide)) - { - mBrowserBox->addSeparator("##3---"); - // TRANSLATORS: popup menu item - // TRANSLATORS: warp to map item - mBrowserBox->addRow("/slide 'MAPX' 'MAPY'", _("Warp")); - } - mBrowserBox->addSeparator("##3---"); - // TRANSLATORS: popup menu item - // TRANSLATORS: close menu - mBrowserBox->addRow("cancel", _("Cancel")); - - showPopup(x, y); -} - -void PopupMenu::showMapPopup(const int x, const int y, - const int x2, const int y2, - const bool isMinimap) -{ - initPopup(); - mX = x2; - mY = y2; - - if (isMinimap) - mCallerWindow = minimap; - - mBrowserBox->clearRows(); - - // TRANSLATORS: popup menu header - mBrowserBox->addRow(_("Map Item")); - - if (isAllowCommand(ServerCommandType::slide)) - { - // TRANSLATORS: popup menu item - // TRANSLATORS: warp to map item - mBrowserBox->addRow("/slide 'MAPX' 'MAPY'", _("Warp")); - } - // TRANSLATORS: popup menu item - // TRANSLATORS: move to map item - mBrowserBox->addRow("/navigate 'X' 'Y'", _("Move")); - // TRANSLATORS: popup menu item - // TRANSLATORS: move camera to map item - mBrowserBox->addRow("/movecamera 'X' 'Y'", _("Move camera")); - if (settings.cameraMode != 0) - { - // TRANSLATORS: popup menu item - // TRANSLATORS: restore camera to default view - mBrowserBox->addRow("/restorecamera", _("Restore camera")); - } - mBrowserBox->addSeparator("##3---"); - if (isMinimap) - { - // TRANSLATORS: popup menu item - mBrowserBox->addRow("window close", _("Close")); - } - mBrowserBox->addSeparator("##3---"); - // TRANSLATORS: popup menu item - // TRANSLATORS: close menu - mBrowserBox->addRow("cancel", _("Cancel")); - - showPopup(x, y); -} - -void PopupMenu::showOutfitsWindowPopup(const int x, const int y) -{ - initPopup(); - mX = x; - mY = y; - mCallerWindow = outfitWindow; - - mBrowserBox->clearRows(); - - // TRANSLATORS: popup menu header - mBrowserBox->addRow(_("Outfits")); - // TRANSLATORS: popup menu item - // TRANSLATORS: copy selected outfit to chat input - mBrowserBox->addRow("/outfittochat", _("Add to chat")); - mBrowserBox->addSeparator("##3---"); - // TRANSLATORS: popup menu item - // TRANSLATORS: copy equipment from player to outfit - mBrowserBox->addRow("/itemstooutfit", _("Copy from player")); - mBrowserBox->addSeparator("##3---"); - // TRANSLATORS: popup menu item - // TRANSLATORS: clear selected outfit - mBrowserBox->addRow("/clearoutfit", _("Clear outfit")); - mBrowserBox->addSeparator("##3---"); - - addWindowMenu(outfitWindow); - mBrowserBox->addSeparator("##3---"); - - // TRANSLATORS: popup menu item - // TRANSLATORS: close menu - mBrowserBox->addRow("cancel", _("Cancel")); - - showPopup(x, y); -} - -void PopupMenu::showSpellPopup(const int x, const int y, - TextCommand *const cmd) -{ - if (cmd == nullptr) - return; - - initPopup(); - mBrowserBox->clearRows(); - - mSpell = cmd; - mX = x; - mY = y; - - // TRANSLATORS: popup menu header - mBrowserBox->addRow(_("Spells")); - // TRANSLATORS: popup menu item - // TRANSLATORS: edit selected spell - mBrowserBox->addRow("edit spell", _("Edit spell")); - mBrowserBox->addSeparator("##3---"); - // TRANSLATORS: popup menu item - // TRANSLATORS: close menu - mBrowserBox->addRow("cancel", _("Cancel")); - - showPopup(x, y); -} - -void PopupMenu::showChatPopup(const int x, const int y, ChatTab *const tab) -{ - if (tab == nullptr || - actorManager == nullptr || - localPlayer == nullptr) - { - return; - } - - initPopup(); - mTab = tab; - mX = x; - mY = y; - mCallerWindow = chatWindow; - - mBrowserBox->clearRows(); - - const ChatTabTypeT &type = tab->getType(); - if (type == ChatTabType::WHISPER || type == ChatTabType::CHANNEL) - { - // TRANSLATORS: popup menu item - // TRANSLATORS: close chat tab - mBrowserBox->addRow("/close", _("Close")); - } - - // TRANSLATORS: popup menu item - // TRANSLATORS: remove all text from chat tab - mBrowserBox->addRow("/chatclear", _("Clear")); - mBrowserBox->addSeparator("##3---"); - - if (tab->getAllowHighlight()) - { - // TRANSLATORS: popup menu item - // TRANSLATORS: disable chat tab highlight - mBrowserBox->addRow("/disablehighlight", _("Disable highlight")); - } - else - { - // TRANSLATORS: popup menu item - // TRANSLATORS: enable chat tab highlight - mBrowserBox->addRow("/enablehighlight", _("Enable highlight")); - } - if (tab->getRemoveNames()) - { - // TRANSLATORS: popup menu item - // TRANSLATORS: do not remove player names from chat tab - mBrowserBox->addRow("/dontremovename", _("Don't remove name")); - } - else - { - // TRANSLATORS: popup menu item - // TRANSLATORS: remove player names from chat tab - mBrowserBox->addRow("/removename", _("Remove name")); - } - if (tab->getNoAway()) - { - // TRANSLATORS: popup menu item - // TRANSLATORS: enable away messages in chat tab - mBrowserBox->addRow("/enableaway", _("Enable away")); - } - else - { - // TRANSLATORS: popup menu item - // TRANSLATORS: disable away messages in chat tab - mBrowserBox->addRow("/disableaway", _("Disable away")); - } - mBrowserBox->addSeparator("##3---"); - if (type == ChatTabType::PARTY) - { - // TRANSLATORS: popup menu item - // TRANSLATORS: enable away messages in chat tab - mBrowserBox->addRow("/leaveparty", _("Leave")); - mBrowserBox->addSeparator("##3---"); - } - // TRANSLATORS: popup menu item - // TRANSLATORS: copy selected text to clipboard - mBrowserBox->addRow("/chatclipboard 'X' 'Y'", _("Copy to clipboard")); - mBrowserBox->addSeparator("##3---"); - - if (type == ChatTabType::WHISPER) - { - const WhisperTab *const wTab = static_cast(tab); - const std::string &name = wTab->getNick(); - - const Being* const being = actorManager->findBeingByName( - name, ActorType::Player); - - addGmCommands(); - if (being != nullptr) - { - mBeingId = being->getId(); - mName = being->getName(); - mExtName = being->getExtName(); - mType = being->getType(); - mSubType = being->getSubType(); - - // TRANSLATORS: popup menu item - // TRANSLATORS: trade with player - mBrowserBox->addRow("/trade 'NAME'", _("Trade")); - // TRANSLATORS: popup menu item - // TRANSLATORS: attack player - mBrowserBox->addRow("/attack 'NAME'", _("Attack")); - addMailCommands(); - mBrowserBox->addSeparator("##3---"); - // TRANSLATORS: popup menu item - // TRANSLATORS: heal player - mBrowserBox->addRow("/heal :'BEINGID'", _("Heal")); - mBrowserBox->addSeparator("##3---"); - addPlayerRelation(name); - mBrowserBox->addSeparator("##3---"); - addFollow(); - // TRANSLATORS: popup menu item - // TRANSLATORS: move to player position - mBrowserBox->addRow("/navigateto 'NAME'", _("Move")); - addPlayerMisc(); - addBuySell(being); - mBrowserBox->addSeparator("##3---"); - addParty(wTab->getNick()); - const Guild *const guild1 = being->getGuild(); - const Guild *const guild2 = localPlayer->getGuild(); - if (guild2 != nullptr) - { - if (guild1 != nullptr) - { - if (guild1->getId() == guild2->getId()) - { -#ifdef TMWA_SUPPORT - if (guild2->getServerGuild() || - (guildManager != nullptr && - guildManager->havePower())) -#endif // TMWA_SUPPORT - { - mBrowserBox->addRow("/kickguild 'NAME'", - // TRANSLATORS: popup menu item - // TRANSLATORS: kick player from guild - _("Kick from guild")); - } - if (guild2->getServerGuild()) - { - mBrowserBox->addRow(strprintf("@@guild-pos|%s >@@", - // TRANSLATORS: popup menu item - // TRANSLATORS: change player position in guild - _("Change pos in guild"))); - } - } - } - else - { -#ifdef TMWA_SUPPORT - if (guild2->getServerGuild() || (guildManager != nullptr - && guildManager->havePower())) -#endif // TMWA_SUPPORT - { - mBrowserBox->addRow("/guild 'NAME'", - // TRANSLATORS: popup menu item - // TRANSLATORS: invite player to guild - _("Invite to guild")); - } - } - } - } - else - { - mBeingId = BeingId_zero; - mName = name; - mExtName = name; - mType = ActorType::Player; - mSubType = BeingTypeId_zero; - addPlayerRelation(name); - mBrowserBox->addSeparator("##3---"); - addMailCommands(); - addFollow(); - - if (localPlayer->isInParty()) - { - const Party *const party = localPlayer->getParty(); - if (party != nullptr) - { - const PartyMember *const m = party->getMember(mName); - if (m != nullptr) - { - // TRANSLATORS: popup menu item - // TRANSLATORS: move to player location - mBrowserBox->addRow("/navigateto 'NAME'", _("Move")); - } - } - } - addPlayerMisc(); - addBuySellDefault(); - if (Net::getNetworkType() != ServerType::TMWATHENA) - addParty(wTab->getNick()); - mBrowserBox->addSeparator("##3---"); - } - } - - addWindowMenu(chatWindow); - // TRANSLATORS: popup menu item - // TRANSLATORS: close menu - mBrowserBox->addRow("cancel", _("Cancel")); - - showPopup(x, y); -} - -void PopupMenu::showChangePos(const int x, const int y) -{ - initPopup(); - mBrowserBox->clearRows(); - // TRANSLATORS: popup menu header - mBrowserBox->addRow(_("Change guild position")); - - if (localPlayer == nullptr) - return; - - mX = x; - mY = y; - const Guild *const guild = localPlayer->getGuild(); - if (guild != nullptr) - { - const PositionsMap &map = guild->getPositions(); - FOR_EACH (PositionsMap::const_iterator, itr, map) - { - mBrowserBox->addRow(strprintf("@@guild-pos-%u|%s@@", - itr->first, itr->second.c_str())); - } - // TRANSLATORS: popup menu item - // TRANSLATORS: close menu - mBrowserBox->addRow("cancel", _("Cancel")); - - showPopup(x, y); - } - else - { - mBeingId = BeingId_zero; - mFloorItemId = BeingId_zero; - mItemIndex = -1; - mItemId = 0; - for (int f = 0; f < maxCards; f ++) - mItemCards[f] = 0; - mMapItem = nullptr; - mName.clear(); - mExtName.clear(); - mType = ActorType::Unknown; - mSubType = BeingTypeId_zero; - mX = 0; - mY = 0; - setVisible(Visible_false); - } -} - -void PopupMenu::showWindowPopup(Window *const window) -{ - if (window == nullptr) - return; - - initPopup(); - setMousePos(); - mCallerWindow = window; - mBrowserBox->clearRows(); - // TRANSLATORS: popup menu header - mBrowserBox->addRow(_("window")); - - addWindowMenu(window); - - // TRANSLATORS: popup menu item - // TRANSLATORS: close menu - mBrowserBox->addRow("cancel", _("Cancel")); - - showPopup(mX, mY); -} - -void PopupMenu::addWindowMenu(const Window *const window) -{ - if (window == nullptr) - return; - - initPopup(); - if (window->getAlowClose()) - { - // TRANSLATORS: popup menu item - // TRANSLATORS: close window - mBrowserBox->addRow("window close", _("Close")); - } - - if (window->isStickyButtonLock()) - { - if (window->isSticky()) - { - // TRANSLATORS: popup menu item - // TRANSLATORS: unlock window - mBrowserBox->addRow("window unlock", _("Unlock")); - } - else - { - // TRANSLATORS: popup menu item - // TRANSLATORS: lock window - mBrowserBox->addRow("window lock", _("Lock")); - } - } -} - -void PopupMenu::showEmoteType() -{ - initPopup(); - setMousePos(); - - mBrowserBox->clearRows(); - // TRANSLATORS: popup menu header - mBrowserBox->addRow(_("Show emotes for:")); - - // TRANSLATORS: popup menu item - // TRANSLATORS: show emotes for player - mBrowserBox->addRow("/setemotetype player", _("Player")); - - // TRANSLATORS: popup menu item - // TRANSLATORS: show emotes for pet - mBrowserBox->addRow("/setemotetype pet", _("Pet")); - - if (Net::getNetworkType() == ServerType::EVOL2) - { - // TRANSLATORS: popup menu item - // TRANSLATORS: show emotes for homuncules - mBrowserBox->addRow("/setemotetype homun", _("Homunculus")); - - // TRANSLATORS: popup menu item - // TRANSLATORS: show emotes for mercenary - mBrowserBox->addRow("/setemotetype merc", _("Mercenary")); - } - mBrowserBox->addSeparator("##3---"); - - // TRANSLATORS: popup menu item - // TRANSLATORS: close menu - mBrowserBox->addRow("cancel", _("Cancel")); - - showPopup(mX, mY); -} - -void PopupMenu::handleLink(const std::string &link, - MouseEvent *event A_UNUSED) -{ - Being *being = nullptr; - if (actorManager != nullptr) - being = actorManager->findBeing(mBeingId); - - mAllowCleanMenu = true; - - if (link == "remove map" && (mMapItem != nullptr)) - { - if (viewport != nullptr) - { - const Map *const map = viewport->getMap(); - if (map != nullptr) - { - SpecialLayer *const specialLayer = map->getSpecialLayer(); - if (specialLayer != nullptr) - { - const bool isHome = (mMapItem->getType() - == CAST_S32(MapItemType::HOME)); - const int x = static_cast(mMapItem->getX()); - const int y = static_cast(mMapItem->getY()); - specialLayer->setTile(x, y, - CAST_S32(MapItemType::EMPTY)); - specialLayer->updateCache(); - if (socialWindow != nullptr) - socialWindow->removePortal(x, y); - if (isHome && (localPlayer != nullptr)) - { - localPlayer->removeHome(); - localPlayer->saveHomes(); - } - } - } - } - } - else if (link == "rename map" && (mMapItem != nullptr)) - { - mRenameListener.setMapItem(mMapItem); - CREATEWIDGETV(mDialog, TextDialog, - // TRANSLATORS: dialog caption - // TRANSLATORS: number of chars in string should be near original - _("Rename map sign "), - // TRANSLATORS: label - // TRANSLATORS: number of chars in string should be near original - _("Name: ")); - mRenameListener.setDialog(mDialog); - mDialog->setText(mMapItem->getComment()); - mDialog->setActionEventId("ok"); - mDialog->addActionListener(&mRenameListener); - } - else if (link == "edit spell" && (mSpell != nullptr)) - { - CREATEWIDGET(TextCommandEditor, mSpell); - } - else if (link == "addcomment" && !mName.empty()) - { - TextDialog *const dialog = CREATEWIDGETR(TextDialog, - // TRANSLATORS: dialog caption - // TRANSLATORS: number of chars in string should be near original - _("Player comment "), - // TRANSLATORS: label - // TRANSLATORS: number of chars in string should be near original - _("Comment: ")); - mPlayerListener.setDialog(dialog); - mPlayerListener.setNick(mName); - mPlayerListener.setType(mType); - - if (being != nullptr) - { - being->updateComment(); - dialog->setText(being->getComment()); - } - else - { - dialog->setText(Being::loadComment(mName, - static_cast(mType))); - } - dialog->setActionEventId("ok"); - dialog->addActionListener(&mPlayerListener); - } - else if (link == "guild-pos" && !mName.empty()) - { - showChangePos(getX(), getY()); - return; - } - else if (link == "clipboard copy") - { - if (mTextField != nullptr) - mTextField->handleCopy(); - } - else if (link == "clipboard paste") - { - if (mTextField != nullptr) - mTextField->handlePaste(); - } - else if (link == "gm" && !mName.empty()) - { - showGMPopup(mName); - return; - } - else if (link == "mute" && !mName.empty()) - { - showMuteCommands(); - return; - } - else if (link == "show" && !mName.empty()) - { - showPlayerMenu(); - return; - } - else if (link == "window close" && (mCallerWindow != nullptr)) - { - if (Widget::widgetExists(mCallerWindow)) - mCallerWindow->close(); - } - else if (link == "window unlock" && (mCallerWindow != nullptr)) - { - if (Widget::widgetExists(mCallerWindow)) - mCallerWindow->setSticky(false); - } - else if (link == "window lock" && (mCallerWindow != nullptr)) - { - if (Widget::widgetExists(mCallerWindow)) - mCallerWindow->setSticky(true); - } - else if (link == "join chat" && (being != nullptr)) - { - const ChatObject *const chat = being->getChat(); - if (chat != nullptr) - chatHandler->joinChat(chat, ""); - } - else if (link == "craftmenu") - { - showCraftPopup(); - return; - } - else if (link.compare(0, 10, "guild-pos-") == 0) - { - if (localPlayer != nullptr) - { - const int num = atoi(link.substr(10).c_str()); - const Guild *const guild = localPlayer->getGuild(); - if (guild != nullptr) - { - guildHandler->changeMemberPostion( - guild->getMember(mName), num); - } - } - } - else if (link.compare(0, 7, "player_") == 0) - { - if (actorManager != nullptr) - { - mBeingId = fromInt(atoi(link.substr(7).c_str()), BeingId); - being = actorManager->findBeing(mBeingId); - if (being != nullptr) - { - showPopup(getX(), getY(), being); - return; - } - } - } - else if (link.compare(0, 10, "flooritem_") == 0) - { - if (actorManager != nullptr) - { - const BeingId id = fromInt(atoi( - link.substr(10).c_str()), BeingId); - if (id != BeingId_zero) - { - const FloorItem *const item = actorManager->findItem(id); - if (item != nullptr) - { - mFloorItemId = item->getId(); - mItemId = item->getItemId(); - for (int f = 0; f < maxCards; f ++) - mItemCards[f] = item->getCard(f); - showPopup(getX(), getY(), item); - return; - } - } - } - } - else if (link.compare(0, 12, "hide button_") == 0) - { - if (windowMenu != nullptr) - windowMenu->showButton(link.substr(12), Visible_false); - } - else if (link.compare(0, 12, "show button_") == 0) - { - if (windowMenu != nullptr) - windowMenu->showButton(link.substr(12), Visible_true); - } - else if (link.compare(0, 9, "hide bar_") == 0) - { - if (miniStatusWindow != nullptr) - miniStatusWindow->showBar(link.substr(9), Visible_false); - } - else if (link.compare(0, 9, "show bar_") == 0) - { - if (miniStatusWindow != nullptr) - miniStatusWindow->showBar(link.substr(9), Visible_true); - } - else if (link.compare(0, 12, "show window_") == 0) - { - const int id = atoi(link.substr(12).c_str()); - if (id >= 0) - inputManager.executeAction(static_cast(id)); - } - else if (link.compare(0, 6, "mute_+") == 0) - { - if (being != nullptr) - { - const int time = atoi(link.substr(6).c_str()); - adminHandler->mute(being, 1, time); - } - } - else if (link.compare(0, 6, "mute_-") == 0) - { - if (being != nullptr) - { - const int time = atoi(link.substr(6).c_str()); - adminHandler->mute(being, 0, time); - } - } - else if (!link.empty() && link[0] == '/') - { - std::string cmd = link.substr(1); - replaceAll(cmd, "'NAME'", mName); - replaceAll(cmd, "'ENAME'", escapeString(mName)); - replaceAll(cmd, "'EXTNAME'", mExtName); - replaceAll(cmd, "'EEXTNAME'", escapeString(mExtName)); - replaceAll(cmd, "'X'", toString(mX)); - replaceAll(cmd, "'Y'", toString(mY)); - replaceAll(cmd, "'BEINGID'", toString(toInt(mBeingId, int))); - replaceAll(cmd, "'FLOORID'", toString(toInt(mFloorItemId, int))); - replaceAll(cmd, "'ITEMID'", toString(mItemId)); - replaceAll(cmd, "'ITEMCOLOR'", toString(toInt(mItemColor, int))); - replaceAll(cmd, "'BEINGTYPEID'", toString(CAST_S32(mType))); - replaceAll(cmd, "'BEINGSUBTYPEID'", toString(CAST_S32(mSubType))); - replaceAll(cmd, "'PLAYER'", localPlayer->getName()); - replaceAll(cmd, "'EPLAYER'", escapeString(localPlayer->getName())); - replaceAll(cmd, "'PLAYERX'", toString(localPlayer->getTileX())); - replaceAll(cmd, "'PLAYERY'", toString(localPlayer->getTileY())); - if (mItemIndex >= 0) - replaceAll(cmd, "'INVINDEX'", toString(mItemIndex)); - else - replaceAll(cmd, "'INVINDEX'", "0"); - if (mMapItem != nullptr) - { - replaceAll(cmd, "'MAPX'", toString(mMapItem->getX())); - replaceAll(cmd, "'MAPY'", toString(mMapItem->getY())); - } - else - { - replaceAll(cmd, "'MAPX'", toString(mX)); - replaceAll(cmd, "'MAPY'", toString(mY)); - } - - std::string cards; - for (int f = 0; f < maxCards; f ++) - { - const int id = mItemCards[f]; - if (id != 0) - { - cards.append(","); - cards.append(toString(id)); - } - } - replaceAll(cmd, "'CARDS'", cards); - replaceAll(cmd, "'ECARDS'", escapeString(cards)); - if (actorManager != nullptr) - { - if (being == nullptr) - { - being = actorManager->findBeingByName(mName, - ActorType::Player); - } - } - if (being != nullptr) - replaceAll(cmd, "'PARTY'", being->getPartyName()); - else - replaceAll(cmd, "'PARTY'", ""); - - const size_t pos = cmd.find(' '); - const std::string type(cmd, 0, pos); - std::string args(cmd, pos == std::string::npos ? cmd.size() : pos + 1); - args = trim(args); - inputManager.executeChatCommand(type, args, mTab); - } - // Unknown actions - else if (link != "cancel") - { - reportAlways("PopupMenu: Warning, unknown action '%s'", link.c_str()); - } - - if (!mAllowCleanMenu) - return; - - setVisible(Visible_false); - - mBeingId = BeingId_zero; - mFloorItemId = BeingId_zero; - mItemId = 0; - mItemIndex = -1; - for (int f = 0; f < maxCards; f ++) - mItemCards[f] = 0; - mItemColor = ItemColor_one; - mMapItem = nullptr; - mTab = nullptr; - mSpell = nullptr; - mCallerWindow = nullptr; - mDialog = nullptr; - mButton = nullptr; - mName.clear(); - mExtName.clear(); - mTextField = nullptr; - mType = ActorType::Unknown; - mSubType = BeingTypeId_zero; - mX = 0; - mY = 0; -} - -void PopupMenu::showPopup(Window *const parent, - const int x, const int y, - const Item *const item, - const InventoryTypeT type) -{ - if (item == nullptr) - return; - - initPopup(); - mItemId = item->getId(); - mItemIndex = item->getInvIndex(); - for (int f = 0; f < maxCards; f ++) - mItemCards[f] = item->getCard(f); - mItemColor = item->getColor(); - mCallerWindow = parent; - mX = x; - mY = y; - mName.clear(); - mExtName.clear(); - mBrowserBox->clearRows(); - - const int cnt = item->getQuantity(); - const bool isProtected = PlayerInfo::isItemProtected(mItemId); - - switch (type) - { - case InventoryType::Inventory: - if (tradeWindow != nullptr && - tradeWindow->isWindowVisible() && - !isProtected) - { - // TRANSLATORS: popup menu item - // TRANSLATORS: add item to trade - mBrowserBox->addRow("/addtrade 'INVINDEX'", _("Add to trade")); - if (cnt > 1) - { - if (cnt > 10) - { - mBrowserBox->addRow("/addtrade 'INVINDEX' 10", - // TRANSLATORS: popup menu item - // TRANSLATORS: add 10 item amount to trade - _("Add to trade 10")); - } - mBrowserBox->addRow("/addtrade 'INVINDEX' /", - // TRANSLATORS: popup menu item - // TRANSLATORS: add half item amount to trade - _("Add to trade half")); - mBrowserBox->addRow("/addtrade 'INVINDEX' -1", - // TRANSLATORS: popup menu item - // TRANSLATORS: add all amount except one item to trade - _("Add to trade all-1")); - mBrowserBox->addRow("/addtrade 'INVINDEX' all", - // TRANSLATORS: popup menu item - // TRANSLATORS: add all amount item to trade - _("Add to trade all")); - } - mBrowserBox->addSeparator("##3---"); - } - if (InventoryWindow::isStorageActive()) - { - // TRANSLATORS: popup menu item - // TRANSLATORS: add item to storage - mBrowserBox->addRow("/invtostorage 'INVINDEX'", _("Store")); - if (cnt > 1) - { - if (cnt > 10) - { - mBrowserBox->addRow("/invtostorage 'INVINDEX' 10", - // TRANSLATORS: popup menu item - // TRANSLATORS: add 10 item amount to storage - _("Store 10")); - } - mBrowserBox->addRow("/invtostorage 'INVINDEX' /", - // TRANSLATORS: popup menu item - // TRANSLATORS: add half item amount to storage - _("Store half")); - mBrowserBox->addRow("/invtostorage 'INVINDEX' -1", - // TRANSLATORS: popup menu item - // TRANSLATORS: add all except one item to storage - _("Store all-1")); - mBrowserBox->addRow("/invtostorage 'INVINDEX' all", - // TRANSLATORS: popup menu item - // TRANSLATORS: add all item amount to storage - _("Store all")); - } - mBrowserBox->addSeparator("##3---"); - } - if (npcHandler != nullptr) - { - NpcDialog *const dialog = npcHandler->getCurrentNpcDialog(); - if ((dialog != nullptr) && - dialog->getInputState() == NpcInputState::ITEM_CRAFT) - { - mBrowserBox->addRow("craftmenu", - // TRANSLATORS: popup menu item - // TRANSLATORS: sub menu for craft - _("Move to craft...")); - } - } - addItemMenu(item, InventoryType::Inventory); - addDrop(item, isProtected); - break; - - case InventoryType::Storage: - // TRANSLATORS: popup menu item - // TRANSLATORS: get item from storage - mBrowserBox->addRow("/storagetoinv 'INVINDEX'", _("Retrieve")); - if (cnt > 1) - { - if (cnt > 10) - { - mBrowserBox->addRow("/storagetoinv 'INVINDEX' 10", - // TRANSLATORS: popup menu item - // TRANSLATORS: get 10 item amount from storage - _("Retrieve 10")); - } - mBrowserBox->addRow("/storagetoinv 'INVINDEX' /", - // TRANSLATORS: popup menu item - // TRANSLATORS: get half item amount from storage - _("Retrieve half")); - mBrowserBox->addRow("/storagetoinv 'INVINDEX' -1", - // TRANSLATORS: popup menu item - // TRANSLATORS: get all except one item amount from storage - _("Retrieve all-1")); - mBrowserBox->addRow("/storagetoinv 'INVINDEX' all", - // TRANSLATORS: popup menu item - // TRANSLATORS: get all item amount from storage - _("Retrieve all")); - mBrowserBox->addSeparator("##3---"); - } - addItemMenu(item, InventoryType::Storage); - break; - case InventoryType::Cart: - addItemMenu(item, InventoryType::Cart); - break; - - case InventoryType::Trade: - case InventoryType::Npc: - case InventoryType::Vending: - case InventoryType::MailEdit: - case InventoryType::MailView: - case InventoryType::Craft: - case InventoryType::TypeEnd: - default: - break; - } - - - addProtection(); - if (config.getBoolValue("enablePickupFilter")) - { - mName = item->getName(); - mExtName = mName; - mBrowserBox->addSeparator("##3---"); - addPickupFilter(mName); - } - addGmCommands(); - // TRANSLATORS: popup menu item - // TRANSLATORS: add item name to chat - mBrowserBox->addRow("/addchat 'ITEMID''CARDS'", _("Add to chat")); - mBrowserBox->addSeparator("##3---"); - // TRANSLATORS: popup menu item - // TRANSLATORS: close menu - mBrowserBox->addRow("cancel", _("Cancel")); - - showPopup(x, y); -} - -void PopupMenu::showItemPopup(const int x, const int y, - const int itemId, - const ItemColor color) -{ - const Inventory *const inv = PlayerInfo::getInventory(); - if (inv == nullptr) - return; - - Item *const item = inv->findItem(itemId, color); - if (item != nullptr) - { - showItemPopup(x, y, item); - } - else - { - initPopup(); - mItemId = itemId; - mItemIndex = -1; - mItemColor = color; - for (int f = 0; f < maxCards; f ++) - mItemCards[f] = 0; - mX = x; - mY = y; - mBrowserBox->clearRows(); - - if (!PlayerInfo::isItemProtected(mItemId)) - { - // TRANSLATORS: popup menu item - // TRANSLATORS: use item - mBrowserBox->addRow("/use 'ITEMID'", _("Use")); - } - addProtection(); - addGmCommands(); - mBrowserBox->addSeparator("##3---"); - // TRANSLATORS: popup menu item - // TRANSLATORS: close menu - mBrowserBox->addRow("cancel", _("Cancel")); - - showPopup(x, y); - } -} - -void PopupMenu::showItemPopup(const int x, const int y, - const Item *const item) -{ - initPopup(); - mX = x; - mY = y; - if (item != nullptr) - { - mItemId = item->getId(); - mItemColor = item->getColor(); - mItemIndex = item->getInvIndex(); - for (int f = 0; f < maxCards; f ++) - mItemCards[f] = item->getCard(f); - } - else - { - mItemId = 0; - mItemColor = ItemColor_one; - mItemIndex = -1; - for (int f = 0; f < maxCards; f ++) - mItemCards[f] = 0; - } - mName.clear(); - mExtName.clear(); - mBrowserBox->clearRows(); - - if (item != nullptr) - { - const bool isProtected = PlayerInfo::isItemProtected(mItemId); - addUse(item); - addDrop(item, isProtected); - if (InventoryWindow::isStorageActive()) - { - // TRANSLATORS: popup menu item - // TRANSLATORS: add item to storage - mBrowserBox->addRow("/invtostorage 'INVINDEX'", _("Store")); - } - // TRANSLATORS: popup menu item - // TRANSLATORS: add item name to chat - mBrowserBox->addRow("/addchat 'ITEMID''CARDS'", _("Add to chat")); - - if (config.getBoolValue("enablePickupFilter")) - { - mName = item->getName(); - mExtName = mName; - mBrowserBox->addSeparator("##3---"); - addPickupFilter(mName); - } - } - addProtection(); - addGmCommands(); - mBrowserBox->addSeparator("##3---"); - // TRANSLATORS: popup menu item - // TRANSLATORS: close menu - mBrowserBox->addRow("cancel", _("Cancel")); - - showPopup(x, y); -} - -void PopupMenu::showDropPopup(const int x, - const int y, - const Item *const item) -{ - initPopup(); - mX = x; - mY = y; - mName.clear(); - mExtName.clear(); - mBrowserBox->clearRows(); - - if (item != nullptr) - { - mItemId = item->getId(); - mItemColor = item->getColor(); - mItemIndex = item->getInvIndex(); - for (int f = 0; f < maxCards; f ++) - mItemCards[f] = item->getCard(f); - const bool isProtected = PlayerInfo::isItemProtected(mItemId); - addUse(item); - addDrop(item, isProtected); - if (InventoryWindow::isStorageActive()) - { - // TRANSLATORS: popup menu item - // TRANSLATORS: add item to storage - mBrowserBox->addRow("/invtostorage 'INVINDEX'", _("Store")); - } - addProtection(); - // TRANSLATORS: popup menu item - // TRANSLATORS: add item name to chat - mBrowserBox->addRow("/addchat 'ITEMID''CARDS'", _("Add to chat")); - if (config.getBoolValue("enablePickupFilter")) - { - mName = item->getName(); - mExtName = mName; - mBrowserBox->addSeparator("##3---"); - addPickupFilter(mName); - } - } - addGmCommands(); - mBrowserBox->addSeparator("##3---"); - // TRANSLATORS: popup menu item - mBrowserBox->addRow("/cleardrops", _("Clear drop window")); - mBrowserBox->addSeparator("##3---"); - // TRANSLATORS: popup menu item - // TRANSLATORS: close menu - mBrowserBox->addRow("cancel", _("Cancel")); - - showPopup(x, y); -} - -void PopupMenu::showPopup(const int x, const int y, Button *const button) -{ - if ((button == nullptr) || (windowMenu == nullptr)) - return; - - initPopup(); - mButton = button; - mX = x; - mY = y; - - mBrowserBox->clearRows(); - STD_VECTOR