Game settings loading is now deferred until the game is fully loading.

This allows auto replaces to be properly loaded from the game file.


git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1295 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
coppro
2009-01-07 00:20:10 +00:00
parent 018b6a6c6b
commit cf4aea531d
4 changed files with 57 additions and 49 deletions
+5 -1
View File
@@ -81,7 +81,11 @@ GameSettings::GameSettings()
{} {}
void GameSettings::initDefaults(const Game& game) { void GameSettings::initDefaults(const Game& game) {
if (initialized) return; // Defer initialization until the game is fully loaded.
// This prevents data that needs to be initialized from
// being accessed from the new set window, but removes
// the need to load the entire file, which takes too long.
if (initialized || !game.isFullyLoaded()) return;
initialized = true; initialized = true;
// init auto_replaces, copy from game file // init auto_replaces, copy from game file
FOR_EACH_CONST(ar, game.auto_replaces) { FOR_EACH_CONST(ar, game.auto_replaces) {
+2 -2
View File
@@ -81,7 +81,7 @@ AutoReplaceList::AutoReplaceList(Window* parent, int id, const Game& game)
items.push_back(ar->clone()); items.push_back(ar->clone());
} }
// Add columns // Add columns
InsertColumn(0, _LABEL_(""), wxLIST_FORMAT_LEFT, 0); // dummy, prevent the image from taking up space InsertColumn(0, _(""), wxLIST_FORMAT_LEFT, 0); // dummy, prevent the image from taking up space
InsertColumn(1, _LABEL_("auto match"), wxLIST_FORMAT_LEFT, 100); InsertColumn(1, _LABEL_("auto match"), wxLIST_FORMAT_LEFT, 100);
InsertColumn(2, _LABEL_("auto replace"), wxLIST_FORMAT_LEFT, 200); InsertColumn(2, _LABEL_("auto replace"), wxLIST_FORMAT_LEFT, 200);
// grey for disabled items // grey for disabled items
@@ -143,7 +143,7 @@ String AutoReplaceList::OnGetItemText (long pos, long col) const {
if (col == 0) return ar->match; if (col == 0) return ar->match;
if (col == 1) return ar->match; if (col == 1) return ar->match;
if (col == 2) return ar->replace; if (col == 2) return ar->replace;
throw InternalError(_("too mana columns")); throw InternalError(_("too many columns"));
} }
int AutoReplaceList::OnGetItemImage(long pos) const { int AutoReplaceList::OnGetItemImage(long pos) const {
+4
View File
@@ -231,6 +231,10 @@ class Packaged : public Package {
/** This is done to force people to fill in the dependencies */ /** This is done to force people to fill in the dependencies */
void requireDependency(Packaged* package); void requireDependency(Packaged* package);
inline bool isFullyLoaded () const {
return fully_loaded;
}
protected: protected:
/// filename of the data file, and extension of the package file /// filename of the data file, and extension of the package file
virtual String typeName() const = 0; virtual String typeName() const = 0;