diff --git a/data/core/images/themes/classic/menubar.png b/data/core/images/themes/classic/menubar.png index 4f5f454b5cb3c..9e2543d08c8cf 100644 Binary files a/data/core/images/themes/classic/menubar.png and b/data/core/images/themes/classic/menubar.png differ diff --git a/data/gui/window/game_ui.cfg b/data/gui/window/game_ui.cfg new file mode 100644 index 0000000000000..17ce7493ec4e3 --- /dev/null +++ b/data/gui/window/game_ui.cfg @@ -0,0 +1,534 @@ +#textdomain wesnoth-lib +### +### Definition of the main game interface. +### + +# GUI_FORCE_WIDGET_MINIMUM_SIZE + +#define _GUI_MENUBAR_STATUS_DISPLAY _ID _ICON _LABEL + [column] + grow_factor = 0 + horizontal_grow = true + + {GUI_FORCE_WIDGET_MINIMUM_SIZE 120 0 ( + [grid] + + [row] + + [column] + grow_factor = 0 + border = "all" + border_size = 5 + horizontal_alignment = "left" + + [image] + definition = "default" + label = {_ICON} + ".png" + [/image] + + [/column] + + [column] + grow_factor = 1 + border = "all" + border_size = 5 + horizontal_grow = true + + [label] + id = {_ID} + definition = "default_small" + label = {_LABEL} + [/label] + + [/column] + + [/row] + + [/grid] + )} + [/column] +#enddef + +#define _GUI_MENUBAR + [stacked_widget] + id = "menubar_stack" + + [layer] + + [row] + grow_factor = 1 + + [column] + grow_factor = 1 + horizontal_grow = true + vertical_alignment = "top" + + [image] + id = "menubar_bg" + definition = "tiled_to_size" + label = "themes/classic/menubar.png" + [/image] + + [/column] + + [/row] + + [/layer] + + [layer] + + [row] + grow_factor = 1 + + # + # Menu buttons + # + + [column] + grow_factor = 0 + border = "right" + border_size = 5 + horizontal_alignment = "left" + + [button] + id = "menu" + definition = "default" + label = "Menu" + [/button] + + [/column] + + [column] + grow_factor = 0 + border = "right" + border_size = 5 + horizontal_alignment = "left" + + [button] + id = "actions" + definition = "default" + label = "Actions" + [/button] + + [/column] + + # + # Status panels + # + + # TODO: remove hardcoded label examples + {_GUI_MENUBAR_STATUS_DISPLAY "turns" "flags/loyalist-flag-icon" "0/00" } + {_GUI_MENUBAR_STATUS_DISPLAY "gold" "themes/gold" "000" } + {_GUI_MENUBAR_STATUS_DISPLAY "villages" "themes/villages" "0/00" } + {_GUI_MENUBAR_STATUS_DISPLAY "units" "themes/units" "00" } + {_GUI_MENUBAR_STATUS_DISPLAY "upkeep" "themes/upkeep" "00" } + {_GUI_MENUBAR_STATUS_DISPLAY "income" "themes/income" "00" } + {_GUI_MENUBAR_STATUS_DISPLAY "time" "themes/sand-clock" "00:00"} + + [column] + grow_factor = 1 + + [spacer] + [/spacer] + + [/column] + + [/row] + + [/layer] + + [/stacked_widget] +#enddef + +#define _GUI_MINIMAP_PANEL + [stacked_widget] + id = "menubar_stack" + + [layer] + + [row] + grow_factor = 1 + + [column] + grow_factor = 1 + horizontal_grow = true + vertical_alignment = "top" + + [image] + id = "minmap_panel_bg" + definition = "default" + label = "themes/classic/minimap.png" + [/image] + + [/column] + + [/row] + + [/layer] + + [layer] + + [row] + grow_factor = 1 + + [column] + border = "all" + border_size = 5 + horizontal_grow = true + vertical_grow = true + + [minimap] + id = "minimap" + definition = "default" + [/minimap] + + [/column] + + [/row] + + [row] + grow_factor = 0 + + [column] + horizontal_grow = true + + [grid] + + [row] + + [column] + grow_factor = 1 + + [toggle_button] + id = "" + definition = "icon_medium" + icon = "icons/action/zoomdefault_25.png" + [/toggle_button] + + [/column] + + [column] + grow_factor = 0 + + [toggle_button] + id = "" + definition = "icon_medium" + icon = "icons/action/minimap-draw-terrain_25.png" + [/toggle_button] + + [/column] + + [column] + grow_factor = 0 + + [toggle_button] + id = "" + definition = "icon_medium" + icon = "icons/action/editor-tool-unit_25.png" + [/toggle_button] + + [/column] + + [column] + grow_factor = 0 + + [toggle_button] + id = "" + definition = "icon_medium" + icon = "icons/action/editor-tool-village_25.png" + [/toggle_button] + + [/column] + + [column] + grow_factor = 0 + + [toggle_button] + id = "" + definition = "icon_medium" + icon = "icons/action/minimap-unit-coding_25.png" + [/toggle_button] + + [/column] + + [column] + grow_factor = 1 + + [toggle_button] + id = "" + definition = "icon_medium" + icon = "icons/action/minimap-terrain-coding_25.png" + [/toggle_button] + + [/column] + + [/row] + + [/grid] + + [/column] + + [/row] + + [/layer] + + [/stacked_widget] +#enddef + +#define _GUI_SIDEBAR_DATA_PANEL _WIDTH _HEIGHT _WML + [column] + border = "all" + border_size = 10 + horizontal_grow = true + vertical_alignment = "top" + + {GUI_FORCE_WIDGET_SIZE {_WIDTH} {_HEIGHT} ( + [panel] + # TODO: nicer definition + definition = "box_display_no_blur_no_border" + + [grid] + {_WML} + [/grid] + + [/panel] + )} + + [/column] +#enddef + +#define _GUI_SIDEBAR + [stacked_widget] + id = "sidebar_stack" + + [layer] + + [row] + grow_factor = 1 + + [column] + grow_factor = 1 + horizontal_alignment = "right" + vertical_grow = true + + [image] + id = "sidebar_bg" + definition = "tiled_to_size" + label = "themes/classic/sidebar.png" + [/image] + + [/column] + + [/row] + + [/layer] + + [layer] + + [row] + grow_factor = 0 + + [column] + grow_factor = 1 + border = "top,bottom" + border_size = 5 + horizontal_grow = true + vertical_alignment = "top" + + {_GUI_MINIMAP_PANEL} + + [/column] + + [/row] + + [row] + grow_factor = 0 + + {_GUI_SIDEBAR_DATA_PANEL 0 50 ()} + + [/row] + + [row] + grow_factor = 0 + + {_GUI_SIDEBAR_DATA_PANEL 0 60 ( + + [row] + grow_factor = 1 + + [column] + horizontal_grow = true + vertical_grow = true + + [image] + definition = "scaled_to_size" + label = "misc/time-schedules/default/schedule-dawn.png" + [/image] + + [/column] + + [/row] + + )} + + [/row] + + [row] + grow_factor = 1 + + # FIXME.. + [column] + border = "all" + border_size = 10 + horizontal_alignment = "left" + vertical_alignment = "top" + + {GUI_FORCE_WIDGET_SIZE 74 74 ( + [panel] + definition = "box_display_no_blur_no_border" + + [grid] + [/grid] + + [/panel] + )} + + [/column] + + [/row] + + [/layer] + + [/stacked_widget] +#enddef + +[window_definition] + id = "game_ui_window" + description = "Main game UI window definition." + + [resolution] + + [background] + + [draw] + + [image] + x = 0 + y = 0 + w = "(width)" + h = "(height)" + + # TODO: use WFL variable if we want to import theme. + name = "terrain/off-map/background.png" + resize_mode = "tile" + [/image] + + [/draw] + + [/background] + + [foreground] + + [draw] + + [/draw] + + [/foreground] + + [/resolution] + +[/window_definition] + +[window] + id = "game_ui" + description = "Main game UI." + + [resolution] + definition = "game_ui_window" + + {GUI_WINDOW_FULLSCREEN} + + [tooltip] + id = "tooltip_large" + [/tooltip] + + [helptip] + id = "tooltip_large" + [/helptip] + + [grid] + + [row] + + [column] + grow_factor = 1 + horizontal_grow = true + vertical_grow = true + + [grid] + + [row] + grow_factor = 0 + + [column] + grow_factor = 1 + horizontal_grow = true + vertical_alignment = "top" + + {_GUI_MENUBAR} + + [/column] + + [/row] + + [row] + grow_factor = 1 + + [column] + horizontal_grow = true + vertical_grow = true + + [viewport] + definition = "default" + + [widget] + + # TODO: actual gamemap goes here. + [spacer] + definition = "default" + [/spacer] + + [/widget] + + [/viewport] + + [/column] + + [/row] + + [/grid] + + [/column] + + [column] + grow_factor = 0 + horizontal_alignment = "right" + vertical_grow = true + + {_GUI_SIDEBAR} + + [/column] + + [/row] + + [/grid] + + [/resolution] + +[/window] + +#undef _GUI_MENUBAR +#undef _GUI_MENUBAR_STATUS_DISPLAY +#undef _GUI_MINIMAP_PANEL +#undef _GUI_SIDEBAR +#undef _GUI_SIDEBAR_DATA_PANEL diff --git a/projectfiles/CodeBlocks/wesnoth.cbp b/projectfiles/CodeBlocks/wesnoth.cbp index 0e729e4121cae..0eb9f3752fc76 100644 --- a/projectfiles/CodeBlocks/wesnoth.cbp +++ b/projectfiles/CodeBlocks/wesnoth.cbp @@ -582,6 +582,8 @@ + + diff --git a/source_lists/wesnoth b/source_lists/wesnoth index 6ce15a3a2fa69..fb6237a0d0712 100644 --- a/source_lists/wesnoth +++ b/source_lists/wesnoth @@ -195,6 +195,7 @@ gui/dialogs/game_delete.cpp gui/dialogs/game_load.cpp gui/dialogs/game_save.cpp gui/dialogs/game_stats.cpp +gui/dialogs/game_ui.cpp gui/dialogs/game_version.cpp gui/dialogs/gamestate_inspector.cpp gui/dialogs/help_browser.cpp diff --git a/src/gui/dialogs/game_ui.cpp b/src/gui/dialogs/game_ui.cpp new file mode 100644 index 0000000000000..b8496660af2b8 --- /dev/null +++ b/src/gui/dialogs/game_ui.cpp @@ -0,0 +1,56 @@ +/* + Copyright (C) 2017 by Charles Dang + Part of the Battle for Wesnoth Project http://www.wesnoth.org/ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY. + + See the COPYING file for more details. +*/ + +#define GETTEXT_DOMAIN "wesnoth-lib" + +#include "gui/dialogs/game_ui.hpp" + +#include "gui/auxiliary/find_widget.hpp" +#include "gui/widgets/label.hpp" +#include "gui/widgets/minimap.hpp" +#include "gui/widgets/settings.hpp" +#include "gui/widgets/window.hpp" + +#include "display.hpp" +#include "formula/variant.hpp" +#include "game_config_manager.hpp" +#include "gettext.hpp" + +namespace gui2 +{ +namespace dialogs +{ +REGISTER_DIALOG(game_ui) + +game_ui::game_ui() + : disp_(display::get_singleton()) + , game_config_(game_config_manager::get()->game_config()) + , scenario_(game_config_.child("scenario")) +{ +} + +void game_ui::pre_show(window& window) +{ + minimap& mmap = find_widget(&window, "minimap", false); + + mmap.set_config(&game_config_); + mmap.set_map_data(scenario_["map_data"].str()); +} + +void game_ui::post_show(window& /*window*/) +{ +} + +} // namespace dialogs +} // namespace gui2 diff --git a/src/gui/dialogs/game_ui.hpp b/src/gui/dialogs/game_ui.hpp new file mode 100644 index 0000000000000..2eaee76c3cad7 --- /dev/null +++ b/src/gui/dialogs/game_ui.hpp @@ -0,0 +1,57 @@ +/* + Copyright (C) 2017 by Charles Dang + Part of the Battle for Wesnoth Project http://www.wesnoth.org/ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY. + + See the COPYING file for more details. +*/ + +#pragma once + +#include "gui/dialogs/modal_dialog.hpp" + +class config; +class CVideo; +class display; + +namespace gui2 +{ +namespace dialogs +{ +class game_ui : public modal_dialog +{ +public: + game_ui(); + + static void display(CVideo& video) + { + game_ui().show(video); + } + +private: + /** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */ + virtual const std::string& window_id() const override; + + /** Inherited from modal_dialog. */ + virtual void pre_show(window& window) override; + + /** Inherited from modal_dialog. */ + virtual void post_show(window& window) override; + + ::display* disp_; // TODO: needed? + + /** Reference to the entire master game config object. */ + const config& game_config_; + + /** Reference to the current scenario's config. */ + const config& scenario_; +}; + +} // namespace dialogs +} // namespace gui2 diff --git a/src/playsingle_controller.cpp b/src/playsingle_controller.cpp index c4ad3c608d0c4..8a9ce9b4c4411 100644 --- a/src/playsingle_controller.cpp +++ b/src/playsingle_controller.cpp @@ -29,6 +29,7 @@ #include "game_events/pump.hpp" #include "preferences/game.hpp" #include "gettext.hpp" +#include "gui/dialogs/game_ui.hpp" #include "gui/dialogs/story_viewer.hpp" #include "gui/dialogs/transient_message.hpp" #include "hotkey/hotkey_handler_sp.hpp" @@ -244,6 +245,10 @@ LEVEL_RESULT playsingle_controller::play_scenario(const config& level) gui2::dialogs::story_viewer::display(get_scenario_name(), cfg, gui_->video()); } } + + // FIXME + gui2::dialogs::game_ui::display(gui_->video()); + gui_->labels().read(level); // Read sound sources