diff --git a/source/imperialism_remake/base/constants.py b/source/imperialism_remake/base/constants.py index dab6f74..42f232c 100644 --- a/source/imperialism_remake/base/constants.py +++ b/source/imperialism_remake/base/constants.py @@ -40,7 +40,8 @@ def extend(path, *parts): # TODO track used resources by the program #: base folders (do not directly contain data) -DATA_FOLDER = extend(os.path.dirname(__file__), os.path.pardir, 'data') +SOURCE_FOLDER = os.path.join(os.path.dirname(__file__), os.path.pardir) +DATA_FOLDER = extend(SOURCE_FOLDER, 'data') ARTWORK_FOLDER = extend(DATA_FOLDER, 'artwork') #: scenarios (save games) diff --git a/tools/build_documentation.py b/tools/build_documentation.py index 7dfcf34..65afb9f 100644 --- a/tools/build_documentation.py +++ b/tools/build_documentation.py @@ -13,30 +13,33 @@ import sphinx from sphinx import apidoc -def sphinx_build(directory): +def sphinx_build(rst_directory): """ + Builds a sphinx project as html and latex. - :param directory: + :param rst_directory: :return: """ - print('build directory {}'.format(directory)) + print('project directory {}'.format(rst_directory)) # output directory and builder name - out_directory = os.path.join(directory, '_build') - builder_name = 'html' + build_directory = os.path.join(rst_directory, '_build') # delete files of old build - if os.path.exists(out_directory): - shutil.rmtree(out_directory) - environment_file = os.path.join(directory, 'environment.pickle') + if os.path.exists(build_directory): + shutil.rmtree(build_directory) + + environment_file = os.path.join(rst_directory, 'environment.pickle') if os.path.exists(environment_file): os.remove(environment_file) - for file_name in glob.glob(os.path.join(directory, '*.doctree')): + + for file_name in glob.glob(os.path.join(rst_directory, '*.doctree')): os.remove(file_name) # call to sphinx - sphinx.build_main(argv=['', '-b', builder_name, directory, out_directory]) + for builder_name in ('html', 'latex'): + sphinx.build_main(argv=['', '-b', builder_name, rst_directory, os.path.join(build_directory, builder_name)]) def sphinx_api_build(source_directory, out_directory): """ @@ -75,17 +78,17 @@ def copy_manual(source, target): source_directory = os.path.join(tools_directory, os.path.pardir, 'source') documentation_directory = os.path.join(tools_directory, os.path.pardir, 'documentation') - # sphinx api build - api_build_out_directory = os.path.join(documentation_directory, 'development', 'source') - sphinx_api_build(source_directory, api_build_out_directory) + # sphinx api build (python to rst) + api_build_directory = os.path.join(documentation_directory, 'development', 'source') + sphinx_api_build(source_directory, api_build_directory) - # build manual + # build manual (rst to html, latex) manual_rst_directory = os.path.join(documentation_directory, 'manual') sphinx_build(manual_rst_directory) - # copy manual to ./data + # copy html manual to source/imperialism_remake/data/manual manual_data_directory = os.path.join(source_directory, 'imperialism_remake', 'data', 'manual') - manual_build_directory = os.path.join(manual_rst_directory, '_build') + manual_build_directory = os.path.join(manual_rst_directory, '_build', 'html') copy_manual(manual_build_directory, manual_data_directory) # build definition diff --git a/tools/create_default_scenario_client_configuration.py b/tools/create_default_scenario_client_configuration.py index 653d78c..196ae1b 100644 --- a/tools/create_default_scenario_client_configuration.py +++ b/tools/create_default_scenario_client_configuration.py @@ -18,17 +18,23 @@ Generate the default scenario client configuration file. """ -import os -os.chdir('..') +import os, sys -from lib import utils -from base import constants +from imperialism_remake.lib import utils +from imperialism_remake.base import constants -config = { - constants.ClientConfiguration.OVERVIEW_WIDTH: 300 -} +if __name__ == '__main__': -# save -file = constants.SCENARIO_CLIENT_STANDARD_FILE -print('write to {}'.format(file)) -utils.write_as_yaml(file, config) \ No newline at end of file + # add source directory to path if needed + source_directory = os.path.realpath(os.path.join(os.path.abspath(os.path.dirname(__file__)), os.path.pardir, 'source')) + if source_directory not in sys.path: + sys.path.insert(0, source_directory) + + config = { + constants.ClientConfiguration.OVERVIEW_WIDTH: 300 + } + + # save + file = constants.SCENARIO_CLIENT_STANDARD_FILE + print('write to {}'.format(file)) + utils.write_as_yaml(file, config) \ No newline at end of file diff --git a/tools/create_default_scenario_ruleset.py b/tools/create_default_scenario_ruleset.py index 01b1371..d0e363d 100644 --- a/tools/create_default_scenario_ruleset.py +++ b/tools/create_default_scenario_ruleset.py @@ -18,27 +18,33 @@ Generate the default rules. """ -import os -os.chdir('..') - -from lib import utils -from base import constants - -rules = {} - -# terrain names -terrain_names = { - 0: 'Sea', - 1: 'Plain', - 2: 'Hills', - 3: 'Mountains', - 4: 'Tundra', - 5: 'Swamp', - 6: 'Desert' -} -rules['terrain.names'] = terrain_names - -# save -file = constants.SCENARIO_RULESET_STANDARD_FILE -print('write to {}'.format(file)) -utils.write_as_yaml(file, rules) \ No newline at end of file +import os, sys + +from imperialism_remake.lib import utils +from imperialism_remake.base import constants + +if __name__ == '__main__': + + # add source directory to path if needed + source_directory = os.path.realpath(os.path.join(os.path.abspath(os.path.dirname(__file__)), os.path.pardir, 'source')) + if source_directory not in sys.path: + sys.path.insert(0, source_directory) + + rules = {} + + # terrain names + terrain_names = { + 0: 'Sea', + 1: 'Plain', + 2: 'Hills', + 3: 'Mountains', + 4: 'Tundra', + 5: 'Swamp', + 6: 'Desert' + } + rules['terrain.names'] = terrain_names + + # save + file = constants.SCENARIO_RULESET_STANDARD_FILE + print('write to {}'.format(file)) + utils.write_as_yaml(file, rules) \ No newline at end of file diff --git a/tools/create_sound_effects_configuration.py b/tools/create_sound_effects_configuration.py index a7fbcb8..64d3289 100644 --- a/tools/create_sound_effects_configuration.py +++ b/tools/create_sound_effects_configuration.py @@ -12,4 +12,8 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see \ No newline at end of file +# along with this program. If not, see + +""" +Will generate the sound effects configuration. (Not yet done.) +""" \ No newline at end of file diff --git a/tools/create_soundtrack_playlist.py b/tools/create_soundtrack_playlist.py index b905158..cab3d91 100644 --- a/tools/create_soundtrack_playlist.py +++ b/tools/create_soundtrack_playlist.py @@ -14,22 +14,30 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see -import os -os.chdir('..') - -from lib import utils as u -from base import constants as c - """ - Generates the playlist of the soundtrack (file names and titles displayed - in the game). Phonon cannot read metadata under Windows sometimes, see: - http://stackoverflow.com/questions/23288557/phonon-cant-get-meta-data-of-audio-files-in-python +Generates the playlist of the soundtrack (file names and titles displayed +in the game). + +Phonon cannot read metadata under Windows sometimes, see: +http://stackoverflow.com/questions/23288557/phonon-cant-get-meta-data-of-audio-files-in-python """ -# create the playlist, a list of (filename, title) -playlist = [['01 Imperialism Theme.ogg', 'Imperialism Theme']] -playlist.append(['02 Silent Ashes.ogg', 'Silent Ashes']) +import os, sys + +from imperialism_remake.lib import utils +from imperialism_remake.base import constants + +if __name__ == '__main__': + + # add source directory to path if needed + source_directory = os.path.realpath(os.path.join(os.path.abspath(os.path.dirname(__file__)), os.path.pardir, 'source')) + if source_directory not in sys.path: + sys.path.insert(0, source_directory) + + # create the playlist, a list of (filename, title) + playlist = [['01 Imperialism Theme.ogg', 'Imperialism Theme']] + playlist.append(['02 Silent Ashes.ogg', 'Silent Ashes']) -# write -print('write to {}'.format(c.SOUNDTRACK_INFO_FILE)) -u.write_as_yaml(c.SOUNDTRACK_INFO_FILE, playlist) \ No newline at end of file + # write + print('write to {}'.format(constants.SOUNDTRACK_INFO_FILE)) + utils.write_as_yaml(constants.SOUNDTRACK_INFO_FILE, playlist) \ No newline at end of file diff --git a/tools/create_start_screen_map.py b/tools/create_start_screen_map.py index ff9bca7..1a9cff7 100644 --- a/tools/create_start_screen_map.py +++ b/tools/create_start_screen_map.py @@ -14,55 +14,61 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see -import os -os.chdir('..') - -from lib import utils as u -from base import constants as c - """ - Generates the hot image areas map of the start screen. +Generates the hot image areas map of the start screen. """ -# hot areas map -map = {} +import os, sys + +from imperialism_remake.lib import utils +from imperialism_remake.base import constants + +if __name__ == '__main__': + + # add source directory to path if needed + source_directory = os.path.realpath(os.path.join(os.path.abspath(os.path.dirname(__file__)), os.path.pardir, 'source')) + if source_directory not in sys.path: + sys.path.insert(0, source_directory) + + # hot areas map + map = {} -# exit -map['exit'] = { - 'overlay': 'start.overlay.door.right.png', - 'offset': [575, 412], - 'label': 'Exit' -} + # exit + map['exit'] = { + 'overlay': 'start.overlay.door.right.png', + 'offset': [575, 412], + 'label': 'Exit' + } -# help browser -map['help'] = { - 'overlay': 'start.overlay.window.left.png', - 'offset': [127, 397], - 'label': 'Help' -} + # help browser + map['help'] = { + 'overlay': 'start.overlay.window.left.png', + 'offset': [127, 397], + 'label': 'Help' + } -# game lobby -map['lobby'] = { - 'overlay': 'start.overlay.throne.png', - 'offset': [421, 459], - 'label': 'Game Lobby' -} + # game lobby + map['lobby'] = { + 'overlay': 'start.overlay.throne.png', + 'offset': [421, 459], + 'label': 'Game Lobby' + } -# editor -map['editor'] = { - 'overlay': 'start.overlay.map.png', - 'offset': [821, 60], - 'label': 'Scenario Editor' -} + # editor + map['editor'] = { + 'overlay': 'start.overlay.map.png', + 'offset': [821, 60], + 'label': 'Scenario Editor' + } -# options -map['options'] = { - 'overlay': 'start.overlay.fireplace.png', - 'offset': [832, 505], - 'label': 'Preferences' -} + # options + map['options'] = { + 'overlay': 'start.overlay.fireplace.png', + 'offset': [832, 505], + 'label': 'Preferences' + } -# write -file_name = os.path.join(c.GRAPHICS_UI_FOLDER, 'start.overlay.info') -print('write to {}'.format(file_name)) -u.write_as_yaml(file_name, map) \ No newline at end of file + # write + file_name = os.path.join(constants.GRAPHICS_UI_FOLDER, 'start.overlay.info') + print('write to {}'.format(file_name)) + utils.write_as_yaml(file_name, map) \ No newline at end of file diff --git a/tools/package_vanilla.py b/tools/package_vanilla.py index 6c68721..4d46198 100644 --- a/tools/package_vanilla.py +++ b/tools/package_vanilla.py @@ -14,16 +14,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see -import os, shutil, zipfile - -import manual_markdown_converter - """ Creates an OS independent package (as zip file) that contains the sources and the data but requires Python and PySide to be installed manually also saving space. It serves as generic non Windows distribution for the moment. """ +import os, shutil, zipfile + # version string for file name encoding version = '0.2.1' diff --git a/tools/process_and_merge_sound_effects.py b/tools/process_and_merge_sound_effects.py index 72f3ffd..a073109 100644 --- a/tools/process_and_merge_sound_effects.py +++ b/tools/process_and_merge_sound_effects.py @@ -14,6 +14,12 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see +""" +Processes sound effects. (Not yet implemented.) + +wavfile (taken from scipy) requires numpy +""" + import wavfile # read sound effects configuration diff --git a/tools/pynsist_installer.cfg b/tools/pynsist_installer.cfg index b547daa..19cff19 100644 --- a/tools/pynsist_installer.cfg +++ b/tools/pynsist_installer.cfg @@ -14,9 +14,9 @@ include_msvcrt=false [Include] pypi_wheels=imperialism_remake==0.2.2 - PyQt5==5.7 - sip==4.18 - PyYaml==3.12 +PyQt5==5.7 +sip==4.18 +PyYaml==3.12 [Build] #directory=../build/nsis