@ -86,11 +86,13 @@ class DBEditor(QMainWindow):
disk_cursor = disk_conn . cursor ( )
disk_cursor = disk_conn . cursor ( )
# Create tables in the file-based database
# Create tables in the file-based database
self . create_games_table ( disk_cursor )
self . create_pokemon_forms_table ( disk_cursor )
self . create_pokemon_forms_table ( disk_cursor )
self . create_pokemon_storage_table ( disk_cursor )
self . create_pokemon_storage_table ( disk_cursor )
self . create_evolution_chains_table ( disk_cursor )
self . create_evolution_chains_table ( disk_cursor )
self . create_exclusive_encounter_groups_table ( disk_cursor )
self . create_exclusive_encounter_groups_table ( disk_cursor )
self . create_encounters_table ( disk_cursor )
self . create_encounters_table ( disk_cursor )
self . create_mark_table ( disk_cursor )
# Commit changes to the file-based database
# Commit changes to the file-based database
disk_conn . commit ( )
disk_conn . commit ( )
@ -118,7 +120,8 @@ class DBEditor(QMainWindow):
name TEXT NOT NULL ,
name TEXT NOT NULL ,
form_name TEXT ,
form_name TEXT ,
national_dex INTEGER NOT NULL ,
national_dex INTEGER NOT NULL ,
generation INTEGER NOT NULL
generation INTEGER NOT NULL ,
is_baby_form BOOLEAN
)
)
''' )
''' )
@ -199,6 +202,131 @@ class DBEditor(QMainWindow):
ADD COLUMN starter BOOLEAN
ADD COLUMN starter BOOLEAN
''' )
''' )
def create_mark_table ( self , cursor ) :
cursor . execute ( '''
CREATE TABLE IF NOT EXISTS marks (
id INTEGER PRIMARY KEY ,
name TEXT NOT NULL ,
icon_path TEXT NOT NULL
)
''' )
cursor . execute ( '''
CREATE TABLE IF NOT EXISTS mark_game_associations (
mark_id INTEGER ,
game_id INTEGER ,
FOREIGN KEY ( mark_id ) REFERENCES marks ( id ) ,
FOREIGN KEY ( game_id ) REFERENCES games ( id ) ,
PRIMARY KEY ( mark_id , game_id )
)
''' )
marks = [
( " Game Boy " , " images/marks/GB_icon_HOME.png " , [ " Red " , " Blue " , " Yellow " , " Gold " , " Silver " , " Crystal " , " Ruby " , " Sapphire " , " Emerald " , " FireRed " , " LeafGreen " ] ) ,
( " Kalos " , " images/marks/Blue_pentagon_HOME.png " , [ " X " , " Y " , " Omega Ruby " , " Alpha Sapphire " ] ) ,
( " Alola " , " images/marks/Black_clover_HOME.png " , [ " Sun " , " Moon " , " Ultra Sun " , " Ultra Moon " ] ) ,
( " Let ' s Go " , " images/marks/Let ' s_Go_icon_HOME.png " , [ " Let ' s Go Pikachu " , " Let ' s Go Eevee " ] ) ,
( " Galar " , " images/marks/Galar_symbol_HOME.png " , [ " Sword " , " Shield " ] ) ,
( " Sinnoh " , " images/marks/BDSP_icon_HOME.png " , [ " Brilliant Diamond " , " Shining Pearl " ] ) ,
( " Hisui " , " images/marks/Arceus_mark_HOME.png " , [ " Legends Arceus " ] ) ,
( " Paldea " , " images/marks/Paldea_icon_HOME.png " , [ " Scarlet " , " Violet " ] ) ,
]
for mark in marks :
cursor . execute ( '''
INSERT OR IGNORE INTO marks ( name , icon_path )
VALUES ( ? , ? )
''' , (mark[0], mark[1]))
mark_id = cursor . lastrowid
for game_name in mark [ 2 ] :
cursor . execute ( '''
INSERT OR IGNORE INTO mark_game_associations ( mark_id , game_id )
SELECT ? , id FROM games WHERE name = ?
''' , (mark_id, game_name))
def create_games_table ( self , cursor ) :
cursor . execute ( '''
CREATE TABLE IF NOT EXISTS games (
id INTEGER PRIMARY KEY ,
name TEXT NOT NULL ,
generation INTEGER NOT NULL
)
''' )
cursor . execute ( '''
CREATE TABLE IF NOT EXISTS alternate_game_names (
id INTEGER PRIMARY KEY ,
game_id INTEGER NOT NULL ,
alternate_name TEXT NOT NULL ,
FOREIGN KEY ( game_id ) REFERENCES games ( id ) ,
UNIQUE ( alternate_name COLLATE NOCASE )
)
''' )
games = [
( " Red " , 1 , [ " Red Version " ] ) ,
( " Blue " , 1 , [ " Blue Version " ] ) ,
( " Yellow " , 1 , [ " Yellow Version " ] ) ,
( " Gold " , 2 , [ " Gold Version " ] ) ,
( " Silver " , 2 , [ " Silver Version " ] ) ,
( " Crystal " , 2 , [ " Crystal Version " ] ) ,
( " Ruby " , 3 , [ " Ruby Version " ] ) ,
( " Sapphire " , 3 , [ " Sapphire Version " ] ) ,
( " Emerald " , 3 , [ " Emerald Version " ] ) ,
( " FireRed " , 3 , [ " Fire Red " , " Fire-Red " ] ) ,
( " LeafGreen " , 3 , [ " Leaf Green " , " Leaf-Green " ] ) ,
( " Diamond " , 4 , [ " Diamond Version " ] ) ,
( " Pearl " , 4 , [ " Pearl Version " ] ) ,
( " Platinum " , 4 , [ " Platinum Version " ] ) ,
( " HeartGold " , 4 , [ " Heart Gold " , " Heart-Gold " ] ) ,
( " SoulSilver " , 4 , [ " Soul Silver " , " Soul-Silver " ] ) ,
( " Black " , 5 , [ " Black Version " ] ) ,
( " White " , 5 , [ " White Version " ] ) ,
( " Black 2 " , 5 , [ " Black Version 2 " , " Black-2 " ] ) ,
( " White 2 " , 5 , [ " White Version 2 " , " White-2 " ] ) ,
( " X " , 6 , [ " X Version " ] ) ,
( " Y " , 6 , [ " Y Version " ] ) ,
( " Omega Ruby " , 6 , [ " Omega Ruby Version " , " Omega-Ruby " ] ) ,
( " Alpha Sapphire " , 6 , [ " Alpha Sapphire Version " , " Alpha-Sapphire " ] ) ,
( " Sun " , 7 , [ " Sun Version " ] ) ,
( " Moon " , 7 , [ " Moon Version " ] ) ,
( " Ultra Sun " , 7 , [ " Ultra Sun Version " , " Ultra-Sun " ] ) ,
( " Ultra Moon " , 7 , [ " Ultra Moon Version " , " Ultra-Moon " ] ) ,
( " Let ' s Go Pikachu " , 7 , [ " Let ' s Go, Pikachu! " , " Lets Go Pikachu " ] ) ,
( " Let ' s Go Eevee " , 7 , [ " Let ' s Go, Eevee! " , " Lets Go Eevee " ] ) ,
( " Sword " , 8 , [ " Sword Version " ] ) ,
( " Shield " , 8 , [ " Shield Version " ] ) ,
( " Expansion Pass " , 8 , [ " Expansion Pass (Sword) " , " Expansion Pass (Shield) " ] ) ,
( " Brilliant Diamond " , 8 , [ " Brilliant Diamond Version " , " Brilliant-Diamond " ] ) ,
( " Shining Pearl " , 8 , [ " Shining Pearl Version " , " Shining-Pearl " ] ) ,
( " Legends Arceus " , 8 , [ " Legends: Arceus " , " Legends-Arceus " ] ) ,
( " Scarlet " , 9 , [ " Scarlet Version " ] ) ,
( " Violet " , 9 , [ " Violet Version " ] ) ,
( " The Teal Mask " , 9 , [ " The Teal Mask Version " , " The Teal Mask (Scarlet) " , " The Teal Mask (Violet) " ] ) ,
( " The Hidden Treasure of Area Zero " , 9 , [ " The Hidden Treasure of Area Zero Version " , " The Hidden Treasure of Area Zero (Scarlet) " , " The Hidden Treasure of Area Zero (Violet) " ] ) ,
( " Pokémon Home " , 98 , [ " Pokémon HOME " ] ) ,
( " Pokémon Go " , 99 , [ " Pokémon GO " ] ) ,
]
for game in games :
cursor . execute ( '''
INSERT OR IGNORE INTO games ( name , generation )
VALUES ( ? , ? )
''' , (game[0], game[1]))
game_id = cursor . lastrowid
# Insert alternate names
for alt_name in game [ 2 ] :
cursor . execute ( '''
INSERT OR IGNORE INTO alternate_game_names ( game_id , alternate_name )
VALUES ( ? , ? )
''' , (game_id, alt_name))
def load_and_apply_patches ( self ) :
def load_and_apply_patches ( self ) :
try :
try :
@ -283,12 +411,14 @@ class DBEditor(QMainWindow):
self . national_dex_label = QLabel ( )
self . national_dex_label = QLabel ( )
self . generation_label = QLabel ( )
self . generation_label = QLabel ( )
self . home_checkbox = QCheckBox ( " Available in Home " )
self . home_checkbox = QCheckBox ( " Available in Home " )
self . is_baby_form_checkbox = QCheckBox ( " Is Baby Form " )
self . edit_form . addRow ( " Name: " , self . name_label )
self . edit_form . addRow ( " Name: " , self . name_label )
self . edit_form . addRow ( " Form: " , self . form_name_label )
self . edit_form . addRow ( " Form: " , self . form_name_label )
self . edit_form . addRow ( " National Dex: " , self . national_dex_label )
self . edit_form . addRow ( " National Dex: " , self . national_dex_label )
self . edit_form . addRow ( " Generation: " , self . generation_label )
self . edit_form . addRow ( " Generation: " , self . generation_label )
self . edit_form . addRow ( self . home_checkbox )
self . edit_form . addRow ( self . home_checkbox )
self . edit_form . addRow ( self . is_baby_form_checkbox )
text_layout . addLayout ( self . edit_form )
text_layout . addLayout ( self . edit_form )
@ -408,7 +538,7 @@ class DBEditor(QMainWindow):
pfic = current . data ( Qt . ItemDataRole . UserRole )
pfic = current . data ( Qt . ItemDataRole . UserRole )
self . cursor . execute ( '''
self . cursor . execute ( '''
SELECT pf . name , pf . form_name , pf . national_dex , pf . generation , ps . storable_in_home
SELECT pf . name , pf . form_name , pf . national_dex , pf . generation , ps . storable_in_home , pf . is_baby_form
FROM pokemon_forms pf
FROM pokemon_forms pf
LEFT JOIN pokemon_storage ps ON pf . PFIC = ps . PFIC
LEFT JOIN pokemon_storage ps ON pf . PFIC = ps . PFIC
WHERE pf . PFIC = ?
WHERE pf . PFIC = ?
@ -416,12 +546,13 @@ class DBEditor(QMainWindow):
pokemon_data = self . cursor . fetchone ( )
pokemon_data = self . cursor . fetchone ( )
if pokemon_data :
if pokemon_data :
name , form_name , national_dex , generation , storable_in_home = pokemon_data
name , form_name , national_dex , generation , storable_in_home , is_baby_form = pokemon_data
self . name_label . setText ( name )
self . name_label . setText ( name )
self . form_name_label . setText ( form_name if form_name else " " )
self . form_name_label . setText ( form_name if form_name else " " )
self . national_dex_label . setText ( str ( national_dex ) )
self . national_dex_label . setText ( str ( national_dex ) )
self . generation_label . setText ( str ( generation ) )
self . generation_label . setText ( str ( generation ) )
self . home_checkbox . setChecked ( bool ( storable_in_home ) )
self . home_checkbox . setChecked ( bool ( storable_in_home ) )
self . is_baby_form_checkbox . setChecked ( bool ( is_baby_form ) )
self . home_checkbox . stateChanged . connect ( self . update_home_storable )
self . home_checkbox . stateChanged . connect ( self . update_home_storable )
# Load and display the image
# Load and display the image
@ -1035,6 +1166,8 @@ class DBEditor(QMainWindow):
# Process the Pokémon data
# Process the Pokémon data
process_pokemon_for_location_data ( pfic , name , form , national_dex , default_forms , cache , temp_conn )
process_pokemon_for_location_data ( pfic , name , form , national_dex , default_forms , cache , temp_conn )
temp_conn . backup ( self . conn )
# Close the temporary connection
# Close the temporary connection
temp_conn . close ( )
temp_conn . close ( )