1
0
forked from 0ad/0ad

Landscape and Daytime gamesetup options for the Unknown, Danubius and Polar Sea, refs #4838.

Allow gamesetup options other than biome to determine the map peview
image, refs #4962, 8adc6d8e93.
Add previews for the 12 Unknown, 2 Danubius and 2 Polar Sea variations.
Concludes deduplication of the Unknown (0d0bc32736), Unknown Land
(25682da568) and Unknown Nomad (7f8adcf8cb), refs #4317.

Differential Revision: https://code.wildfiregames.com/D2564
This was SVN commit r23392.
This commit is contained in:
elexis 2020-01-14 07:02:40 +00:00
parent 0307a642fe
commit af15d5972d
31 changed files with 1525 additions and 1113 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -63,22 +63,14 @@ class MapCache
}
getMapPreview(mapType, mapPath, gameAttributes = undefined)
{
let filename = gameAttributes && gameAttributes.settings && gameAttributes.settings.Preview || undefined;
if (!filename)
{
let mapData = this.getMapData(mapType, mapPath);
let biomePreviewFile =
basename(mapPath) + "_" +
basename(gameAttributes && gameAttributes.settings.Biome || "") + ".png";
let biomePreview = Engine.TextureExists(
this.TexturesPath + this.PreviewsPath + biomePreviewFile) && biomePreviewFile;
let filename =
biomePreview ?
biomePreview :
mapData && mapData.settings && mapData.settings.Preview ?
mapData.settings.Preview :
this.DefaultPreview;
filename = mapData && mapData.settings && mapData.settings.Preview || this.DefaultPreview;
}
return "cropped:" + this.PreviewWidth + "," + this.PreviewHeight + ":" + this.PreviewsPath + filename;
}

View File

