Kill unused map installation code.
This commit is contained in:
@@ -44,9 +44,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
panel.GetWidget<ButtonWidget>("BUTTON_OK").OnClick = () => { Widget.CloseWindow(); onSelect(map); };
|
panel.GetWidget<ButtonWidget>("BUTTON_OK").OnClick = () => { Widget.CloseWindow(); onSelect(map); };
|
||||||
panel.GetWidget<ButtonWidget>("BUTTON_CANCEL").OnClick = () => { Widget.CloseWindow(); onExit(); };
|
panel.GetWidget<ButtonWidget>("BUTTON_CANCEL").OnClick = () => { Widget.CloseWindow(); onExit(); };
|
||||||
|
|
||||||
panel.GetWidget<ButtonWidget>("BUTTON_INSTALL").IsDisabled = () => true;
|
|
||||||
panel.GetWidget<ButtonWidget>("BUTTON_INSTALL").OnClick = () => InstallMap();
|
|
||||||
|
|
||||||
scrollpanel = panel.GetWidget<ScrollPanelWidget>("MAP_LIST");
|
scrollpanel = panel.GetWidget<ScrollPanelWidget>("MAP_LIST");
|
||||||
itemTemplate = scrollpanel.GetWidget<ScrollItemWidget>("MAP_TEMPLATE");
|
itemTemplate = scrollpanel.GetWidget<ScrollItemWidget>("MAP_TEMPLATE");
|
||||||
EnumerateMaps();
|
EnumerateMaps();
|
||||||
@@ -68,31 +65,5 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
scrollpanel.AddChild(item);
|
scrollpanel.AddChild(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InstallMap()
|
|
||||||
{
|
|
||||||
Game.Utilities.PromptFilepathAsync("Select an OpenRA map file", path =>
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(path))
|
|
||||||
Game.RunAfterTick(() => InstallMapInner(path));
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InstallMapInner(string path)
|
|
||||||
{
|
|
||||||
var toPath = new [] { Platform.SupportDir, "maps", Game.modData.Manifest.Mods[0], Path.GetFileName(path) }.Aggregate(Path.Combine);
|
|
||||||
|
|
||||||
// Create directory if required
|
|
||||||
var dir = Path.GetDirectoryName(toPath);
|
|
||||||
if (!Directory.Exists(dir))
|
|
||||||
Directory.CreateDirectory(dir);
|
|
||||||
|
|
||||||
// TODO: Attempt to mount the map and verify that
|
|
||||||
// it is a valid Game.modData.Manifest.Mods[0] map.
|
|
||||||
File.Copy(path, toPath, true);
|
|
||||||
Game.modData.ReloadMaps();
|
|
||||||
EnumerateMaps();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,8 +56,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
bg.GetWidget("BUTTON_INSTALL").IsVisible = () => false;
|
|
||||||
//bg.GetWidget<ButtonWidget>("BUTTON_INSTALL").OnMouseUp = mi => InstallMap();
|
|
||||||
scrollpanel = bg.GetWidget<ScrollPanelWidget>("MAP_LIST");
|
scrollpanel = bg.GetWidget<ScrollPanelWidget>("MAP_LIST");
|
||||||
itemTemplate = scrollpanel.GetWidget<ScrollItemWidget>("MAP_TEMPLATE");
|
itemTemplate = scrollpanel.GetWidget<ScrollItemWidget>("MAP_TEMPLATE");
|
||||||
EnumerateMaps();
|
EnumerateMaps();
|
||||||
@@ -79,34 +77,5 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
scrollpanel.AddChild(item);
|
scrollpanel.AddChild(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InstallMap()
|
|
||||||
{
|
|
||||||
Game.Utilities.PromptFilepathAsync("Select an OpenRA map file", path =>
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(path))
|
|
||||||
Game.RunAfterTick(() => InstallMapInner(path));
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InstallMapInner(string path)
|
|
||||||
{
|
|
||||||
var toPath = "{0}{1}maps{1}{2}{1}{3}"
|
|
||||||
.F(Platform.SupportDir,Path.DirectorySeparatorChar,
|
|
||||||
Game.modData.Manifest.Mods[0],
|
|
||||||
Path.GetFileName(path));
|
|
||||||
|
|
||||||
// Create directory if required
|
|
||||||
var dir = Path.GetDirectoryName(toPath);
|
|
||||||
if (!Directory.Exists(dir))
|
|
||||||
Directory.CreateDirectory(dir);
|
|
||||||
|
|
||||||
// TODO: Attempt to mount the map and verify that
|
|
||||||
// it is a valid Game.modData.Manifest.Mods[0] map.
|
|
||||||
File.Copy(path, toPath, true);
|
|
||||||
Game.modData.ReloadMaps();
|
|
||||||
EnumerateMaps();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,13 +197,6 @@ Container@MAPCHOOSER_PANEL:
|
|||||||
Width:140
|
Width:140
|
||||||
Height:35
|
Height:35
|
||||||
Text:Cancel
|
Text:Cancel
|
||||||
Button@BUTTON_INSTALL:
|
|
||||||
Id:BUTTON_INSTALL
|
|
||||||
X:450
|
|
||||||
Y:499
|
|
||||||
Width:140
|
|
||||||
Height:35
|
|
||||||
Text:Install Map
|
|
||||||
Button@BUTTON_OK:
|
Button@BUTTON_OK:
|
||||||
Id:BUTTON_OK
|
Id:BUTTON_OK
|
||||||
Key:return
|
Key:return
|
||||||
|
|||||||
@@ -714,12 +714,4 @@ Background@MAP_CHOOSER:
|
|||||||
Width:120
|
Width:120
|
||||||
Height:25
|
Height:25
|
||||||
Text:Cancel
|
Text:Cancel
|
||||||
Font:Bold
|
Font:Bold
|
||||||
Button@BUTTON_INSTALL:
|
|
||||||
Id:BUTTON_INSTALL
|
|
||||||
X:20
|
|
||||||
Y:PARENT_BOTTOM-49
|
|
||||||
Width:120
|
|
||||||
Height:25
|
|
||||||
Text:Install Map
|
|
||||||
Font:Bold
|
|
||||||
Reference in New Issue
Block a user