Skip to content

Commit

Permalink
made most tools executable again
Browse files Browse the repository at this point in the history
  • Loading branch information
Trilarion committed Jul 27, 2017
1 parent a3a104d commit 9aace2f
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 118 deletions.
3 changes: 2 additions & 1 deletion source/imperialism_remake/base/constants.py
Expand Up @@ -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)
Expand Down
35 changes: 19 additions & 16 deletions tools/build_documentation.py
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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
Expand Down
28 changes: 17 additions & 11 deletions tools/create_default_scenario_client_configuration.py
Expand Up @@ -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)
# 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)
54 changes: 30 additions & 24 deletions tools/create_default_scenario_ruleset.py
Expand Up @@ -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)
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)
6 changes: 5 additions & 1 deletion tools/create_sound_effects_configuration.py
Expand Up @@ -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 <http://www.gnu.org/licenses/>
# along with this program. If not, see <http://www.gnu.org/licenses/>

"""
Will generate the sound effects configuration. (Not yet done.)
"""
38 changes: 23 additions & 15 deletions tools/create_soundtrack_playlist.py
Expand Up @@ -14,22 +14,30 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>

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)
# write
print('write to {}'.format(constants.SOUNDTRACK_INFO_FILE))
utils.write_as_yaml(constants.SOUNDTRACK_INFO_FILE, playlist)
92 changes: 49 additions & 43 deletions tools/create_start_screen_map.py
Expand Up @@ -14,55 +14,61 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>

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)
# 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)
6 changes: 2 additions & 4 deletions tools/package_vanilla.py
Expand Up @@ -14,16 +14,14 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>

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'

Expand Down
6 changes: 6 additions & 0 deletions tools/process_and_merge_sound_effects.py
Expand Up @@ -14,6 +14,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>

"""
Processes sound effects. (Not yet implemented.)
wavfile (taken from scipy) requires numpy
"""

import wavfile

# read sound effects configuration
Expand Down
6 changes: 3 additions & 3 deletions tools/pynsist_installer.cfg
Expand Up @@ -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
Expand Down

0 comments on commit 9aace2f

Please sign in to comment.