Skip to content

Commit

Permalink
EPPL_auto_modificator
Browse files Browse the repository at this point in the history
  • Loading branch information
Max-RM committed Dec 7, 2023
1 parent 1e4c3f6 commit b3dd7b8
Show file tree
Hide file tree
Showing 16 changed files with 168 additions and 0 deletions.
Binary file added EPPL_Auto_Modificator/!Source/EPPL_128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added EPPL_Auto_Modificator/!Source/EPPL_16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added EPPL_Auto_Modificator/!Source/EPPL_255.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added EPPL_Auto_Modificator/!Source/EPPL_32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added EPPL_Auto_Modificator/!Source/EPPL_48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added EPPL_Auto_Modificator/!Source/EPPL_64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import wx
import sys
import os

class MyFrame(wx.Frame):
def __init__(self):
super().__init__(parent=None, title='EPPL_Auto_Modificator', size=(350, 200))
self.filename = os.path.join('..','!McChinaDev','unpacked_Minecraft.Windows.exe')
# остальной код
self.panel = wx.Panel(self)
self.checkbox = wx.CheckBox(self.panel, label='Enable/Disable the EPPL Mod', pos=(10, 10))
self.checkbox.Bind(wx.EVT_CHECKBOX, self.on_checkbox_toggle)
static_text = wx.StaticText(self.panel, label='Developed by MaxRM for MDLC', pos=(10, 140))
# Чтение информации из файла конфигурации
with open('config.txt', 'r') as config_file:
lines = config_file.readlines()
self.config_data = [line.strip().split(' >> ') for line in lines]

# Преобразование строк в целые числа и шестнадцатеричные значения
for i in range(len(self.config_data)):
self.config_data[i][0] = int(self.config_data[i][0], 16)
self.config_data[i][1:] = [value.strip() for value in self.config_data[i][1:]]

self.update_checkbox_state()

# Метод обновления состояния флажка
def update_checkbox_state(self):
with open(self.filename, 'rb') as file:
file.seek(self.config_data[0][0])
hex_value1 = file.read(1).hex().upper()
file.seek(self.config_data[1][0])
hex_value2 = file.read(1).hex().upper()
if hex_value1 == self.config_data[0][2] and hex_value2 == self.config_data[1][2]:
self.checkbox.SetValue(True)
elif hex_value1 == self.config_data[0][1] and hex_value2 == self.config_data[1][1]:
self.checkbox.SetValue(False)
else:
self.checkbox.Disable()
wx.MessageBox("Error: Invalid values found", "Error", style=wx.OK | wx.ICON_ERROR)
self.Close()

def replace_hex(self, hex_value):
with open(self.filename, 'rb+') as file:
file.seek(self.config_data[0][0])
file.write(bytes.fromhex(hex_value))
file.seek(self.config_data[1][0])
file.write(bytes.fromhex(hex_value))
file.flush()

def on_checkbox_toggle(self, event):
if self.checkbox.GetValue():
self.replace_hex(self.config_data[0][2])
else:
self.replace_hex(self.config_data[0][1])
self.update_checkbox_state()

app = wx.App()
frame = MyFrame()
frame.Show()
app.MainLoop()
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import wx
import sys
import os

class MyFrame(wx.Frame):
def __init__(self):
super().__init__(parent=None, title='EPPL_Auto_Modificator', size=(350, 200))
self.filename = os.path.join('Minecraft.Windows.exe')
# остальной код
self.panel = wx.Panel(self)
self.checkbox = wx.CheckBox(self.panel, label='Enable/Disable the EPPL Mod', pos=(10, 10))
self.checkbox.Bind(wx.EVT_CHECKBOX, self.on_checkbox_toggle)
static_text = wx.StaticText(self.panel, label='Developed by MaxRM for MDLC', pos=(10, 140))
# Чтение информации из файла конфигурации
with open('config.txt', 'r') as config_file:
lines = config_file.readlines()
self.config_data = [line.strip().split(' >> ') for line in lines]

