Kenshi
poweredMOD UI
 This topic has been pinned, so it's probably important
DOG  [developer] 12 Jan @ 4:52pm
Code Python Steam version
import random
import os
import subprocess
import sys

# Получаем путь к текущей папке, где находится .exe файл
current_dir = os.path.dirname(sys.argv[0])
xml_file_path = os.path.join(current_dir, 'kenshi_images.xml')

# Список доступных текстур
textures = ["title_screen1.dds", "title_screen2.dds", "title_screen3.dds", "title_screen4.dds"]

# Выбираем случайную текстуру
selected_texture = random.choice(textures)

# Читаем текущий XML файл
try:
with open(xml_file_path, 'r', encoding='utf-8') as file:
xml_content = file.read()

# Заменяем все вхождения title_screen1.dds/title_screen2.dds/title_screen3.dds/title_screen4.dds на случайную текстуру
for texture in textures:
xml_content = xml_content.replace(texture, selected_texture)

# Записываем измененный XML файл
with open(xml_file_path, 'w', encoding='utf-8') as file:
file.write(xml_content)

print(f"Random texture {selected_texture} has been set in {xml_file_path}")
except FileNotFoundError:
print(f"Файл {xml_file_path} не найден.")
sys.exit()

# Извлекаем путь к Steam из реестра
steam_path = None
try:
for line in os.popen('reg query "HKEY_CURRENT_USER\\Software\\Valve\\Steam" /v "SteamPath"'):
if "SteamPath" in line:
steam_path = line.split()[-1]
break
except Exception as e:
print(f"Error reading registry: {e}")

# Проверяем, найден ли путь к Steam
if not steam_path:
print("Не удалось найти Steam. Убедитесь, что Steam установлен и путь к нему доступен в реестре.")
sys.exit()

# Запускаем игру через Steam с использованием ID игры
game_id = "233860" # ID игры Kenshi
subprocess.Popen([os.path.join(steam_path, "Steam.exe"), f"steam://rungameid/{game_id}"])
Last edited by DOG; 21 Jan @ 9:12pm
< >
Showing 1-3 of 3 comments
DOG  [developer] 13 Jan @ 4:34am 
You can review and compile it yourself.
Можете просмотреть и сами скомпилировать.
Last edited by DOG; 13 Jan @ 7:02am
DOG  [developer] 21 Jan @ 8:30pm 
Добавил 4 титульных экрана. так как тестирую сам желающих я так понял нет, прошу кто скачал написать о тесте хоть пару строчек и приятно и информация для размышления.
----------------------------------
Added 4 title screens. as I test myself willing to I understand there is no, please who downloaded to write about the test at least a couple of lines and nice and information for reflection.
Last edited by DOG; 21 Jan @ 9:10pm
DOG  [developer] 21 Jan @ 8:31pm 
Улучшен код :steamhappy:, удалены некритичные проверки ошибок.
Добавил файлы для Steam и NoSteam версий.
Оба кода находятся в моде в папке"\gui\images" "titlescreen_Steam.py" и "titlescreen_NoSteam.py" возле файла "kenshi_images.xml"
----------------------------------
Improved the code :steamhappy: removed non-critical error checking.
Added files for Steam and NoSteam versions.
Both codes are located in the mod in the folder"\gui\images" "titlescreen_Steam.py" and "titlescreen_NoSteam.py" near the file "kenshi_images.xml"

---------------------------------- Code NoSteam ----------------------------------
# Путь к корню игры (где лежат исполнимые файлы)
game_dir = os.path.abspath(os.path.join(current_dir, "..", "..", "..", ".."))

# Список возможных путей для исполнимых файлов игры
possible_exe_paths = [
os.path.join(game_dir, "kenshi_x32.exe"),
os.path.join(game_dir, "kenshi_x64.exe"),
os.path.join(game_dir, "kenshi_x64_vanilla.exe"),
os.path.join(game_dir, "kenshi_steam.exe"),
os.path.join(game_dir, "kenshi_gog_x64.exe")
Last edited by DOG; 21 Jan @ 9:09pm
< >
Showing 1-3 of 3 comments
Per page: 1530 50