Skip to content

Commit

Permalink
Merge pull request #2 from AngelsAndDemonsDM/texture_update
Browse files Browse the repository at this point in the history
Texture update
  • Loading branch information
themanyfaceddemon authored Jul 28, 2024
2 parents f282e17 + 53afc3a commit b3ad230
Show file tree
Hide file tree
Showing 14 changed files with 212 additions and 10 deletions.
28 changes: 28 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
### Описание PR'ра
<!-- Кратко опишите, какие изменения были внесены в этом PR и зачем данный PR нужен. -->
<!-- Пример: В этом PR улучшена производительность системы за счет оптимизации алгоритма обработки данных. -->

### Медиа
<!-- Если возможно, добавьте изображения ваших изменений. Вы можете добавить изображение через ссылку или вставить его напрямую, если оно сохранено в буфере обмена. -->

### Техническая информация
- [ ] PR полностью завершён.
- [ ] Мне **НЕ** нужна помощь для завершения PR.
- [ ] Проверено на локальной машине.
- [ ] Документация обновлена. <!-- при условии, что это применимо -->
- [ ] Тесты обновлены / добавлены. <!-- при условии, что это применимо -->

<!-- version_update: номер_версии -->
<!-- Поле с указанием новой версии. Если не указано, будет использована версия из последнего changelog. -->

<!-- autor: имя_автора -->
<!-- Изменяет имя автора ченджлога. Если не указано, будет использовано имя пользователя GitHub. -->

<!-- Здесь вы можете добавить любые дополнительные сведения, список задач, комментарии и прочее. Учтите, что раздел "### Изменения" должен идти последним. -->

### Изменения
<!-- Перечислите изменения, начиная каждое с новой строки и добавляя дефис перед каждым пунктом. Если после changes идёт NOT - ченджлог не создаётся-->
changes:
- Изменение 1: подробное описание изменения.
- Изменение 2: подробное описание изменения.
- Изменение 3: подробное описание изменения.
24 changes: 24 additions & 0 deletions .github/workflows/assignee.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Auto Assign

on:
issues:
types: [opened]
pull_request_target:
types: [opened]

jobs:
run:
runs-on: ubuntu-latest
if: ${{ github.actor != 'themanyfaceddemon' }}

permissions:
issues: write
pull-requests: write

steps:
- name: 'Auto-assign issue'
uses: pozil/auto-assign-issue@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
assignees: themanyfaceddemon
numOfAssignee: 1
23 changes: 23 additions & 0 deletions .github/workflows/close-pr-on-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Close PRs on master

on:
pull_request_target:
types: [opened, ready_for_review]

jobs:
run:
runs-on: ubuntu-latest
if: ${{ github.head_ref == 'master' || github.head_ref == 'main' }}