# Преобразование строк в целые числа и шестнадцатеричные значения
for i in range(len(self.config_data)):
self.config_data[i][0] = int(self.config_data[i][0], 16)
self.config_data[i][1:] = [value.strip() for value in self.config_data[i][1:]]

self.update_checkbox_state()

# Метод обновления состояния флажка
def update_checkbox_state(self):
with open(self.filename, 'rb') as file:
file.seek(self.config_data[0][0])
hex_value1 = file.read(1).hex().upper()
file.seek(self.config_data[1][0])
hex_value2 = file.read(1).hex().upper()
if hex_value1 == self.config_data[0][2] and hex_value2 == self.config_data[1][2]:
self.checkbox.SetValue(True)
elif hex_value1 == self.config_data[0][1] and hex_value2 == self.config_data[1][1]:
self.checkbox.SetValue(False)
else:
self.checkbox.Disable()
wx.MessageBox("Error: Invalid values found", "Error", style=wx.OK | wx.ICON_ERROR)
self.Close()

def replace_hex(self, hex_value):
with open(self.filename, 'rb+') as file:
file.seek(self.config_data[0][0])
file.write(bytes.fromhex(hex_value))
file.seek(self.config_data[1][0])
file.write(bytes.fromhex(hex_value))
file.flush()

def on_checkbox_toggle(self, event):
if self.checkbox.GetValue():
self.replace_hex(self.config_data[0][2])
else:
self.replace_hex(self.config_data[0][1])
self.update_checkbox_state()

app = wx.App()
frame = MyFrame()
frame.Show()
app.MainLoop()
1 change: 1 addition & 0 deletions EPPL_Auto_Modificator/!Source/ico.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python png2ico.py EPPL_16.png EPPL_32.png EPPL_48.png EPPL_64.png EPPL_128.png EPPL_255.png
Binary file added EPPL_Auto_Modificator/!Source/icon.ico
Binary file not shown.
47 changes: 47 additions & 0 deletions EPPL_Auto_Modificator/!Source/png2ico.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from pathlib import Path
from typing import Sequence
from PIL import Image
import argparse


AUTO_RESIZE_OUTPUT_ICO_SIZES = ((16, 16), (24, 24), (32, 32), (48, 48), (64, 64), (128, 128), (255, 255))


def png2ico(pngs_paths: Sequence[str], ico_path: str, *, auto_resize: bool = False):
if auto_resize:
imgs = {Path(png_path).stat().st_size: png_path for png_path in pngs_paths}
largest_img_path = imgs[max(imgs.keys())]
img = Image.open(largest_img_path)
img.save(ico_path, sizes=AUTO_RESIZE_OUTPUT_ICO_SIZES)
else:
data = bytes((0, 0, 1, 0, len(pngs_paths), 0))
offset = 6 + len(pngs_paths) * 16

for png_path in pngs_paths:
img = Image.open(png_path)
try:
data += bytes((img.width, img.height, 0, 0, 1, 0, 32, 0,))
except ValueError:
raise ValueError('Image size can\'t be larger than 255x255 pixels. '
'Resize your image or use -r flag to continue.')
bytesize = Path(png_path).stat().st_size
data += bytesize.to_bytes(4, byteorder="little")
data += offset.to_bytes(4, byteorder="little")
offset += bytesize

for png in pngs_paths:
data += Path(png).read_bytes()

Path(ico_path).write_bytes(data)


if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Converting multiple .PNG files to one multisize .ICO file')
parser.add_argument('files', nargs='+', type=str, help='Input .PNG filenames')
parser.add_argument('-o', '--output', default='icon.ico', type=str, required=False, help='Output .ICO filename')
parser.add_argument('-r', '--resize', default=False, type=bool, action=argparse.BooleanOptionalAction,
help='Resizes the largest .PNG file automatically. '
'The output is multisize .ICO file with sizes: '
'16x16, 24x24, 32x32, 48x48, 64x64, 128x128, 255x255.')
args = parser.parse_args()
png2ico(pngs_paths=args.files, ico_path=args.output, auto_resize=args.resize)
Binary file added EPPL_Auto_Modificator/!Source/python311.dll
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Empty file.

0 comments on commit b3dd7b8

Please sign in to comment.