diff --git a/.vscode/settings.json b/.vscode/settings.json index 86fd9577..5b703ba9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -51,6 +51,7 @@ "pyinstaller", "pypresence", "qsize", + "rbga", "sangvis", "sfpsp", "simhei", diff --git a/Data/chapter_dialogs_example.yaml b/Data/chapter_dialogs_example.yaml index a1328a74..b9828208 100644 --- a/Data/chapter_dialogs_example.yaml +++ b/Data/chapter_dialogs_example.yaml @@ -50,4 +50,15 @@ dialogs: last_dialog_id: head narrator: Name next_dialog_id: null + dialog_during_battle: + head: + background_img: + background_music: null + characters_img: null + content: + - '' + last_dialog_id: null + narrator: Name + next_dialog_id: + type: break title: The title of this chapter diff --git a/Data/chapter_map_example.yaml b/Data/chapter_map_example.yaml index bbe3f07d..cbf1c5dd 100644 --- a/Data/chapter_map_example.yaml +++ b/Data/chapter_map_example.yaml @@ -1,3 +1,4 @@ +atNight: false backgroundImage: snowfield.jpg background_music: Combat_02_RemnantFantasyPackage_Synari.ogg character: @@ -6,7 +7,6 @@ character: type: sv-98 x: 5 y: 7 -darkMode: false decoration: campfire: campfire1: diff --git a/Data/main_chapter/chapter1_dialogs_English.yaml b/Data/main_chapter/chapter1_dialogs_English.yaml index 50fbccef..07d107a9 100644 --- a/Data/main_chapter/chapter1_dialogs_English.yaml +++ b/Data/main_chapter/chapter1_dialogs_English.yaml @@ -6,114 +6,6 @@ battle_info: - 'Location: approximately 50 km east of the temporary base' description: Above the snowy plains, the bitter cold wind whipped my cheeks. But at least, you are with me. -dialog_during_battle: - initial_dialog: - - changePos: - x: 0 - y: 0 - - move: - gsh-18: - x: 8 - y: 4 - pp1901: - x: 8 - y: 3 - - dialoguebox_down: - content: - - At last, we're free of SangvisFerri's - - pursuers. Did anyone get hurt? - speaker: sv-98 - speaker_icon: sv-98 - dialoguebox_up: null - - dialoguebox_down: - content: - - At last, we're free of SangvisFerri's - - pursuers. Did anyone get hurt? - speaker: sv-98 - speaker_icon: sv-98 - dialoguebox_up: - content: - - Fine - speaker: Everyone - speaker_icon: null - - direction: - asval: true - - idle: 1 - - direction: - asval: false - - idle: 1 - - dialoguebox_down: - content: - - Sv-98, we have signs of SangvisFerri - - activity ahead. - speaker: asval - speaker_icon: asval - dialoguebox_up: null - - changePos: - x: 30 - y: 30 - - idle: 1 - - changePos: - x: 0 - y: 0 - - dialoguebox_down: - content: - - Oh no! I'm out of ammo... - speaker: sv-98 - speaker_icon: sv-98 - dialoguebox_up: null - - dialoguebox_down: - content: - - The SangvisFerri in the front... - - Seems to be guarding something. - speaker: pp1901 - speaker_icon: pp1901 - dialoguebox_up: null - - move: - sv-98: - x: 5 - y: 12 - - dialoguebox_down: - content: - - From a distance, it looks like a supply - - crate. - speaker: gsh-18 - speaker_icon: gsh-18 - dialoguebox_up: null - - dialoguebox_down: - content: - - Sv-98, go for it. We'll cover you. - speaker: asval - speaker_icon: asval - dialoguebox_up: null - - dialoguebox_down: - content: - - It seems like I have no choice... - - Girls, load your guns and prepare to - - fight! - speaker: sv-98 - speaker_icon: sv-98 - dialoguebox_up: null - - dialoguebox_down: - content: - - sv-98 has no bullets at this moment - - and cannot attack - speaker: Tip - speaker_icon: null - dialoguebox_up: null - tutorial1: - - dialoguebox_down: - content: - - Guys, I got the supplies! - speaker: sv-98 - speaker_icon: sv-98 - dialoguebox_up: null - - dialoguebox_down: - content: - - Please note the ammunition change. - speaker: Tip - speaker_icon: null - dialoguebox_up: null dialogs: dialog_after_battle: head: @@ -278,7 +170,6 @@ dialogs: 16: content: - Asval, how is everything going so far? - narrator: Sv-98 17: content: - The commander has already sent a helicopter to pick us up. @@ -289,7 +180,6 @@ dialogs: - Let's hurry up! As long as we can destroy all SangvisFerri's forces in the area before - the helicopters arrive, we'll be able to evacuate safely. - narrator: Sv-98 19: content: - Great! @@ -297,5 +187,45 @@ dialogs: 20: content: - Keep your voice down! It's not like SangvisFerri didn't have ears. - narrator: Sv-98 + dialog_during_battle: + head: + content: + - At last, we're free of SangvisFerri's + - pursuers. Did anyone get hurt? + initial_dialog_2: + content: + - Fine + narrator: Everyone + initial_dialog_3: + content: + - Sv-98, we have signs of SangvisFerri activity ahead. + initial_dialog_4: + content: + - Oh no! I'm out of ammo... + initial_dialog_5: + content: + - The SangvisFerri in the front... + - Seems to be guarding something. + initial_dialog_6: + content: + - From a distance, it looks like a supply crate. + initial_dialog_7: + content: + - Sv-98, go for it. We'll cover you. + initial_dialog_8: + content: + - It seems like I have no choice... + - Girls, get ready, it is our show time! + initial_dialog_9: + content: + - sv-98 has no bullets at this moment + - and cannot attack + narrator: Tip + tutorial1: + content: + - Guys, I got the supplies! + tutorial2: + content: + - Please remember to reload. + narrator: Tip title: A Wish Likes Snow diff --git a/Data/main_chapter/chapter1_dialogs_SimplifiedChinese.yaml b/Data/main_chapter/chapter1_dialogs_SimplifiedChinese.yaml index 17d946d0..0179363e 100644 --- a/Data/main_chapter/chapter1_dialogs_SimplifiedChinese.yaml +++ b/Data/main_chapter/chapter1_dialogs_SimplifiedChinese.yaml @@ -5,109 +5,6 @@ battle_info: - 能见度:0.78公里 - 地点:临时据点以东约50公里 description: 茫茫雪原之上,刺骨的寒风拂过我的脸颊。但至少,还有你们的陪伴 -dialog_during_battle: - initial_dialog: - - changePos: - x: 0 - y: 0 - - move: - gsh-18: - x: 8 - y: 4 - pp1901: - x: 8 - y: 3 - - dialoguebox_down: - content: - - 总算是摆脱铁血的追兵了 - - 大家都没事吧 - speaker: sv-98 - speaker_icon: sv-98 - dialoguebox_up: null - - dialoguebox_down: - content: - - 总算是摆脱铁血的追兵了 - - 大家都没事吧 - speaker: sv-98 - speaker_icon: sv-98 - dialoguebox_up: - content: - - 没事 - speaker: 众人 - speaker_icon: null - - direction: - asval: true - - idle: 1 - - direction: - asval: false - - idle: 1 - - dialoguebox_down: - content: - - sv-98,前方发现有铁血活动的痕迹 - speaker: asval - speaker_icon: asval - dialoguebox_up: null - - changePos: - x: 30 - y: 30 - - idle: 1 - - changePos: - x: 0 - y: 0 - - dialoguebox_down: - content: - - 该死...我已经没有弹药了 - speaker: sv-98 - speaker_icon: sv-98 - dialoguebox_up: null - - dialoguebox_down: - content: - - 前方的铁血...好像在守着什么 - speaker: pp1901 - speaker_icon: pp1901 - dialoguebox_up: null - - move: - sv-98: - x: 5 - y: 12 - - dialoguebox_down: - content: - - 远远看过去,好像是物资箱 - speaker: gsh-18 - speaker_icon: gsh-18 - dialoguebox_up: null - - dialoguebox_down: - content: - - sv-98,上吧。我们会掩护你的。 - speaker: asval - speaker_icon: asval - dialoguebox_up: null - - dialoguebox_down: - content: - - 那就拜托你们了... - - 各位,子弹上膛,准备战斗! - speaker: sv-98 - speaker_icon: sv-98 - dialoguebox_up: null - - dialoguebox_down: - content: - - 目前sv-98没有子弹,无法攻击 - speaker: 提示 - speaker_icon: null - dialoguebox_up: null - tutorial1: - - dialoguebox_down: - content: - - 各位,我拿到补给了! - speaker: sv-98 - speaker_icon: sv-98 - dialoguebox_up: null - - dialoguebox_down: - content: - - 请注意换弹 - speaker: 提示 - speaker_icon: null - dialoguebox_up: null dialogs: dialog_after_battle: head: @@ -559,4 +456,133 @@ dialogs: last_dialog_id: 19 narrator: asval next_dialog_id: null + dialog_during_battle: + head: + background_img: + background_music: null + characters_img: + - sv-98.png + content: + - 总算是摆脱铁血的追兵了 + - 大家都没事吧 + last_dialog_id: null + narrator: sv-98 + next_dialog_id: + target: initial_dialog_2 + type: default + initial_dialog_2: + background_img: + background_music: null + characters_img: + - sv-98.png + content: + - 没事 + last_dialog_id: head + narrator: 众人 + next_dialog_id: + type: break + initial_dialog_3: + background_img: + background_music: null + characters_img: + - asval.png + content: + - sv-98,前方发现有铁血活动的痕迹 + last_dialog_id: null + narrator: asval + next_dialog_id: + type: break + initial_dialog_4: + background_img: + background_music: null + characters_img: + - sv-98.png + content: + - 该死...我已经没有弹药了 + last_dialog_id: null + narrator: sv-98 + next_dialog_id: + target: initial_dialog_5 + type: default + initial_dialog_5: + background_img: + background_music: null + characters_img: + - pp1901.png + content: + - 前方的铁血...好像在守着什么 + last_dialog_id: initial_dialog_4 + narrator: pp1901 + next_dialog_id: + target: initial_dialog_6 + type: default + initial_dialog_6: + background_img: + background_music: null + characters_img: + - gsh-18.png + content: + - 远远看过去,好像是物资箱 + last_dialog_id: null + narrator: gsh-18 + next_dialog_id: + target: initial_dialog_7 + type: default + initial_dialog_7: + background_img: + background_music: null + characters_img: + - asval.png + content: + - sv-98,上吧。我们会掩护你的。 + last_dialog_id: initial_dialog_6 + narrator: asval + next_dialog_id: + target: initial_dialog_8 + type: default + initial_dialog_8: + background_img: + background_music: null + characters_img: + - sv-98.png + content: + - 那就拜托你们了... + - 各位,子弹上膛,准备战斗! + last_dialog_id: initial_dialog_7 + narrator: sv-98 + next_dialog_id: + target: initial_dialog_9 + type: default + initial_dialog_9: + background_img: + background_music: null + characters_img: null + content: + - 目前sv-98没有子弹,无法攻击 + last_dialog_id: initial_dialog_8 + narrator: 提示 + next_dialog_id: + type: break + tutorial1: + background_img: + background_music: null + characters_img: + - sv-98.png + content: + - 各位,我拿到补给了! + last_dialog_id: null + narrator: sv-98 + next_dialog_id: + target: tutorial2 + type: default + tutorial2: + background_img: + background_music: null + characters_img: null + content: + - 请注意换弹 + last_dialog_id: tutorial1 + narrator: 提示 + next_dialog_id: + type: break title: 白色的希望 diff --git a/Data/main_chapter/chapter1_map.yaml b/Data/main_chapter/chapter1_map.yaml index 7f4f0c1e..7362311b 100644 --- a/Data/main_chapter/chapter1_map.yaml +++ b/Data/main_chapter/chapter1_map.yaml @@ -1,3 +1,4 @@ +atNight: false backgroundImage: snowfield.jpg background_music: Combat_02_RemnantFantasyPackage_Synari.ogg character: @@ -22,7 +23,6 @@ character: type: sv-98 x: 5 y: 7 -darkMode: false decoration: campfire: campfire1: @@ -441,13 +441,44 @@ decoration: x: 3 y: 5 dialogs: - initial: initial_dialog - move: - 15-10: - dialog_key: tutorial1 - repeat: false - whitelist: - - sv-98 + data: + initial_dialog: + - changePos: + x: 0 + y: 0 + - move: + gsh-18: + x: 8 + y: 4 + pp1901: + x: 8 + y: 3 + - dialog: head + - direction: + asval: true + - idle: 1 + - direction: + asval: false + - idle: 1 + - dialog: initial_dialog_3 + - changePos: + x: 30 + y: 30 + - idle: 1 + - changePos: + x: 0 + y: 0 + - dialog: initial_dialog_4 + tutorial1: + - dialog: tutorial1 + dictionary: + initial: initial_dialog + move: + 15-10: + dialog_key: tutorial1 + repeat: false + whitelist: + - sv-98 local_x: -3000 local_y: 1000 map: diff --git a/Data/main_chapter/info.yaml b/Data/main_chapter/info.yaml index a587abf1..e76e1bc9 100644 --- a/Data/main_chapter/info.yaml +++ b/Data/main_chapter/info.yaml @@ -1,4 +1,6 @@ author: Tigeia-Workshop +cover_image: +- Assets/image/covers/chapter1.png default_lang: SimplifiedChinese link: https://github.com/Tigeia-Workshop/GirlsFrontLine-LastWish title: diff --git a/Data/version.yaml b/Data/version.yaml index 53ae8438..6b255d71 100644 --- a/Data/version.yaml +++ b/Data/version.yaml @@ -1,3 +1,3 @@ -patch: 2 +patch: 3 revision: 0 version: 0 diff --git a/README.md b/README.md index e26b8e98..834dfa85 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Total alerts](https://img.shields.io/lgtm/alerts/g/Tigeia-Workshop/GirlsFrontLine-LastWish.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Tigeia-Workshop/GirlsFrontLine-LastWish/alerts/) [![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/Tigeia-Workshop/GirlsFrontLine-LastWish.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Tigeia-Workshop/GirlsFrontLine-LastWish/context:python) ![GitHub all releases](https://img.shields.io/github/downloads/Tigeia-Workshop/GirlsFrontLine-LastWish/total) ![GitHub](https://img.shields.io/github/license/Tigeia-Workshop/GirlsFrontLine-LastWish) ![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/Tigeia-Workshop/GirlsFrontLine-LastWish?include_prereleases) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/linpg) + # :speech_balloon: Preamble / 前言 Their stories may be forgotten by history, but what they have done will be remembered forever. @@ -56,10 +58,8 @@ Their stories may be forgotten by history, but what they have done will be remem | Name / 名称 | Recommended Version / 建议版本 | | :---------: | :----------------------------: | -| pygame | 2.0.1 | | pyyaml | 5.4 | -| pyav | 8.0.2 | -| numpy | 1.20 | +| pypresence | 4.2 | | linpg | * | ##### * You have to install the latest version of Linpg Engine! diff --git a/Source/basic.py b/Source/base.py similarity index 84% rename from Source/basic.py rename to Source/base.py index 62d41b9e..e5a185bd 100644 --- a/Source/basic.py +++ b/Source/base.py @@ -16,11 +16,11 @@ RPC = Presence(str(CLIENT_ID)) RPC.connect() RPC.update(state=linpg.get_lang("DiscordStatus","game_is_initializing"),large_image=LARGE_IMAGE) - except: + except Exception: RPC = None #加载版本信息 -version_info:dict = linpg.loadConfig("Data/version.yaml") +version_info:dict = linpg.load_config("Data/version.yaml") VERSION:int = version_info["version"] REVISION:int = version_info["revision"] PATCH:int = version_info["patch"] @@ -31,7 +31,7 @@ #alpha构建警告 ALPHA_BUILD_WARNING = linpg.TextSurface( - linpg.fontRender(linpg.get_lang("alpha_build_warning"),"white",linpg.get_standard_font_size("medium")/2),0,0 + linpg.render_font(linpg.get_lang("alpha_build_warning"),"white",linpg.get_standard_font_size("medium")/2),0,0 ) ALPHA_BUILD_WARNING.set_centerx(linpg.display.get_width()/2) ALPHA_BUILD_WARNING.set_bottom(linpg.display.get_height()-ALPHA_BUILD_WARNING.get_height()) diff --git a/Source/component.py b/Source/component.py new file mode 100644 index 00000000..adadd237 --- /dev/null +++ b/Source/component.py @@ -0,0 +1,41 @@ +# cython: language_level=3 +from .scene import * + +#blit载入页面 +def dispaly_loading_screen(screen:linpg.ImageSurface, start:int, end:int, value:int) -> None: + window_x,window_y = screen.get_size() + #获取健康游戏忠告 + HealthyGamingAdvice = linpg.try_get_lang("HealthyGamingAdvice") + if HealthyGamingAdvice == "HealthyGamingAdvice": + HealthyGamingAdvice = [] + else: + for i in range(len(HealthyGamingAdvice)): + HealthyGamingAdvice[i] = linpg.render_font(HealthyGamingAdvice[i],"white",window_x/64) + #其他载入页面需要的数据 + text1 = linpg.render_font(linpg.get_lang("title1"), "white", window_x/64) + text2 = linpg.render_font(linpg.get_lang("title2"), "white", window_x/64) + #主循环 + for i in range(start,end,value): + screen.fill(linpg.get_color_rbga("black")) + text1.set_alpha(i) + text2.set_alpha(i) + screen.blits(((text1,(window_x/64,window_y*0.9)),(text2,(window_x/64,window_y*0.9-window_x/32)))) + for a in range(len(HealthyGamingAdvice)): + HealthyGamingAdvice[a].set_alpha(i) + screen.blit(HealthyGamingAdvice[a],(window_x-window_x/32-HealthyGamingAdvice[a].get_width(),window_y*0.9-window_x/64*a*1.5)) + linpg.display.flip() + +#控制台 +class Console(linpg.Console): + def _check_command(self, conditions:list) -> None: + if conditions[0] == "load": + if conditions[1] == "dialog": + dialog(linpg.display.screen_window, conditions[2], conditions[3], conditions[4], conditions[5]) + elif conditions[1] == "battle": + battle(linpg.display.screen_window, conditions[2], conditions[3], conditions[4]) + else: + self.txtOutput.append("Error, do not know what to load.") + else: + super()._check_command(conditions) + +console = Console(linpg.display.get_width()*0.1, linpg.display.get_height()*0.8) \ No newline at end of file diff --git a/Source/gamemode/editor.py b/Source/gamemode/editor.py index 03326b27..03100b11 100644 --- a/Source/gamemode/editor.py +++ b/Source/gamemode/editor.py @@ -15,12 +15,12 @@ def __load_characters_data(self, mapFileData:dict) -> None: #类似多线程的join,待完善 while self._is_characters_loader_alive(): pass #初始化 - def load(self, screen:pygame.Surface, chapterType:str, chapterId:int, projectName:str=None) -> None: + def load(self, screen:linpg.ImageSurface, chapterType:str, chapterId:int, projectName:str=None) -> None: self._initialize(chapterType, chapterId, projectName) self.folder_for_save_file,self.name_for_save_file = os.path.split(self.get_map_file_location()) - self.decorations_setting = linpg.loadConfig("Data/decorations.yaml","decorations") + self.decorations_setting = linpg.load_config("Data/decorations.yaml","decorations") #载入地图数据 - mapFileData:dict = linpg.loadConfig(self.get_map_file_location()) + mapFileData:dict = linpg.load_config(self.get_map_file_location()) #初始化角色信息 self.__load_characters_data(mapFileData) #初始化地图 @@ -29,12 +29,9 @@ def load(self, screen:pygame.Surface, chapterType:str, chapterId:int, projectNam SnowEnvImg = ["TileSnow01","TileSnow01ToStone01","TileSnow01ToStone02","TileSnow02","TileSnow02ToStone01","TileSnow02ToStone02"] block_y = 50 block_x = 50 - default_map = [[SnowEnvImg[linpg.randomInt(0,5)] for a in range(block_x)] for i in range(block_y)] + default_map = [[SnowEnvImg[linpg.get_random_int(0,5)] for a in range(block_x)] for i in range(block_y)] mapFileData["map"] = default_map - linpg.saveConfig(self.get_map_file_location(),mapFileData) - else: - block_y = len(mapFileData["map"]) - block_x = len(mapFileData["map"][0]) + linpg.save_config(self.get_map_file_location(),mapFileData) #加载地图 self._create_map(mapFileData) del mapFileData @@ -46,18 +43,18 @@ def load(self, screen:pygame.Surface, chapterType:str, chapterId:int, projectNam button_height:int = int(screen.get_height()*0.2) panding:int = int(screen.get_height()*0.01) font_size:int = int(button_width/3) - self.__button_select_block = linpg.loadButtonWithTextInCenter( + self.__button_select_block = linpg.load_button_with_text_in_center( "Assets/image/UI/menu.png",linpg.get_lang("MapEditor","block"),"black",font_size,(0,screen.get_width()*0.03),100 ) - self.__button_select_decoration = linpg.loadButtonWithTextInCenter( + self.__button_select_decoration = linpg.load_button_with_text_in_center( "Assets/image/UI/menu.png",linpg.get_lang("MapEditor","decoration"),"black",font_size,(0,screen.get_width()*0.03),100 ) self.__button_select_block.set_left( int((container_width-self.__button_select_block.get_width()-self.__button_select_decoration.get_width()-panding)/2) ) self.__button_select_decoration.set_left(self.__button_select_block.right+panding) - self.__UIContainerRight = linpg.loadImage("Assets/image/UI/container.png",(0,0),container_width,container_height) - self.__UIContainerButtonRight = linpg.loadDynamicImage("Assets/image/UI/container_button.png", + self.__UIContainerRight = linpg.load_dynamic_image("Assets/image/UI/container.png",(0,0),container_width,container_height) + self.__UIContainerButtonRight = linpg.load_movable_image("Assets/image/UI/container_button.png", (screen.get_width()-button_width,int((screen.get_height()-button_height)/2)), (screen.get_width()-button_width-container_width,int((screen.get_height()-button_height)/2)), (int(container_width/10),0),button_width,button_height @@ -69,7 +66,7 @@ def load(self, screen:pygame.Surface, chapterType:str, chapterId:int, projectNam None, int(container_width*0.075), int(screen.get_height()*0.1), int(container_width*0.85), int(screen.get_height()*0.85), "vertical" ) for imgPath in glob.glob(r'Assets/image/environment/block/*.png'): - self.__envImgContainer.set(os.path.basename(imgPath).replace(".png",""),linpg.loadImg(imgPath,(self.MAP.block_width/3,None))) + self.__envImgContainer.set(os.path.basename(imgPath).replace(".png",""),linpg.load_img(imgPath,(self.MAP.block_width/3,None))) self.__envImgContainer.set_item_per_line(4) self.__envImgContainer.set_scroll_bar_pos("right") self.__envImgContainer.hidden = False @@ -79,7 +76,7 @@ def load(self, screen:pygame.Surface, chapterType:str, chapterId:int, projectNam None, int(container_width*0.075), int(screen.get_height()*0.1), int(container_width*0.85), int(screen.get_height()*0.85), "vertical" ) for imgPath in glob.glob(r'Assets/image/environment/decoration/*.png'): - self.__decorationsImgContainer.set(os.path.basename(imgPath).replace(".png",""),linpg.loadImg(imgPath,(self.MAP.block_width/3,None))) + self.__decorationsImgContainer.set(os.path.basename(imgPath).replace(".png",""),linpg.load_img(imgPath,(self.MAP.block_width/3,None))) self.__decorationsImgContainer.set_item_per_line(4) self.__decorationsImgContainer.set_scroll_bar_pos("right") self.__decorationsImgContainer.hidden = True @@ -91,14 +88,14 @@ def load(self, screen:pygame.Surface, chapterType:str, chapterId:int, projectNam button_height = int(screen.get_height()*0.05) panding = int(screen.get_height()*0.01) font_size = int(button_height/2) - self.__button_select_character = linpg.loadButtonWithTextInCenter( + self.__button_select_character = linpg.load_button_with_text_in_center( "Assets/image/UI/menu.png",linpg.get_lang("General","griffin_Kryuger"),"black",font_size,(0,0),100 ) - self.__button_select_sangvisFerri = linpg.loadButtonWithTextInCenter( + self.__button_select_sangvisFerri = linpg.load_button_with_text_in_center( "Assets/image/UI/menu.png",linpg.get_lang("General","sangvis_ferri"),"black",font_size,(self.__button_select_character.get_width(),0),100 ) - self.__UIContainerBottom = linpg.loadImage("Assets/image/UI/container.png",(0,0),container_width,container_height) - self.__UIContainerButtonBottom = linpg.loadDynamicImage( + self.__UIContainerBottom = linpg.load_dynamic_image("Assets/image/UI/container.png",(0,0),container_width,container_height) + self.__UIContainerButtonBottom = linpg.load_movable_image( "Assets/image/UI/container_button.png", ((container_width-button_width)/2,screen.get_height()-button_height), ((container_width-button_width)/2,screen.get_height()-button_height-container_height), @@ -112,7 +109,7 @@ def load(self, screen:pygame.Surface, chapterType:str, chapterId:int, projectNam img_name = os.path.basename(imgPath) self.__charactersImgContainer.set( img_name, - linpg.copeBounding(linpg.loadImg(os.path.join(imgPath, "wait", "{}_wait_0.png".format(img_name)), (None, container_height*1.5))) + linpg.cope_bounding(linpg.load_img(os.path.join(imgPath, "wait", "{}_wait_0.png".format(img_name)), (None, container_height*1.5))) ) self.__charactersImgContainer.set_scroll_bar_pos("bottom") self.__charactersImgContainer.hidden = False @@ -125,15 +122,15 @@ def load(self, screen:pygame.Surface, chapterType:str, chapterId:int, projectNam img_name = os.path.basename(imgPath) self.__sangvisFerrisImgContainer.set( img_name, - linpg.copeBounding(linpg.loadImg(os.path.join(imgPath, "wait", "{}_wait_0.png".format(img_name)), (None, container_height*1.5))) + linpg.cope_bounding(linpg.load_img(os.path.join(imgPath, "wait", "{}_wait_0.png".format(img_name)), (None, container_height*1.5))) ) self.__sangvisFerrisImgContainer.set_scroll_bar_pos("bottom") self.__sangvisFerrisImgContainer.hidden = True self.__sangvisFerrisImgContainer.distance_between_item = panding #绿色方块/方块标准 - self.greenBlock = linpg.loadImg("Assets/image/UI/range/green.png",(self.MAP.block_width*0.8,None)) + self.greenBlock = linpg.load_img("Assets/image/UI/range/green.png",(self.MAP.block_width*0.8,None)) self.greenBlock.set_alpha(150) - self.redBlock = linpg.loadImg("Assets/image/UI/range/red.png",(self.MAP.block_width*0.8,None)) + self.redBlock = linpg.load_img("Assets/image/UI/range/red.png",(self.MAP.block_width*0.8,None)) self.redBlock.set_alpha(150) self.deleteMode:bool = False self.object_to_put_down = None @@ -142,54 +139,51 @@ def load(self, screen:pygame.Surface, chapterType:str, chapterId:int, projectNam UI_x = self.MAP.block_width*0.5 UI_y = int(screen.get_height()*0.02) font_size = int(self.MAP.block_width*0.2) - self.UIButton["save"] = linpg.loadButtonWithTextInCenter( + self.UIButton["save"] = linpg.load_button_with_text_in_center( "Assets/image/UI/menu.png", linpg.get_lang("Global", "save"), "black", font_size, (UI_x, UI_y), 100 ) UI_x += self.UIButton["save"].get_width()+font_size - self.UIButton["back"] = linpg.loadButtonWithTextInCenter( + self.UIButton["back"] = linpg.load_button_with_text_in_center( "Assets/image/UI/menu.png", linpg.get_lang("Global", "back"), "black", font_size, (UI_x, UI_y), 100 ) UI_x += self.UIButton["back"].get_width()+font_size - self.UIButton["delete"] = linpg.loadButtonWithTextInCenter( + self.UIButton["delete"] = linpg.load_button_with_text_in_center( "Assets/image/UI/menu.png", linpg.get_lang("Global", "delete"), "black", font_size, (UI_x, UI_y), 100 ) UI_x += self.UIButton["delete"].get_width()+font_size - self.UIButton["reload"] = linpg.loadButtonWithTextInCenter( + self.UIButton["reload"] = linpg.load_button_with_text_in_center( "Assets/image/UI/menu.png", linpg.get_lang("Global", "reload_file"), "black", font_size, (UI_x, UI_y), 100 ) #其他函数 self.UI_local_x = 0 self.UI_local_y = 0 #未保存离开时的警告 - self.__no_save_warning = linpg.LeaveWithoutSavingWarning( - os.path.join("Assets/image/UI","container.png"),0,0,screen.get_width()/2,screen.get_height()/4 - ) - self.__no_save_warning.set_center(screen.get_width()/2,screen.get_height()/2) + self.__no_save_warning = linpg.converter.generate_ui(linpg.get_raw_deault_ui("leave_without_saving_warning")) #用于储存即将发下的物品的具体参数 self.data_to_edit = None #读取地图原始文件 - self.originalData = linpg.loadConfig(self.get_map_file_location()) + self.originalData = linpg.load_config(self.get_map_file_location()) #将地图制作器的界面画到屏幕上 - def draw(self, screen:pygame.Surface) -> None: + def draw(self, screen:linpg.ImageSurface) -> None: mouse_x,mouse_y = linpg.controller.get_mouse_pos() block_get_click = self.MAP.calBlockInMap(mouse_x,mouse_y) for event in linpg.controller.events: - if event.type == pygame.KEYDOWN: - if event.key == pygame.K_ESCAPE: + if event.type == linpg.KEY.DOWN: + if event.key == linpg.KEY.ESCAPE: self.object_to_put_down = None self.data_to_edit = None self.deleteMode = False self._check_key_down(event) - elif event.type == pygame.KEYUP: + elif event.type == linpg.KEY.UP: self._check_key_up(event) - elif event.type == pygame.MOUSEBUTTONDOWN: + elif event.type == linpg.MOUSE_BUTTON_DOWN: #上下滚轮-放大和缩小地图 if self.__UIContainerButtonRight.is_hover(): self.__UIContainerButtonRight.switch() - self.__UIContainerButtonRight.flip(True,False) + self.__UIContainerButtonRight.flip() elif self.__UIContainerButtonBottom.is_hover(): self.__UIContainerButtonBottom.switch() - self.__UIContainerButtonBottom.flip(False,True) + self.__UIContainerButtonBottom.flip() elif self.deleteMode is True and block_get_click is not None: #查看当前位置是否有装饰物 decoration = self.MAP.find_decoration_on((block_get_click["x"],block_get_click["y"])) @@ -198,7 +192,7 @@ def draw(self, screen:pygame.Surface) -> None: self.MAP.remove_decoration(decoration) else: any_chara_replace = None - for key,value in linpg.dicMerge(self.alliances_data,self.enemies_data).items(): + for key,value in linpg.merge_dict(self.alliances_data,self.enemies_data).items(): if value.x == block_get_click["x"] and value.y == block_get_click["y"]: any_chara_replace = key break @@ -209,22 +203,22 @@ def draw(self, screen:pygame.Surface) -> None: elif any_chara_replace in self.enemies_data: self.enemies_data.pop(any_chara_replace) self.originalData["sangvisFerri"].pop(any_chara_replace) - elif linpg.isHover(self.UIButton["save"]) and self.object_to_put_down is None and not self.deleteMode: + elif linpg.is_hover(self.UIButton["save"]) and self.object_to_put_down is None and not self.deleteMode: self.save_progress() - elif linpg.isHover(self.UIButton["back"]) and self.object_to_put_down is None and not self.deleteMode: - if linpg.loadConfig(self.get_map_file_location()) == self.originalData: + elif linpg.is_hover(self.UIButton["back"]) and self.object_to_put_down is None and not self.deleteMode: + if linpg.load_config(self.get_map_file_location()) == self.originalData: self.stop() break else: self.__no_save_warning.hidden = False - elif linpg.isHover(self.UIButton["delete"]) and self.object_to_put_down is None and not self.deleteMode: + elif linpg.is_hover(self.UIButton["delete"]) and self.object_to_put_down is None and not self.deleteMode: self.object_to_put_down = None self.data_to_edit = None self.deleteMode = True - elif linpg.isHover(self.UIButton["reload"]) and self.object_to_put_down is None and not self.deleteMode: - tempLocal_x,tempLocal_y = self.MAP.getPos() + elif linpg.is_hover(self.UIButton["reload"]) and self.object_to_put_down is None and not self.deleteMode: + tempLocal_x,tempLocal_y = self.MAP.get_local_pos() #读取地图数据 - mapFileData = linpg.loadConfig(self.get_map_file_location()) + mapFileData = linpg.load_config(self.get_map_file_location()) #初始化角色信息 self.__load_characters_data(mapFileData) #加载地图 @@ -232,11 +226,11 @@ def draw(self, screen:pygame.Surface) -> None: del mapFileData self.MAP.setPos(tempLocal_x,tempLocal_y) #读取地图 - self.originalData = linpg.loadConfig(self.get_map_file_location()) + self.originalData = linpg.load_config(self.get_map_file_location()) else: - if pygame.mouse.get_pressed()[0] and block_get_click is not None and self.object_to_put_down is not None and\ - not linpg.isHover(self.__UIContainerRight,local_x=self.__UIContainerButtonRight.right) and\ - not linpg.isHover(self.__UIContainerBottom,local_y=self.__UIContainerButtonBottom.bottom): + if linpg.controller.get_event("confirm") and block_get_click is not None and self.object_to_put_down is not None and\ + not linpg.is_hover(self.__UIContainerRight,off_set_x=self.__UIContainerButtonRight.right) and\ + not linpg.is_hover(self.__UIContainerBottom,off_set_y=self.__UIContainerButtonBottom.bottom): if self.object_to_put_down["type"] == "block": self.originalData["map"][block_get_click["y"]][block_get_click["x"]] = self.object_to_put_down["id"] self.MAP.update_block(block_get_click,self.object_to_put_down["id"]) @@ -258,7 +252,7 @@ def draw(self, screen:pygame.Surface) -> None: self.MAP.load_decorations(self.originalData["decoration"]) elif self.object_to_put_down["type"] == "character" or self.object_to_put_down["type"] == "sangvisFerri": any_chara_replace = None - for key,value in linpg.dicMerge(self.alliances_data,self.enemies_data).items(): + for key,value in linpg.merge_dict(self.alliances_data,self.enemies_data).items(): if value.x == block_get_click["x"] and value.y == block_get_click["y"]: any_chara_replace = key break @@ -292,14 +286,14 @@ def draw(self, screen:pygame.Surface) -> None: } self.enemies_data[nameTemp] = linpg.HostileCharacter(self.originalData["sangvisFerri"][nameTemp],self.DATABASE[self.originalData["sangvisFerri"][nameTemp]["type"]],"dev") #其他移动的检查 - self._check_right_click_move(mouse_x,mouse_y) + self._check_right_click_move() self._check_jostick_events() #画出地图 self._display_map(screen) if block_get_click is not None and\ - not linpg.isHover(self.__UIContainerRight,local_x=self.__UIContainerButtonRight.right) and\ - not linpg.isHover(self.__UIContainerBottom,local_y=self.__UIContainerButtonBottom.bottom): + not linpg.is_hover(self.__UIContainerRight,off_set_x=self.__UIContainerButtonRight.right) and\ + not linpg.is_hover(self.__UIContainerBottom,off_set_y=self.__UIContainerButtonBottom.bottom): if self.deleteMode is True: xTemp,yTemp = self.MAP.calPosInMap(block_get_click["x"],block_get_click["y"]) screen.blit(self.redBlock,(xTemp+self.MAP.block_width*0.1,yTemp)) @@ -310,11 +304,11 @@ def draw(self, screen:pygame.Surface) -> None: #角色动画 for key in self.alliances_data: self.alliances_data[key].draw(screen,self.MAP) - if self.object_to_put_down is None and pygame.mouse.get_pressed()[0] and self.alliances_data[key].x == int(mouse_x/self.greenBlock.get_width()) and self.alliances_data[key].y == int(mouse_y/self.greenBlock.get_height()): + if self.object_to_put_down is None and linpg.controller.get_event("confirm") and self.alliances_data[key].x == int(mouse_x/self.greenBlock.get_width()) and self.alliances_data[key].y == int(mouse_y/self.greenBlock.get_height()): self.data_to_edit = self.alliances_data[key] for key in self.enemies_data: self.enemies_data[key].draw(screen,self.MAP) - if self.object_to_put_down is None and pygame.mouse.get_pressed()[0] and self.enemies_data[key].x == int(mouse_x/self.greenBlock.get_width()) and self.enemies_data[key].y == int(mouse_y/self.greenBlock.get_height()): + if self.object_to_put_down is None and linpg.controller.get_event("confirm") and self.enemies_data[key].x == int(mouse_x/self.greenBlock.get_width()) and self.enemies_data[key].y == int(mouse_y/self.greenBlock.get_height()): self.data_to_edit = self.enemies_data[key] #展示设施 @@ -326,15 +320,15 @@ def draw(self, screen:pygame.Surface) -> None: self.__UIContainerRight.display(screen,(self.__UIContainerButtonRight.right,0)) self.__envImgContainer.display(screen,(self.__UIContainerButtonRight.right,0)) self.__decorationsImgContainer.display(screen,(self.__UIContainerButtonRight.right,0)) - if linpg.isHover(self.__button_select_block,local_x=self.__UIContainerButtonRight.right) and pygame.mouse.get_pressed()[0]: + if linpg.is_hover(self.__button_select_block,off_set_x=self.__UIContainerButtonRight.right) and linpg.controller.get_event("confirm"): self.__envImgContainer.hidden = False self.__decorationsImgContainer.hidden = True - if linpg.isHover(self.__button_select_decoration,local_x=self.__UIContainerButtonRight.right) and pygame.mouse.get_pressed()[0]: + if linpg.is_hover(self.__button_select_decoration,off_set_x=self.__UIContainerButtonRight.right) and linpg.controller.get_event("confirm"): self.__envImgContainer.hidden = True self.__decorationsImgContainer.hidden = False self.__button_select_block.display(screen,(self.__UIContainerButtonRight.right,0)) self.__button_select_decoration.display(screen,(self.__UIContainerButtonRight.right,0)) - if pygame.mouse.get_pressed()[0]: + if linpg.controller.get_event("confirm"): if not self.__envImgContainer.hidden and self.__envImgContainer.current_hovered_item is not None: self.object_to_put_down = {"type":"block","id":self.__envImgContainer.current_hovered_item} elif not self.__decorationsImgContainer.hidden and self.__decorationsImgContainer.current_hovered_item is not None: @@ -345,15 +339,15 @@ def draw(self, screen:pygame.Surface) -> None: self.__UIContainerBottom.display(screen,(0,self.__UIContainerButtonBottom.bottom)) self.__charactersImgContainer.display(screen,(0,self.__UIContainerButtonBottom.bottom)) self.__sangvisFerrisImgContainer.display(screen,(0,self.__UIContainerButtonBottom.bottom)) - if linpg.isHover(self.__button_select_character,local_y=self.__UIContainerButtonBottom.bottom) and pygame.mouse.get_pressed()[0]: + if linpg.is_hover(self.__button_select_character,off_set_y=self.__UIContainerButtonBottom.bottom) and linpg.controller.get_event("confirm"): self.__charactersImgContainer.hidden = False self.__sangvisFerrisImgContainer.hidden = True - if linpg.isHover(self.__button_select_sangvisFerri,local_y=self.__UIContainerButtonBottom.bottom) and pygame.mouse.get_pressed()[0]: + if linpg.is_hover(self.__button_select_sangvisFerri,off_set_y=self.__UIContainerButtonBottom.bottom) and linpg.controller.get_event("confirm"): self.__charactersImgContainer.hidden = True self.__sangvisFerrisImgContainer.hidden = False self.__button_select_character.display(screen,(0,self.__UIContainerButtonBottom.bottom)) self.__button_select_sangvisFerri.display(screen,(0,self.__UIContainerButtonBottom.bottom)) - if pygame.mouse.get_pressed()[0]: + if linpg.controller.get_event("confirm"): if not self.__charactersImgContainer.hidden and self.__charactersImgContainer.current_hovered_item is not None: self.object_to_put_down = {"type":"character","id":self.__charactersImgContainer.current_hovered_item} elif not self.__sangvisFerrisImgContainer.hidden and self.__sangvisFerrisImgContainer.current_hovered_item is not None: @@ -361,7 +355,7 @@ def draw(self, screen:pygame.Surface) -> None: #画出上方其他按钮 for key in self.UIButton: - linpg.isHover(self.UIButton[key]) + linpg.is_hover(self.UIButton[key]) self.UIButton[key].draw(screen) #跟随鼠标显示即将被放下的物品 @@ -378,27 +372,27 @@ def draw(self, screen:pygame.Surface) -> None: #显示即将被编辑的数据 if self.data_to_edit is not None: screen.blits(( - (linpg.fontRender("action points: "+str(self.data_to_edit.max_action_point),"black",15),(screen.get_width()*0.91,screen.get_height()*0.8)), - (linpg.fontRender("attack range: "+str(self.data_to_edit.attack_range),"black",15),(screen.get_width()*0.91,screen.get_height()*0.8+20)), - (linpg.fontRender("current bullets: "+str(self.data_to_edit.current_bullets),"black",15),(screen.get_width()*0.91,screen.get_height()*0.8+20*2)), - (linpg.fontRender("magazine capacity: "+str(self.data_to_edit.magazine_capacity),"black",15),(screen.get_width()*0.91,screen.get_height()*0.8+20*3)), - (linpg.fontRender("max hp: "+str(self.data_to_edit.max_hp),"black",15),(screen.get_width()*0.91,screen.get_height()*0.8+20*4)), - (linpg.fontRender("effective range: "+str(self.data_to_edit.effective_range),"black",15),(screen.get_width()*0.91,screen.get_height()*0.8+20*5)), - (linpg.fontRender("max damage: "+str(self.data_to_edit.max_damage),"black",15),(screen.get_width()*0.91,screen.get_height()*0.8+20*6)), - (linpg.fontRender("min damage: "+str(self.data_to_edit.min_damage),"black",15),(screen.get_width()*0.91,screen.get_height()*0.8+20*7)), - (linpg.fontRender("x: "+str(self.data_to_edit.x),"black",15),(screen.get_width()*0.91,screen.get_height()*0.8+20*8)), - (linpg.fontRender("y: "+str(self.data_to_edit.y),"black",15),(screen.get_width()*0.91,screen.get_height()*0.8+20*9)), + (linpg.render_font("action points: "+str(self.data_to_edit.max_action_point),"black",15),(screen.get_width()*0.91,screen.get_height()*0.8)), + (linpg.render_font("attack range: "+str(self.data_to_edit.attack_range),"black",15),(screen.get_width()*0.91,screen.get_height()*0.8+20)), + (linpg.render_font("current bullets: "+str(self.data_to_edit.current_bullets),"black",15),(screen.get_width()*0.91,screen.get_height()*0.8+20*2)), + (linpg.render_font("magazine capacity: "+str(self.data_to_edit.magazine_capacity),"black",15),(screen.get_width()*0.91,screen.get_height()*0.8+20*3)), + (linpg.render_font("max hp: "+str(self.data_to_edit.max_hp),"black",15),(screen.get_width()*0.91,screen.get_height()*0.8+20*4)), + (linpg.render_font("effective range: "+str(self.data_to_edit.effective_range),"black",15),(screen.get_width()*0.91,screen.get_height()*0.8+20*5)), + (linpg.render_font("max damage: "+str(self.data_to_edit.max_damage),"black",15),(screen.get_width()*0.91,screen.get_height()*0.8+20*6)), + (linpg.render_font("min damage: "+str(self.data_to_edit.min_damage),"black",15),(screen.get_width()*0.91,screen.get_height()*0.8+20*7)), + (linpg.render_font("x: "+str(self.data_to_edit.x),"black",15),(screen.get_width()*0.91,screen.get_height()*0.8+20*8)), + (linpg.render_font("y: "+str(self.data_to_edit.y),"black",15),(screen.get_width()*0.91,screen.get_height()*0.8+20*9)), )) #未保存离开时的警告 self.__no_save_warning.draw(screen) - if pygame.mouse.get_pressed()[0] is True and self.__no_save_warning.button_hovered != "": + if linpg.controller.get_event("confirm") and self.__no_save_warning.item_hovered != "": #保存并离开 - if self.__no_save_warning.button_hovered == "save": + if self.__no_save_warning.item_hovered == "save": self.save_progress() self.stop() #取消 - elif self.__no_save_warning.button_hovered == "cancel": + elif self.__no_save_warning.item_hovered == "cancel": self.__no_save_warning.hidden = True #不保存并离开 - elif self.__no_save_warning.button_hovered == "dont_save": + elif self.__no_save_warning.item_hovered == "dont_save": self.stop() \ No newline at end of file diff --git a/Source/gamemode/survival.py b/Source/gamemode/survival.py index 75f1de4d..3f68f9d8 100644 --- a/Source/gamemode/survival.py +++ b/Source/gamemode/survival.py @@ -5,28 +5,28 @@ class SurvivalBattleSystem(BattleSystem): def __init__(self): """data""" - super().__init__(None,None,None) + super().__init__() #用于检测是否有方向键被按到的字典 self.__pressKeyToMoveMe = {"up":False,"down":False,"left":False,"right":False} self.window_x,self.window_y = linpg.display.get_size() self.DATABASE = linpg.loadCharacterData() self.original_UI_img = { - "green" : linpg.loadImg("Assets/image/UI/range/green.png"), - "red" : linpg.loadImg("Assets/image/UI/range/red.png"), - "yellow": linpg.loadImg("Assets/image/UI/range/yellow.png"), - "blue": linpg.loadImg("Assets/image/UI/range/blue.png"), - "orange": linpg.loadImg("Assets/image/UI/range/orange.png"), + "green" : linpg.load_img("Assets/image/UI/range/green.png"), + "red" : linpg.load_img("Assets/image/UI/range/red.png"), + "yellow": linpg.load_img("Assets/image/UI/range/yellow.png"), + "blue": linpg.load_img("Assets/image/UI/range/blue.png"), + "orange": linpg.load_img("Assets/image/UI/range/orange.png"), "eyeImg": linpg.ProgressBarSurface("Assets/image/UI/eye_red.png","Assets/image/UI/eye_orange.png",0,0,0,0), "vigilanceImg": linpg.ProgressBarSurface("Assets/image/UI/vigilance_red.png","Assets/image/UI/vigilance_orange.png",0,0,0,0,"height"), - "supplyBoard":linpg.loadImage("Assets/image/UI/score.png",((self.window_x-self.window_x/3)/2,-self.window_y/12),self.window_x/3,self.window_y/12), + "supplyBoard":linpg.load_dynamic_image("Assets/image/UI/score.png",((self.window_x-self.window_x/3)/2,-self.window_y/12),self.window_x/3,self.window_y/12), } """init""" #shutil.copyfile("Data/chapter_map_example.yaml","Save/map1.yaml") - mapFileData = linpg.loadConfig("Save/map1.yaml") + mapFileData = linpg.load_config("Save/map1.yaml") SnowEnvImg = ["TileSnow01","TileSnow01ToStone01","TileSnow01ToStone02","TileSnow02","TileSnow02ToStone01","TileSnow02ToStone02"] block_y = 50 block_x = 50 - default_map = [[SnowEnvImg[linpg.randomInt(0,len(SnowEnvImg)-1)] for a in range(block_x)] for i in range(block_y)] + default_map = [[SnowEnvImg[linpg.get_random_int(0,len(SnowEnvImg)-1)] for a in range(block_x)] for i in range(block_y)] mapFileData["map"] = default_map self.MAP = linpg.MapObject(mapFileData,round(linpg.display.get_width()/10),round(linpg.display.get_height()/10),True) self.alliances = {"me": linpg.FriendlyCharacter(mapFileData["character"]["sv-98"],self.DATABASE["sv-98"])} @@ -34,16 +34,16 @@ def __init__(self): self.pos_last = self.alliances["me"].get_pos() def _check_key_down(self, event:object) -> None: super()._check_key_down(event) - if event.key == pygame.K_w: self.__pressKeyToMoveMe["up"] = True - if event.key == pygame.K_s: self.__pressKeyToMoveMe["down"] = True - if event.key == pygame.K_a: self.__pressKeyToMoveMe["left"] = True - if event.key == pygame.K_d: self.__pressKeyToMoveMe["right"] = True + if event.unicode == "w": self.__pressKeyToMoveMe["up"] = True + if event.unicode == "s": self.__pressKeyToMoveMe["down"] = True + if event.unicode == "a": self.__pressKeyToMoveMe["left"] = True + if event.unicode == "d": self.__pressKeyToMoveMe["right"] = True def _check_key_up(self, event:object) -> None: super()._check_key_up(event) - if event.key == pygame.K_w: self.__pressKeyToMoveMe["up"] = False - if event.key == pygame.K_s: self.__pressKeyToMoveMe["down"] = False - if event.key == pygame.K_a: self.__pressKeyToMoveMe["left"] = False - if event.key == pygame.K_d: self.__pressKeyToMoveMe["right"] = False + if event.unicode == "w": self.__pressKeyToMoveMe["up"] = False + if event.unicode == "s": self.__pressKeyToMoveMe["down"] = False + if event.unicode == "a": self.__pressKeyToMoveMe["left"] = False + if event.unicode == "d": self.__pressKeyToMoveMe["right"] = False def _check_if_move_screen(self) -> None: super()._check_if_move_screen() ifDisplayMove = False @@ -77,29 +77,28 @@ def _check_if_move_screen(self) -> None: #根据本地坐标移动屏幕 def _move_screen(self) -> None: tempX,tempY = self.MAP.calPosInMap(self.alliances["me"].x,self.alliances["me"].y) - if tempX < self.window_x*0.3 and self.MAP.getPos_x()<=0: + if tempX < self.window_x*0.3 and self.MAP.get_local_x()<=0: self.screen_to_move_x = self.window_x*0.3-tempX - elif tempX > self.window_x*0.7 and self.MAP.getPos_x()>=self.MAP.column*self.MAP.block_width*-1: + elif tempX > self.window_x*0.7 and self.MAP.get_local_x()>=self.MAP.column*self.MAP.block_width*-1: self.screen_to_move_x = self.window_x*0.7-tempX - if tempY < self.window_y*0.3 and self.MAP.getPos_y()<=0: + if tempY < self.window_y*0.3 and self.MAP.get_local_y()<=0: self.screen_to_move_y = self.window_y*0.3-tempY - elif tempY > self.window_y*0.7 and self.MAP.getPos_y()>=self.MAP.row*self.MAP.block_height*-1: + elif tempY > self.window_y*0.7 and self.MAP.get_local_y()>=self.MAP.row*self.MAP.block_height*-1: self.screen_to_move_y = self.window_y*0.7-tempY super()._move_screen() #展示场景装饰物 - def _display_decoration(self, screen:pygame.Surface) -> None: self.MAP.display_decoration(screen,self.alliances,{}) + def _display_decoration(self, screen:linpg.ImageSurface) -> None: self.MAP.display_decoration(screen,self.alliances,{}) #把所有内容画到屏幕上 - def draw(self, screen:pygame.Surface) -> None: - mouse_x,mouse_y = linpg.controller.get_mouse_pos() + def draw(self, screen:linpg.ImageSurface) -> None: for event in linpg.controller.events: - if event.type == pygame.KEYDOWN: - if event.key == pygame.K_ESCAPE: + if event.type == linpg.KEY.DOWN: + if event.key == linpg.KEY.ESCAPE: self.stop() self._check_key_down(event) - elif event.type == pygame.KEYUP: + elif event.type == linpg.KEY.UP: self._check_key_up(event) #其他移动的检查 - self._check_right_click_move(mouse_x,mouse_y) + self._check_right_click_move() #画出地图 self._display_map(screen) self.alliances["me"].draw(screen,self.MAP) @@ -108,5 +107,5 @@ def draw(self, screen:pygame.Surface) -> None: self._display_decoration(screen) pos_x,pos_y = self.MAP.calPosInMap(self.alliances["me"].x,self.alliances["me"].y) pos_x += linpg.display.get_width()/20 - pygame.draw.line(screen,linpg.findColorRGBA("red"),(pos_x,pos_y),(mouse_x,mouse_y),5) + #pygame.draw.line(screen,linpg.get_color_rbga("red"),(pos_x,pos_y),(mouse_x,mouse_y),5) linpg.display.flip() \ No newline at end of file diff --git a/Source/gamemode/turnBased.py b/Source/gamemode/turnBased.py index b8becc52..c49a0dd4 100644 --- a/Source/gamemode/turnBased.py +++ b/Source/gamemode/turnBased.py @@ -72,14 +72,14 @@ def characterInControl(self) -> object: return self.alliances_data[self.characte def enemyInControl(self) -> object: return self.enemies_data[self.sangvisFerris_name_list[self.enemies_in_control_id]] """加载与储存""" #从存档中加载游戏进程 - def load(self, screen:pygame.Surface) -> None: - DataTmp = linpg.loadConfig("Save/save.yaml") + def load(self, screen:linpg.ImageSurface) -> None: + DataTmp = linpg.load_config("Save/save.yaml") if DataTmp["type"] == "battle": self._initialize(DataTmp["chapter_type"], DataTmp["chapter_id"], DataTmp["project_name"]) self._initial_characters_loader(DataTmp["griffin"],DataTmp["sangvisFerri"]) self.MAP = DataTmp["MAP"] - self.dialogKey = DataTmp["dialogKey"] - self.dialogData = DataTmp["dialogData"] + self.dialog_key = DataTmp["dialog_key"] + self.dialog_parameters = DataTmp["dialog_parameters"] self.resultInfo = DataTmp["resultInfo"] else: raise Exception('Error: Cannot load the data from the "save.yaml" file because the file type does not match') @@ -87,35 +87,29 @@ def load(self, screen:pygame.Surface) -> None: self.MAP.load_env_img((round(screen.get_width()/10),round(screen.get_height()/10))) self.__load_from_save = True self.__process_data(screen) - def new(self, screen:pygame.Surface, chapterType:str, chapterId:int, projectName:str=None): + def new(self, screen:linpg.ImageSurface, chapterType:str, chapterId:int, projectName:str=None): self._initialize(chapterType, chapterId, projectName) self.__process_data(screen) #加载游戏进程 - def __process_data(self, screen:pygame.Surface) -> None: + def __process_data(self, screen:linpg.ImageSurface) -> None: self.window_x,self.window_y = screen.get_size() + #加载视觉小说系统 + self._DIALOG.new(self._chapter_type, self._chapter_id, "dialog_during_battle", self._project_name) + self._DIALOG.stop() #生成标准文字渲染器 self.FONTSIZE = int(self.window_x/76) - self.FONT = linpg.createFont(self.FONTSIZE) + self.FONT = linpg.create_font(self.FONTSIZE) #加载按钮的文字 self.selectMenuUI = SelectMenu() self.battleModeUiTxt = linpg.get_lang("Battle_UI") self.warnings_to_display = WarningSystem(int(screen.get_height()*0.03)) loading_info = linpg.get_lang("LoadingTxt") #加载剧情 - DataTmp = linpg.loadConfig( - os.path.join( - "Data", self._chapter_type, - "chapter{0}_dialogs_{1}.yaml".format(self._chapter_id,linpg.get_setting('Language')) - ) if self._project_name is None else os.path.join( - "Data", self._chapter_type, self._project_name, - "chapter{0}_dialogs_{1}.yaml".format(self._chapter_id,linpg.get_setting('Language')) - ) - ) + DataTmp = linpg.load_config(self._DIALOG.get_dialog_file_location()) #如果暂时没有翻译 if "title" not in DataTmp: DataTmp["title"] = linpg.get_lang("Global", "no_translation") if "description" not in DataTmp: DataTmp["description"] = linpg.get_lang("Global", "no_translation") - if "battle_info" not in DataTmp: DataTmp["battle_info"] = linpg.loadConfig(r"Data/chapter_dialogs_example.yaml", "battle_info") - if "dialog_during_battle" not in DataTmp: DataTmp["dialog_during_battle"] = {} + if "battle_info" not in DataTmp: DataTmp["battle_info"] = linpg.load_config(r"Data/chapter_dialogs_example.yaml", "battle_info") #章节标题显示 self.infoToDisplayDuringLoading = LoadingTitle( self.window_x, @@ -124,12 +118,11 @@ def __process_data(self, screen:pygame.Surface) -> None: self._chapter_id,DataTmp["title"],DataTmp["description"] ) self.battleMode_info = DataTmp["battle_info"] - self.dialog_during_battle = DataTmp["dialog_during_battle"] #正在加载的gif动态图标 - nowLoadingIcon = linpg.loadGif( - "Assets/image/UI/sv98_walking.gif", - (self.window_x*0.7,self.window_y*0.83), - (self.window_x*0.003*15,self.window_x*0.003*21) + nowLoadingIcon = linpg.load_gif( + r"Assets/image/UI/sv98_walking.gif", + (self.window_x*0.7, self.window_y*0.83), + (self.window_x*0.003*15, self.window_x*0.003*21) ) #渐入效果 for i in range(1,255,2): @@ -142,7 +135,7 @@ def __process_data(self, screen:pygame.Surface) -> None: nowLoadingIcon.draw(screen) linpg.display.flip() #读取并初始化章节信息 - DataTmp = linpg.loadConfig(self.get_map_file_location()) + DataTmp = linpg.load_config(self.get_map_file_location()) #背景音乐路径 self._background_music_folder_path:str = "Assets/music" #设置背景音乐 @@ -156,17 +149,18 @@ def __process_data(self, screen:pygame.Surface) -> None: self.environment_sound.add(os.path.join("Assets/sound/environment","{}.ogg".format(DataTmp["weather"]))) self.weatherController = linpg.WeatherSystem(DataTmp["weather"],self.window_x,self.window_y) #加载对话信息 - self.dialogInfo = DataTmp["dialogs"] + self._dialog_dictionary = DataTmp["dialogs"]["dictionary"] + self._dialog_data = DataTmp["dialogs"]["data"] if not self.__load_from_save: self._create_map(DataTmp) #加载对应角色所需的图片 self._initial_characters_loader(DataTmp["character"],DataTmp["sangvisFerri"]) #查看是否有战斗开始前的对话 - if "initial" not in self.dialogInfo or self.dialogInfo["initial"] is None: - self.dialogKey = None + if "initial" not in self._dialog_dictionary or self._dialog_dictionary["initial"] is None: + self.dialog_key = None else: - self.dialogKey = self.dialogInfo["initial"] - self.dialogData = None + self.dialog_key = self._dialog_dictionary["initial"] + self.dialog_parameters = None #加载角色信息 self._start_characters_loader() while self._is_characters_loader_alive(): @@ -179,21 +173,21 @@ def __process_data(self, screen:pygame.Surface) -> None: self._calculate_darkness() #开始加载关卡设定 self.infoToDisplayDuringLoading.draw(screen) - now_loading = self.FONT.render(loading_info["now_loading_level"],linpg.get_antialias(),linpg.findColorRGBA("white")) + now_loading = self.FONT.render(loading_info["now_loading_level"],linpg.get_antialias(),linpg.get_color_rbga("white")) screen.blit(now_loading,(self.window_x*0.75,self.window_y*0.9)) nowLoadingIcon.draw(screen) linpg.display.flip() #加载UI: #加载结束回合的图片 - self.end_round_txt = self.FONT.render(linpg.get_lang("Battle_UI","endRound"),linpg.get_antialias(),linpg.findColorRGBA("white")) - self.end_round_button = linpg.loadImage("Assets/image/UI/end_round_button.png",(self.window_x*0.8,self.window_y*0.7),self.end_round_txt.get_width()*2,self.end_round_txt.get_height()*2.5) + self.end_round_txt = self.FONT.render(linpg.get_lang("Battle_UI","endRound"),linpg.get_antialias(),linpg.get_color_rbga("white")) + self.end_round_button = linpg.load_static_image("Assets/image/UI/end_round_button.png",(self.window_x*0.8,self.window_y*0.7),self.end_round_txt.get_width()*2,self.end_round_txt.get_height()*2.5) #加载子弹图片 - #bullet_img = loadImg("Assets/image/UI/bullet.png", get_block_width()/6, self.MAP.block_height/12) + #bullet_img = load_img("Assets/image/UI/bullet.png", get_block_width()/6, self.MAP.block_height/12) #加载显示获取到补给后的信息栏 supply_board_width:int = int(self.window_x/3) supply_board_height:int = int(self.window_y/12) supply_board_x:int = int((self.window_x-supply_board_width)/2) - self.supply_board = linpg.loadDynamicImage( + self.supply_board = linpg.load_movable_image( "Assets/image/UI/score.png", (supply_board_x,-supply_board_height), (supply_board_x,0), @@ -204,21 +198,26 @@ def __process_data(self, screen:pygame.Surface) -> None: self.supply_board.stayingTime = 0 #用于表示范围的方框图片 self.range_ui_images = { - "green" : linpg.StaticImageSurface("Assets/image/UI/range/green.png",0,0), - "red" : linpg.StaticImageSurface("Assets/image/UI/range/red.png",0,0), - "yellow": linpg.StaticImageSurface("Assets/image/UI/range/yellow.png",0,0), - "blue": linpg.StaticImageSurface("Assets/image/UI/range/blue.png",0,0), - "orange": linpg.StaticImageSurface("Assets/image/UI/range/orange.png",0,0), + "green" : linpg.load_static_image(r"Assets/image/UI/range/green.png",(0,0)), + "red" : linpg.load_static_image(r"Assets/image/UI/range/red.png",(0,0)), + "yellow": linpg.load_static_image(r"Assets/image/UI/range/yellow.png",(0,0)), + "blue": linpg.load_static_image(r"Assets/image/UI/range/blue.png",(0,0)), + "orange": linpg.load_static_image(r"Assets/image/UI/range/orange.png",(0,0)), } for key in self.range_ui_images: self.range_ui_images[key].set_width_with_size_locked(self.MAP.block_width*0.8) #角色信息UI管理 self.characterInfoBoardUI = CharacterInfoBoard(self.window_x,self.window_y) - #加载对话框图片 - self.dialoguebox_up = linpg.DialogBox("Assets/image/UI/dialoguebox.png",self.window_x,self.window_y/2-self.window_y*0.35,self.window_x*0.3,self.window_y*0.15,self.FONTSIZE) - self.dialoguebox_up.flip() - self.dialoguebox_down = linpg.DialogBox("Assets/image/UI/dialoguebox.png",-self.window_x*0.3,self.window_y/2+self.window_y*0.2,self.window_x*0.3,self.window_y*0.15,self.FONTSIZE) - #-----加载音效----- + #加载用于渲染电影效果的上下黑色帘幕 + black_curtain = linpg.new_surface((self.window_x,self.window_y*0.15)).convert() + black_curtain.fill(linpg.get_color_rbga("black")) + self.__up_black_curtain = linpg.load_movable_image( + black_curtain,(0,-black_curtain.get_height()),(0,0),(0,black_curtain.get_height()*0.05) + ) + self.__down_black_curtain = linpg.load_movable_image( + black_curtain,(0,self.window_y),(0,self.window_y-black_curtain.get_height()),(0,black_curtain.get_height()*0.051) + ) + """-----加载音效-----""" #行走的音效 -- 频道0 self.footstep_sounds = linpg.SoundManagement(0) for walkingSoundPath in glob.glob(r'Assets/sound/snow/*.wav'): @@ -244,21 +243,21 @@ def __process_data(self, screen:pygame.Surface) -> None: screen.blit(temp_secode,(self.window_x/20+self.battleMode_info[i].get_width(),self.window_y*0.75+self.battleMode_info[i].get_height()*1.2)) linpg.display.flip() #返回需要保存数据 - def _get_data_need_to_save(self) -> dict: return linpg.dicMerge( + def _get_data_need_to_save(self) -> dict: return linpg.merge_dict( self.get_data_of_parent_game_system(),{ "type": "battle", "griffin": self.griffinCharactersData, "sangvisFerri": self.sangvisFerrisData, "MAP": self.MAP, - "dialogKey": self.dialogKey, - "dialogData": self.dialogData, + "dialog_key": self.dialog_key, + "dialog_parameters": self.dialog_parameters, "resultInfo": self.resultInfo, "timeStamp": time.strftime(":%S", time.localtime()) } ) """画面""" #新增需要在屏幕上画出的物品 - def __add_on_screen_object(self, image:pygame.Surface, weight:int=-1, pos:Union[tuple,list]=(0,0), offSet:Union[tuple,list]=(0,0)) -> None: + def __add_on_screen_object(self, image:linpg.ImageSurface, weight:int=-1, pos:Union[tuple,list]=(0,0), offSet:Union[tuple,list]=(0,0)) -> None: if weight < 0: self.__max_item_weight += 1 weight = self.__max_item_weight @@ -266,7 +265,7 @@ def __add_on_screen_object(self, image:pygame.Surface, weight:int=-1, pos:Union[ self.__max_item_weight = weight self.__items_to_blit.append(linpg.ItemNeedBlit(image,weight,pos,offSet)) #更新屏幕 - def __update_scene(self, screen:pygame.Surface) -> None: + def __update_scene(self, screen:linpg.ImageSurface) -> None: self.__items_to_blit.sort() for item in self.__items_to_blit: item.draw(screen) @@ -320,22 +319,15 @@ def updated_language(self, screen) -> None: self.selectMenuUI = SelectMenu() self.battleModeUiTxt = linpg.get_lang("Battle_UI") self.RoundSwitchUI = RoundSwitch(self.window_x,self.window_y,self.battleModeUiTxt) - self.end_round_txt = self.FONT.render(linpg.get_lang("Battle_UI","endRound"),linpg.get_antialias(),linpg.findColorRGBA("white")) - self.end_round_button = linpg.loadImage("Assets/image/UI/end_round_button.png",(self.window_x*0.8,self.window_y*0.7),self.end_round_txt.get_width()*2,self.end_round_txt.get_height()*2.5) + self.end_round_txt = self.FONT.render(linpg.get_lang("Battle_UI","endRound"),linpg.get_antialias(),linpg.get_color_rbga("white")) + self.end_round_button = linpg.load_static_image( + r"Assets/image/UI/end_round_button.png", + (self.window_x*0.8, self.window_y*0.7), + self.end_round_txt.get_width()*2, + self.end_round_txt.get_height()*2.5 + ) self.warnings_to_display = WarningSystem(int(screen.get_height()*0.03)) - self.dialog_during_battle = linpg.loadConfig( - os.path.join( - "Data", self._chapter_type, - "chapter{0}_dialogs_{1}.yaml".format(self._chapter_id,linpg.get_setting('Language')) - ) if self._project_name is None else os.path.join( - "Data", self._chapter_type, self._project_name, - "chapter{0}_dialogs_{1}.yaml".format(self._chapter_id,linpg.get_setting('Language')) - ), - "dialog_during_battle" - ) - if not self.__is_battle_mode: - self.dialoguebox_up.reset() - self.dialoguebox_down.reset() + self._DIALOG.updated_language(screen) #警告某个角色周围的敌人 def __alert_enemy_around(self, name:str, value:int=10) -> None: enemies_need_check:list = [] @@ -353,7 +345,7 @@ def __alert_enemy_around(self, name:str, value:int=10) -> None: def reset_areaDrawColorBlock(self): for value in self.areaDrawColorBlock.values(): value.clear() #切换回合 - def __switch_round(self, screen:pygame.Surface) -> None: + def __switch_round(self, screen:linpg.ImageSurface) -> None: if self.whose_round == "playerToSangvisFerris" or self.whose_round == "sangvisFerrisToPlayer": if self.RoundSwitchUI.draw(screen,self.whose_round,self.resultInfo["total_rounds"]): if self.whose_round == "playerToSangvisFerris": @@ -409,16 +401,14 @@ def __skill(self, characterName:str, pos_click:any, the_skill_cover_area:any, ac healed_hp = round((self.griffinCharactersData[skill_target].max_hp - self.griffinCharactersData[skill_target].current_hp)*0.3) self.griffinCharactersData[skill_target].heal(healed_hp) if not self.griffinCharactersData[skill_target].dying: self.griffinCharactersData[skill_target].dying = False - damage_do_to_character[skill_target] = linpg.fontRender("+"+str(healed_hp),"green",25) + damage_do_to_character[skill_target] = linpg.render_font("+"+str(healed_hp),"green",25) elif self.griffinCharactersData[characterName].type == "asval" or self.griffinCharactersData[characterName].type == "pp1901" or self.griffinCharactersData[characterName].type == "sv-98": - the_damage = linpg.randomInt(self.griffinCharactersData[characterName].min_damage,self.griffinCharactersData[characterName].max_damage) + the_damage = linpg.get_random_int(self.griffinCharactersData[characterName].min_damage,self.griffinCharactersData[characterName].max_damage) self.sangvisFerrisData[skill_target].decreaseHp(the_damage) - damage_do_to_character[skill_target] = linpg.fontRender("-"+str(the_damage),"red",25) + damage_do_to_character[skill_target] = linpg.render_font("-"+str(the_damage),"red",25) return damage_do_to_character #对话模块 - def __play_dialog(self, screen:pygame.Surface) -> None: - #画出地图 - self._display_map(screen) + def __play_dialog(self, screen:linpg.ImageSurface) -> None: #角色动画 for every_chara in self.griffinCharactersData: self.griffinCharactersData[every_chara].draw(screen,self.MAP) @@ -429,19 +419,24 @@ def __play_dialog(self, screen:pygame.Surface) -> None: self._display_decoration(screen) #加载雪花 self._display_weather(screen) + #营造电影视觉 + self.__up_black_curtain.move_toward() + self.__up_black_curtain.draw(screen) + self.__down_black_curtain.move_toward() + self.__down_black_curtain.draw(screen) #如果战斗有对话 - if self.dialogKey is not None: + if self.dialog_key is not None: #设定初始化 - if self.dialogData is None: - self.dialogData = { + if self.dialog_parameters is None: + self.dialog_parameters = { "dialogId": 0, "charactersPaths": None, "secondsAlreadyIdle":0, "secondsToIdle":None } #对话系统总循环 - if self.dialogData["dialogId"] < len(self.dialog_during_battle[self.dialogKey]): - currentDialog = self.dialog_during_battle[self.dialogKey][self.dialogData["dialogId"]] + if self.dialog_parameters["dialogId"] < len(self._dialog_data[self.dialog_key]): + currentDialog = self._dialog_data[self.dialog_key][self.dialog_parameters["dialogId"]] #如果操作是移动 if "move" in currentDialog and currentDialog["move"] is not None: #为所有角色设置路径 @@ -483,7 +478,7 @@ def __play_dialog(self, screen:pygame.Surface) -> None: if allGetToTargetPos: #脚步停止 self.footstep_sounds.stop() - self.dialogData["dialogId"] += 1 + self.dialog_parameters["dialogId"] += 1 self.__dialog_is_route_generated = False #改变方向 elif "direction" in currentDialog and currentDialog["direction"] is not None: @@ -494,7 +489,7 @@ def __play_dialog(self, screen:pygame.Surface) -> None: self.sangvisFerrisData[key].set_flip(value) else: raise Exception('Error: Cannot find character {}!'.format(key)) - self.dialogData["dialogId"] += 1 + self.dialog_parameters["dialogId"] += 1 #改变动作(一次性) elif "action" in currentDialog and currentDialog["action"] is not None: for key,action in currentDialog["action"].items(): @@ -502,7 +497,7 @@ def __play_dialog(self, screen:pygame.Surface) -> None: self.griffinCharactersData[key].set_action(action,False) elif key in self.sangvisFerrisData: self.sangvisFerrisData[key].set_action(action,False) - self.dialogData["dialogId"] += 1 + self.dialog_parameters["dialogId"] += 1 #改变动作(长期) elif "actionLoop" in currentDialog and currentDialog["actionLoop"] is not None: for key,action in currentDialog["actionLoop"].items(): @@ -510,46 +505,30 @@ def __play_dialog(self, screen:pygame.Surface) -> None: self.griffinCharactersData[key].set_action(action) elif key in self.sangvisFerrisData: self.sangvisFerrisData[key].set_action(action) - self.dialogData["dialogId"] += 1 + self.dialog_parameters["dialogId"] += 1 #开始对话 - elif "dialoguebox_up" in currentDialog or "dialoguebox_down" in currentDialog: - #上方对话框 - if currentDialog["dialoguebox_up"] is not None: - #对话框的移动 - if self.dialoguebox_up.x > self.window_x/2+self.dialoguebox_up.get_width()*0.4: - self.dialoguebox_up.x -= self.dialoguebox_up.get_width()*0.134 - elif not self.dialoguebox_up.updated: - self.dialoguebox_up.update( - currentDialog["dialoguebox_up"]["content"], - currentDialog["dialoguebox_up"]["speaker"], - currentDialog["dialoguebox_up"]["speaker_icon"] - ) - #对话框图片 - self.dialoguebox_up.draw(screen,self.characterInfoBoardUI) - #下方对话框 - if currentDialog["dialoguebox_down"] is not None: - #对话框的移动 - if self.dialoguebox_down.x < self.window_x/2-self.dialoguebox_down.get_width()*1.4: - self.dialoguebox_down.x += self.dialoguebox_down.get_width()*0.134 - elif not self.dialoguebox_down.updated: - self.dialoguebox_down.update( - currentDialog["dialoguebox_down"]["content"], - currentDialog["dialoguebox_down"]["speaker"], - currentDialog["dialoguebox_down"]["speaker_icon"] - ) - #对话框图片 - self.dialoguebox_down.draw(screen,self.characterInfoBoardUI) + elif "dialog" in currentDialog: + # 如果当前段落的对话数据还没被更新 + if not self._is_dialog_updated: + self._DIALOG.continue_scene(currentDialog["dialog"]) + self._is_dialog_updated = True + # 如果对话还在播放 + if self._DIALOG.is_playing(): + self._DIALOG.draw(screen) + else: + self.dialog_parameters["dialogId"] += 1 + self._is_dialog_updated = False #闲置一定时间(秒) elif "idle" in currentDialog and currentDialog["idle"] is not None: - if self.dialogData["secondsToIdle"] is None: - self.dialogData["secondsToIdle"] = currentDialog["idle"]*linpg.display.fps + if self.dialog_parameters["secondsToIdle"] is None: + self.dialog_parameters["secondsToIdle"] = currentDialog["idle"]*linpg.display.fps else: - if self.dialogData["secondsAlreadyIdle"] < self.dialogData["secondsToIdle"]: - self.dialogData["secondsAlreadyIdle"] += 1 + if self.dialog_parameters["secondsAlreadyIdle"] < self.dialog_parameters["secondsToIdle"]: + self.dialog_parameters["secondsAlreadyIdle"] += 1 else: - self.dialogData["dialogId"] += 1 - self.dialogData["secondsAlreadyIdle"] = 0 - self.dialogData["secondsToIdle"] = None + self.dialog_parameters["dialogId"] += 1 + self.dialog_parameters["secondsAlreadyIdle"] = 0 + self.dialog_parameters["secondsToIdle"] = None #调整窗口位置 elif "changePos" in currentDialog and currentDialog["changePos"] is not None: if self.screen_to_move_x is None or self.screen_to_move_y is None: @@ -559,56 +538,17 @@ def __play_dialog(self, screen:pygame.Surface) -> None: if self.screen_to_move_x == 0 and self.screen_to_move_y == 0: self.screen_to_move_x = None self.screen_to_move_y = None - self.dialogData["dialogId"] += 1 + self.dialog_parameters["dialogId"] += 1 else: - raise Exception("Error: Dialog Data on '{0}' with id '{1}' cannot pass through any statement!".format(self.dialogKey,self.dialogData["dialogId"])) + raise Exception("Error: Dialog Data on '{0}' with id '{1}' cannot pass through any statement!".format(self.dialog_key,self.dialog_parameters["dialogId"])) #玩家输入按键判定 - for event in linpg.controller.events: - if event.type == pygame.KEYDOWN: - if event.key == pygame.K_ESCAPE: - self.pause_menu.hidden = False - elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1 or event.type == pygame.JOYBUTTONDOWN and linpg.controller.joystick.get_button(0) == 1: - goToNextSlide = False - if "dialoguebox_up" in currentDialog and self.dialoguebox_up.updated: - if not self.dialoguebox_up.is_all_played(): - self.dialoguebox_up.play_all() - else: - goToNextSlide = True - if "dialoguebox_down" in currentDialog and self.dialoguebox_down.updated: - if not self.dialoguebox_down.is_all_played(): - self.dialoguebox_down.play_all() - else: - goToNextSlide = True - if goToNextSlide: - self.dialogData["dialogId"] += 1 - if self.dialogData["dialogId"] < len(self.dialog_during_battle[self.dialogKey]): - currentDialog = self.dialog_during_battle[self.dialogKey][self.dialogData["dialogId"]] - lastDialog = self.dialog_during_battle[self.dialogKey][self.dialogData["dialogId"]-1] if self.dialogData["dialogId"] > 0 else {} - if "dialoguebox_up" in currentDialog: - #检测上方对话框 - if currentDialog["dialoguebox_up"] is None or "dialoguebox_up" not in lastDialog or lastDialog["dialoguebox_up"] is None or currentDialog["dialoguebox_up"]["speaker"] != lastDialog["dialoguebox_up"]["speaker"]: - self.dialoguebox_up.reset() - elif currentDialog["dialoguebox_up"]["content"] != lastDialog["dialoguebox_up"]["content"]: - self.dialoguebox_up.updated = False - else: - self.dialoguebox_up.reset() - if "dialoguebox_down" in currentDialog: - #检测下方对话框 - if currentDialog["dialoguebox_down"] is None or "dialoguebox_down" not in lastDialog or lastDialog["dialoguebox_down"] is None or currentDialog["dialoguebox_down"]["speaker"] != lastDialog["dialoguebox_down"]["speaker"]: - self.dialoguebox_down.reset() - elif currentDialog["dialoguebox_down"]["content"] != lastDialog["dialoguebox_down"]["content"]: - self.dialoguebox_down.updated = False - else: - self.dialoguebox_down.reset() - else: - self.dialoguebox_up.reset() - self.dialoguebox_down.reset() + if linpg.controller.get_event("back"): self.pause_menu.hidden = False else: - self.dialogData = None - self.dialogKey = None + self.dialog_parameters = None + self.dialog_key = None self.__is_battle_mode = True #如果战斗前无·对话 - elif self.dialogKey is None: + elif self.dialog_key is None: #角色UI for every_chara in self.griffinCharactersData: self.griffinCharactersData[every_chara].drawUI(screen,self.MAP) @@ -618,55 +558,30 @@ def __play_dialog(self, screen:pygame.Surface) -> None: if self.txt_alpha == 0: self.__is_battle_mode = True #战斗模块 - def __play_battle(self, screen:pygame.Surface) -> None: - self.play_bgm() - right_click = False + def __play_battle(self, screen:linpg.ImageSurface) -> None: #获取鼠标坐标 mouse_x,mouse_y = linpg.controller.get_mouse_pos() skill_range = None for event in linpg.controller.events: - if event.type == pygame.KEYDOWN: - if event.key == pygame.K_ESCAPE and self.characterGetClick is None: + if event.type == linpg.KEY.DOWN: + if event.key == linpg.KEY.ESCAPE and self.characterGetClick is None: self.pause_menu.hidden = False - if event.key == pygame.K_ESCAPE and self.__is_waiting is True: + if event.key == linpg.KEY.ESCAPE and self.__is_waiting is True: self.__if_draw_range = True self.characterGetClick = None self.action_choice = None skill_range = None self.reset_areaDrawColorBlock() self._check_key_down(event) - if event.key == pygame.K_m: - linpg.display.quit() - elif event.type == pygame.KEYUP: + elif event.type == linpg.KEY.UP: self._check_key_up(event) #鼠标点击 - elif event.type == pygame.MOUSEBUTTONDOWN: - #右键 - if event.button == 1 or event.type == pygame.JOYBUTTONDOWN and linpg.controller.joystick.get_button(0) == 1: - right_click = True + elif event.type == linpg.MOUSE_BUTTON_DOWN: #上下滚轮-放大和缩小地图 - elif event.button == 4 and self.zoomIntoBe < 150: + if event.button == 4 and self.zoomIntoBe < 150: self.zoomIntoBe += 10 elif event.button == 5 and self.zoomIntoBe > 50: self.zoomIntoBe -= 10 - #其他移动的检查 - self._check_right_click_move(mouse_x,mouse_y) - self._check_jostick_events() - - #根据self.zoomIntoBe调整self.zoomIn大小 - if self.zoomIntoBe != self.zoomIn: - if self.zoomIntoBe < self.zoomIn: - self.zoomIn -= 5 - elif self.zoomIntoBe > self.zoomIn: - self.zoomIn += 5 - self.MAP.changePerBlockSize(self._standard_block_width*self.zoomIn/100,self._standard_block_height*self.zoomIn/100) - #根据block尺寸重新加载对应尺寸的UI - for key in self.range_ui_images: - self.range_ui_images[key].set_width_with_size_locked(self.MAP.block_width*0.8) - self.selectMenuUI.allButton = None - - #画出地图 - self._display_map(screen) #画出用彩色方块表示的范围 for area in self.areaDrawColorBlock: @@ -677,10 +592,10 @@ def __play_battle(self, screen:pygame.Surface) -> None: #玩家回合 if self.whose_round == "player": - if right_click is True: + if linpg.controller.get_event("confirm"): block_get_click = self.MAP.calBlockInMap(mouse_x,mouse_y) #如果点击了回合结束的按钮 - if linpg.isHover(self.end_round_button) and self.__is_waiting is True: + if linpg.is_hover(self.end_round_button) and self.__is_waiting is True: self.whose_round = "playerToSangvisFerris" self.characterGetClick = None self.__if_draw_range = True @@ -802,14 +717,14 @@ def __play_battle(self, screen:pygame.Surface) -> None: #移动画面以使得被点击的角色可以被更好的操作 tempX,tempY = self.MAP.calPosInMap(self.characterInControl.x,self.characterInControl.y) if self.screen_to_move_x is None: - if tempX < self.window_x*0.2 and self.MAP.getPos_x()<=0: + if tempX < self.window_x*0.2 and self.MAP.get_local_x()<=0: self.screen_to_move_x = self.window_x*0.2-tempX - elif tempX > self.window_x*0.8 and self.MAP.getPos_x()>=self.MAP.column*self.MAP.block_width*-1: + elif tempX > self.window_x*0.8 and self.MAP.get_local_x()>=self.MAP.column*self.MAP.block_width*-1: self.screen_to_move_x = self.window_x*0.8-tempX if self.screen_to_move_y is None: - if tempY < self.window_y*0.2 and self.MAP.getPos_y()<=0: + if tempY < self.window_y*0.2 and self.MAP.get_local_y()<=0: self.screen_to_move_y = self.window_y*0.2-tempY - elif tempY > self.window_y*0.8 and self.MAP.getPos_y()>=self.MAP.row*self.MAP.block_height*-1: + elif tempY > self.window_y*0.8 and self.MAP.get_local_y()>=self.MAP.row*self.MAP.block_height*-1: self.screen_to_move_y = self.window_y*0.8-tempY #显示攻击/移动/技能范围 if not self.__if_draw_range and self.characterGetClick is not None: @@ -995,12 +910,12 @@ def __play_battle(self, screen:pygame.Surface) -> None: self.MAP.remove_decoration(decoration) #检测当前所在点是否应该触发对话 name_from_by_pos = str(self.characterInControl.x)+"-"+str(self.characterInControl.y) - if "move" in self.dialogInfo and name_from_by_pos in self.dialogInfo["move"]: - dialog_to_check = self.dialogInfo["move"][name_from_by_pos] + if "move" in self._dialog_dictionary and name_from_by_pos in self._dialog_dictionary["move"]: + dialog_to_check = self._dialog_dictionary["move"][name_from_by_pos] if "whitelist" not in dialog_to_check or dialog_to_check["whitelist"] is None \ or self.characterGetClick == dialog_to_check["whitelist"] \ or self.characterGetClick in dialog_to_check["whitelist"]: - self.dialogKey = dialog_to_check["dialog_key"] + self.dialog_key = dialog_to_check["dialog_key"] self.__is_battle_mode = False #如果对话不重复,则删除(默认不重复) if "repeat" not in dialog_to_check or not dialog_to_check["repeat"]: del dialog_to_check @@ -1020,12 +935,12 @@ def __play_battle(self, screen:pygame.Surface) -> None: self.attackingSounds.play(self.characterInControl.kind) if self.characterInControl.get_imgId("attack") == self.characterInControl.get_imgNum("attack")-2: for each_enemy in self.enemiesGetAttack: - if self.enemiesGetAttack[each_enemy] == "near" and linpg.randomInt(1,100) <= 95 or self.enemiesGetAttack[each_enemy] == "middle" and linpg.randomInt(1,100) <= 80 or self.enemiesGetAttack[each_enemy] == "far" and linpg.randomInt(1,100) <= 65: + if self.enemiesGetAttack[each_enemy] == "near" and linpg.get_random_int(1,100) <= 95 or self.enemiesGetAttack[each_enemy] == "middle" and linpg.get_random_int(1,100) <= 80 or self.enemiesGetAttack[each_enemy] == "far" and linpg.get_random_int(1,100) <= 65: the_damage = self.characterInControl.attack(self.sangvisFerrisData[each_enemy]) - self.damage_do_to_characters[each_enemy] = self.FONT.render("-"+str(the_damage),linpg.get_antialias(),linpg.findColorRGBA("red")) + self.damage_do_to_characters[each_enemy] = self.FONT.render("-"+str(the_damage),linpg.get_antialias(),linpg.get_color_rbga("red")) self.sangvisFerrisData[each_enemy].alert(100) else: - self.damage_do_to_characters[each_enemy] = self.FONT.render("Miss",linpg.get_antialias(),linpg.findColorRGBA("red")) + self.damage_do_to_characters[each_enemy] = self.FONT.render("Miss",linpg.get_antialias(),linpg.get_color_rbga("red")) self.sangvisFerrisData[each_enemy].alert(50) elif self.characterInControl.get_imgId("attack") == self.characterInControl.get_imgNum("attack")-1: self.characterInControl.current_bullets -= 1 @@ -1068,7 +983,7 @@ def __play_battle(self, screen:pygame.Surface) -> None: if self.enemyInControl.get_imgId("attack") == 3: self.attackingSounds.play(self.enemyInControl.kind) elif self.enemyInControl.get_imgId("attack") == self.enemyInControl.get_imgNum("attack")-1: - temp_value = linpg.randomInt(0,100) + temp_value = linpg.get_random_int(0,100) if self.current_instruction.target_area == "near" and temp_value <= 95 \ or self.current_instruction.target_area == "middle" and temp_value <= 80 \ or self.current_instruction.target_area == "far" and temp_value <= 65: @@ -1077,9 +992,9 @@ def __play_battle(self, screen:pygame.Surface) -> None: if not self.griffinCharactersData[self.current_instruction.target].is_alive(): self.resultInfo["times_characters_down"] += 1 #重新计算迷雾区域 self._calculate_darkness() - self.damage_do_to_characters[self.current_instruction.target] = self.FONT.render("-"+str(the_damage),linpg.get_antialias(),linpg.findColorRGBA("red")) + self.damage_do_to_characters[self.current_instruction.target] = self.FONT.render("-"+str(the_damage),linpg.get_antialias(),linpg.get_color_rbga("red")) else: - self.damage_do_to_characters[self.current_instruction.target] = self.FONT.render("Miss",linpg.get_antialias(),linpg.findColorRGBA("red")) + self.damage_do_to_characters[self.current_instruction.target] = self.FONT.render("Miss",linpg.get_antialias(),linpg.get_color_rbga("red")) self.current_instruction = None else: self.enemyInControl.set_action() @@ -1090,10 +1005,10 @@ def __play_battle(self, screen:pygame.Surface) -> None: """↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓角色动画展示区↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓""" rightClickCharacterAlphaDeduct = True - for key,value in linpg.dicMerge(self.griffinCharactersData,self.sangvisFerrisData).items(): + for key,value in linpg.merge_dict(self.griffinCharactersData,self.sangvisFerrisData).items(): #如果天亮的双方都可以看见/天黑,但是是友方角色/天黑,但是是敌方角色在可观测的范围内 -- 则画出角色 if value.faction == "character" or value.faction == "sangvisFerri" and self.MAP.inLightArea(value): - if self.__if_draw_range is True and pygame.mouse.get_pressed()[2]: + if self.__if_draw_range is True and linpg.controller.mouse_get_press(2): block_get_click = self.MAP.calBlockInMap(mouse_x,mouse_y) if block_get_click is not None and block_get_click["x"] == value.x and block_get_click["y"] == value.y: rightClickCharacterAlphaDeduct = False @@ -1122,7 +1037,7 @@ def __play_battle(self, screen:pygame.Surface) -> None: xTemp,yTemp = self.MAP.calPosInMap(value.x,value.y) xTemp+=self.MAP.block_width*0.05 yTemp-=self.MAP.block_width*0.05 - linpg.displayInCenter(self.damage_do_to_characters[key],self.range_ui_images["green"],xTemp,yTemp,screen) + linpg.display_in_center(self.damage_do_to_characters[key],self.range_ui_images["green"],xTemp,yTemp,screen) self.damage_do_to_characters[key].set_alpha(the_alpha_to_check-5) else: del self.damage_do_to_characters[key] @@ -1183,7 +1098,14 @@ def __play_battle(self, screen:pygame.Surface) -> None: self.buttonGetHover = self.selectMenuUI.draw(screen,round(self.MAP.block_width/10),self.MAP.getBlockExactLocation(self.characterInControl.x,self.characterInControl.y),self.characterInControl.kind,self.friendsCanSave,self.thingsCanReact) #加载雪花 self._display_weather(screen) - + #移除电影视觉 + self.__up_black_curtain.move_back() + self.__up_black_curtain.draw(screen) + self.__down_black_curtain.move_back() + self.__down_black_curtain.draw(screen) + #其他移动的检查 + self._check_right_click_move() + self._check_jostick_events() #检测回合是否结束 self.__switch_round(screen) #检测玩家是否胜利或失败 @@ -1229,8 +1151,8 @@ def __play_battle(self, screen:pygame.Surface) -> None: self.resultInfo["total_time"] = time.localtime(time.time()-self.resultInfo["total_time"]) self.ResultBoardUI = ResultBoard(self.resultInfo,self.window_x/96) for event in linpg.controller.events: - if event.type == pygame.KEYDOWN: - if event.key == pygame.K_SPACE: + if event.type == linpg.KEY.DOWN: + if event.key == linpg.KEY.SPACE: self.__is_battle_mode = False self.stop() self.__add_on_screen_object(self.ResultBoardUI) @@ -1240,25 +1162,42 @@ def __play_battle(self, screen:pygame.Surface) -> None: self.resultInfo["total_time"] = time.localtime(time.time()-self.resultInfo["total_time"]) self.ResultBoardUI = ResultBoard(self.resultInfo,self.window_x/96,False) for event in linpg.controller.events: - if event.type == pygame.KEYDOWN: - if event.key == pygame.K_SPACE: - linpg.unloadBackgroundMusic() + if event.type == linpg.KEY.DOWN: + if event.key == linpg.KEY.SPACE: + linpg.unload_all_music() chapter_info:dict = self.get_data_of_parent_game_system() self.__init__() self.new(screen,chapter_info["chapter_type"], chapter_info["chapter_id"], chapter_info["project_name"]) break - elif event.key == pygame.K_BACKSPACE: - linpg.unloadBackgroundMusic() + elif event.key == linpg.KEY.BACKSPACE: + linpg.unload_all_music() self.stop() self.__is_battle_mode = False break if self.ResultBoardUI is not None: self.__add_on_screen_object(self.ResultBoardUI) #把战斗系统的画面画到screen上 - def draw(self, screen:pygame.Surface) -> None: + def draw(self, screen:linpg.ImageSurface) -> None: #环境声音-频道1 self.environment_sound.play() + #调整并更新地图大小 + if self.zoomIntoBe != self.zoomIn: + if self.zoomIntoBe < self.zoomIn: + self.zoomIn -= 10 + elif self.zoomIntoBe > self.zoomIn: + self.zoomIn += 10 + self.MAP.changePerBlockSize(self._standard_block_width*self.zoomIn/100,self._standard_block_height*self.zoomIn/100) + #根据block尺寸重新加载对应尺寸的UI + for key in self.range_ui_images: + self.range_ui_images[key].set_width_with_size_locked(self.MAP.block_width*0.8) + self.selectMenuUI.allButton = None + #画出地图 + self._display_map(screen) # 游戏主循环 - if self.__is_battle_mode: + if self.__is_battle_mode is True: + self.play_bgm() + #营造电影视觉 + self.__up_black_curtain.move_toward() + self.__down_black_curtain.move_toward() self.__play_battle(screen) #在战斗状态 else: @@ -1281,8 +1220,12 @@ def draw(self, screen:pygame.Surface) -> None: self.__update_scene(screen) #展示暂停菜单 if not self.pause_menu.hidden: - progress_saved_text = linpg.ImageSurface(self.FONT.render(linpg.get_lang("Global","progress_has_been_saved"),linpg.get_antialias(),(255,255,255)),0,0) + progress_saved_text = linpg.load_static_image( + self.FONT.render(linpg.get_lang("Global","progress_has_been_saved"),linpg.get_antialias(),(255,255,255)), + (0,0) + ) progress_saved_text.set_alpha(0) + progress_saved_text.set_center(screen.get_width()/2, screen.get_height()/2) while not self.pause_menu.hidden: linpg.display.flip() self.pause_menu.draw(screen) @@ -1297,7 +1240,7 @@ def draw(self, screen:pygame.Surface) -> None: linpg.get_option_menu().hidden = False elif result == "back_to_mainMenu": linpg.get_option_menu().hidden = True - linpg.unloadBackgroundMusic() + linpg.unload_all_music() progress_saved_text.set_alpha(0) self.stop() self.pause_menu.hidden = True @@ -1308,7 +1251,7 @@ def draw(self, screen:pygame.Surface) -> None: #更新语言 if linpg.get_option_menu().need_update["language"] is True: self.updated_language(screen) #显示进度已保存的文字 - progress_saved_text.drawOnTheCenterOf(screen) + progress_saved_text.draw(screen) progress_saved_text.fade_out(5) del progress_saved_text self.pause_menu.screenshot = None \ No newline at end of file diff --git a/Source/gamemode/ui.py b/Source/gamemode/ui.py index f0fa5bf6..c0b64f92 100644 --- a/Source/gamemode/ui.py +++ b/Source/gamemode/ui.py @@ -4,19 +4,18 @@ import time from typing import Union # 第三方 -import pygame import linpg -#from linpgdev import linpg, pygame +#from linpgdev import linpg from collections import deque # 显示回合切换的UI class RoundSwitch: def __init__(self, window_x:int, window_y:int, battleUiTxt:dict): - self.lineRedDown = linpg.loadImg("Assets/image/UI/lineRed.png",(window_x,window_y/50)) - self.lineRedUp = pygame.transform.rotate(self.lineRedDown, 180) - self.lineGreenDown = linpg.loadImg("Assets/image/UI/lineGreen.png",(window_x,window_y/50)) - self.lineGreenUp = pygame.transform.rotate(self.lineGreenDown, 180) - self.baseImg = linpg.loadImg("Assets/image/UI/roundSwitchBase.png",(window_x,window_y/5)) + self.lineRedDown = linpg.load_img(r"Assets/image/UI/lineRed.png", (window_x, window_y/50)) + self.lineRedUp = linpg.rotate_img(self.lineRedDown, 180) + self.lineGreenDown = linpg.load_img(r"Assets/image/UI/lineGreen.png", (window_x, window_y/50)) + self.lineGreenUp = linpg.rotate_img(self.lineGreenDown, 180) + self.baseImg = linpg.load_img(r"Assets/image/UI/roundSwitchBase.png", (window_x, window_y/5)) self.baseImg.set_alpha(0) self.x = -window_x self.y = int((window_y - self.baseImg.get_height())/2) @@ -26,14 +25,14 @@ def __init__(self, window_x:int, window_y:int, battleUiTxt:dict): self.idleTime = 60 self.now_total_rounds_text = battleUiTxt["numRound"] self.now_total_rounds_surface = None - self.your_round_txt_surface = linpg.fontRender(battleUiTxt["yourRound"], "white",window_x/36) + self.your_round_txt_surface = linpg.render_font(battleUiTxt["yourRound"], "white",window_x/36) self.your_round_txt_surface.set_alpha(0) - self.enemy_round_txt_surface = linpg.fontRender(battleUiTxt["enemyRound"], "white",window_x/36) + self.enemy_round_txt_surface = linpg.render_font(battleUiTxt["enemyRound"], "white",window_x/36) self.enemy_round_txt_surface.set_alpha(0) - def draw(self, screen:pygame.Surface, whose_round:str, total_rounds:int) -> bool: + def draw(self, screen:linpg.ImageSurface, whose_round:str, total_rounds:int) -> bool: #如果“第N回合”的文字surface还没有初始化,则初始化该文字 if self.now_total_rounds_surface is None: - self.now_total_rounds_surface = linpg.fontRender(self.now_total_rounds_text.format(linpg.get_num_in_local_text(total_rounds)), "white",screen.get_width()/38) + self.now_total_rounds_surface = linpg.render_font(self.now_total_rounds_text.format(linpg.get_num_in_local_text(total_rounds)), "white",screen.get_width()/38) self.now_total_rounds_surface.set_alpha(0) #如果UI底的alpha值在渐入阶段 if self.baseAlphaUp: @@ -129,15 +128,15 @@ def __init__(self, font_size:int=30): def add(self, the_warning:str) -> None: if len(self.__all_warnings)>=5: self.__all_warnings.pop() - self.__all_warnings.appendleft(linpg.fontRender(self.__warnings_msg[the_warning], "red", self.font_size, True)) + self.__all_warnings.appendleft(linpg.render_font(self.__warnings_msg[the_warning], "red", self.font_size, True)) #清空所有当前正在播放的警告讯息 def clear(self) -> None: self.__all_warnings.clear() #画出 - def draw(self, screen:pygame.Surface) -> None: + def draw(self, screen:linpg.ImageSurface) -> None: for i in range(len(self.__all_warnings)): try: img_alpha = self.__all_warnings[i].get_alpha() - except BaseException: + except Exception: break if img_alpha > 0: screen.blit(self.__all_warnings[i],((screen.get_width()-self.__all_warnings[i].get_width())/2,(screen.get_height()-self.__all_warnings[i].get_height())/2+i*self.__all_warnings[i].get_height()*1.2)) @@ -149,7 +148,7 @@ def draw(self, screen:pygame.Surface) -> None: class SelectMenu: def __init__(self): selectMenuTxtDic:dict = linpg.get_lang("SelectMenu") - self.selectButtonImg = linpg.loadImg("Assets/image/UI/menu.png") + self.selectButtonImg = linpg.load_img("Assets/image/UI/menu.png") #攻击 self.attackAP = linpg.AP_IS_NEEDED_TO_ATTACK self.attackTxt = selectMenuTxtDic["attack"] @@ -178,7 +177,7 @@ def __init__(self): self.allButton = None #初始化按钮 def initialButtons(self, fontSize:Union[int,float]) -> None: - selectButtonBase = linpg.resizeImg(self.selectButtonImg, (round(fontSize*5), round(fontSize*2.6))) + selectButtonBase = linpg.resize_img(self.selectButtonImg, (round(fontSize*5), round(fontSize*2.6))) selectButtonBaseWidth = selectButtonBase.get_width() sizeBig = int(fontSize) sizeSmall = int(fontSize*0.75) @@ -191,37 +190,37 @@ def initialButtons(self, fontSize:Union[int,float]) -> None: "interact": selectButtonBase.copy() } #攻击按钮 - txt_temp = linpg.fontRender(self.attackTxt,"black",sizeBig) - txt_temp2 = linpg.fontRender(self.attackAPTxt,"black",sizeSmall) + txt_temp = linpg.render_font(self.attackTxt,"black",sizeBig) + txt_temp2 = linpg.render_font(self.attackAPTxt,"black",sizeSmall) self.allButton["attack"].blit(txt_temp,((selectButtonBaseWidth-txt_temp.get_width())/2,txt_temp.get_height()*0.15)) self.allButton["attack"].blit(txt_temp2,((selectButtonBaseWidth-txt_temp2.get_width())/2,txt_temp.get_height()*1.1)) #移动按钮 - txt_temp = linpg.fontRender(self.moveTxt,"black",sizeBig) - txt_temp2 = linpg.fontRender(self.moveAPTxt,"black",sizeSmall) + txt_temp = linpg.render_font(self.moveTxt,"black",sizeBig) + txt_temp2 = linpg.render_font(self.moveAPTxt,"black",sizeSmall) self.allButton["move"].blit(txt_temp,((selectButtonBaseWidth-txt_temp.get_width())/2,txt_temp.get_height()*0.15)) self.allButton["move"].blit(txt_temp2,((selectButtonBaseWidth-txt_temp2.get_width())/2,txt_temp.get_height()*1.1)) #换弹按钮 - txt_temp = linpg.fontRender(self.reloadTxt,"black",sizeBig) - txt_temp2 = linpg.fontRender(self.reloadAPTxt,"black",sizeSmall) + txt_temp = linpg.render_font(self.reloadTxt,"black",sizeBig) + txt_temp2 = linpg.render_font(self.reloadAPTxt,"black",sizeSmall) self.allButton["reload"].blit(txt_temp,((selectButtonBaseWidth-txt_temp.get_width())/2,txt_temp.get_height()*0.15)) self.allButton["reload"].blit(txt_temp2,((selectButtonBaseWidth-txt_temp2.get_width())/2,txt_temp.get_height()*1.1)) #技能按钮 - txt_temp = linpg.fontRender(self.skillTxt,"black",sizeBig) - txt_temp2 = linpg.fontRender(self.skillAPTxt,"black",sizeSmall) + txt_temp = linpg.render_font(self.skillTxt,"black",sizeBig) + txt_temp2 = linpg.render_font(self.skillAPTxt,"black",sizeSmall) self.allButton["skill"].blit(txt_temp,((selectButtonBaseWidth-txt_temp.get_width())/2,txt_temp.get_height()*0.15)) self.allButton["skill"].blit(txt_temp2,((selectButtonBaseWidth-txt_temp2.get_width())/2,txt_temp.get_height()*1.1)) #救助按钮 - txt_temp = linpg.fontRender(self.rescueTxt,"black",sizeBig) - txt_temp2 = linpg.fontRender(self.rescueAPTxt,"black",sizeSmall) + txt_temp = linpg.render_font(self.rescueTxt,"black",sizeBig) + txt_temp2 = linpg.render_font(self.rescueAPTxt,"black",sizeSmall) self.allButton["rescue"].blit(txt_temp,((selectButtonBaseWidth-txt_temp.get_width())/2,txt_temp.get_height()*0.15)) self.allButton["rescue"].blit(txt_temp2,((selectButtonBaseWidth-txt_temp2.get_width())/2,txt_temp.get_height()*1.1)) #互动按钮 - txt_temp = linpg.fontRender(self.interactTxt,"black",sizeBig) - txt_temp2 = linpg.fontRender(self.interactAPTxt,"black",sizeSmall) + txt_temp = linpg.render_font(self.interactTxt,"black",sizeBig) + txt_temp2 = linpg.render_font(self.interactAPTxt,"black",sizeSmall) self.allButton["interact"].blit(txt_temp,((selectButtonBaseWidth-txt_temp.get_width())/2,txt_temp.get_height()*0.15)) self.allButton["interact"].blit(txt_temp2,((selectButtonBaseWidth-txt_temp2.get_width())/2,txt_temp.get_height()*1.1)) #将菜单按钮画出 - def draw(self, screen:pygame.Surface, fontSize:Union[int,float], location:dict, kind:str, friendsCanSave:list, thingsCanReact:list) -> str: + def draw(self, screen:linpg.ImageSurface, fontSize:Union[int,float], location:dict, kind:str, friendsCanSave:list, thingsCanReact:list) -> str: #如果按钮没有初始化,则应该立刻初始化按钮 if self.allButton is None: self.initialButtons(fontSize) buttonGetHover:str = "" @@ -229,40 +228,40 @@ def draw(self, screen:pygame.Surface, fontSize:Union[int,float], location:dict, #攻击按钮 - 左 txt_tempX = location["xStart"]-selectButtonBaseWidth*0.6 txt_tempY = location["yStart"] - if linpg.isHover(self.allButton["attack"],(txt_tempX,txt_tempY)): + if linpg.is_hover(self.allButton["attack"],(txt_tempX,txt_tempY)): buttonGetHover = "attack" screen.blit(self.allButton["attack"],(txt_tempX,txt_tempY)) #移动按钮 - 右 txt_tempX = location["xEnd"]-selectButtonBaseWidth*0.4 #txt_tempY 与攻击按钮一致 - if linpg.isHover(self.allButton["move"],(txt_tempX,txt_tempY)): + if linpg.is_hover(self.allButton["move"],(txt_tempX,txt_tempY)): buttonGetHover = "move" screen.blit(self.allButton["move"],(txt_tempX,txt_tempY)) #换弹按钮 - 下 txt_tempX = location["xStart"]+selectButtonBaseWidth*0.5 txt_tempY = location["yEnd"]-selectButtonBaseWidth*0.25 - if linpg.isHover(self.allButton["reload"],(txt_tempX,txt_tempY)): + if linpg.is_hover(self.allButton["reload"],(txt_tempX,txt_tempY)): buttonGetHover = "reload" screen.blit(self.allButton["reload"],(txt_tempX,txt_tempY)) #技能按钮 - 上 if kind != "HOC": #txt_tempX与换弹按钮一致 txt_tempY = location["yStart"]-selectButtonBaseWidth*0.7 - if linpg.isHover(self.allButton["skill"],(txt_tempX,txt_tempY)): + if linpg.is_hover(self.allButton["skill"],(txt_tempX,txt_tempY)): buttonGetHover = "skill" screen.blit(self.allButton["skill"],(txt_tempX,txt_tempY)) #救助队友 if len(friendsCanSave)>0: txt_tempX = location["xStart"]-selectButtonBaseWidth*0.6 txt_tempY = location["yStart"]-selectButtonBaseWidth*0.7 - if linpg.isHover(self.allButton["rescue"],(txt_tempX,txt_tempY)): + if linpg.is_hover(self.allButton["rescue"],(txt_tempX,txt_tempY)): buttonGetHover = "rescue" screen.blit(self.allButton["rescue"],(txt_tempX,txt_tempY)) #互动 if len(thingsCanReact)>0: txt_tempX = location["xEnd"]-selectButtonBaseWidth*0.4 txt_tempY = location["yStart"]-selectButtonBaseWidth*0.7 - if linpg.isHover(self.allButton["interact"],(txt_tempX,txt_tempY)): + if linpg.is_hover(self.allButton["interact"],(txt_tempX,txt_tempY)): buttonGetHover = "interact" screen.blit(self.allButton["interact"],(txt_tempX,txt_tempY)) return buttonGetHover @@ -270,16 +269,16 @@ def draw(self, screen:pygame.Surface, fontSize:Union[int,float], location:dict, #角色信息板 class CharacterInfoBoard: def __init__(self, window_x:int, window_y:int, text_size:int=20): - self.boardImg = linpg.loadImg("Assets/image/UI/score.png",(window_x/5,window_y/6)) + self.boardImg = linpg.load_img("Assets/image/UI/score.png",(window_x/5,window_y/6)) self.characterIconImages = {} all_icon_file_list = glob.glob(r'Assets/image/npc_icon/*.png') for i in range(len(all_icon_file_list)): img_name = all_icon_file_list[i].replace("Assets","").replace("image","").replace("npc_icon","").replace(".png","").replace("\\","").replace("/","") - self.characterIconImages[img_name] = linpg.smoothscaleImg(linpg.loadImg(all_icon_file_list[i]),(window_y*0.08,window_y*0.08)) + self.characterIconImages[img_name] = linpg.smoothly_resize_img(linpg.load_img(all_icon_file_list[i]),(window_y*0.08,window_y*0.08)) del all_icon_file_list self.text_size = text_size self.informationBoard = None - hp_empty_img = linpg.loadImg("Assets/image/UI/hp_empty.png") + hp_empty_img = linpg.load_img("Assets/image/UI/hp_empty.png") self.hp_red = linpg.ProgressBarSurface("Assets/image/UI/hp_red.png",hp_empty_img,0,0,window_x/15,text_size) self.hp_green = linpg.ProgressBarSurface("Assets/image/UI/hp_green.png",hp_empty_img,0,0,window_x/15,text_size) self.action_point_blue = linpg.ProgressBarSurface("Assets/image/UI/action_point.png",hp_empty_img,0,0,window_x/15,text_size) @@ -293,12 +292,12 @@ def updateInformationBoard(self, fontSize:int, theCharacterData:object) -> None: #画出角色图标 self.informationBoard.blit(self.characterIconImages[theCharacterData.type],(padding,padding)) #加载所需的文字 - tcgc_hp1 = linpg.fontRender("HP: ","white",fontSize) - tcgc_hp2 = linpg.fontRender(str(theCharacterData.current_hp)+"/"+str(theCharacterData.max_hp),"black",fontSize) - tcgc_action_point1 = linpg.fontRender("AP: ","white",fontSize) - tcgc_action_point2 = linpg.fontRender(str(theCharacterData.current_action_point)+"/"+str(theCharacterData.max_action_point),"black",fontSize) - tcgc_bullets_situation1 = linpg.fontRender("BP: ","white",fontSize) - tcgc_bullets_situation2 = linpg.fontRender(str(theCharacterData.current_bullets)+"/"+str(theCharacterData.bullets_carried),"black",fontSize) + tcgc_hp1 = linpg.render_font("HP: ","white",fontSize) + tcgc_hp2 = linpg.render_font(str(theCharacterData.current_hp)+"/"+str(theCharacterData.max_hp),"black",fontSize) + tcgc_action_point1 = linpg.render_font("AP: ","white",fontSize) + tcgc_action_point2 = linpg.render_font(str(theCharacterData.current_action_point)+"/"+str(theCharacterData.max_action_point),"black",fontSize) + tcgc_bullets_situation1 = linpg.render_font("BP: ","white",fontSize) + tcgc_bullets_situation2 = linpg.render_font(str(theCharacterData.current_bullets)+"/"+str(theCharacterData.bullets_carried),"black",fontSize) #先画出hp,ap和bp的文字 temp_posX = self.characterIconImages[theCharacterData.type].get_width()*2 temp_posY = padding-fontSize*0.2 @@ -318,13 +317,13 @@ def updateInformationBoard(self, fontSize:int, theCharacterData:object) -> None: self.bullets_number_brown.set_percentage(theCharacterData.current_bullets/theCharacterData.magazine_capacity) #画出 self.hp_green.draw(self.informationBoard) - linpg.displayInCenter(tcgc_hp2,self.hp_green,temp_posX ,temp_posY,self.informationBoard) + linpg.display_in_center(tcgc_hp2,self.hp_green,temp_posX ,temp_posY,self.informationBoard) self.action_point_blue.draw(self.informationBoard) - linpg.displayInCenter(tcgc_action_point2,self.action_point_blue,temp_posX ,temp_posY+self.text_size*1.5,self.informationBoard) + linpg.display_in_center(tcgc_action_point2,self.action_point_blue,temp_posX ,temp_posY+self.text_size*1.5,self.informationBoard) self.bullets_number_brown.draw(self.informationBoard) - linpg.displayInCenter(tcgc_bullets_situation2,self.bullets_number_brown,temp_posX ,temp_posY+self.text_size*3,self.informationBoard) + linpg.display_in_center(tcgc_bullets_situation2,self.bullets_number_brown,temp_posX ,temp_posY+self.text_size*3,self.informationBoard) #画出信息板 - def draw(self, screen:pygame.Surface, theCharacterData:object) -> None: + def draw(self, screen:linpg.ImageSurface, theCharacterData:object) -> None: #如果信息板还没更新,则应该先更新再画出 if self.informationBoard is None: self.updateInformationBoard(int(screen.get_width()/96),theCharacterData) #画出信息板 @@ -337,14 +336,14 @@ def __init__(self, finalResult:dict, font_size:int, is_win:bool=True): self.x = int(font_size*10) self.y = int(font_size*10) self.txt_x = int(font_size*12) - self.boardImg = linpg.loadImg("Assets/image/UI/score.png",(font_size*16,font_size*32)) - self.total_kills = linpg.fontRender(resultTxt["total_kills"]+": "+str(finalResult["total_kills"]),"white",font_size) - self.total_time = linpg.fontRender(resultTxt["total_time"]+": "+str(time.strftime('%M:%S',finalResult["total_time"])),"white",font_size) - self.total_rounds_txt = linpg.fontRender(resultTxt["total_rounds"]+": "+str(finalResult["total_rounds"]),"white",font_size) - self.characters_down = linpg.fontRender(resultTxt["characters_down"]+": "+str(finalResult["times_characters_down"]),"white",font_size) - self.player_rate = linpg.fontRender(resultTxt["rank"]+": "+"A","white",font_size) - self.pressKeyContinue = linpg.fontRender(resultTxt["pressKeyContinue"],"white",font_size) if is_win else linpg.fontRender(resultTxt["pressKeyRestart"],"white",font_size) - def draw(self, screen:pygame.Surface) -> None: + self.boardImg = linpg.load_img("Assets/image/UI/score.png",(font_size*16,font_size*32)) + self.total_kills = linpg.render_font(resultTxt["total_kills"]+": "+str(finalResult["total_kills"]),"white",font_size) + self.total_time = linpg.render_font(resultTxt["total_time"]+": "+str(time.strftime('%M:%S',finalResult["total_time"])),"white",font_size) + self.total_rounds_txt = linpg.render_font(resultTxt["total_rounds"]+": "+str(finalResult["total_rounds"]),"white",font_size) + self.characters_down = linpg.render_font(resultTxt["characters_down"]+": "+str(finalResult["times_characters_down"]),"white",font_size) + self.player_rate = linpg.render_font(resultTxt["rank"]+": "+"A","white",font_size) + self.pressKeyContinue = linpg.render_font(resultTxt["pressKeyContinue"],"white",font_size) if is_win else linpg.render_font(resultTxt["pressKeyRestart"],"white",font_size) + def draw(self, screen:linpg.ImageSurface) -> None: screen.blits(( (self.boardImg,(self.x,self.y)), (self.total_kills,(self.txt_x,300)), @@ -358,14 +357,14 @@ def draw(self, screen:pygame.Surface) -> None: #章节标题(在加载时显示) class LoadingTitle: def __init__(self, window_x:int, window_y:int, numChapter_txt:str, chapterId:int, chapterTitle_txt:str, chapterDesc_txt:str): - self.black_bg = linpg.getSingleColorSurface("black") - title_chapterNum = linpg.fontRender(numChapter_txt.format(chapterId),"white",window_x/38) - self.title_chapterNum = linpg.ImageSurface(title_chapterNum,(window_x-title_chapterNum.get_width())/2,window_y*0.37) - title_chapterName = linpg.fontRender(chapterTitle_txt,"white",window_x/38) - self.title_chapterName = linpg.ImageSurface(title_chapterName,(window_x-title_chapterName.get_width())/2,window_y*0.46) - title_description = linpg.fontRender(chapterDesc_txt,"white",window_x/76) - self.title_description = linpg.ImageSurface(title_description,(window_x-title_description.get_width())/2,window_y*0.6) - def draw(self, screen:pygame.Surface, alpha:int=255) -> None: + self.black_bg = linpg.get_single_color_surface("black") + title_chapterNum = linpg.render_font(numChapter_txt.format(chapterId),"white",window_x/38) + self.title_chapterNum = linpg.load_static_image(title_chapterNum,((window_x-title_chapterNum.get_width())/2,window_y*0.37)) + title_chapterName = linpg.render_font(chapterTitle_txt,"white",window_x/38) + self.title_chapterName = linpg.load_static_image(title_chapterName,((window_x-title_chapterName.get_width())/2,window_y*0.46)) + title_description = linpg.render_font(chapterDesc_txt,"white",window_x/76) + self.title_description = linpg.load_static_image(title_description,((window_x-title_description.get_width())/2,window_y*0.6)) + def draw(self, screen:linpg.ImageSurface, alpha:int=255) -> None: self.title_chapterNum.set_alpha(alpha) self.title_chapterName.set_alpha(alpha) self.title_description.set_alpha(alpha) diff --git a/Source/mainMenu.py b/Source/mainMenu.py index 0093a20f..af8ea650 100644 --- a/Source/mainMenu.py +++ b/Source/mainMenu.py @@ -1,18 +1,14 @@ # cython: language_level=3 -from .scene import * +from .component import * import shutil #主菜单系统 class MainMenu(linpg.AbstractSystem): - def __init__(self, screen:pygame.Surface): + def __init__(self, screen:linpg.ImageSurface): #初始化系统模块 super().__init__() - #获取屏幕的尺寸 - window_x,window_y = screen.get_size() #载入页面 - 渐入 dispaly_loading_screen(screen,0,250,int(2*linpg.display.sfpsp)) - #修改控制台的位置 - linpg.console.set_pos(window_x*0.1,window_y*0.8) #检测继续按钮是否可用的参数 self.continueButtonIsOn:bool = False #主菜单文字 @@ -22,22 +18,25 @@ def __init__(self, screen:pygame.Surface): #加载主菜单文字 self.__reset_menu_text(screen.get_size()) #数值初始化 - self.cover_alpha:int = 0 self.menu_type:int = 0 self.chapter_select:list = [] self.workshop_files:list = [] self.workshop_files_text:list = [] self.current_selected_workshop_project = None #关卡选择的封面 - self.cover_img = linpg.loadImg(r"Assets/image/covers/chapter1.png",screen.get_size()) + self.__cover_img_surface = None #音效 - self.click_button_sound = linpg.loadSound(r"Assets/sound/ui/main_menu_click_button.ogg",linpg.get_setting("Sound","sound_effects")/100.0) - self.hover_on_button_sound = linpg.loadSound(r"Assets/sound/ui/main_menu_hover_on_button.ogg",linpg.get_setting("Sound","sound_effects")/100.0) + self.click_button_sound = linpg.load_sound(r"Assets/sound/ui/main_menu_click_button.ogg",linpg.get_setting("Sound","sound_effects")/100.0) + self.hover_on_button_sound = linpg.load_sound(r"Assets/sound/ui/main_menu_hover_on_button.ogg",linpg.get_setting("Sound","sound_effects")/100.0) self.hover_sound_play_on = None self.last_hover_sound_play_on = None #加载主菜单背景 - self.videoCapture = linpg.VedioFrame( - r"Assets/movie/SquadAR.mp4",window_x,window_y,True,True,(32,103),linpg.get_setting("Sound","background_music")/100.0 + self.__background = linpg.VedioSurface( + r"Assets/movie/SquadAR.mp4", + screen.get_width(),screen.get_height(), + True,True, + (32,103), + linpg.get_setting("Sound","background_music")/100.0 ) #初始化返回菜单判定参数 linpg.set_glob_value("BackToMainMenu",False) @@ -53,18 +52,18 @@ def __reload_workshop_files_list(self, screen_size:tuple, createMode:bool=False) if createMode: self.workshop_files.append(self.main_menu_txt["other"]["new_project"]) for path in glob.glob(r"Data/workshop/*"): try: - info_data = linpg.loadConfig(os.path.join(path,"info.yaml")) - except: - info_data = linpg.loadConfig(r"Data/info_example.yaml") + info_data = linpg.load_config(os.path.join(path,"info.yaml")) + except Exception: + info_data = linpg.load_config(r"Data/info_example.yaml") info_data["default_lang"] = linpg.get_setting("Language") - linpg.saveConfig(os.path.join(path,"info.yaml"),info_data) + linpg.save_config(os.path.join(path,"info.yaml"),info_data) self.workshop_files_text.append(os.path.basename(path)) self.workshop_files.append(info_data["title"][linpg.get_setting("Language")]) self.workshop_files.append(linpg.get_lang("Global","back")) txt_location:int = int(screen_size[0]*2/3) txt_y:int = int((screen_size[1]-len(self.workshop_files)*linpg.get_standard_font_size("medium")*2)/2) for i in range(len(self.workshop_files)): - self.workshop_files[i] = linpg.fontRenderPro(self.workshop_files[i],"enable",(txt_location,txt_y),linpg.get_standard_font_size("medium")) + self.workshop_files[i] = linpg.load_dynamic_text(self.workshop_files[i],"enable",(txt_location,txt_y),linpg.get_standard_font_size("medium")) txt_y += linpg.get_standard_font_size("medium")*2 #获取章节id def __get_chapter_title(self, chapterType:str, chapterId:int) -> str: @@ -77,7 +76,7 @@ def __get_chapter_title(self, chapterType:str, chapterId:int) -> str: ) chapter_title:str if os.path.exists(dialog_file_path): - dialog_data = linpg.loadConfig(dialog_file_path) + dialog_data = linpg.load_config(dialog_file_path) #如果dialog文件中有title,则读取 chapter_title = dialog_data["title"] if "title" in dialog_data else linpg.get_lang("Global","no_translation") else: @@ -106,40 +105,40 @@ def __reload_chapter_select_list(self, screen_size:tuple, chapterType:str="main_ mode = "disable" """ mode = "enable" - self.chapter_select[i] = linpg.fontRenderPro(self.chapter_select[i],mode,(txt_x,txt_y),linpg.get_standard_font_size("medium")) + self.chapter_select[i] = linpg.load_dynamic_text(self.chapter_select[i],mode,(txt_x,txt_y),linpg.get_standard_font_size("medium")) txt_y += linpg.get_standard_font_size("medium")*2 #画出文字按钮 - def __draw_buttons(self, screen:pygame.Surface) -> None: + def __draw_buttons(self, screen:linpg.ImageSurface) -> None: i:int = 0 #主菜单 if self.menu_type == 0: for button in self.main_menu_txt["menu_main"].values(): button.draw(screen) - if linpg.isHover(button): self.hover_sound_play_on = i + if linpg.is_hover(button): self.hover_sound_play_on = i i+=1 #选择主线的章节 elif self.menu_type == 1: for button in self.chapter_select: button.draw(screen) - if linpg.isHover(button): self.hover_sound_play_on = i + if linpg.is_hover(button): self.hover_sound_play_on = i i+=1 #创意工坊选择菜单 elif self.menu_type == 2: for button in self.main_menu_txt["menu_workshop_choice"].values(): button.draw(screen) - if linpg.isHover(button): self.hover_sound_play_on = i + if linpg.is_hover(button): self.hover_sound_play_on = i i+=1 #展示合集 (3-游玩,4-地图编辑器,5-对话编辑器) elif 5 >= self.menu_type >= 3: for button in self.workshop_files: button.draw(screen) - if linpg.isHover(button): self.hover_sound_play_on = i + if linpg.is_hover(button): self.hover_sound_play_on = i i+=1 #选择章节(6-游玩,7-地图编辑器,8-对话编辑器) elif 8 >= self.menu_type >= 6: for button in self.chapter_select: button.draw(screen) - if linpg.isHover(button): self.hover_sound_play_on = i + if linpg.is_hover(button): self.hover_sound_play_on = i i+=1 #播放按钮的音效 if self.last_hover_sound_play_on != self.hover_sound_play_on: @@ -160,9 +159,9 @@ def __create_new_project(self) -> None: #创建文件夹 os.makedirs(os.path.join("Data","workshop",fileName)) #储存数据 - info_data:dict = linpg.loadConfig("Data/info_example.yaml") + info_data:dict = linpg.load_config(r"Data/info_example.yaml") info_data["default_lang"] = linpg.get_setting("Language") - linpg.saveConfig(os.path.join("Data","workshop",fileName,"info.yaml"),info_data) + linpg.save_config(os.path.join("Data","workshop",fileName,"info.yaml"),info_data) #创建新的对话文和地图文件 def __create_new_chapter(self) -> None: chapterId:int = len(glob.glob(os.path.join( @@ -189,21 +188,21 @@ def __find_chapter_id(self, path:str) -> int: else: raise Exception('Error: Cannot find the id of chapter because the file is not properly named!') #加载章节 - def __load_scene(self, chapterType:str, chapterId:int, screen:pygame.Surface) -> None: + def __load_scene(self, chapterType:str, chapterId:int, screen:linpg.ImageSurface) -> None: if RPC is not None: RPC.update( details = linpg.get_lang('General','main_chapter') if chapterType == "main_chapter" else linpg.get_lang('General','workshop'), state = self.__get_chapter_title(chapterType,chapterId), large_image = LARGE_IMAGE, start = time.time() ) - self.videoCapture.stop() + self.__background.stop() projectName = None if chapterType == "main_chapter" else self.current_selected_workshop_project dialog(screen, chapterType, chapterId, "dialog_before_battle", projectName) if not linpg.get_glob_value("BackToMainMenu"): battle(screen,chapterType,chapterId,projectName) if not linpg.get_glob_value("BackToMainMenu"): dialog(screen, chapterType, chapterId, "dialog_after_battle", projectName) - linpg.if_get_set_value("BackToMainMenu",True,False) + linpg.if_get_set_glob_value("BackToMainMenu",True,False) else: linpg.set_glob_value("BackToMainMenu",False) else: @@ -211,9 +210,9 @@ def __load_scene(self, chapterType:str, chapterId:int, screen:pygame.Surface) -> self.__reset_menu() if RPC is not None: RPC.update(state=linpg.get_lang("DiscordStatus","staying_at_main_menu"),large_image=LARGE_IMAGE) #继续章节 - def __continue_scene(self, screen:pygame.Surface) -> None: - self.videoCapture.stop() - SAVE:dict = linpg.loadConfig("Save/save.yaml") + def __continue_scene(self, screen:linpg.ImageSurface) -> None: + self.__background.stop() + SAVE:dict = linpg.load_config(r"Save/save.yaml") if RPC is not None: RPC.update( details = linpg.get_lang('General','main_chapter') if SAVE["chapter_type"] == "main_chapter" else linpg.get_lang('General','workshop'), state = self.__get_chapter_title(SAVE["chapter_type"],SAVE["chapter_id"]), @@ -239,22 +238,22 @@ def __continue_scene(self, screen:pygame.Surface) -> None: linpg.set_glob_value("BackToMainMenu",False) elif startPoint == "dialog_after_battle": dialog(screen, None, None, None) - linpg.if_get_set_value("BackToMainMenu",True,False) + linpg.if_get_set_glob_value("BackToMainMenu",True,False) self.__reset_menu() if RPC is not None: RPC.update(state=linpg.get_lang("DiscordStatus","staying_at_main_menu"),large_image=LARGE_IMAGE) #更新主菜单的部分元素 def __reset_menu(self) -> None: - self.videoCapture = self.videoCapture.copy() - self.videoCapture.start() + self.__background = self.__background.copy() + self.__background.start() #是否可以继续游戏了(save文件是否被创建) if os.path.exists("Save/save.yaml") and not self.continueButtonIsOn: - self.main_menu_txt["menu_main"]["0_continue"] = linpg.fontRenderPro( + self.main_menu_txt["menu_main"]["0_continue"] = linpg.load_dynamic_text( linpg.get_lang("MainMenu","menu_main")["0_continue"], "enable", self.main_menu_txt["menu_main"]["0_continue"].get_pos(), linpg.get_standard_font_size("medium") ) self.continueButtonIsOn = True elif not os.path.exists("Save/save.yaml") and self.continueButtonIsOn is True: - self.main_menu_txt["menu_main"]["0_continue"] = linpg.fontRenderPro( + self.main_menu_txt["menu_main"]["0_continue"] = linpg.load_dynamic_text( linpg.get_lang("MainMenu","menu_main")["0_continue"], "disable", self.main_menu_txt["menu_main"]["0_continue"].get_pos(), linpg.get_standard_font_size("medium") ) @@ -275,7 +274,7 @@ def __reset_menu_text(self, screen_size:tuple) -> None: txt_y = (screen_size[1]-len(self.main_menu_txt["menu_main"])*font_size)/2 for key,txt in self.main_menu_txt["menu_main"].items(): mode = "enable" if key not in disabled_option else "disable" - self.main_menu_txt["menu_main"][key] = linpg.fontRenderPro(txt,mode,(txt_location,txt_y),linpg.get_standard_font_size("medium")) + self.main_menu_txt["menu_main"][key] = linpg.load_dynamic_text(txt,mode,(txt_location,txt_y),linpg.get_standard_font_size("medium")) txt_y += font_size #加载创意工坊选择页面的文字 self.main_menu_txt["menu_workshop_choice"]["map_editor"] = linpg.get_lang("General","map_editor") @@ -283,7 +282,7 @@ def __reset_menu_text(self, screen_size:tuple) -> None: self.main_menu_txt["menu_workshop_choice"]["back"] = linpg.get_lang("Global","back") txt_y = (screen_size[1]-len(self.main_menu_txt["menu_workshop_choice"])*font_size)/2 for key,txt in self.main_menu_txt["menu_workshop_choice"].items(): - self.main_menu_txt["menu_workshop_choice"][key] = linpg.fontRenderPro(txt,"enable",(txt_location,txt_y),linpg.get_standard_font_size("medium")) + self.main_menu_txt["menu_workshop_choice"][key] = linpg.load_dynamic_text(txt,"enable",(txt_location,txt_y),linpg.get_standard_font_size("medium")) txt_y += font_size #加载退出确认消息框 self.exit_confirm_menu = linpg.Message( @@ -291,7 +290,7 @@ def __reset_menu_text(self, screen_size:tuple) -> None: (self.main_menu_txt["other"]["confirm"],self.main_menu_txt["other"]["deny"]),True,return_button=1,escape_button=1 ) #更新语言 - def updated_language(self, screen:pygame.Surface) -> None: + def updated_language(self, screen:linpg.ImageSurface) -> None: super().updated_language() self.__reset_menu_text(screen.get_size()) if self.menu_type == 1: @@ -303,23 +302,40 @@ def updated_language(self, screen:pygame.Surface) -> None: def __update_sound_volume(self) -> None: self.click_button_sound.set_volume(linpg.get_setting("Sound","sound_effects")/100.0) self.hover_on_button_sound.set_volume(linpg.get_setting("Sound","sound_effects")/100.0) - self.videoCapture.set_volume(linpg.get_setting("Sound","background_music")/100.0) - #画出主菜单 - def draw(self, screen:pygame.Surface) -> None: + self.__background.set_volume(linpg.get_setting("Sound","background_music")/100.0) + #画出背景 + def __draw_background(self, screen:linpg.ImageSurface) -> None: #开始播放背景视频 - if not self.videoCapture.started: self.videoCapture.start() + if not self.__background.started: self.__background.start() + #处理封面的更替 + cover_path:str = None + if self.menu_type == 1: + for i in range(len(self.chapter_select)-1): + if linpg.is_hover(self.chapter_select[i]): + cover_path = linpg.load_config(r"Data/main_chapter/info.yaml", "cover_image")[i] + break + if cover_path is not None: + if self.__cover_img_surface is None: + self.__cover_img_surface = linpg.load_static_image(cover_path, (0,0), screen.get_width(), screen.get_height(), cover_path) + self.__cover_img_surface.set_alpha(10) + elif cover_path != self.__cover_img_surface.tag: + self.__cover_img_surface.update_image(cover_path) + self.__cover_img_surface.tag = cover_path + if self.__cover_img_surface is not None: + self.__cover_img_surface.add_alpha(5) + elif self.__cover_img_surface is not None: + if self.__cover_img_surface.get_alpha() > 10: + self.__cover_img_surface.subtract_alpha(5) + else: + self.__cover_img_surface = None #背景视频 - self.videoCapture.draw(screen) - #画出章节背景 - if self.menu_type == 1 and linpg.isHover(self.chapter_select[0]): - if self.cover_alpha < 255: - self.cover_alpha += 15 - elif self.cover_alpha >= 0: - self.cover_alpha -= 15 - #如果图片的透明度大于10则展示图片 - if self.cover_alpha > 10: - self.cover_img.set_alpha(self.cover_alpha) - screen.blit(self.cover_img,(0,0)) + if self.__cover_img_surface is None or self.__cover_img_surface.get_alpha() < 255: self.__background.draw(screen) + #封面 + if self.__cover_img_surface is not None: self.__cover_img_surface.draw(screen) + #画出主菜单 + def draw(self, screen:linpg.ImageSurface) -> None: + #背景 + self.__draw_background(screen) #菜单选项 self.__draw_buttons(screen) #展示设置UI @@ -331,71 +347,71 @@ def draw(self, screen:pygame.Surface) -> None: if linpg.get_option_menu().need_update["language"] is True or self.language_need_update() is True: self.updated_language(screen) #展示控制台 - linpg.console.draw(screen) + console.draw(screen) #判断按键 - if linpg.controller.get_event("comfirm") is True and linpg.get_option_menu().hidden is True: + if linpg.controller.get_event("confirm") is True and linpg.get_option_menu().hidden is True: self.click_button_sound.play() #主菜单 if self.menu_type == 0: #继续游戏 - if linpg.isHover(self.main_menu_txt["menu_main"]["0_continue"]) and os.path.exists("Save/save.yaml"): + if linpg.is_hover(self.main_menu_txt["menu_main"]["0_continue"]) and os.path.exists("Save/save.yaml"): self.__continue_scene(screen) #选择章节 - elif linpg.isHover(self.main_menu_txt["menu_main"]["1_chooseChapter"]): + elif linpg.is_hover(self.main_menu_txt["menu_main"]["1_chooseChapter"]): #加载菜单章节选择页面的文字 self.__reload_chapter_select_list(screen.get_size()) self.menu_type = 1 #dlc - elif linpg.isHover(self.main_menu_txt["menu_main"]["2_dlc"]): + elif linpg.is_hover(self.main_menu_txt["menu_main"]["2_dlc"]): pass #创意工坊 - elif linpg.isHover(self.main_menu_txt["menu_main"]["3_workshop"]): + elif linpg.is_hover(self.main_menu_txt["menu_main"]["3_workshop"]): self.menu_type = 2 #收集物 - elif linpg.isHover(self.main_menu_txt["menu_main"]["4_collection"]): + elif linpg.is_hover(self.main_menu_txt["menu_main"]["4_collection"]): pass #设置 - elif linpg.isHover(self.main_menu_txt["menu_main"]["5_setting"]): + elif linpg.is_hover(self.main_menu_txt["menu_main"]["5_setting"]): linpg.get_option_menu().hidden = False #制作组 - elif linpg.isHover(self.main_menu_txt["menu_main"]["6_developer_team"]): + elif linpg.is_hover(self.main_menu_txt["menu_main"]["6_developer_team"]): pass #退出 - elif linpg.isHover(self.main_menu_txt["menu_main"]["7_exit"]) and self.exit_confirm_menu.draw() == 0: - self.videoCapture.stop() + elif linpg.is_hover(self.main_menu_txt["menu_main"]["7_exit"]) and self.exit_confirm_menu.draw() == 0: + self.__background.stop() self.stop() if RPC is not None: RPC.close() #选择主线章节 elif self.menu_type == 1: - if linpg.isHover(self.chapter_select[-1]): + if linpg.is_hover(self.chapter_select[-1]): self.menu_type = 0 else: for i in range(len(self.chapter_select)-1): #章节选择 - if linpg.isHover(self.chapter_select[i]): + if linpg.is_hover(self.chapter_select[i]): self.__load_scene("main_chapter",i+1,screen) break #选择创意工坊选项 elif self.menu_type == 2: - if linpg.isHover(self.main_menu_txt["menu_workshop_choice"]["0_play"]): + if linpg.is_hover(self.main_menu_txt["menu_workshop_choice"]["0_play"]): self.__reload_workshop_files_list(screen.get_size(),False) self.menu_type = 3 - elif linpg.isHover(self.main_menu_txt["menu_workshop_choice"]["map_editor"]): + elif linpg.is_hover(self.main_menu_txt["menu_workshop_choice"]["map_editor"]): self.__reload_workshop_files_list(screen.get_size(),True) self.menu_type = 4 - elif linpg.isHover(self.main_menu_txt["menu_workshop_choice"]["dialog_editor"]): + elif linpg.is_hover(self.main_menu_txt["menu_workshop_choice"]["dialog_editor"]): self.__reload_workshop_files_list(screen.get_size(),True) self.menu_type = 5 - elif linpg.isHover(self.main_menu_txt["menu_workshop_choice"]["back"]): + elif linpg.is_hover(self.main_menu_txt["menu_workshop_choice"]["back"]): self.menu_type = 0 #创意工坊-选择想要游玩的合集 elif self.menu_type == 3: - if linpg.isHover(self.workshop_files[-1]): + if linpg.is_hover(self.workshop_files[-1]): self.menu_type = 2 else: for i in range(len(self.workshop_files)-1): #章节选择 - if linpg.isHover(self.workshop_files[i]): + if linpg.is_hover(self.workshop_files[i]): self.current_selected_workshop_project = self.workshop_files_text[i] self.__reload_chapter_select_list(screen.get_size(),"workshop") self.menu_type = 6 @@ -403,16 +419,16 @@ def draw(self, screen:pygame.Surface) -> None: #创意工坊-选择想要编辑地图的合集 elif self.menu_type == 4: #新建合集 - if linpg.isHover(self.workshop_files[0]): + if linpg.is_hover(self.workshop_files[0]): self.__create_new_project() self.__reload_workshop_files_list(screen.get_size(),True) #返回创意工坊选项菜单 - elif linpg.isHover(self.workshop_files[-1]): + elif linpg.is_hover(self.workshop_files[-1]): self.menu_type = 2 else: for i in range(1,len(self.workshop_files)-1): #章节选择 - if linpg.isHover(self.workshop_files[i]): + if linpg.is_hover(self.workshop_files[i]): self.current_selected_workshop_project = self.workshop_files_text[i-1] self.__reload_chapter_select_list(screen.get_size(),"workshop",True) self.menu_type = 7 @@ -420,60 +436,60 @@ def draw(self, screen:pygame.Surface) -> None: #创意工坊-选择想要编辑对话的合集 elif self.menu_type == 5: #新建合集 - if linpg.isHover(self.workshop_files[0]): + if linpg.is_hover(self.workshop_files[0]): self.__create_new_project() self.__reload_workshop_files_list(screen.get_size(),True) #返回创意工坊选项菜单 - elif linpg.isHover(self.workshop_files[-1]): + elif linpg.is_hover(self.workshop_files[-1]): self.menu_type = 2 else: for i in range(1,len(self.workshop_files)-1): #章节选择 - if linpg.isHover(self.workshop_files[i]): + if linpg.is_hover(self.workshop_files[i]): self.current_selected_workshop_project = self.workshop_files_text[i-1] self.__reload_chapter_select_list(screen.get_size(),"workshop",True) self.menu_type = 8 break #创意工坊-选择当前合集想要游玩的关卡 elif self.menu_type == 6: - if linpg.isHover(self.chapter_select[-1]): + if linpg.is_hover(self.chapter_select[-1]): self.menu_type = 3 else: for i in range(len(self.chapter_select)-1): #章节选择 - if linpg.isHover(self.chapter_select[i]): + if linpg.is_hover(self.chapter_select[i]): self.__load_scene("workshop",i+1,screen) break #创意工坊-选择当前合集想要编辑地图的关卡 elif self.menu_type == 7: - if linpg.isHover(self.chapter_select[0]): + if linpg.is_hover(self.chapter_select[0]): self.__create_new_chapter() self.__reload_chapter_select_list(screen.get_size(),"workshop",True) - elif linpg.isHover(self.chapter_select[-1]): + elif linpg.is_hover(self.chapter_select[-1]): self.menu_type = 4 else: for i in range(1,len(self.chapter_select)-1): #章节选择 - if linpg.isHover(self.chapter_select[i]): - self.videoCapture.stop() + if linpg.is_hover(self.chapter_select[i]): + self.__background.stop() mapEditor(screen,"workshop",i,self.current_selected_workshop_project) - self.videoCapture = self.videoCapture.copy() - self.videoCapture.start() + self.__background = self.__background.copy() + self.__background.start() break #创意工坊-选择当前合集想要编辑对话的关卡 elif self.menu_type == 8: - if linpg.isHover(self.chapter_select[0]): + if linpg.is_hover(self.chapter_select[0]): self.__create_new_chapter() self.__reload_chapter_select_list(screen.get_size(),"workshop",True) - elif linpg.isHover(self.chapter_select[-1]): + elif linpg.is_hover(self.chapter_select[-1]): self.menu_type = 5 else: for i in range(1,len(self.chapter_select)-1): #章节选择 - if linpg.isHover(self.chapter_select[i]): - self.videoCapture.stop() + if linpg.is_hover(self.chapter_select[i]): + self.__background.stop() dialogEditor(screen,"workshop",i,"dialog_before_battle",self.current_selected_workshop_project) - self.videoCapture = self.videoCapture.copy() - self.videoCapture.start() + self.__background = self.__background.copy() + self.__background.start() break ALPHA_BUILD_WARNING.draw(screen) \ No newline at end of file diff --git a/Source/scene.py b/Source/scene.py index 1231b228..2aca081b 100644 --- a/Source/scene.py +++ b/Source/scene.py @@ -1,5 +1,5 @@ # cython: language_level=3 -from .basic import * +from .base import * #视觉小说系统 class DialogSystem(linpg.DialogSystem): @@ -9,20 +9,24 @@ def save_progress(self) -> None: #检查global.yaml配置文件 if not os.path.exists(os.path.join(self.folder_for_save_file,"global.yaml")): DataTmp = {"chapter_unlocked":1} - linpg.saveConfig(os.path.join(self.folder_for_save_file,"global.yaml"),DataTmp) + linpg.save_config(os.path.join(self.folder_for_save_file,"global.yaml"),DataTmp) #对话系统 -def dialog(screen:pygame.Surface, chapterType:str, chapterId:int, part:str, projectName:str=None) -> dict: +def dialog(screen:linpg.ImageSurface, chapterType:str, chapterId:int, part:str, projectName:str=None) -> dict: #加载闸门动画的图片素材 - LoadingImgAbove:pygame.Surface = linpg.loadImg("Assets/image/UI/LoadingImgAbove.png",(screen.get_width()+8,screen.get_height()/1.7)) - LoadingImgBelow:pygame.Surface = linpg.loadImg("Assets/image/UI/LoadingImgBelow.png",(screen.get_width()+8,screen.get_height()/2.05)) + LoadingImgAbove:linpg.ImageSurface = linpg.smoothly_resize_img( + linpg.cope_bounding(linpg.quickly_load_img(r"Assets/image/UI/LoadingImgAbove.png")), (screen.get_width()+4, screen.get_height()/1.7) + ) + LoadingImgBelow:linpg.ImageSurface = linpg.smoothly_resize_img( + linpg.cope_bounding(linpg.quickly_load_img(r"Assets/image/UI/LoadingImgBelow.png")), (screen.get_width()+4, screen.get_height()/2.05) + ) #开始加载-闸门关闭的效果 for i in range(101): - screen.blit(LoadingImgAbove,(-4,LoadingImgAbove.get_height()/100*i-LoadingImgAbove.get_height())) - screen.blit(LoadingImgBelow,(-4,screen.get_height()-LoadingImgBelow.get_height()/100*i)) + screen.blit(LoadingImgAbove,(-2,LoadingImgAbove.get_height()/100*i-LoadingImgAbove.get_height())) + screen.blit(LoadingImgBelow,(-2,screen.get_height()-LoadingImgBelow.get_height()/100*i)) linpg.display.flip() #卸载音乐 - linpg.unloadBackgroundMusic() + linpg.unload_all_music() #初始化对话系统模块 DIALOG:object = DialogSystem() if chapterType is not None: @@ -32,8 +36,8 @@ def dialog(screen:pygame.Surface, chapterType:str, chapterId:int, part:str, proj #加载完成-闸门开启的效果 for i in range(100,-1,-1): DIALOG.display_background_image(screen) - screen.blit(LoadingImgAbove,(-4,LoadingImgAbove.get_height()/100*i-LoadingImgAbove.get_height())) - screen.blit(LoadingImgBelow,(-4,screen.get_height()-LoadingImgBelow.get_height()/100*i)) + screen.blit(LoadingImgAbove,(-2,LoadingImgAbove.get_height()/100*i-LoadingImgAbove.get_height())) + screen.blit(LoadingImgBelow,(-2,screen.get_height()-LoadingImgBelow.get_height()/100*i)) linpg.display.flip() #DIALOG.auto_save = True #主循环 @@ -45,9 +49,9 @@ def dialog(screen:pygame.Surface, chapterType:str, chapterId:int, part:str, proj return DIALOG.dialog_options #对话编辑器 -def dialogEditor(screen:pygame.Surface, chapterType:str, chapterId:int, part:str, projectName:str=None) -> None: +def dialogEditor(screen:linpg.ImageSurface, chapterType:str, chapterId:int, part:str, projectName:str=None) -> None: #卸载音乐 - linpg.unloadBackgroundMusic() + linpg.unload_all_music() #改变标题 linpg.display.set_caption("{0} ({1})".format(linpg.get_lang('General','game_title'),linpg.get_lang('General','dialog_editor'))) if RPC is not None: @@ -65,9 +69,9 @@ def dialogEditor(screen:pygame.Surface, chapterType:str, chapterId:int, part:str if RPC is not None: RPC.update(state=linpg.get_lang("DiscordStatus","staying_at_main_menu"),large_image=LARGE_IMAGE) #战斗系统 -def battle(screen:pygame.Surface, chapterType:str, chapterId:int, projectName:str=None) -> dict: +def battle(screen:linpg.ImageSurface, chapterType:str, chapterId:int, projectName:str=None) -> dict: #卸载音乐 - linpg.unloadBackgroundMusic() + linpg.unload_all_music() BATTLE:object = TurnBasedBattleSystem() if chapterType is not None: BATTLE.new(screen, chapterType, chapterId, projectName) @@ -79,13 +83,13 @@ def battle(screen:pygame.Surface, chapterType:str, chapterId:int, projectName:st ALPHA_BUILD_WARNING.draw(screen) linpg.display.flip() #暂停声效 - 尤其是环境声 - linpg.unloadBackgroundMusic() + linpg.unload_all_music() return BATTLE.resultInfo #地图编辑器 -def mapEditor(screen:pygame.Surface, chapterType:str, chapterId:int, projectName:str=None) -> None: +def mapEditor(screen:linpg.ImageSurface, chapterType:str, chapterId:int, projectName:str=None) -> None: #卸载音乐 - linpg.unloadBackgroundMusic() + linpg.unload_all_music() MAP_EDITOR = MapEditor() MAP_EDITOR.load(screen, chapterType, chapterId, projectName) #改变标题 @@ -100,27 +104,3 @@ def mapEditor(screen:pygame.Surface, chapterType:str, chapterId:int, projectName #改变标题回主菜单的样式 linpg.display.set_caption(linpg.get_lang('General','game_title')) if RPC is not None: RPC.update(state=linpg.get_lang("DiscordStatus","staying_at_main_menu"),large_image=LARGE_IMAGE) - -#blit载入页面 -def dispaly_loading_screen(screen:pygame.Surface, start:int, end:int, value:int) -> None: - window_x,window_y = screen.get_size() - #获取健康游戏忠告 - HealthyGamingAdvice = linpg.try_get_lang("HealthyGamingAdvice") - if HealthyGamingAdvice == "HealthyGamingAdvice": - HealthyGamingAdvice = [] - else: - for i in range(len(HealthyGamingAdvice)): - HealthyGamingAdvice[i] = linpg.fontRender(HealthyGamingAdvice[i],"white",window_x/64) - #其他载入页面需要的数据 - text1 = linpg.fontRender(linpg.get_lang("title1"),"white",window_x/64) - text2 = linpg.fontRender(linpg.get_lang("title2"),"white",window_x/64) - #主循环 - for i in range(start,end,value): - screen.fill(linpg.findColorRGBA("black")) - text1.set_alpha(i) - text2.set_alpha(i) - screen.blits(((text1,(window_x/64,window_y*0.9)),(text2,(window_x/64,window_y*0.9-window_x/32)))) - for a in range(len(HealthyGamingAdvice)): - HealthyGamingAdvice[a].set_alpha(i) - screen.blit(HealthyGamingAdvice[a],(window_x-window_x/32-HealthyGamingAdvice[a].get_width(),window_y*0.9-window_x/64*a*1.5)) - linpg.display.flip() \ No newline at end of file diff --git a/main.py b/main.py index 5f1d9b71..34174c9e 100644 --- a/main.py +++ b/main.py @@ -1,14 +1,15 @@ +#导入核心组件 try: - from Source_pyd.mainMenu import MainMenu, linpg, pygame -except: + from Source_pyd.mainMenu import MainMenu, linpg +except Exception: print("Cannot import from Source_pyd") - from Source.mainMenu import MainMenu, linpg, pygame + from Source.mainMenu import MainMenu, linpg #读取并整理配置文件 folders = ['Lang/*.yaml','Data/*.yaml','Data/main_chapter/*.yaml'] for folderPath in folders: #pass - linpg.organizeConfigInFolder(folderPath) + linpg.organize_config_in_folder(folderPath) #是否启动游戏 GAMESTART:bool = True @@ -16,9 +17,7 @@ #游戏主进程 if GAMESTART is True and __name__ == "__main__": #创建窗口 - screen = linpg.display.init_screen( - pygame.DOUBLEBUF | pygame.SCALED | pygame.FULLSCREEN if linpg.get_setting("FullScreen") is True else pygame.SCALED - ) + screen = linpg.display.init_screen() #窗口标题图标 linpg.display.set_icon("Assets/image/UI/icon.png") linpg.display.set_caption(linpg.get_lang('General','game_title')) diff --git a/requirements.txt b/requirements.txt index 6527f5f7..83f9e63f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,3 @@ -av -linpg -numpy -pygame pyyaml -pypresence \ No newline at end of file +pypresence +linpg \ No newline at end of file