Skip to content

Commit

Permalink
EnumProperty add
Browse files Browse the repository at this point in the history
  • Loading branch information
magicbear committed Feb 10, 2024
1 parent 5e7263c commit f9041a1
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 19 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ Changelog
Note that they these tags will not actually close the issue/PR until they
are merged into the "default" branch.

v0.5.3
-------

Update:

- For PalEdit
- EnumProperty add

v0.5.2
-------

Expand Down
2 changes: 1 addition & 1 deletion palworld_server_toolkit/PalEdit
62 changes: 45 additions & 17 deletions palworld_server_toolkit/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,8 @@ def __init__(self):
#
# tk.font.Font(family=
self.__font = ("Courier New", 12)
with open(f"{module_dir}/resources/enum.json", "r", encoding="utf-8") as f:
self.enum_options = json.load(f)

def build_subgui(self, g_frame, attribute_key, attrib_var, attrib):
sub_frame = ttk.Frame(master=g_frame, borderwidth=1, relief=tk.constants.GROOVE, padding=2)
Expand Down Expand Up @@ -1014,20 +1016,12 @@ def build_variable_gui(self, parent, attrib_var, attribs, with_labelframe=True):
tk.Checkbutton(master=g_frame, text="Enabled", variable=attrib_var[attribute_key]).pack(
side="left")
self.assign_attrib_var(attrib_var[attribute_key], attrib)
elif attrib['type'] == "EnumProperty" and attrib['value']['type'] == "EPalWorkSuitability":
enum_options = ['EPalWorkSuitability::EmitFlame', 'EPalWorkSuitability::Watering',
'EPalWorkSuitability::Seeding',
'EPalWorkSuitability::GenerateElectricity', 'EPalWorkSuitability::Handcraft',
'EPalWorkSuitability::Collection', 'EPalWorkSuitability::Deforest',
'EPalWorkSuitability::Mining',
'EPalWorkSuitability::OilExtraction', 'EPalWorkSuitability::ProductMedicine',
'EPalWorkSuitability::Cool', 'EPalWorkSuitability::Transport',
'EPalWorkSuitability::MonsterFarm']
if attrib['value']['value'] not in enum_options:
enum_options.append(attrib['value']['value'])
ttk.Combobox(master=g_frame, font=self.__font, state="readonly", width=40,
elif attrib['type'] == "EnumProperty" and attrib['value']['type'] in self.enum_options:
if attrib['value']['value'] not in self.enum_options[attrib['value']['type']]:
self.enum_options[attrib['value']['type']].append(attrib['value']['value'])
AutocompleteCombobox(master=g_frame, font=self.__font, width=40,
textvariable=attrib_var[attribute_key],
values=enum_options).pack(side="right")
values=self.enum_options[attrib['value']['type']]).pack(side="right")
self.assign_attrib_var(attrib_var[attribute_key], attrib)
elif attrib['type'] == "ArrayProperty" and attrib['array_type'] in ["StructProperty",
"NameProperty"]:
Expand Down Expand Up @@ -1711,10 +1705,16 @@ def edit_player_save(self):

def pal_edit(self):
PalEditConfig.font = self.font
pal = PalEditGUI()
pal.load_i18n(self.language)
pal.load(None)
pal.mainloop()
global paledit
try:
if paledit is not None:
paledit.gui.destroy()
except NameError:
pass
paledit = PalEditGUI()
paledit.load_i18n(self.language)
paledit.load(None)
paledit.mainloop()

def delete_base(self):
target_guild_uuid = self.target_guild.get().split(" - ")[0]
Expand Down Expand Up @@ -3066,6 +3066,34 @@ def search_values(dicts, key, level=""):
return isFound



