Grid and background image settings are now saved along with the map

This commit is contained in:
codeimp 2009-02-23 18:23:39 +00:00
parent f647a899f0
commit 8336309dc8
3 changed files with 41 additions and 0 deletions

View file

@ -124,6 +124,36 @@ namespace CodeImp.DoomBuilder.Editing
#region ================== Methods
// Write settings to configuration
internal void WriteToConfig(Configuration cfg, string path)
{
// Write settings
cfg.WriteSetting(path + ".background", background);
cfg.WriteSetting(path + ".backsource", backsource);
cfg.WriteSetting(path + ".backoffsetx", backoffsetx);
cfg.WriteSetting(path + ".backoffsety", backoffsety);
cfg.WriteSetting(path + ".backscalex", backscalex);
cfg.WriteSetting(path + ".backscaley", backscaley);
cfg.WriteSetting(path + ".gridsize", gridsize);
}
// Read settings from configuration
internal void ReadFromConfig(Configuration cfg, string path)
{
// Read settings
background = cfg.ReadSetting(path + ".background", "");
backsource = cfg.ReadSetting(path + ".backsource", 0);
backoffsetx = cfg.ReadSetting(path + ".backoffsetx", 0);
backoffsety = cfg.ReadSetting(path + ".backoffsety", 0);
backscalex = cfg.ReadSetting(path + ".backscalex", 1.0f);
backscaley = cfg.ReadSetting(path + ".backscaley", 1.0f);
gridsize = cfg.ReadSetting(path + ".gridsize", DEFAULT_GRID_SIZE);
// Setup
SetGridSize(gridsize);
LinkBackground();
}
// This sets the grid size
internal void SetGridSize(int size)
{

View file

@ -269,6 +269,7 @@ namespace CodeImp.DoomBuilder
data.Load(configinfo.Resources, options.Resources);
// Update structures
options.ApplyGridSettings();
map.UpdateConfiguration();
map.Update();
thingsfilter.Update();
@ -359,6 +360,7 @@ namespace CodeImp.DoomBuilder
data.Load(configinfo.Resources, options.Resources, maplocation);
// Update structures
options.ApplyGridSettings();
map.UpdateConfiguration();
map.SnapAllToAccuracy();
map.Update();

View file

@ -163,6 +163,9 @@ namespace CodeImp.DoomBuilder.Map
// Write resources to config
resources.WriteToConfig(mapconfig, "resources");
// Write grid settings
General.Map.Grid.WriteToConfig(mapconfig, "grid");
// Write scripts to config
mapconfig.DeleteSetting("scripts");
for(int i = 0; i < scriptfiles.Count; i++)
@ -230,6 +233,12 @@ namespace CodeImp.DoomBuilder.Map
resources.Clear();
resources.AddRange(fromlist);
}
// This loads the grid settings
internal void ApplyGridSettings()
{
General.Map.Grid.ReadFromConfig(mapconfig, "grid");
}
// This displays the current map name
public override string ToString()