Skip to content

Commit

Permalink
Merge pull request #125 from ChrisNeedham24/MCR-124
Browse files Browse the repository at this point in the history
MCR-124 Added bundling as an Action for all operating systems.
  • Loading branch information
ChrisNeedham24 authored Mar 28, 2023
2 parents b465b89 + eca7f59 commit 67b8faa
Show file tree
Hide file tree
Showing 31 changed files with 144 additions and 31 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/bundle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Bundle

on:
push:
branches:
- main
workflow_dispatch:

jobs:
bundle:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install requirements
run: |
python -m pip install --upgrade pip
pip install -r dev_requirements.txt
- name: Bundle (MacOS)
run: |
python -m nuitka --standalone --include-data-dir=source=source --noinclude-data-files='*.json' --remove-output --assume-yes-for-downloads --macos-create-app-bundle --macos-app-icon=source/resources/icon.png microcosm.py
ditto -c -k --sequesterRsrc --keepParent microcosm.app microcosm-osx.zip
if: matrix.os == 'macos-latest'
- name: Bundle (Ubuntu)
run: |
python -m nuitka --onefile --standalone --include-data-dir=source=source --noinclude-data-files='*.json' --remove-output --assume-yes-for-downloads --linux-icon=source/resources/icon.png -o microcosm microcosm.py
chmod 744 microcosm
tar -cvf microcosm.tar.gz microcosm
if: matrix.os == 'ubuntu-latest'
- name: Bundle (Windows)
run: |
python -m nuitka --onefile --standalone --include-data-dir=source=source --noinclude-data-files='*.json' --remove-output --assume-yes-for-downloads --mingw64 microcosm.py
if: matrix.os == 'windows-latest'
- name: Upload artifact (MacOS)
uses: actions/upload-artifact@v3
with:
name: microcosm-osx
path: microcosm-osx.zip
if: matrix.os == 'macos-latest'
- name: Upload artifact (Ubuntu)
uses: actions/upload-artifact@v3
with:
name: microcosm-ubuntu-x86
path: microcosm.tar.gz
if: matrix.os == 'ubuntu-latest'
- name: Upload artifact (Windows)
uses: actions/upload-artifact@v3
with:
name: microcosm-windows
path: microcosm.exe
if: matrix.os == 'windows-latest'
bundle-fedora:
runs-on: ubuntu-latest
container: fedora
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install system packages
run: |
dnf update -y
dnf install -y patchelf gcc-c++
- name: Install requirements
run: |
python -m pip install --upgrade pip
python -m pip install -r dev_requirements.txt
- name: Bundle
run: |
python -m nuitka --onefile --standalone --include-data-dir=source=source --noinclude-data-files='*.json' --remove-output --assume-yes-for-downloads --linux-icon=source/resources/icon.png -o microcosm microcosm.py
chmod 744 microcosm
tar -cvf microcosm.tar.gz microcosm
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: microcosm-fedora-x86
path: microcosm.tar.gz
11 changes: 4 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,18 @@ jobs:
strategy:
matrix:
os: [macos-latest, ubuntu-latest]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
ref: ${{ github.ref }}

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install system packages (Ubuntu)
run: |
sudo apt-get update -y
sudo apt-get install -y libsdl2-2.0-0
sudo apt-get install -y vlc
sudo apt-get install -y libsdl2-2.0-0 vlc
if: matrix.os == 'ubuntu-latest'
- name: Install system packages (MacOS)
run: |
Expand All @@ -37,7 +34,7 @@ jobs:
- name: Install requirements
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r dev_requirements.txt
- name: Lint
run: pylint $(git ls-files '*.py')
- name: Test
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Alternatively, you can use the `# pragma: no cover` comment to do the same thing
### Environment details

To contribute to Microcosm, first create a fork of the repository into your own GitHub account.
For development, Python 3.10 as well as the requirements defined in requirements.txt are needed.
For development, Python 3.10 as well as the requirements defined in dev_requirements.txt are needed.

Please note that all changes should be made on a branch *other* than main.