steps:
- uses: superbrothers/close-pull-request@v3
with:
comment: |
Похоже, вы новичок в нашем репозитории и пытаетесь внести изменения из ветки master.
Пожалуйста, прочитайте следующие гайды для правильной работы с репозиторием:
- [Подготовка окружения](http://dmbotwiki.a0001.net/ru/guide/prepare-environment.html)
- [Как создать форк](http://dmbotwiki.a0001.net/ru/guide/how-to-create-a-fork.html)
- [Первые изменения](http://dmbotwiki.a0001.net/ru/guide/first-changes.html)
Данный pull request будет закрыт, так как вы пытаетесь внести изменения из ветки master вашей локальной копии репозитория в ветку master основного репозитория. В будущем, пожалуйста, создавайте отдельные ветки для ваших изменений.
38 changes: 38 additions & 0 deletions .github/workflows/label-not-sorted.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "Label new issues with 'Not sorted'"

on:
issues:
types: [opened]

jobs:
add-label:
runs-on: ubuntu-latest

permissions:
issues: write

steps:
- name: Label new issues with "Not sorted"
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { owner, repo } = context.repo;
const issue_number = context.issue.number;
// Get issue details
const { data: issue } = await github.rest.issues.get({
owner,
repo,
issue_number
});
// Check if author is "themanyfaceddemon"
if (issue.user.login !== "themanyfaceddemon" || issue.labels.length === 0) {
await github.rest.issues.addLabels({
owner,
repo,
issue_number,
labels: ["Issue: Not sorted"]
});
}
22 changes: 22 additions & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "Set labels for PR"
on:
- pull_request_target

jobs:
labeler:
runs-on: ubuntu-latest

permissions:
contents: read
pull-requests: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set labels
uses: actions/labeler@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
configuration-path: .github/workflows_config/labeler.yml
sync-labels: true
38 changes: 38 additions & 0 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Tests

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Set PYTHONPATH
run: echo "PYTHONPATH=$PYTHONPATH:$(pwd)/Code" >> $GITHUB_ENV

- name: Run tests
timeout-minutes: 10
run: |
python -m unittest discover -s Tests -p "*.py" -v -f
env:
pythonLocation: /opt/hostedtoolcache/Python/3.12.3/x64
LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.12.3/x64/lib
2 changes: 2 additions & 0 deletions .github/workflows_config/assignee.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"**/*":
- themanyfaceddemon
15 changes: 15 additions & 0 deletions .github/workflows_config/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"Changes: Unit test":
- changed-files:
- any-glob-to-any-file: ['Tests/**']

"Changes: Workflows":
- changed-files:
- any-glob-to-any-file: ['.github/workflows/**']

"Changes: Workflows config":
- changed-files:
- any-glob-to-any-file: ['.github/workflows_config/**']

"Changes: GitHub template":
- changed-files:
- any-glob-to-any-file: ['.github/ISSUE_TEMPLATE/**', '.github/PULL_REQUEST_TEMPLATE.md']
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ venv.bak/

# Data
[Dd]ata/*
Content/*
Content/Servers/*

# Texture
Sprites/
Expand Down
3 changes: 2 additions & 1 deletion Code/gui/login_window.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import os

from gui.main_window import MainApplicationWindow
from PyQt6.QtCore import QThread, pyqtSignal
from PyQt6.QtGui import QPixmap
from PyQt6.QtWidgets import (QDialog, QLabel, QLineEdit, QMainWindow,
QMessageBox, QProgressBar, QPushButton)
from PyQt6.uic import loadUi
from root_path import ROOT_PATH
from systems.decorators import global_class
from systems.network import ClientUnit
from PyQt6.QtCore import QThread, pyqtSignal


@global_class
class LoginWindow(QMainWindow):
Expand Down
25 changes: 18 additions & 7 deletions Code/systems/network/client_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,15 @@ def check_server(self, ip: str, port: int = 5000) -> None:
self._socket_url = (ip, server_info.get("socket_port"))

def download_server_content(self, progress_callback=None) -> None:
response = self._session.get(f"{self._http_url}/server/download_server_content", stream=True)
try:
response = self._session.get(f"{self._http_url}/server/download_server_content", stream=True)
response.raise_for_status()

except requests.RequestException as e:
raise RuntimeError(f"Error during HTTP request: {e}")

archive_path = "content.zip"
content_dir = os.path.join(ROOT_PATH, 'Content')

content_dir = os.path.join(ROOT_PATH, 'Content', "Servers", self._http_url)
total_size = int(response.headers.get('content-length', 0))
downloaded_size = 0

Expand All @@ -68,17 +72,24 @@ def download_server_content(self, progress_callback=None) -> None:
downloaded_size += len(chunk)
if progress_callback:
progress_callback(downloaded_size, total_size)

except IOError as e:
raise IOError(f"Error saving file: {e}")

if os.path.exists(content_dir):
shutil.rmtree(content_dir)

with zipfile.ZipFile(archive_path, 'r') as zip_ref:
zip_ref.extractall(content_dir)
os.makedirs(content_dir, exist_ok=True)

os.remove(archive_path)
try:
with zipfile.ZipFile(archive_path, 'r') as zip_ref:
zip_ref.extractall(content_dir)

except zipfile.BadZipFile as e:
raise RuntimeError(f"Error extracting zip file: {e}")

finally:
os.remove(archive_path)

# --- Auth API --- #
def register(self, login: str, password: str) -> None:
Expand Down
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion Tests/Texture/TextureSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import yaml
from PIL import Image

from Code.texture_system import TextureSystem
from Code.systems.texture_system import TextureSystem


class TestTextureSystem(unittest.TestCase):
Expand Down

0 comments on commit b3ad230

Please sign in to comment.