def dump_enums(dicts, level=""):
isFound = {}
if isinstance(dicts, dict):
if 'type' in dicts and dicts['type'] == "EnumProperty":
if dicts['value']['type'] not in isFound:
isFound[dicts['value']['type']] = set()
isFound[dicts['value']['type']].add(dicts['value']['value'])
for k in dicts:
if isinstance(dicts[k], dict) or isinstance(dicts[k], list):
_dump = dump_enums(dicts[k], level + "['%s']" % k)
for _type in _dump:
if _type in isFound:
isFound[_type].update(_dump[_type])
else:
isFound[_type] = _dump[_type]
elif isinstance(dicts, list):
for idx, l in enumerate(dicts):
if isinstance(l, dict) or isinstance(l, list):
_dump = dump_enums(l, level + "[%d]" % idx)
for _type in _dump:
if _type in isFound:
isFound[_type].update(_dump[_type])
else:
isFound[_type] = _dump[_type]
return isFound


def LoadPlayers(data_source=None):
global wsd, playerMapping
if data_source is None:
Expand Down
70 changes: 70 additions & 0 deletions palworld_server_toolkit/resources/enum.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"EPalWorkSuitability": [
"EPalWorkSuitability::OilExtraction",
"EPalWorkSuitability::Seeding",
"EPalWorkSuitability::GenerateElectricity",
"EPalWorkSuitability::ProductMedicine",
"EPalWorkSuitability::Watering",
"EPalWorkSuitability::Deforest",
"EPalWorkSuitability::Cool",
"EPalWorkSuitability::Collection",
"EPalWorkSuitability::Handcraft",
"EPalWorkSuitability::MonsterFarm",
"EPalWorkSuitability::Mining",
"EPalWorkSuitability::Transport",
"EPalWorkSuitability::EmitFlame"
],
"EPalGenderType": [
"EPalGenderType::Female",
"EPalGenderType::Male"
],
"EPalBaseCampWorkerSickType": [
"EPalBaseCampWorkerSickType::Weakness",
"EPalBaseCampWorkerSickType::Fracture",
"EPalBaseCampWorkerSickType::Bulimia",
"EPalBaseCampWorkerSickType::Cold",
"EPalBaseCampWorkerSickType::GastricUlcer",
"EPalBaseCampWorkerSickType::DepressionSprain",
"EPalBaseCampWorkerSickType::Sprain"
],
"EPalStatusPhysicalHealthType": [
"EPalStatusPhysicalHealthType::MinorInjury",
"EPalStatusPhysicalHealthType::Dying",
"EPalStatusPhysicalHealthType::Severe"
],
"EPalStatusHungerType": [
"EPalStatusHungerType::Hunger",
"EPalStatusHungerType::Starvation"
],
"EPalBaseCampWorkerEventType": [
"EPalBaseCampWorkerEventType::EatTooMuch",
"EPalBaseCampWorkerEventType::DodgeWork_Sleep",
"EPalBaseCampWorkerEventType::DodgeWork_Short",
"EPalBaseCampWorkerEventType::DodgeWork"
],
"EPalWorkableType": [
"EPalWorkableType::MonsterFarm",
"EPalWorkableType::Repair",
"EPalWorkableType::OnlyJoin",
"EPalWorkableType::Progress",
"EPalWorkableType::OnlyJoinAndWalkAround",
"EPalWorkableType::Defense"
],
"EPalTribeID": [
"EPalTribeID::None",
"EPalTribeID::GrassMammoth"
],
"EPalGroupType": [
"EPalGroupType::Organization",
"EPalGroupType::Guild",
"EPalGroupType::Neutral"
],
"EPalDungeonType": [
"EPalDungeonType::Fixed",
"EPalDungeonType::Normal"
],
"EPalDungeonInstanceBossState": [
"EPalDungeonInstanceBossState::Dead",
"EPalDungeonInstanceBossState::Spawned"
]
}
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = palworld-server-toolkit
version = 0.5.2
version = 0.5.3
author = MagicBear
author_email = [email protected]
description = A toolset for PalWorld Server
Expand Down

0 comments on commit f9041a1

Please sign in to comment.