Compare commits
2 Commits
83a8edf94c
...
1da050232c
Author | SHA1 | Date | |
---|---|---|---|
1da050232c | |||
3c76eb4844 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@
|
||||
__pycache__
|
||||
.doit.db
|
||||
*.kate-swp
|
||||
/vanilla
|
||||
|
47
dodo.py
47
dodo.py
@ -4,14 +4,16 @@ from doit import get_var
|
||||
|
||||
DOIT_CONFIG = {
|
||||
'default_tasks': ['build'],
|
||||
'action_string_formatting': 'new'
|
||||
'action_string_formatting': 'both'
|
||||
}
|
||||
|
||||
|
||||
def files(p):
|
||||
for i in p:
|
||||
if i.is_file():
|
||||
yield i
|
||||
|
||||
|
||||
class RawFiles(list):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.src_path = Path(kwargs.pop('src_path'))
|
||||
@ -21,26 +23,33 @@ class RawFiles(list):
|
||||
def sources(self):
|
||||
for i in self:
|
||||
yield self.src_path/i
|
||||
|
||||
def targets(self):
|
||||
for i in self:
|
||||
yield self.image_path/i
|
||||
|
||||
|
||||
class BasePatchwork(dict):
|
||||
patches_path = None
|
||||
patchwork_path = None
|
||||
vanilla_path = None
|
||||
|
||||
def __init__(self, *arkg, **kwargs):
|
||||
self.patches_path = Path(kwargs.pop('patches_path'))
|
||||
self.patchwork_path = Path(kwargs.pop('patchwork_path'))
|
||||
self.vanilla_path = Path(kwargs.pop('vanilla_path'))
|
||||
super().__init__(*arkg, **kwargs)
|
||||
|
||||
def targets(self):
|
||||
for i in self.keys():
|
||||
yield self.patchwork_path/i
|
||||
|
||||
def key_vanilla(self, orig_key):
|
||||
return self.vanilla_path/orig_key
|
||||
|
||||
def key_target(self, orig_key):
|
||||
return self.patchwork_path/orig_key
|
||||
|
||||
def tasks(self, actions):
|
||||
def repack_action(action, **kwargs):
|
||||
if callable(action):
|
||||
@ -63,7 +72,6 @@ class BasePatchwork(dict):
|
||||
}
|
||||
|
||||
|
||||
|
||||
class Patchwork(BasePatchwork):
|
||||
def tasks_(self, actions):
|
||||
for k, v in self.items():
|
||||
@ -73,7 +81,7 @@ class Patchwork(BasePatchwork):
|
||||
'targets': [self.patchwork_path/k],
|
||||
'actions': [
|
||||
f"mkdir -p {self.patchwork_path}/{Path(k).parent}",
|
||||
f"patch -u --binary -N -o '{self.patchwork_path}/{k}' "\
|
||||
f"patch -u --binary -N -o '{self.patchwork_path}/{k}' "
|
||||
f"'{self.vanilla_path}/{k}' '{self.patches_path}/{v}'"
|
||||
], # action ( mkdir, patch )
|
||||
'clean': True
|
||||
@ -87,9 +95,15 @@ class ScriptedPatchwork(BasePatchwork):
|
||||
super().__init__(*args, **kwargs)
|
||||
with open(file) as s:
|
||||
for key, data in safe_load(s).items():
|
||||
discovered_source = next((Path(self.vanilla_path)/'history'/'states').glob(f"{key}*"))
|
||||
relative_path = discovered_source.relative_to(self.vanilla_path)
|
||||
try:
|
||||
discovered_source = next(
|
||||
(Path(self.vanilla_path)/'history'/'states').glob(f"{key}*"))
|
||||
relative_path = discovered_source.relative_to(
|
||||
self.vanilla_path)
|
||||
self[relative_path] = data
|
||||
except StopIteration:
|
||||
print(f"{key}: not found")
|
||||
|
||||
|
||||
class RasterPatchwork(BasePatchwork):
|
||||
@staticmethod
|
||||
@ -135,8 +149,11 @@ class Patchset(list):
|
||||
|
||||
|
||||
mod_name = 'randchgs'
|
||||
mod_install_path = get_var('descriptor_mod_path', 'C:/Users/User/Documents/Paradox Interactive/Hearts of Iron IV/mod/randchgs')
|
||||
dir_vanilla = Path(get_var('vanilla_path', '../vanilla/current'))
|
||||
mod_install_path = get_var(
|
||||
'descriptor_mod_path', 'C:/Users/User/Documents/Paradox Interactive/Hearts of Iron IV/mod/randchgs')
|
||||
dir_vanilla = Path(get_var('vanilla_path', './vanilla/current'))
|
||||
if not dir_vanilla.is_dir():
|
||||
raise EnvironmentError(dir_vanilla)
|
||||
dir_image = Path('build/image')
|
||||
dir_modimage = dir_image/mod_name
|
||||
dir_src_raw = Path('src/raw')
|
||||
@ -150,7 +167,6 @@ dir_patchwork_path = Path('build/patched')
|
||||
|
||||
patchwork = Patchwork(
|
||||
{
|
||||
'map/definition.csv': 'map_definition.patch',
|
||||
'history/countries/ISR - Israel.txt': 'history_countries_ISR.patch',
|
||||
'history/states/454-Israel.txt': 'history_states_454.patch',
|
||||
},
|
||||
@ -185,6 +201,7 @@ patch_set = Patchset(
|
||||
modimage_path=dir_modimage
|
||||
)
|
||||
|
||||
|
||||
def task_patch_history_states_scripted():
|
||||
def history_state_patch(task, provinces):
|
||||
source = Path(next(iter(task.file_dep)))
|
||||
@ -199,9 +216,10 @@ def task_patch_history_states_scripted():
|
||||
if not wrote_history and seen_history and '{' in line_in:
|
||||
for province_id, province_info in provinces.items():
|
||||
outfile.write(
|
||||
"\t\tvictory_points = {\r\n"\
|
||||
f"\t\t\t{province_id} {province_info['points']}\r\n"\
|
||||
"\t\t}\r\n"\
|
||||
"\t\tvictory_points = {\r\n"
|
||||
f"\t\t\t{province_id} {
|
||||
province_info['points']}\r\n"
|
||||
"\t\t}\r\n"
|
||||
)
|
||||
wrote_history = True
|
||||
for state_src, state_data in patchwork_scripted.items():
|
||||
@ -213,9 +231,11 @@ def task_patch_history_states_scripted():
|
||||
'clean': True
|
||||
}
|
||||
|
||||
|
||||
def task_patch_raster():
|
||||
yield from patchwork_raster.tasks([patchwork_raster.patch_action])
|
||||
|
||||
|
||||
def task_patch():
|
||||
def mkdir(target, original, patch):
|
||||
Path(target).parent.mkdir(parents=True, exist_ok=True)
|
||||
@ -224,16 +244,18 @@ def task_patch():
|
||||
"patch -u --binary -N -o '{target}' '{original}' '{patch}'"
|
||||
])
|
||||
|
||||
|
||||
def task_image():
|
||||
return {
|
||||
'file_dep': list(patch_set.image_sources()),
|
||||
'targets': list(patch_set.image_files()),
|
||||
'actions': [f"mkdir -p {dir_modimage}",
|
||||
f"rsync -rv {dir_src_raw}/ {patchwork.patchwork_path}/"\
|
||||
f"rsync -rv {dir_src_raw}/ {patchwork.patchwork_path}/"
|
||||
f" {dir_modimage}/"],
|
||||
'clean': True
|
||||
}
|
||||
|
||||
|
||||
def task_image_mod():
|
||||
def prepare_modname_mod(task):
|
||||
source = Path(next(iter(task.file_dep)))
|
||||
@ -250,6 +272,7 @@ def task_image_mod():
|
||||
'clean': True
|
||||
}
|
||||
|
||||
|
||||
def task_build():
|
||||
return {
|
||||
'file_dep': [f"{dir_image}/{mod_name}.mod"] + list(patch_set.image_files()),
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,29 +0,0 @@
|
||||
--- ../vanilla/current/map/definition.csv 2023-10-10 13:46:35.000000000 +0400
|
||||
+++ build/image/randchgs/map/definition.csv 2023-11-27 23:45:22.219054356 +0400
|
||||
@@ -1013,7 +1013,7 @@
|
||||
1012;5;17;244;sea;false;ocean;0
|
||||
1013;5;18;30;land;true;plains;5
|
||||
1014;5;18;85;land;true;jungle;6
|
||||
-1015;5;18;135;land;true;desert;7
|
||||
+1015;5;18;135;land;true;urban;7
|
||||
1016;5;19;240;sea;false;ocean;0
|
||||
1017;5;20;248;sea;false;ocean;0
|
||||
1018;5;21;50;land;true;forest;6
|
||||
@@ -1063,7 +1063,7 @@
|
||||
1062;5;54;170;land;false;mountain;5
|
||||
1063;5;57;30;land;true;forest;6
|
||||
1064;5;57;85;land;false;desert;5
|
||||
-1065;5;57;135;land;true;plains;7
|
||||
+1065;5;57;135;land;true;urban;7
|
||||
1066;5;60;50;land;false;mountain;6
|
||||
1067;5;60;200;land;true;hills;6
|
||||
1068;5;63;15;land;false;desert;5
|
||||
@@ -1084,7 +1084,7 @@
|
||||
1083;5;78;145;land;false;forest;6
|
||||
1084;5;81;5;land;false;plains;6
|
||||
1085;5;81;60;land;true;jungle;4
|
||||
-1086;5;81;210;land;false;desert;7
|
||||
+1086;5;81;210;land;false;urban;7
|
||||
1087;5;84;25;land;false;plains;6
|
||||
1088;5;84;70;land;true;plains;7
|
||||
1089;5;84;175;land;true;hills;6
|
@ -1,5 +0,0 @@
|
||||
ISR_create_ships={
|
||||
create_ship {
|
||||
type = ship_hull_light_1
|
||||
}
|
||||
}
|
@ -144,3 +144,4 @@
|
||||
VICTORY_POINTS_11977:0 "Тэтджон"
|
||||
VICTORY_POINTS_6928:0 "Ханнам"
|
||||
VICTORY_POINTS_8136:0 "Ондангва"
|
||||
VICTORY_POINTS_9215:0 "Сосновка"
|
||||
|
Loading…
Reference in New Issue
Block a user