widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #01494
[Merge] lp:~widelands-dev/widelands/wareslist_sizes into lp:widelands
cghislai has proposed merging lp:~widelands-dev/widelands/wareslist_sizes into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1205609 in widelands: "Wincondition scripts reloaded too often"
https://bugs.launchpad.net/widelands/+bug/1205609
Bug #1205806 in widelands: "Ware statistics window too small for empire warelist"
https://bugs.launchpad.net/widelands/+bug/1205806
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/wareslist_sizes/+merge/178257
This changes the max height for wares list wrapping so that it wraps nice at 800x600 in order to display all the whole ware statistics window. No wrapping occurs at 1024*768. I moved the code to do so from the ware display window to the tribe loading, as it makes much more sense imho.
I also added a small fix to not create a game object each time a replay as preloaded. Instead, the one created in wlapplication is passed in, similar to what is done in the load game menu.
--
https://code.launchpad.net/~widelands-dev/widelands/wareslist_sizes/+merge/178257
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/wareslist_sizes into lp:widelands.
=== modified file 'src/logic/editor_game_base.cc'
--- src/logic/editor_game_base.cc 2013-07-31 17:00:28 +0000
+++ src/logic/editor_game_base.cc 2013-08-02 14:23:27 +0000
@@ -34,6 +34,7 @@
#include "logic/findimmovable.h"
#include "logic/game.h"
#include "logic/instances.h"
+#include "logic/item_ware_descr.h"
#include "logic/mapregion.h"
#include "logic/player.h"
#include "logic/roadtype.h"
@@ -166,6 +167,9 @@
map().load_world();
assert(map().get_world());
Tribe_Descr & result = *new Tribe_Descr(tribe, *this);
+ //resize the configuration of our wares if they won't fit in the current window (12 = info label size)
+ int number = (g_gr->get_yres() - 270) / (WARE_MENU_PIC_HEIGHT + WARE_MENU_PIC_PAD_Y + 12);
+ result.resize_ware_orders(number);
m_tribes.push_back(&result);
return result;
}
=== modified file 'src/ui_fsmenu/loadreplay.cc'
--- src/ui_fsmenu/loadreplay.cc 2013-07-31 17:09:15 +0000
+++ src/ui_fsmenu/loadreplay.cc 2013-08-02 14:23:27 +0000
@@ -30,7 +30,7 @@
#include "timestring.h"
#include "ui_basic/messagebox.h"
-Fullscreen_Menu_LoadReplay::Fullscreen_Menu_LoadReplay() :
+Fullscreen_Menu_LoadReplay::Fullscreen_Menu_LoadReplay(Widelands::Game & g) :
Fullscreen_Menu_Base("choosemapmenu.jpg"),
// Values for alignment and size
@@ -82,7 +82,8 @@
m_ta_players
(this, get_w() * 71 / 100, get_h() * 41 / 100),
m_ta_win_condition
- (this, get_w() * 71 / 100, get_h() * 9 / 20)
+ (this, get_w() * 71 / 100, get_h() * 9 / 20),
+ m_game(g)
{
m_back.sigclicked.connect(boost::bind(&Fullscreen_Menu_LoadReplay::end_modal, boost::ref(*this), 0));
m_ok.sigclicked.connect(boost::bind(&Fullscreen_Menu_LoadReplay::clicked_ok, boost::ref(*this)));
@@ -171,11 +172,10 @@
if (m_list.has_selection()) {
std::string name = m_list.get_selected() + WLGF_SUFFIX;
- Widelands::Game game;
Widelands::Game_Preload_Data_Packet gpdp;
try {
- Widelands::Game_Loader gl(name, game);
+ Widelands::Game_Loader gl(name, m_game);
gl.preload_game(gpdp);
} catch (const _wexception & e) {
log("Replay '%s' must have changed from under us\nException: %s\n", name.c_str(), e.what());
@@ -215,6 +215,7 @@
g_fs->FindFiles(REPLAY_DIR, "*" REPLAY_SUFFIX, &files, 1);
+ Widelands::Game_Preload_Data_Packet gpdp;
for
(filenameset_t::iterator pname = files.begin();
pname != files.end();
@@ -226,9 +227,7 @@
continue;
try {
- Widelands::Game_Preload_Data_Packet gpdp;
- Widelands::Game game;
- Widelands::Game_Loader gl(savename, game);
+ Widelands::Game_Loader gl(savename, m_game);
gl.preload_game(gpdp);
m_list.add
=== modified file 'src/ui_fsmenu/loadreplay.h'
--- src/ui_fsmenu/loadreplay.h 2013-07-26 20:19:36 +0000
+++ src/ui_fsmenu/loadreplay.h 2013-08-02 14:23:27 +0000
@@ -25,12 +25,13 @@
#include "ui_basic/listselect.h"
#include "ui_basic/textarea.h"
-
+namespace Widelands
+{struct Game;}
/**
* Select a replay from a list of replays.
*/
struct Fullscreen_Menu_LoadReplay : public Fullscreen_Menu_Base {
- Fullscreen_Menu_LoadReplay();
+ Fullscreen_Menu_LoadReplay(Widelands::Game &);
const std::string & filename() {return m_filename;}
@@ -51,16 +52,17 @@
UI::Button m_back;
UI::Button m_ok;
UI::Button m_delete;
- UI::Listselect<std::string> m_list;
- UI::Textarea m_title;
- UI::Textarea m_label_mapname;
- UI::Textarea m_tamapname;
- UI::Textarea m_label_gametime;
- UI::Textarea m_tagametime;
- UI::Textarea m_label_players;
- UI::Textarea m_ta_players;
- UI::Textarea m_ta_win_condition;
- std::string m_filename;
+ UI::Listselect<std::string> m_list;
+ UI::Textarea m_title;
+ UI::Textarea m_label_mapname;
+ UI::Textarea m_tamapname;
+ UI::Textarea m_label_gametime;
+ UI::Textarea m_tagametime;
+ UI::Textarea m_label_players;
+ UI::Textarea m_ta_players;
+ UI::Textarea m_ta_win_condition;
+ std::string m_filename;
+ Widelands::Game & m_game;
};
=== modified file 'src/wlapplication.cc'
--- src/wlapplication.cc 2013-07-30 08:58:02 +0000
+++ src/wlapplication.cc 2013-08-02 14:23:27 +0000
@@ -84,12 +84,12 @@
#include "wui/interactive_player.h"
#include "wui/interactive_spectator.h"
-#ifndef NDEBUG
+#ifndef NDEBUG
#ifndef _WIN32
int32_t WLApplication::pid_me = 0;
int32_t WLApplication::pid_peer = 0;
volatile int32_t WLApplication::may_run = 0;
-#endif
+#endif
#endif
#define MINIMUM_DISK_SPACE 250000000lu
@@ -2204,15 +2204,15 @@
*/
void WLApplication::replay()
{
+ Widelands::Game game;
if (m_filename.empty()) {
- Fullscreen_Menu_LoadReplay rm;
+ Fullscreen_Menu_LoadReplay rm(game);
if (rm.run() <= 0)
return;
m_filename = rm.filename();
}
- Widelands::Game game;
try {
UI::ProgressWindow loaderUI;
std::vector<std::string> tipstext;
=== modified file 'src/wui/waresdisplay.cc'
--- src/wui/waresdisplay.cc 2013-07-26 20:19:36 +0000
+++ src/wui/waresdisplay.cc 2013-08-02 14:23:27 +0000
@@ -72,10 +72,6 @@
m_selection_anchor(Widelands::Ware_Index::Null()),
m_callback_function(callback_function)
{
- //resize the configuration of our wares if they won't fit in the current window
- int number = (g_gr->get_yres() - 160) / (WARE_MENU_PIC_HEIGHT + WARE_MENU_INFO_SIZE + WARE_MENU_PIC_PAD_Y);
- const_cast<Widelands::Tribe_Descr &>(m_tribe).resize_ware_orders(number);
-
// Find out geometry from icons_order
unsigned int columns = icons_order().size();
unsigned int rows = 0;
Follow ups