From 41ec4ed68571091f2e2500344a7aeb527a91dc92 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 18 Jul 2020 17:20:32 +0200 Subject: Added standard close button widget class, added tooltips where approriate. --- src/client/Makefile.am | 2 ++ src/client/audiosettingsmenu.cc | 3 ++- src/client/chat.cc | 3 ++- src/client/closeiconbutton.cc | 22 ++++++++++++++++++++++ src/client/closeiconbutton.h | 28 ++++++++++++++++++++++++++++ src/client/controlsettingsmenu.cc | 3 ++- src/client/gamewindow.cc | 24 ++++++++++++------------ src/client/graphicssettingsmenu.cc | 3 ++- src/client/hudenginestatus.cc | 7 +++++-- src/client/inventorywindow.cc | 18 ++++++++++-------- src/client/mapwindow.cc | 21 ++++++++++++--------- src/client/playersettingsmenu.cc | 3 ++- src/client/reputationwindow.cc | 10 +++++----- src/client/savegamemenu.cc | 31 ++++++++++++++++++------------- src/client/targeticonbutton.cc | 7 ++++++- src/client/targeticonbutton.h | 3 ++- src/client/testmodelwindow.cc | 10 +++++++--- src/client/trademenu.cc | 15 +++++++++------ 18 files changed, 148 insertions(+), 65 deletions(-) create mode 100644 src/client/closeiconbutton.cc create mode 100644 src/client/closeiconbutton.h (limited to 'src/client') diff --git a/src/client/Makefile.am b/src/client/Makefile.am index 391892a..21704f4 100644 --- a/src/client/Makefile.am +++ b/src/client/Makefile.am @@ -16,6 +16,7 @@ noinst_HEADERS = \ chat.h \ client.h \ clientext.h \ + closeiconbutton.h \ control.h \ controlsettingsmenu.h \ entitymenu.h \ @@ -57,6 +58,7 @@ libclient_la_SOURCES = \ chat.cc \ client.cc \ clientext.cc \ + closeiconbutton.cc \ control.cc \ controlsettingsmenu.cc \ entitymenu.cc \ diff --git a/src/client/audiosettingsmenu.cc b/src/client/audiosettingsmenu.cc index b09586a..13e6d57 100644 --- a/src/client/audiosettingsmenu.cc +++ b/src/client/audiosettingsmenu.cc @@ -5,6 +5,7 @@ */ #include "client/audiosettingsmenu.h" +#include "client/closeiconbutton.h" #include "core/cvar.h" #include "ui/button.h" #include "ui/checkbox.h" @@ -36,7 +37,7 @@ AudioSettingsMenu::AudioSettingsMenu(ui::Widget *parent, const char *label) : ui _titlelabel->set_text("AUDIO SETTINGS"); // close button - _closebutton = new ui::IconButton(_titlelabel, "bitmaps/icons/window_close"); + _closebutton = new CloseIconButton(_titlelabel); // content frame _frame = new ui::Widget(this); diff --git a/src/client/chat.cc b/src/client/chat.cc index dd71d57..f921e79 100644 --- a/src/client/chat.cc +++ b/src/client/chat.cc @@ -7,6 +7,7 @@ #include "auxiliary/functions.h" #include "client/chat.h" #include "client/client.h" +#include "client/closeiconbutton.h" #include "core/core.h" #include "core/gameinterface.h" #include "sys/sys.h" @@ -35,7 +36,7 @@ Chat::Chat(ui::Widget *parent) : ui::Window(parent) chat_titlelabel->set_text("CHAT"); // close button - chat_closebutton = new ui::IconButton(chat_titlelabel, "bitmaps/icons/window_close"); + chat_closebutton = new CloseIconButton(chat_titlelabel); // player list chat_playerlist = new ui::ListView(this); diff --git a/src/client/closeiconbutton.cc b/src/client/closeiconbutton.cc new file mode 100644 index 0000000..82c37f0 --- /dev/null +++ b/src/client/closeiconbutton.cc @@ -0,0 +1,22 @@ +/* + client/closeiconbutton.cc + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 +*/ + +#include "client/closeiconbutton.h" + +namespace client +{ + +CloseIconButton::CloseIconButton(Widget *parent) : ui::IconButton(parent, "bitmaps/icons/window_close", "Close") +{ + set_label("close"); +} + +CloseIconButton::~CloseIconButton() +{ +} + +} + diff --git a/src/client/closeiconbutton.h b/src/client/closeiconbutton.h new file mode 100644 index 0000000..a822731 --- /dev/null +++ b/src/client/closeiconbutton.h @@ -0,0 +1,28 @@ +/* + client/closeiconbutton.h + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 +*/ + +#ifndef __INCLUDED_CLIENT_CLOSEICONBUTTON_H__ +#define __INCLUDED_CLIENT_CLOSEICONBUTTON_H__ + +#include "ui/iconbutton.h" + +namespace client +{ + +class CloseIconButton : public ui::IconButton +{ + +public: + /** + * @brief Default close button + * */ + CloseIconButton(Widget *parent); + virtual ~CloseIconButton(); +}; + +} + +#endif // __INCLUDED_CLIENT_CLOSEICONBUTTON_H__ diff --git a/src/client/controlsettingsmenu.cc b/src/client/controlsettingsmenu.cc index 4417bf3..bd60fb4 100644 --- a/src/client/controlsettingsmenu.cc +++ b/src/client/controlsettingsmenu.cc @@ -5,6 +5,7 @@ */ #include "client/controlsettingsmenu.h" +#include "client/closeiconbutton.h" #include "client/input.h" #include "ui/button.h" #include "ui/iconbutton.h" @@ -278,7 +279,7 @@ ControlSettingsMenu::ControlSettingsMenu(ui::Widget *parent, const char *label) _titlelabel->set_text("CONTROLS"); // close button - _closebutton = new ui::IconButton(_titlelabel, "bitmaps/icons/window_close"); + _closebutton = new CloseIconButton(_titlelabel); // command listview _controlslistview = new ui::ListView(this); diff --git a/src/client/gamewindow.cc b/src/client/gamewindow.cc index 0b39cea..139755f 100644 --- a/src/client/gamewindow.cc +++ b/src/client/gamewindow.cc @@ -54,20 +54,20 @@ GameWindow::GameWindow(ui::Widget *parent) : ui::Window(parent) gamewindow_chat = new Chat(this); // icon buttons - gamewindow_menubutton = new ui::IconButton(this, "bitmaps/icons/button_menu", "ui_menu"); - - gamewindow_launchbutton = new ui::IconButton(this, "bitmaps/icons/button_launch", "launch"); + gamewindow_menubutton = new ui::IconButton(this, "bitmaps/icons/button_menu", "Menu", "ui_menu"); + gamewindow_launchbutton = new ui::IconButton(this, "bitmaps/icons/button_launch", "Launch", "launch"); + gamewindow_freeflightbutton = new ui::IconButton(this, "bitmaps/icons/button_freeflight", "Cancel Autopilot", "freeflight"); - gamewindow_freeflightbutton = new ui::IconButton(this, "bitmaps/icons/button_freeflight", "freeflight"); - gamewindow_gotobutton = new TargetIconButton(this, "bitmaps/icons/button_goto", "goto"); - gamewindow_dockbutton = new TargetIconButton(this, "bitmaps/icons/button_dock", "dock", core::Entity::Dockable); - gamewindow_formationbutton = new TargetIconButton(this, "bitmaps/icons/button_formation", "formation"); + gamewindow_gotobutton = new TargetIconButton(this, "bitmaps/icons/button_goto", "Goto", "goto"); + gamewindow_dockbutton = new TargetIconButton(this, "bitmaps/icons/button_dock", "Dock", "dock", core::Entity::Dockable); + gamewindow_formationbutton = new TargetIconButton(this, "bitmaps/icons/button_formation", "Formation", "formation"); + gamewindow_formationbutton->set_tooltip("Formation"); - gamewindow_homebutton = new ui::IconButton(this, "bitmaps/icons/button_home", "view main"); - gamewindow_chatbutton = new ui::IconButton(this, "bitmaps/icons/button_chat", "ui_chat"); - gamewindow_mapbutton = new ui::IconButton(this, "bitmaps/icons/button_map", "ui_map"); - gamewindow_inventorybutton = new ui::IconButton(this, "bitmaps/icons/button_ship", "ui_inventory"); - gamewindow_reputationbutton = new ui::IconButton(this, "bitmaps/icons/button_reputation", "ui_reputation"); + gamewindow_homebutton = new ui::IconButton(this, "bitmaps/icons/button_home", "Home", "view main"); + gamewindow_chatbutton = new ui::IconButton(this, "bitmaps/icons/button_chat", "Chat", "ui_chat"); + gamewindow_mapbutton = new ui::IconButton(this, "bitmaps/icons/button_map", "Map", "ui_map"); + gamewindow_inventorybutton = new ui::IconButton(this, "bitmaps/icons/button_ship", "Inventory", "ui_inventory"); + gamewindow_reputationbutton = new ui::IconButton(this, "bitmaps/icons/button_reputation", "Reputation", "ui_reputation"); } GameWindow::~GameWindow() diff --git a/src/client/graphicssettingsmenu.cc b/src/client/graphicssettingsmenu.cc index ab05635..716570a 100644 --- a/src/client/graphicssettingsmenu.cc +++ b/src/client/graphicssettingsmenu.cc @@ -5,6 +5,7 @@ */ #include "client/graphicssettingsmenu.h" +#include "client/closeiconbutton.h" #include "core/cvar.h" #include "ui/button.h" #include "ui/checkbox.h" @@ -34,7 +35,7 @@ GraphicsSettingsMenu::GraphicsSettingsMenu(ui::Widget *parent, const char *label _titlelabel->set_text("GRAPHICS SETTINGS"); // close button - _closebutton = new ui::IconButton(_titlelabel, "bitmaps/icons/window_close"); + _closebutton = new CloseIconButton(_titlelabel); // content frame _frame = new ui::Widget(this); diff --git a/src/client/hudenginestatus.cc b/src/client/hudenginestatus.cc index ab51709..bae1f3f 100644 --- a/src/client/hudenginestatus.cc +++ b/src/client/hudenginestatus.cc @@ -6,6 +6,7 @@ #include "client/input.h" #include "client/hudenginestatus.h" +#include "client/closeiconbutton.h" #include "core/core.h" #include "core/application.h" #include "ui/ui.h" @@ -24,11 +25,11 @@ HUDEngineStatus::HUDEngineStatus(ui::Widget *parent) : ui::Widget(parent) set_background(false); _button_auto_palette = new ui::Palette(*palette()); - _button_auto = new ui::IconButton(this, "bitmaps/hud/button_auto", "freeflight"); + _button_auto = new ui::IconButton(this, "bitmaps/hud/button_auto", "Cancel autopilot", "freeflight"); _button_auto->set_palette(_button_auto_palette); _button_lock_palette = new ui::Palette(*palette()); - _button_lock = new ui::IconButton(this, "bitmaps/hud/button_lock", "ui_control"); + _button_lock = new ui::IconButton(this, "bitmaps/hud/button_lock", "Lock control", "ui_control"); _button_lock->set_palette(_button_lock_palette); } @@ -115,10 +116,12 @@ void HUDEngineStatus::draw() if (control_lock) { _button_lock_palette->set_foreground(math::Color(1.0f, 0.0f, 0.0f)); + _button_lock->set_tooltip("Unlock control"); } else { // free controls _button_lock_palette->set_foreground(palette()->foreground()); + _button_lock->set_tooltip("Lock control"); } // health bar size diff --git a/src/client/inventorywindow.cc b/src/client/inventorywindow.cc index de27d13..09bd71e 100644 --- a/src/client/inventorywindow.cc +++ b/src/client/inventorywindow.cc @@ -6,6 +6,7 @@ #include "core/application.h" #include "client/inventorywindow.h" +#include "client/closeiconbutton.h" #include "ui/label.h" #include "ui/bitmap.h" #include "ui/listitem.h" @@ -63,9 +64,8 @@ InventoryWindow::InventoryWindow(ui::Widget *parent) : ui::Window(parent) inventorywindow_inventorytext->set_font(ui::root()->font_small()); inventorywindow_inventorytext->set_alignment(ui::AlignLeft | ui::AlignTop); - inventorywindow_shipbutton = new ui::IconButton(this, "bitmaps/icons/button_ship"); - inventorywindow_ejectbutton = new ui::IconButton(this, "bitmaps/icons/button_eject"); - //inventorywindow_mountbutton = new ui::IconButton(this, "bitmaps/icons/button_mount"); + inventorywindow_shipbutton = new ui::IconButton(this, "bitmaps/icons/button_ship", "Ship info"); + inventorywindow_ejectbutton = new ui::IconButton(this, "bitmaps/icons/button_eject", "Eject cargo"); // window title inventorywindow_titlelabel = new ui::Label(this); @@ -77,7 +77,7 @@ InventoryWindow::InventoryWindow(ui::Widget *parent) : ui::Window(parent) inventorywindow_titlelabel->set_text("INVENTORY"); // close button - inventorywindow_closebutton = new ui::IconButton(inventorywindow_titlelabel, "bitmaps/icons/window_close"); + inventorywindow_closebutton = new CloseIconButton(inventorywindow_titlelabel); // eject dialog inventorywindow_ejectconfirmbutton = new ui::Button(inventorywindow_scrollpane, "Eject"); @@ -146,24 +146,26 @@ void InventoryWindow::update_inventory() listitem->set_sortkey(sortkey); if (item->has_flag(core::Item::Mounted)) { - // unmount button - ui::IconButton *ismounted_button = new ui::IconButton(listitem, "bitmaps/icons/button_mount"); + // wepaon is mounted, show the unmount button + ui::IconButton *ismounted_button = new ui::IconButton(listitem, "bitmaps/icons/button_unmount"); std::ostringstream strcmd; strcmd << "remote mount " << item->id(); ismounted_button->set_command(strcmd.str()); ismounted_button->set_background(true); ismounted_button->set_size(icon_size, icon_size); ismounted_button->set_location(ui::UI::elementsize.width() - icon_size - padding, padding); + ismounted_button->set_tooltip("Unmount weapon"); } else if (item->has_flag(core::Item::Mountable)) { - // mount button - ui::IconButton *isunmounted_button = new ui::IconButton(listitem, "bitmaps/icons/button_unmount"); + // weapon is not mounted, show mount button + ui::IconButton *isunmounted_button = new ui::IconButton(listitem, "bitmaps/icons/button_mount"); std::ostringstream strcmd; strcmd << "remote mount " << item->id(); isunmounted_button->set_command(strcmd.str()); isunmounted_button->set_background(true); isunmounted_button->set_size(icon_size, icon_size); isunmounted_button->set_location(ui::UI::elementsize.width() - icon_size - padding, padding); + isunmounted_button->set_tooltip("Mount weapon"); } // preserve previous selection during update diff --git a/src/client/mapwindow.cc b/src/client/mapwindow.cc index 3dbb1fb..de49ad9 100644 --- a/src/client/mapwindow.cc +++ b/src/client/mapwindow.cc @@ -5,18 +5,23 @@ the terms of the GNU General Public License version 2 */ -#include "audio/audio.h" -#include "core/application.h" -#include "core/entity.h" -#include "core/entityglobe.h" #include "client/mapwindow.h" #include "client/targets.h" +#include "client/closeiconbutton.h" + #include "ui/ui.h" #include "ui/paint.h" + #include "render/gl.h" #include "render/textures.h" #include "render/text.h" +#include "audio/audio.h" + +#include "core/application.h" +#include "core/entity.h" +#include "core/entityglobe.h" + namespace client { @@ -82,8 +87,8 @@ MapWindow::MapWindow(ui::Widget *parent) : ui::Window(parent) mapwindow_maplabel->set_alignment(ui::AlignCenter); // map buttons - mapwindow_zonebutton = new ui::IconButton(mapwindow_pane_left, "bitmaps/icons/button_map"); - mapwindow_galaxybutton = new ui::IconButton(mapwindow_pane_left, "bitmaps/icons/button_galaxy"); + mapwindow_zonebutton = new ui::IconButton(mapwindow_pane_left, "bitmaps/icons/button_map", "Zone map"); + mapwindow_galaxybutton = new ui::IconButton(mapwindow_pane_left, "bitmaps/icons/button_galaxy", "Galaxy map"); // ---- window title mapwindow_titlelabel = new ui::Label(this); @@ -95,10 +100,8 @@ MapWindow::MapWindow(ui::Widget *parent) : ui::Window(parent) mapwindow_titlelabel->set_text("STAR CHART"); // close button - mapwindow_closebutton = new ui::IconButton(mapwindow_titlelabel, "bitmaps/icons/window_close"); + mapwindow_closebutton = new CloseIconButton(mapwindow_titlelabel); - - hide(); } diff --git a/src/client/playersettingsmenu.cc b/src/client/playersettingsmenu.cc index b8992cb..d09b269 100644 --- a/src/client/playersettingsmenu.cc +++ b/src/client/playersettingsmenu.cc @@ -5,6 +5,7 @@ */ #include "client/playersettingsmenu.h" +#include "client/closeiconbutton.h" #include "core/cvar.h" #include "ui/button.h" #include "ui/colorpicker.h" @@ -34,7 +35,7 @@ PlayerSettingsMenu::PlayerSettingsMenu(ui::Widget *parent, const char *label) : _titlelabel->set_text("PLAYER SETTINGS"); // close button - _closebutton = new ui::IconButton(_titlelabel, "bitmaps/icons/window_close"); + _closebutton = new CloseIconButton(_titlelabel); // content frame _frame = new ui::Widget(this); diff --git a/src/client/reputationwindow.cc b/src/client/reputationwindow.cc index e60b384..cbda138 100644 --- a/src/client/reputationwindow.cc +++ b/src/client/reputationwindow.cc @@ -4,14 +4,14 @@ the terms of the GNU General Public License version 2 */ -#include - -#include "ui/paint.h" -#include "ui/ui.h" #include "client/client.h" #include "client/reputationwindow.h" +#include "client/closeiconbutton.h" +#include "ui/paint.h" +#include "ui/ui.h" #include "core/reputation.h" #include "core/range.h" +#include namespace client { @@ -110,7 +110,7 @@ ReputationWindow::ReputationWindow(ui::Widget *parent) : ui::Window(parent) reputationwindow_titlelabel->set_text("REPUTATION"); // close button - reputationwindow_closebutton = new ui::IconButton(reputationwindow_titlelabel, "bitmaps/icons/window_close"); + reputationwindow_closebutton = new CloseIconButton(reputationwindow_titlelabel); // reputation listview reputationwindow_listview = new ui::ListView(this); diff --git a/src/client/savegamemenu.cc b/src/client/savegamemenu.cc index 1b47101..ce62247 100644 --- a/src/client/savegamemenu.cc +++ b/src/client/savegamemenu.cc @@ -4,25 +4,31 @@ the terms of the GNU General Public License version 2 */ -#include -#include - -#include "core/application.h" -#include "core/gameinterface.h" -#include "core/gameserver.h" -#include "model/material.h" #include "client/savegamemenu.h" +#include "client/closeiconbutton.h" #include "client/video.h" -#include "filesystem/filesystem.h" + +#include "ui/ui.h" + +#include "model/material.h" + #include "render/screenshot.h" #include "render/camera.h" #include "render/draw.h" #include "render/textures.h" #include "render/gl.h" -#include "ui/ui.h" +#include "filesystem/filesystem.h" + +#include "core/application.h" +#include "core/gameinterface.h" +#include "core/gameserver.h" + #include "sys/sys.h" +#include +#include + namespace client { @@ -50,9 +56,8 @@ SaveGameMenu::SaveGameMenu(ui::Widget *parent, const char *label, const Mode mod } // close button - savegamemenu_closebutton = new ui::IconButton(savegamemenu_titlelabel, "bitmaps/icons/window_close"); - savegamemenu_closebutton->set_label("close"); - + savegamemenu_closebutton = new CloseIconButton(savegamemenu_titlelabel); + // file listview savegamemenu_filelistview = new ui::ListView(this); savegamemenu_filelistview->set_label("files"); @@ -81,7 +86,7 @@ SaveGameMenu::SaveGameMenu(ui::Widget *parent, const char *label, const Mode mod savegamemenu_savebutton->set_label("save"); // delete button - savegamemenu_deletebutton = new ui::IconButton(this, "bitmaps/icons/button_delete"); + savegamemenu_deletebutton = new ui::IconButton(this, "Delete", "bitmaps/icons/button_delete"); savegamemenu_deletebutton->set_label("delete"); // cancel save/load/overwrite button diff --git a/src/client/targeticonbutton.cc b/src/client/targeticonbutton.cc index ebd5ec3..27dfd0e 100644 --- a/src/client/targeticonbutton.cc +++ b/src/client/targeticonbutton.cc @@ -12,12 +12,17 @@ namespace client { -TargetIconButton::TargetIconButton(Widget *parent, const char *icon, const char *command, unsigned int flags) : IconButton(parent, icon, command) +TargetIconButton::TargetIconButton(Widget *parent, const char *icon, const char *tooltip, const char *command, unsigned int flags) : IconButton(parent, icon, tooltip, command) { set_label("targeticonbutton"); entity_flags = flags; } +TargetIconButton::~TargetIconButton() +{ + entity_flags = 0; +} + bool TargetIconButton::on_mousepress(const unsigned int button) { if (button == SDL_BUTTON_LEFT) diff --git a/src/client/targeticonbutton.h b/src/client/targeticonbutton.h index cb6a147..ccc3baf 100644 --- a/src/client/targeticonbutton.h +++ b/src/client/targeticonbutton.h @@ -17,7 +17,8 @@ class TargetIconButton : public ui::IconButton public: /// special icon button that sends target '@' commands. - TargetIconButton(Widget *parent, const char *icon, const char *command, unsigned int flags = 0); + TargetIconButton(Widget *parent, const char *icon, const char *tooltip = 0, const char *command = 0, unsigned int flags = 0); + virtual ~TargetIconButton(); protected: /** diff --git a/src/client/testmodelwindow.cc b/src/client/testmodelwindow.cc index d70fbbf..9778102 100644 --- a/src/client/testmodelwindow.cc +++ b/src/client/testmodelwindow.cc @@ -4,10 +4,14 @@ the terms and conditions of the GNU General Public License version 2 */ +#include "client/testmodelwindow.h" +#include "client/closeiconbutton.h" + #include "ui/ui.h" #include "ui/paint.h" -#include "client/testmodelwindow.h" + #include "model/model.h" + #include "core/gameinterface.h" namespace client @@ -26,9 +30,9 @@ TestModelWindow::TestModelWindow(ui::Widget *parent) testmodelwindow_text->set_background(false); testmodelwindow_text->set_border(false); - testmodelwindow_wireframebutton = new ui::IconButton(this, "bitmaps/icons/button_wireframe", "toggle r_wireframe"); + testmodelwindow_wireframebutton = new ui::IconButton(this, "bitmaps/icons/button_wireframe", "Toggle wireframe", "toggle r_wireframe"); - testmodelwindow_normalsbutton = new ui::IconButton(this, "bitmaps/icons/button_normals", "toggle r_normals"); + testmodelwindow_normalsbutton = new ui::IconButton(this, "bitmaps/icons/button_normals", "Toggle normals", "toggle r_normals"); testmodelwindow_closebutton = new ui::Button(this); testmodelwindow_closebutton->set_text("Close"); diff --git a/src/client/trademenu.cc b/src/client/trademenu.cc index a16c5c4..62ad972 100644 --- a/src/client/trademenu.cc +++ b/src/client/trademenu.cc @@ -4,16 +4,19 @@ the terms of the GNU General Public License version 2 */ -#include +#include "client/trademenu.h" +#include "client/closeiconbutton.h" -#include "core/application.h" -#include "core/info.h" -#include "core/inventory.h" #include "ui/button.h" #include "ui/paint.h" #include "ui/ui.h" #include "ui/listitem.h" -#include "client/trademenu.h" + +#include "core/application.h" +#include "core/info.h" +#include "core/inventory.h" + +#include namespace client { @@ -76,7 +79,7 @@ TradeMenu::TradeMenu(ui::Widget *parent, const char * label) : ui::Window(parent menu_titlelabel->show(); // close button - menu_closebutton = new ui::IconButton(menu_titlelabel, "bitmaps/icons/window_close"); + menu_closebutton = new CloseIconButton(menu_titlelabel); menu_inventorylistview = new InventoryListView(menu_tradewindow); menu_inventorylistview->set_label("inventorylistview"); -- cgit v1.2.3