Expand Down
5 changes: 5 additions & 0 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-r requirements.txt
pylint==2.17.1
coverage==6.5.0
nuitka==1.5.3
imageio==2.26.1
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pyxel==1.9.0
python-vlc==3.0.16120
pylint==2.13.9
coverage==6.5.0
platformdirs==3.1.1
18 changes: 9 additions & 9 deletions source/display/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ def draw(self):
pyxel.text(28, 40, "Player Faction", self.get_option_colour(SetupOption.PLAYER_FACTION))
faction_offset = 50 - pow(len(self.faction_colours[self.faction_idx][0]), 1.4)
if self.faction_idx == 0:
pyxel.text(100 + faction_offset, 40, f"{self.faction_colours[self.faction_idx][0]} ->",
pyxel.text(100 + faction_offset, 40, f"{self.faction_colours[self.faction_idx][0].value} ->",
self.faction_colours[self.faction_idx][1])
elif self.faction_idx == len(self.faction_colours) - 1:
pyxel.text(95 + faction_offset, 40, f"<- {self.faction_colours[self.faction_idx][0]}",
pyxel.text(95 + faction_offset, 40, f"<- {self.faction_colours[self.faction_idx][0].value}",
self.faction_colours[self.faction_idx][1])
else:
pyxel.text(88 + faction_offset, 40, f"<- {self.faction_colours[self.faction_idx][0]} ->",
pyxel.text(88 + faction_offset, 40, f"<- {self.faction_colours[self.faction_idx][0].value} ->",
self.faction_colours[self.faction_idx][1])
pyxel.text(26, 50, "(Press F to show more faction details)", pyxel.COLOR_WHITE)
pyxel.text(28, 65, "Player Count", self.get_option_colour(SetupOption.PLAYER_COUNT))
Expand Down Expand Up @@ -185,7 +185,7 @@ def draw(self):
pyxel.text(25, 35 + (idx - self.load_game_boundaries[0]) * 10, save, pyxel.COLOR_WHITE)
pyxel.text(150, 35 + (idx - self.load_game_boundaries[0]) * 10, "Load",
pyxel.COLOR_RED if self.save_idx is idx else pyxel.COLOR_WHITE)
if self.load_game_boundaries[1] != len(self.saves) - 1:
if self.load_game_boundaries[1] < len(self.saves) - 1:
self.draw_paragraph(147, 135, "More down!", 5)
pyxel.blt(167, 136, 0, 0, 76, 8, 8)
pyxel.text(56, 152, "Press SPACE to go back", pyxel.COLOR_WHITE)
Expand Down Expand Up @@ -373,7 +373,7 @@ def draw(self):
else:
pyxel.text(30, 63 + adj_idx * 25, "victory", pyxel.COLOR_GREEN)
pyxel.text(56, 162, "Press SPACE to go back", pyxel.COLOR_WHITE)
if self.blessing_boundaries[1] != len(BLESSINGS) - 1:
if self.blessing_boundaries[1] < len(BLESSINGS) - 1:
self.draw_paragraph(152, 155, "More down!", 5)
pyxel.blt(172, 156, 0, 0, 76, 8, 8)
case WikiOption.IMPROVEMENTS:
Expand Down Expand Up @@ -412,7 +412,7 @@ def draw(self):
pyxel.blt(20 + effects * 25, 64 + adj_offset, 0, satisfaction_u, 28, 8, 8)
pyxel.text(30 + effects * 25, 64 + adj_offset, f"{satisfaction:+}", pyxel.COLOR_WHITE)
pyxel.text(56, 162, "Press SPACE to go back", pyxel.COLOR_WHITE)
if self.improvement_boundaries[1] != len(IMPROVEMENTS) - 1:
if self.improvement_boundaries[1] < len(IMPROVEMENTS) - 1:
self.draw_paragraph(152, 155, "More down!", 5)
pyxel.blt(172, 156, 0, 0, 76, 8, 8)
case WikiOption.PROJECTS:
Expand Down Expand Up @@ -456,7 +456,7 @@ def draw(self):
pyxel.text(108, 50 + adj_idx * 10, str(unit.power), pyxel.COLOR_WHITE)
pyxel.text(132, 50 + adj_idx * 10, str(unit.total_stamina), pyxel.COLOR_WHITE)
pyxel.text(56, 162, "Press SPACE to go back", pyxel.COLOR_WHITE)
if self.unit_boundaries[1] != len(UNIT_PLANS) - 1:
if self.unit_boundaries[1] < len(UNIT_PLANS) - 1:
self.draw_paragraph(152, 155, "More down!", 5)
pyxel.blt(172, 156, 0, 0, 76, 8, 8)
case _:
Expand Down Expand Up @@ -642,7 +642,7 @@ def next_menu_option(self, current_option: MenuOptions, wrap_around: bool = Fals
current_option_idx = list(options_enum := type(current_option)).index(current_option)

# Determine the index of the next option value.
target_option_idx = (current_option_idx + 1) % len(options_enum)
target_option_idx = (current_option_idx + 1) % len(list(options_enum))
# If the currently selected option is the last option in the list and wrap-around is disabled, revert the index
# to its original value. In other words, we're staying at the bottom of the list and not going back up.
if (current_option_idx + 1) == len(options_enum) and not wrap_around:
Expand All @@ -661,7 +661,7 @@ def previous_menu_option(self, current_option: MenuOptions, wrap_around: bool =
current_option_idx = list(options_enum := type(current_option)).index(current_option)

# Determine the index of the previous option value.
target_option_idx = (current_option_idx - 1) % len(options_enum)
target_option_idx = (current_option_idx - 1) % len(list(options_enum))
# If the currently selected option is the first option in the list and wrap-around is disabled, revert the
# index to its original value. In other words, we're staying at the top of the list and not going back down.
if (current_option_idx - 1) < 0 and not wrap_around:
Expand Down
Loading

0 comments on commit 67b8faa

Please sign in to comment.