|
|
|
@ -748,18 +748,20 @@ class PokemonUI(QWidget): # Change from QMainWindow to QWidget |
|
|
|
new_fishing = fishing_check.isChecked() |
|
|
|
new_rods = rods_edit.text() or None |
|
|
|
new_exclusive_group_id = exclusive_group_combo.currentData() |
|
|
|
|
|
|
|
game_id = event_system.call_sync('get_game_id_for_name', new_game) |
|
|
|
|
|
|
|
# Update the database |
|
|
|
self.cursor.execute(''' |
|
|
|
UPDATE encounters |
|
|
|
SET game = ?, location = ?, day = ?, time = ?, dual_slot = ?, |
|
|
|
UPDATE encounters |
|
|
|
SET game_id = ?, location = ?, day = ?, time = ?, dual_slot = ?, |
|
|
|
static_encounter = ?, static_encounter_count = ?, extra_text = ?, |
|
|
|
stars = ?, fishing = ?, rods = ? |
|
|
|
WHERE pfic = ? AND game = ? AND location = ? |
|
|
|
''', (new_game, new_location, new_day, new_time, new_dual_slot, |
|
|
|
new_static_encounter, new_static_encounter_count, new_extra_text, |
|
|
|
new_stars, new_fishing, new_rods, |
|
|
|
self.current_pfic, game, location)) |
|
|
|
WHERE pfic = ? AND game_id = ? AND location = ? |
|
|
|
''', (game_id, new_location, new_day, new_time, new_dual_slot, |
|
|
|
new_static_encounter, new_static_encounter_count, new_extra_text, |
|
|
|
new_stars, new_fishing, new_rods, |
|
|
|
self.current_pfic, game_id, location)) |
|
|
|
self.conn.commit() |
|
|
|
|
|
|
|
# Update the cache if all encounters for this Pokémon were deleted |
|
|
|
@ -828,7 +830,7 @@ class PokemonUI(QWidget): # Change from QMainWindow to QWidget |
|
|
|
|
|
|
|
game_id = event_system.call_sync('get_game_id_for_name', game) |
|
|
|
|
|
|
|
# Insert new encounter into the database |
|
|
|
# Insert new encounter into the in-memory database |
|
|
|
self.cursor.execute(''' |
|
|
|
INSERT INTO encounters |
|
|
|
(pfic, game_id, location, day, time, dual_slot, static_encounter, static_encounter_count, extra_text, stars, fishing, rods) |
|
|
|
@ -845,10 +847,31 @@ class PokemonUI(QWidget): # Change from QMainWindow to QWidget |
|
|
|
def save_changes(self): |
|
|
|
if hasattr(self, 'current_pfic'): |
|
|
|
storable_in_home = self.home_checkbox.isChecked() |
|
|
|
self.patches[self.current_pfic] = {'storable_in_home': storable_in_home} |
|
|
|
is_baby_form = self.is_baby_form_checkbox.isChecked() |
|
|
|
|
|
|
|
# Update the in-memory database |
|
|
|
#self.cursor.execute(''' |
|
|
|
# UPDATE pokemon_storage |
|
|
|
# SET storable_in_home = ? |
|
|
|
# WHERE PFIC = ? |
|
|
|
#''', (storable_in_home, self.current_pfic)) |
|
|
|
|
|
|
|
#self.cursor.execute(''' |
|
|
|
# UPDATE pokemon_forms |
|
|
|
# SET is_baby_form = ? |
|
|
|
# WHERE PFIC = ? |
|
|
|
#''', (is_baby_form, self.current_pfic)) |
|
|
|
|
|
|
|
with open('patches.json', 'w') as f: |
|
|
|
json.dump(self.patches, f) |
|
|
|
#self.conn.commit() |
|
|
|
|
|
|
|
# Write the in-memory database to disk |
|
|
|
#disk_conn = sqlite3.connect('pokemon_forms.db') |
|
|
|
#self.conn.backup(disk_conn) |
|
|
|
#disk_conn.close() |
|
|
|
|
|
|
|
event_system.emit_sync('save_changes') |
|
|
|
|
|
|
|
QMessageBox.information(self, "Save Complete", "Changes have been saved to the database.") |
|
|
|
|
|
|
|
def export_database(self): |
|
|
|
export_conn = sqlite3.connect('pokemon_forms_production.db') |
|
|
|
@ -873,16 +896,6 @@ class PokemonUI(QWidget): # Change from QMainWindow to QWidget |
|
|
|
VALUES (?, ?, ?) |
|
|
|
''', (new_from_pfic, new_to_pfic, new_method)) |
|
|
|
|
|
|
|
# Create a new patch |
|
|
|
patch_key = f"evolution_{new_from_pfic}_{new_to_pfic}" |
|
|
|
self.patches[patch_key] = { |
|
|
|
'action': 'add', |
|
|
|
'from_pfic': new_from_pfic, |
|
|
|
'to_pfic': new_to_pfic, |
|
|
|
'method': new_method |
|
|
|
} |
|
|
|
self.save_patches() |
|
|
|
|
|
|
|
# Refresh the evolution chain display |
|
|
|
self.load_evolution_chain(self.current_pfic) |
|
|
|
|
|
|
|
|