@ -10,7 +10,9 @@ var g_GameSettingsLayout = [
"MapFilter",
"MapSelection",
"MapSize",
"Landscape",
"Biome",
"Daytime",
"TriggerDifficulty",
"Nomad",
"Treasures",

View File

@ -7,6 +7,8 @@ GameSettingControls.Biome = class extends GameSettingControlDropdown
this.values = undefined;
this.biomeValues = undefined;
this.lastBiome = undefined;
this.randomItem = {
"Id": this.RandomBiomeId,
"Title": setStringTags(this.RandomBiome, this.RandomItemTags),
@ -46,11 +48,13 @@ GameSettingControls.Biome = class extends GameSettingControlDropdown
}
else
this.values = undefined;
this.lastBiome = undefined;
}
onGameAttributesChange()
{
if (!g_GameAttributes.mapType)
if (!g_GameAttributes.mapType || !g_GameAttributes.map)
return;
if (this.values)
@ -60,6 +64,18 @@ GameSettingControls.Biome = class extends GameSettingControlDropdown
g_GameAttributes.settings.Biome = this.RandomBiomeId;
this.gameSettingsControl.updateGameAttributes();
}
if (this.lastBiome != g_GameAttributes.settings.Biome)
{
let biomePreviewFile =
basename(g_GameAttributes.map) + "_" +
basename(g_GameAttributes.settings.Biome || "") + ".png";
if (Engine.TextureExists(this.mapCache.TexturesPath + this.mapCache.PreviewsPath + biomePreviewFile))
g_GameAttributes.settings.Preview = biomePreviewFile;
this.lastBiome = g_GameAttributes.settings.Biome;
}
}
else if (g_GameAttributes.settings.Biome)
{

View File

@ -0,0 +1,107 @@
GameSettingControls.Daytime = class extends GameSettingControlDropdown
{
constructor(...args)
{
super(...args);
this.values = undefined;
}
onHoverChange()
{
this.dropdown.tooltip = this.values.Description[this.dropdown.hovered] || this.Tooltip;
}
onMapChange(mapData)
{
if (mapData && mapData.settings && mapData.settings.Daytime)
{
this.values = prepareForDropdown([
{
"Id": "random",
"Name": setStringTags(this.RandomTitle, this.RandomItemTags),
"Description": this.RandomDescription,
"Preview": mapData.settings.Preview
},
...mapData.settings.Daytime
]);
this.dropdown.list = this.values.Name;
this.dropdown.list_data = this.values.Id;
}
else
this.values = undefined;
this.setHidden(!this.values);
}
onGameAttributesChange()
{
if (!g_GameAttributes.map)
return;
if (this.values)
{
if (this.values.Id.indexOf(g_GameAttributes.settings.Daytime || undefined) == -1)
{
g_GameAttributes.settings.Daytime = "random";
this.gameSettingsControl.updateGameAttributes();
}
let preview = this.values.Preview[this.values.Id.indexOf(g_GameAttributes.settings.Daytime)];
if (!g_GameAttributes.settings.Preview || g_GameAttributes.settings.Preview != preview)
{
g_GameAttributes.settings.Preview = preview;
this.gameSettingsControl.updateGameAttributes();
}
}
else if (g_GameAttributes.settings.Daytime !== undefined)
{
delete g_GameAttributes.settings.Daytime;
this.gameSettingsControl.updateGameAttributes();
}
}
onGameAttributesBatchChange()
{
if (g_GameAttributes.settings.Daytime)
this.setSelectedValue(g_GameAttributes.settings.Daytime);
}
getAutocompleteEntries()
{
return this.values.Name;
}
onSelectionChange(itemIdx)
{
g_GameAttributes.settings.Daytime = this.values.Id[itemIdx];
this.gameSettingsControl.updateGameAttributes();
this.gameSettingsControl.setNetworkGameAttributes();
}
onPickRandomItems()
{
if (this.values && g_GameAttributes.settings.Daytime == "random")
{
g_GameAttributes.settings.Daytime = pickRandom(this.values.Id.slice(1));
this.gameSettingsControl.updateGameAttributes();
this.gameSettingsControl.pickRandomItems();
}
}
};
GameSettingControls.Daytime.prototype.TitleCaption =
translate("Daytime");
GameSettingControls.Daytime.prototype.Tooltip =
translate("Select whether the match takes place at daylight or night.");
GameSettingControls.Daytime.prototype.RandomTitle =
translateWithContext("daytime selection", "Random");
GameSettingControls.Daytime.prototype.RandomDescription =
translateWithContext("daytime selection", "Randomly pick a time of the day.");
GameSettingControls.Daytime.prototype.AutocompleteOrder = 0;

View File

@ -0,0 +1,145 @@
GameSettingControls.Landscape = class extends GameSettingControlDropdown
{
constructor(...args)
{
super(...args);
this.values = undefined;
this.lastLandscape = undefined;
this.mapData = undefined;
}
onHoverChange()
{
this.dropdown.tooltip = this.values.Description[this.dropdown.hovered] || this.Tooltip;
}
onMapChange(mapData)
{
this.mapData = mapData;
if (mapData && mapData.settings && mapData.settings.Landscapes)
{
let randomItems = [];
for (let item of this.RandomItems)
if (item.Id == "random" || mapData.settings.Landscapes.land && mapData.settings.Landscapes.naval)
randomItems.push({
"Id": item.Id,
"Name": setStringTags(item.Name, this.RandomItemTags),
"Description": item.Description,
"Preview": mapData.settings.Preview || this.mapCache.DefaultPreview
});
let sort = (item1, item2) => item1.Name > item2.Name;
this.values = prepareForDropdown([
...randomItems,
...mapData.settings.Landscapes.land.sort(sort),
...mapData.settings.Landscapes.naval.sort(sort)
]);
this.dropdown.list = this.values.Name;
this.dropdown.list_data = this.values.Id;
}
else
this.values = undefined;
this.lastLandscape = undefined;
this.setHidden(!this.values);
}
onGameAttributesChange()
{
if (this.values)
{
if (this.values.Id.indexOf(g_GameAttributes.settings.Landscape || undefined) == -1)
{
g_GameAttributes.settings.Landscape = "random";
this.gameSettingsControl.updateGameAttributes();
}
if (this.lastLandscape != g_GameAttributes.settings.Landscape)
{
g_GameAttributes.settings.Preview = this.values.Preview[this.values.Id.indexOf(g_GameAttributes.settings.Landscape)];
this.lastLandscape = g_GameAttributes.settings.Biome;
}
}
else if (g_GameAttributes.settings.Landscape !== undefined)
{
delete g_GameAttributes.settings.Landscape;
this.gameSettingsControl.updateGameAttributes();
}
}
onGameAttributesBatchChange()
{
if (g_GameAttributes.settings.Landscape)
this.setSelectedValue(g_GameAttributes.settings.Landscape);
}
getAutocompleteEntries()
{
return this.values.Name;
}
onSelectionChange(itemIdx)
{
g_GameAttributes.settings.Landscape = this.values.Id[itemIdx];
this.gameSettingsControl.updateGameAttributes();
this.gameSettingsControl.setNetworkGameAttributes();
}
onPickRandomItems()
{
let items;
let landscapes = this.mapData.settings.Landscapes;
switch (g_GameAttributes.settings.Landscape || undefined)
{
case "random":
items = [...landscapes.land, ...landscapes.naval];
break;
case "random_land":
items = landscapes.land;
break;
case "random_naval":
items = landscapes.naval;
break;
default:
return;
}
g_GameAttributes.settings.Landscape = pickRandom(items).Id;
this.gameSettingsControl.updateGameAttributes();
this.gameSettingsControl.pickRandomItems();
}
};
GameSettingControls.Landscape.prototype.TitleCaption =
translate("Landscape");
GameSettingControls.Landscape.prototype.Tooltip =
translate("Select one of the landscapes of this map.");
GameSettingControls.Landscape.prototype.RandomItems =
[
{
"Id": "random",
"Name": translateWithContext("landscape selection", "Random Land or Naval"),
"Description": translateWithContext("landscape selection", "Select a random land or naval map generation.")
},
{
"Id": "random_land",
"Name": translateWithContext("landscape selection", "Random Land"),
"Description": translateWithContext("landscape selection", "Select a random land map generation.")
},
{
"Id": "random_naval",
"Name": translateWithContext("landscape selection", "Random Naval"),
"Description": translateWithContext("landscape selection", "Select a random naval map generation.")
}
];
GameSettingControls.Landscape.prototype.AutocompleteOrder = 0;

View File

@ -2,14 +2,26 @@ class MapPreview
{
constructor(gameSettingsControl, mapCache)
{
this.gameSettingsControl = gameSettingsControl;
this.mapCache = mapCache;
this.mapInfoName = Engine.GetGUIObjectByName("mapInfoName");
this.mapPreview = Engine.GetGUIObjectByName("mapPreview");
gameSettingsControl.registerMapChangeHandler(this.onMapChange.bind(this));
gameSettingsControl.registerGameAttributesBatchChangeHandler(this.onGameAttributesBatchChange.bind(this));
}
onMapChange(mapData)
{
let preview = mapData && mapData.settings && mapData.settings.Preview;
if (!g_GameAttributes.settings.Preview || g_GameAttributes.settings.Preview != preview)
{
g_GameAttributes.settings.Preview = preview;
this.gameSettingsControl.updateGameAttributes();
}
}
onGameAttributesBatchChange()
{
if (!g_GameAttributes.map || !g_GameAttributes.mapType)

View File

@ -1,6 +1,8 @@
Engine.LoadLibrary("rmgen");
Engine.LoadLibrary("rmgen-common");
const day = g_MapSettings.dayTime !== undefined ? g_MapSettings.dayTime == "day" : randBool(2/3);
// Spawn ships away from the shoreline, but patrol close to the shoreline
const triggerPointShipSpawn = "trigger/trigger_point_A";
const triggerPointShipPatrol = "trigger/trigger_point_B";
@ -303,8 +305,8 @@ if (gallicCC)
for (let participants of ritualParticipants)
{
let [positions, angles] = distributePointsOnCircle(participants.count, startAngle, participants.radius * mRadius, meetingPlacePosition);
for (let i = 0; i < positions.length; ++i)
g_Map.placeEntityPassable(pickRandom(participants.templates), 0, positions[i], angles[i] + participants.angle);
for (let j = 0; j < positions.length; ++j)
g_Map.placeEntityPassable(pickRandom(participants.templates), 0, positions[j], angles[j] + participants.angle);
}
}
@ -323,7 +325,7 @@ if (gallicCC)
placeCustomFortress(civicCenterPosition, fortressDanubiusSpikes, "danubius_spikes", 0, startAngle + Math.PI);
// Place treasure, potentially inside buildings
for (let i = 0; i < gallicCCTreasureCount; ++i)
for (let j = 0; j < gallicCCTreasureCount; ++j)
g_Map.placeEntityPassable(
pickRandom(oTreasures),
0,
@ -444,7 +446,7 @@ Engine.SetProgress(50);
g_Map.log("Creating grass patches");
createLayeredPatches(
[scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
[[tGrass, tGrass2],[tGrass2, tGrass3], [tGrass3, tGrass]],
[[tGrass, tGrass2], [tGrass2, tGrass3], [tGrass3, tGrass]],
[1, 1],
avoidClasses(clForest, 0, clPlayer, 10, clWater, 2, clDirt, 2, clHill, 1, clGauls, 5, clPath, 1),
scaleByMapSize(15, 45),
@ -566,7 +568,7 @@ for (let i = 0; i < 2; ++i)
],
i == 0 ?
avoidClasses(clWater, 4, clForest, 1, clPlayer, 16, clRock, 4, clMetal, 4, clHill, 4, clGauls, 5, clPath, 1) :
[stayClasses(clIsland, 4) , avoidClasses(clForest, 1, clRock, 4, clMetal, 4)]);
[stayClasses(clIsland, 4), avoidClasses(clForest, 1, clRock, 4, clMetal, 4)]);
Engine.SetProgress(75);
g_Map.log("Creating fish");
@ -797,7 +799,7 @@ createObjectGroupsByAreas(
placePlayersNomad(clPlayer, avoidClasses(clWater, 4, clMetal, 4, clRock, 4, clIsland, 4, clGauls, 20, clRitualPlace, 20, clForest, 1, clBaseResource, 4, clHill, 4, clFood, 2));
if (randBool(2/3))
if (day)
{
g_Map.log("Setting day theme");
setSkySet("cumulus");

View File

@ -5,10 +5,25 @@
"Description" : "Players start along the banks of the river Danube in the period following the expansion into Pannonia by the Celtic Boii tribe. Seeking to consolidate their hold on this land, celtic reinforcements have been sent to root out the remaining foreign cultures. Players not only have to vie for power amongst themselves, but also beat back these ruthless invaders. Ultimately, the Boii were defeated by the rising power of the Dacians, hence leading to the reemergence of the Geto-Dacian Confederation under King Burebista.",
"Keywords": ["trigger", "naval"],
"CircularMap" : true,
"Preview" : "danubius.png",
"Preview" : "danubius_night.png",
"TriggerScripts" : [
"scripts/TriggerHelper.js",
"random/danubius_triggers.js"
],
"Daytime":
[
{
"Id": "day",
"Name": "Day",
"Description": "Bright daylight illuminates the scene.",
"Preview" : "danubius_day.png"
},
{
"Id": "night",
"Name": "Night",
"Description": "Attackers are covered by the darkness of the night.",
"Preview" : "danubius_night.png"
}
]
}
}

View File

@ -134,7 +134,7 @@ Engine.SetProgress(65);
g_Map.log("Creating dirt patches");
createLayeredPatches(
[scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
[[tDirt,tHalfSnow], [tHalfSnow,tSnowLimited]],
[[tDirt, tHalfSnow], [tHalfSnow, tSnowLimited]],
[2],
avoidClasses(clWater, 3, clDirt, 5, clPlayer, 12),
scaleByMapSize(15, 45),
@ -150,10 +150,10 @@ createPatches(
Engine.SetProgress(70);
g_Map.log("Creating stone mines");
createMines(
createMines(
[
[new SimpleObject(oStoneSmall, 0, 2, 0, 4, 0, 2 * Math.PI, 1), new SimpleObject(oStoneLarge, 1, 1, 0, 4, 0, 2 * Math.PI, 4)],
[new SimpleObject(oStoneSmall, 2,5, 1,3)]
[new SimpleObject(oStoneSmall, 2, 5, 1, 3)]
],
avoidClasses(clWater, 3, clPlayer, 20, clRock, 18, clHill, 2),
clRock);
@ -161,7 +161,7 @@ g_Map.log("Creating stone mines");
g_Map.log("Creating metal mines");
createMines(
[
[new SimpleObject(oMetalLarge, 1,1, 0,4)]
[new SimpleObject(oMetalLarge, 1, 1, 0, 4)]
],
avoidClasses(clWater, 3, clPlayer, 20, clMetal, 18, clRock, 5, clHill, 2),
clMetal);
@ -241,7 +241,7 @@ createObjectGroupsDeprecated(
100);
Engine.SetProgress(95);
if (randBool(1/3))
if (g_MapSettings.Daytime !== undefined ? g_MapSettings.Daytime == "dawn" : randBool(1/3))
{
setSkySet("sunset 1");
setSunColor(0.8, 0.7, 0.6);

View File

@ -4,7 +4,7 @@
"Script" : "polar_sea.js",
"Description" : "Players start in a cold polar region barren of vegetation. In the sea fish and whales abound, while the fragile icy land teems with huntable walruses and deadly wolves. These wolves, made ravenous by the harsh and forbidding climate, drawn by the scent of prey, have started appearing in terrifying numbers. A wise and strong ruler will not only achieve victory over his enemies, but also keep the number of these beasts at bay, lest they undermine his economy and cause his downfall. [color=\"red\"]Warning: It is inadvisable to disable treasures, since there is no gatherable wood. Not recommended for inexperienced players.[/color]",
"Keywords": ["trigger"],
"Preview" : "polar_sea.png",
"Preview" : "polar_sea_dawn.png",
"CircularMap" : true,
"TriggerScripts" : [
"scripts/TriggerHelper.js",
@ -14,6 +14,21 @@
"gather_lumbering_ironaxes",
"gather_lumbering_sharpaxes",
"gather_lumbering_strongeraxes"
],
"Daytime":
[
{
"Id": "dawn",
"Name": "Dawn",
"Description": "Scattered sunlight illuminates the scenery in a vivid red tone.",
"Preview" : "polar_sea_dawn.png"
},
{
"Id": "daylight",
"Name": "Daylight",
"Description": "The scenery is illuminated by direct or indirect sunlight.",
"Preview" : "polar_sea_daylight.png"
}
]
}
}

File diff suppressed because it is too large Load Diff

View File

@ -2,9 +2,87 @@
"settings" : {
"Name" : "Unknown",
"Script" : "unknown.js",
"Description" : "The unknown. Warning: May be a naval map.",
"Description" : "The unknown.",
"Preview" : "unknown.png",
"SupportedBiomes": "generic/",
"CircularMap" : true
"CircularMap" : true,
"Landscapes": {
"land" : [
{
"Id": "Continent",
"Name": "Continent",
"Description": "All players starts on a continent surrounded by water.",
"Preview": "unknown_continent.png"
},
{
"Id": "Isthmus",
"Name": "Isthmus",
"Description": "Two Mediterranean land masses connected by a narrow spit of land, called an 'Isthmus'.",
"Preview": "unknown_isthmus.png"
},
{
"Id": "CentralRiver",
"Name": "Central River",
"Description": "A small central river.",
"Preview": "unknown_central_river.png"
},
{
"Id": "EdgeSeas",
"Name": "Edge Seas",
"Description": "Players are aligned on a strip of land with seas bordering on one or both sides that may hold islands.",
"Preview": "unknown_edge_seas.png"
},
{
"Id": "Gulf",
"Name": "Gulf",
"Description": "Land shaped like a concrescent moon around a central lake.",
"Preview": "unknown_gulf.png"
},
{
"Id": "Lakes",
"Name": "Lakes",
"Description": "Mainland style with some small random lakes.",
"Preview": "unknown_lakes.png"
},
{
"Id": "Passes",
"Name": "Passes",
"Description": "A large hill encompasses the map and leaves players only a small passage to the two neighboring players.",
"Preview": "unknown_passes.png"
},
{
"Id": "Lowlands",
"Name": "Lowlands",
"Description": "The land is enclosed by a hill that leaves a small area per player connected to the large central place.",
"Preview": "unknown_lowlands.png"
},
{
"Id": "Mainland",
"Name": "Mainland",
"Description": "A typical map without any water.",
"Preview": "unknown_mainland.png"
}
],
"naval": [
{
"Id": "CentralSea",
"Name": "Naval: Central Sea",
"Description": "A huge sea is dividing the map into two halves.",
"Preview": "unknown_central_sea.png"
},
{
"Id": "Archipelago",
"Name": "Naval: Archipelago",
"Description": "Players are scattered across island chains and disconnected islands.",
"Preview": "unknown_archipelago.png"
},
{
"Id": "RiversAndLake",
"Name": "Naval: Lake and rivers",
"Description": "A central lake with rivers possibly separating neighboring players.",
"Preview": "unknown_rivers_and_lake.png"
}
]
}
}
}

View File

@ -1,10 +0,0 @@
Engine.LoadLibrary("rmgen");
Engine.LoadLibrary("rmgen-common");
Engine.LoadLibrary("rmbiome");
Engine.LoadLibrary("the_unknown");
g_AllowNaval = false;
createUnknownMap();
g_Map.ExportMap();

View File

@ -1,10 +0,0 @@
{
"settings" : {
"Name" : "Unknown Land",
"Script" : "unknown_land.js",
"Description" : "The unknown.",
"Preview" : "unknown.png",
"SupportedBiomes": "generic/",
"CircularMap" : true
}
}