Browse Source

Add initial implementation for map lists

Shtoyan 2 years ago
parent
commit
7dc731a2e6
  1. 2
      config/AcediaGameModes.ini
  2. 2
      config/AcediaLauncher.ini
  3. 7
      config/AcediaMaps.ini
  4. 1
      sources/AcediaLauncherMut.uc
  5. 10
      sources/GameModes/GameMode.uc
  6. 55
      sources/MapList/MapList.uc
  7. 7
      sources/MapList/MapList_Feature.uc
  8. 3
      sources/StartUp.uc
  9. 43
      sources/VotingHandlerAdapter.uc

2
config/AcediaGameModes.ini

@ -1,7 +1,9 @@
[hard GameMode]
title={$green Hard difficulty}
difficulty=hard
mapList=defaultHard
[hell GameMode]
title={$crimson Hell On Earth}
difficulty=hoe
mapList=defaultHOE

2
config/AcediaLauncher.ini

@ -1,2 +1,2 @@
[AcediaLauncher.Packages]
useGameModes=false
useGameModes=true

7
config/AcediaMaps.ini

@ -0,0 +1,7 @@
[default MapList]
autoEnable=true
map="KF-BioticsLab"
map="KF-Farm"
map="KF-Manor"
map="KF-Offices"
map="KF-WestLondon"

1
sources/AcediaLauncherMut.uc

@ -45,6 +45,7 @@ simulated function PreBeginPlay()
}
if (votingAdapter != none) {
votingAdapter.InjectIntoVotingHandler();
votingAdapter.TrySetupMapList();
}
SetupMutatorSignals();
}

10
sources/GameModes/GameMode.uc

@ -77,6 +77,7 @@ protected function HashTable ToData()
result.SetString(P("gameTypeClass"), gameTypeClass);
result.SetString(P("acronym"), acronym);
result.SetString(P("mapPrefix"), mapPrefix);
nextArray = _.collections.EmptyArrayList();
for (i = 0; i < option.length; i += 1)
{
@ -103,9 +104,10 @@ protected function FromData(HashTable source)
return;
}
gameTypeClass = source.GetString(P("gameTypeClass"));
acronym = source.GetString(P("acronym"));
mapPrefix = source.GetString(P("mapPrefix"));
nextArray = source.GetArrayList(P("option"));
acronym = source.GetString(P("acronym"));
mapPrefix = source.GetString(P("mapPrefix"));
nextArray = source.GetArrayList(P("option"));
if (nextArray == none) {
return;
}
@ -271,6 +273,8 @@ defaultproperties
hardSynonyms(0) = "harder" // "hard" is prefix of this, so it will count
hardSynonyms(1) = "difficult"
suicidalSynonyms(0) = "suicidal"
// DONE!
suicidalSynonyms(1) = "sui"
hoeSynonyms(0) = "hellonearth"
hoeSynonyms(1) = "hellon earth"
hoeSynonyms(2) = "hell onearth"

55
sources/MapList/MapList.uc

@ -0,0 +1,55 @@
class MapList extends FeatureConfig
perObjectConfig
config(AcediaMaps);
var public config array<string> map;
protected function HashTable ToData() {
local int i;
local ArrayList mapArray;
local HashTable result;
result = _.collections.EmptyHashTable();
mapArray = _.collections.EmptyArrayList();
for (i = 0; i < map.length; i += 1) {
mapArray.AddString(map[i]);
}
result.SetItem(P("maps"), mapArray);
_.memory.Free(mapArray);
return result;
}
protected function FromData(HashTable source) {
local int i;
local ArrayList mapArray;
if (source == none) {
return;
}
mapArray = source.GetArrayList(P("maps"));
if (mapArray == none) {
return;
}
map.length = 0;
for (i = 0; i < mapArray.GetLength(); i += 1) {
map[map.length] = mapArray.GetString(i);
}
_.memory.Free(mapArray);
}
protected function DefaultIt() {
map[0] = "KF-BioticsLab";
map[1] = "KF-Farm";
map[2] = "KF-Manor";
map[3] = "KF-Offices";
map[4] = "KF-WestLondon";
}
defaultproperties {
configName = "AcediaMaps"
}

7
sources/MapList/MapList_Feature.uc

@ -0,0 +1,7 @@
class MapList_Feature extends Feature;
defaultproperties {
configClass = class'MapList'
}

3
sources/StartUp.uc

@ -125,6 +125,9 @@ public function array<Packages.FeatureConfigPair> GetAutoConfigurationInfo()
local array<Packages.FeatureConfigPair> result;
availableFeatures = _.environment.GetAvailableFeatures();
// We only have a single feature, so instead of adding our own manifest, simply add it here
class'MapList_Feature'.static.LoadConfigs();
availableFeatures[availableFeatures.length] = class'MapList_Feature';
for (i = 0; i < availableFeatures.length; i += 1)
{
autoConfig = availableFeatures[i].static.GetAutoEnabledConfig();

43
sources/VotingHandlerAdapter.uc

@ -102,6 +102,7 @@ protected function Finalizer()
* Backup of replaced configs is made internally, so that they can be restored
* on map change.
*/
// TODO ADD ME!
public final function InjectIntoVotingHandler()
{
local int i;
@ -138,6 +139,48 @@ public final function InjectIntoVotingHandler()
votingHandler.gameConfig = newVotingHandlerConfig;
}
public function TrySetupMapList() {
local MapList_Feature mapListFeature;
local Text currentConfigName;
local MapList currentConfig;
warn(">>>>>>>> START!");
mapListFeature = MapList_Feature(class'MapList_Feature'.static.GetEnabledInstance());
currentConfigName = mapListFeature.GetCurrentConfig();
currentConfig = MapList(class'MapList'.static.GetConfigInstance(currentConfigName));
ReplaceHandlerMaps(XVotingHandler(votingHandlerReference.Get()), currentConfig.map);
}
public function ReplaceHandlerMaps(XVotingHandler votingHandler, array<string> maps) {
local int i;
local VotingHandler.MapVoteMapList nextRecord;
local array<VotingHandler.MapVoteMapList> recordArray;
if (votingHandler == none) {
warn("votingHandler is none!");
return;
}
if (maps.length == 0) {
warn("maps.length is 0!");
return;
}
recordArray = votingHandler.mapList;
warn(">>> recordArray.length =" $ recordArray.length);
recordArray.length = maps.length;
votingHandler.mapCount = maps.length;
nextRecord.bEnabled = true;
for (i = 0; i < maps.length; i += 1) {
nextRecord.mapName = maps[i];
recordArray[i] = nextRecord;
}
votingHandler.mapList = recordArray;
}
private function VotingHandler.MapVoteGameConfig BuildVotingHandlerConfig(
GameMode gameMode)
{

Loading…
Cancel
Save