Spoiler:
# Autor - Gatoz (shiwt). Szczególne podziękowania dla Thieffer'a. Egrimowi i # HellKillerowi też dzięki za pomoc przy malutkim błędzie ;) # Jest mój pierwszy CMS więc proszę o wyrozumiałość :] #-------------------------------Window CMS 1.1---------------------------------- # Dodałem możliwość zmiany przezroczystości, czcionki i jej rozmiaru, kilka # napisów znajdujących się w menu, tj. czas gry, kroki i inne. Szybkość # wchodzenia okienek. Zmienna odpowiadającej za reputację i szybka możliwość # zmiany poszczególnych nazw w reputacji. Szybkość = 5 # UWAGA! Szybkość wchodzenia okienek może wynosić TYLKO 1, 2 albo 5 Przezroczystość = 127 Zmienna = 0001 Czcionka = "Galileo Font" Rozmiar = 18 Napis_u_góry_ekranu = " Menu" Liczba_kroków = "Liczba kroków" Czas_gry = "Czas gry" Przełącznik_50 = "Nieznajomy" Przełącznik_1 = "Chłop" Przełącznik_1 = "Obywatel" Przełącznik_1= "Rycerz" Poziom_5 = "Szlachcic" Poziom_6 = "Król" #------------------------------------------------------------------------------- # Scene_Menu ------------------------------------------------------------------- #------------------------------------------------------------------------------- class Scene_Menu def initialize(menu_index = 0) @menu_index = menu_index end def main s1 = $data_system.words.item s2 = $data_system.words.skill s3 = $data_system.words.equip s4 = "Status" s5 = "Zapisz" s6 = "Wczytaj" s7 = "Wyjście" @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7]) @command_window.index = @menu_index @command_window.x = -160 - @command_window.width / 30 @command_window.y = 58 - @command_window.height / 30 @command_window.back_opacity = Przezroczystość if $game_party.actors.size == 0 @command_window.disable_item(0) @command_window.disable_item(1) @command_window.disable_item(2) @command_window.disable_item(3) end if $game_system.save_disabled @command_window.disable_item(4) end #------------------------------------------------------------------------------- # Wchodzenie okienek ----------------------------------------------------------- #------------------------------------------------------------------------------- @okno1 = Window_Gold2.new @okno2 = Window_Steps2.new @okno3 = Window_PlayTime2.new @okno4 = Window_Napis.new @status_window = Window_Postać.new @okno6 = Window_Lokacja.new @okno7 = Window_Reputacja.new @okno1.x = 640 @okno1.y = 50 @okno2.x = 640 @okno2.y = 114 @okno3.x = 640 @okno3.y = 210 @okno4.x = 0 @okno4.y = -50 @status_window.x = 0 @status_window.y = 480 @okno6.x = 640 @okno6.y = 306 @okno7.x = -165 @okno7.y = 306 @spriteset = Spriteset_Map.new @appearing = true Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end Graphics.freeze @okno1.dispose @okno2.dispose @okno3.dispose @okno4.dispose @status_window.dispose @okno6.dispose @command_window.dispose @spriteset.dispose @okno7.dispose end def appear @okno1.x -= Szybkość if @okno1.x > 480 @okno2.x -= Szybkość if @okno2.x > 480 @okno3.x -= Szybkość if @okno3.x > 480 @okno4.y += Szybkość if @okno4.y < 0 @status_window.y -= Szybkość if @status_window.y > 370 @okno6.x -= Szybkość if @okno6.x > 480 @command_window.x += Szybkość if @command_window.x < 0 @okno7.x += Szybkość if @okno7.x < 0 if @okno1.x == 480 and @okno2.x == 480 and @okno3.x == 480 and @okno4.y == 0 and @status_window.y == 370 and @okno6.x == 480 and @command_window.x == 0 and @okno7.x == 0 @appearing = false end end def update if @appearing appear end @okno1.update @okno2.update @okno3.update @okno4.update @status_window.update @okno6.update @command_window.update @spriteset.update @okno7.update #------------------------------------------------------------------------------- # Reszta Scene_Menu ------------------------------------------------------------ #------------------------------------------------------------------------------- if @command_window.active update_command return end if @status_window.active update_status return end end def update_command if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) $scene = Scene_Map.new return end if Input.trigger?(Input::C) if $game_party.actors.size == 0 and @command_window.index < 4 $game_system.se_play($data_system.buzzer_se) return end case @command_window.index when 0 # item $game_system.se_play($data_system.decision_se) $scene = Scene_Item.new when 1 # skill $game_system.se_play($data_system.decision_se) @command_window.active = false @status_window.active = true @status_window.index = 0 when 2 # equipment $game_system.se_play($data_system.decision_se) @command_window.active = false @status_window.active = true @status_window.index = 0 when 3 # status $game_system.se_play($data_system.decision_se) @command_window.active = false @status_window.active = true @status_window.index = 0 when 4 # save if $game_system.save_disabled $game_system.se_play($data_system.buzzer_se) return end $game_system.se_play($data_system.decision_se) $scene = Scene_Save.new when 5 # load $game_system.se_play($data_system.decision_se) $scene = Scene_Loading.new when 6 # end game $game_system.se_play($data_system.decision_se) $scene = Scene_End.new end return end end def update_status if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @command_window.active = true @status_window.active = false @status_window.index = -1 return end if Input.trigger?(Input::C) case @command_window.index when 1 # skill if $game_party.actors[@status_window.index].restriction >= 2 $game_system.se_play($data_system.buzzer_se) return end $game_system.se_play($data_system.decision_se) $scene = Scene_Skill.new(@status_window.index) when 2 # equipment $game_system.se_play($data_system.decision_se) $scene = Scene_Equip.new(@status_window.index) when 3 # status $game_system.se_play($data_system.decision_se) $scene = Scene_Status.new(@status_window.index) end return end end end #------------------------------------------------------------------------------- # Window_Selectable2 ----------------------------------------------------------- #------------------------------------------------------------------------------- class Window_Selectable2 < Window_Base attr_reader :index attr_reader :help_window def initialize(x, y, width, height) super(x, y, width, height) @item_max = 1 @column_max = 4 @index = -1 end def index=(index) @index = index if self.active and @help_window != nil update_help end update_cursor_rect end def row_max return (@item_max + @column_max - 1) / @column_max end def top_row return self.ox / 32 end def top_row=(row) if row < 0 row = 0 end if row > row_max - 1 row = row_max - 1 end self.ox = row * 32 end def page_row_max return (self.height - 32) / 32 end def page_item_max return page_row_max * @column_max end def help_window=(help_window) @help_window = help_window if self.active and @help_window != nil update_help end end def update_cursor_rect if @index < 0 self.cursor_rect.empty return end row = @index / @column_max if row < self.top_row self.top_row = row end if row > self.top_row + (self.page_row_max - 1) self.top_row = row - (self.page_row_max - 1) end cursor_width = self.width / @column_max - 32 y = @index % @column_max * (cursor_width + 32) x = @index / @column_max * 32 - self.oy self.cursor_rect.set(x, y, cursor_width, 32) end def update super if self.active and @item_max > 0 and @index >= 0 if Input.repeat?(Input::DOWN) if (@column_max == 1 and Input.trigger?(Input::DOWN)) or @index < @item_max - @column_max $game_system.se_play($data_system.cursor_se) @index = (@index + @column_max) % @item_max end end if Input.repeat?(Input::UP) if (@column_max == 1 and Input.trigger?(Input::UP)) or @index >= @column_max $game_system.se_play($data_system.cursor_se) @index = (@index - @column_max + @item_max) % @item_max end end if Input.repeat?(Input::RIGHT) if @column_max >= 2 and @index < @item_max - 1 $game_system.se_play($data_system.cursor_se) @index += 1 end end if Input.repeat?(Input::LEFT) if @column_max >= 2 and @index > 0 $game_system.se_play($data_system.cursor_se) @index -= 1 end end if Input.repeat?(Input::R) if self.top_row + (self.page_row_max - 1) < (self.row_max - 1) $game_system.se_play($data_system.cursor_se) @index = [@index + self.page_item_max, @item_max - 1].min self.top_row += self.page_row_max end end if Input.repeat?(Input::L) if self.top_row > 0 $game_system.se_play($data_system.cursor_se) @index = [@index - self.page_item_max, 0].max self.top_row -= self.page_row_max end end end if self.active and @help_window != nil update_help end update_cursor_rect end end #------------------------------------------------------------------------------- # Scene_Loading ---------------------------------------------------------------- #------------------------------------------------------------------------------- class Scene_Loading < Scene_File def initialize $game_temp = Game_Temp.new $game_temp.last_file_index = 0 latest_time = Time.at(0) for i in 0..3 filename = make_filename(i) if FileTest.exist?(filename) file = File.open(filename, "r") if file.mtime > latest_time latest_time = file.mtime $game_temp.last_file_index = i end file.close end end super("Czy chcesz wczytać grę?") end def on_decision(filename) unless FileTest.exist?(filename) $game_system.se_play($data_system.buzzer_se) return end $game_system.se_play($data_system.load_se) file = File.open(filename, "rb") read_save_data(file) file.close $game_system.bgm_play($game_system.playing_bgm) $game_system.bgs_play($game_system.playing_bgs) $game_map.update $scene = Scene_Map.new end def on_cancel $game_system.se_play($data_system.cancel_se) $scene = Scene_Menu.new(5) end def read_save_data(file) characters = Marshal.load(file) Graphics.frame_count = Marshal.load(file) $game_system = Marshal.load(file) $game_switches = Marshal.load(file) $game_variables = Marshal.load(file) $game_self_switches = Marshal.load(file) $game_screen = Marshal.load(file) $game_actors = Marshal.load(file) $game_party = Marshal.load(file) $game_troop = Marshal.load(file) $game_map = Marshal.load(file) $game_player = Marshal.load(file) if $game_system.magic_number != $data_system.magic_number $game_map.setup($game_map.map_id) $game_player.center($game_player.x, $game_player.y) end $game_party.refresh end end #------------------------------------------------------------------------------- # Scene_End -------------------------------------------------------------------- #------------------------------------------------------------------------------- class Scene_End alias oldupdate update def update @command_window.update if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) $scene = Scene_Menu.new(6) return end if Input.trigger?(Input::C) case @command_window.index when 0 # to title command_to_title when 1 # shutdown command_shutdown when 2 # quit command_cancel $scene = Scene_Menu.new(6) end return oldupdate end end end #------------------------------------------------------------------------------- # Window_Postać (Status Menu) -------------------------------------------------- #------------------------------------------------------------------------------- class Window_Postać < Window_Selectable2 def initialize super(0, 480, 640, 110) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = Czcionka self.contents.font.size = Rozmiar @frame = 0 refresh self.active = false self.index = -1 self.back_opacity = Przezroczystość end def refresh self.contents.clear @item_max = $game_party.actors.size for i in 0...$game_party.actors.size x = i * 160 y = 0 actor = $game_party.actors[i] draw_actor_sprite(actor, x + 90, y + 10) draw_actor_name(actor, x, y) draw_actor_state(actor, x, y + 32) end end def update_cursor_rect if @index < 0 self.cursor_rect.empty else self.cursor_rect.set(@index * 160, 0, self.height + 18, 78) end end def draw_actor_sprite (actor, x, y) bitmap = RPG::Cache.character(actor.character_name, actor.character_hue) src_rect = Rect.new(bitmap.width / 4 * @frame, 0, bitmap.width / 4, bitmap.height / 4) cw = bitmap.width / 4 ch = bitmap.height / 4 self.contents.stretch_blt(Rect.new(x, y, cw, ch), bitmap, src_rect) end def update super if Graphics.frame_count % 10 == 0 @frame == 3 ? @frame = 0 : @frame += 1 refresh end end end #------------------------------------------------------------------------------- # Napis "Menu" u góry ekranu --------------------------------------------------- #------------------------------------------------------------------------------- class Window_Napis < Window_Base def initialize super(0, -50, 640, 50) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = Czcionka self.contents.font.size = Rozmiar self.back_opacity = Przezroczystość refresh end def refresh self.contents.clear self.contents.draw_text(100, -3, 400, 25, Napis_u_góry_ekranu, 1) end end #------------------------------------------------------------------------------- # Window_Lokacja --------------------------------------------------------------- #------------------------------------------------------------------------------- class Game_Map def name $map_infos[@map_id] end end class Scene_Title $map_infos = load_data("Data/MapInfos.rxdata") for key in $map_infos.keys $map_infos[key] = $map_infos[key].name end end class Window_Lokacja < Window_Base def initialize super(640, 306, 160, 64) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = Czcionka self.contents.font.size = Rozmiar self.back_opacity = Przezroczystość refresh end def refresh self.contents.clear cx = contents.text_size($game_map.name).width self.contents.draw_text(124-cx, 0, cx, 32, $game_map.name, 1) end end #------------------------------------------------------------------------------- # Window_Gold ------------------------------------------------------------------ #------------------------------------------------------------------------------- class Window_Gold2 < Window_Base def initialize super(0, 0, 160, 64) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = Czcionka self.contents.font.size = Rozmiar self.back_opacity = Przezroczystość refresh end def refresh self.contents.clear cx = contents.text_size($data_system.words.gold).width self.contents.font.color = normal_color self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2) self.contents.font.color = system_color self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2) end end #------------------------------------------------------------------------------- # Window_Steps ----------------------------------------------------------------- #------------------------------------------------------------------------------- class Window_Steps2 < Window_Base def initialize super(0, 0, 160, 96) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = Czcionka self.contents.font.size = Rozmiar self.back_opacity = Przezroczystość refresh end def refresh self.contents.clear self.contents.font.color = system_color self.contents.draw_text(4, 0, 120, 32, Liczba_kroków) self.contents.font.color = normal_color self.contents.draw_text(4, 32, 120, 32, $game_party.steps.to_s, 2) end end #------------------------------------------------------------------------------- # Window_PlayTime -------------------------------------------------------------- #------------------------------------------------------------------------------- class Window_PlayTime2 < Window_Base def initialize super(0, 0, 160, 96) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = Czcionka self.contents.font.size = Rozmiar self.back_opacity = Przezroczystość refresh end def refresh self.contents.clear self.contents.font.color = system_color self.contents.draw_text(4, 0, 120, 32, Czas_gry) @total_sec = Graphics.frame_count / Graphics.frame_rate hour = @total_sec / 60 / 60 min = @total_sec / 60 % 60 sec = @total_sec % 60 text = sprintf("%02d:%02d:%02d", hour, min, sec) self.contents.font.color = normal_color self.contents.draw_text(4, 32, 120, 32, text, 2) end def update super if Graphics.frame_count / Graphics.frame_rate != @total_sec refresh end end end #------------------------------------------------------------------------------- # Window_Reputacja ------------------------------------------------------------- #------------------------------------------------------------------------------- class Window_Reputacja < Window_Base def initialize super(640, 306, 160, 64) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = Czcionka self.contents.font.size = Rozmiar self.back_opacity = Przezroczystość refresh end def refresh self.contents.clear @reputacja = $game_variables[Zmienna] if @reputacja == 0 self.contents.draw_text(0, 0, 124, 32, Przełącznik_50, 1) end self.contents.clear if @reputacja == 10 self.contents.draw_text(0, 0, 124, 32, Poziom_2, 1) end self.contents.clear if @reputacja == 30 self.contents.draw_text(0, 0, 124, 32, Poziom_3, 1) end self.contents.clear if @reputacja == 50 self.contents.draw_text(0, 0, 124, 32, Poziom_4, 1) end self.contents.clear if @reputacja == 85 self.contents.draw_text(0, 0, 124, 32, Poziom_5, 1) end self.contents.clear if @reputacja == 100 self.contents.draw_text(0, 0, 124, 32, Poziom_6, 1) end end end