problem z cms - M4t3us2 - 24-09-13 16:29
Witam, potrafiłby ktoś przerobić skrypt (własne komendy w menu)
Kod:
#==============================================================================
# Własne komendy w menu [XP] / Custom Menu Commands [XP]
#==============================================================================
# Autor: Ayene
#==============================================================================
# Skrypt pozwala dodać do menu własne polecenia. Przewidziano również wyłączenie
# okien ze złotem, czasem i liczbą kroków.
# Instalacja: Umieść skrypt nad Main.
#==============================================================================
module Ayene
# Lista poleceń w menu
MENU_COMMANDS = [
#["Nazwa" , "Scena", Wybór postaci
["Ekwipunek", 'Scene_Equip', false],
["Przedmioty", 'Scene_Item', false],
["Rozdaj Pkt", 'Scene_Points', false],
["Umiejętności", 'Scene_Skill', false],
["Profil postaci", 'Scene_Status', false],
["Zadania", 'Scene_QuestLog', false],
["Opcje gry", 'Scene_Option', false],
["Zapisz", 'Scene_Save', false],
["Wyjście", 'Scene_End', false],
]
# Wybór postaci, to opcja zaznaczenia okna statusu w menu, jak to ma miejsce
# w przypadku wyboru Umiejętności czy Ekwipunku - po ich wyborze bowiem można
# wybrać postać, której właściwości chcemy zobaczyć.
# Maksymalna liczba wierszy
ROW_MAX = 6
# Indeks poleceń (kolejność w MENU_COMMANDS), które mają być nieaktywne,
# gdy nie ma bohaterów w drużynie.
DISABLE_COMMANDS = [0, 1, 2, 3, 4]
# Okno ze złotem (tak - true / nie - false)
GOLD_WINDOW = true
# Okno z czasem gry (tak - true / nie - false)
PLAY_TIME_WINDOW = true
# Okno z liczbą kroków (tak - true / nie - false)
STEP_WINDOW = true
end
#==============================================================================
# ** Game_Temp
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :menu_command_index
#--------------------------------------------------------------------------
# * Object Initialization (alias)
#--------------------------------------------------------------------------
alias aye_gametemp_ini initialize
def initialize
aye_gametemp_ini
@menu_command_index = 0
end
end
#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
alias aye_scmap_main main
def main
$game_temp.menu_command_index = 0
aye_scmap_main
end
end
#==============================================================================
# ** Scene_Menu
#==============================================================================
class Scene_Menu
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
@command_window = Window_Command.new(160, commands[0])
@command_window.height = [@command_window.height, Ayene::ROW_MAX * 32 + 32].min
@command_window.index = $game_temp.menu_command_index
Ayene::DISABLE_COMMANDS.each{|i| @command_window.disable_item(i) if $game_party.actors.size == 0}
@windows = []
@windows.push(Window_PlayTime.new) if Ayene::PLAY_TIME_WINDOW
@windows.push(Window_Steps.new) if Ayene::STEP_WINDOW
@windows.push(Window_Gold.new) if Ayene::GOLD_WINDOW
y = @command_window.height
for window in @windows
window.x = 0
window.y = y
y += window.height
end
@status_window = Window_MenuStatus.new
@status_window.x = 160
@status_window.y = 0
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@command_window.dispose
for window in @windows
window.dispose
end
@status_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
@command_window.update
@status_window.update
for window in @windows
window.update
end
if @command_window.active
update_command
return
end
if @status_window.active
update_status
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
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)
unless command_enabled?(@command_window.index)
$game_system.se_play($data_system.buzzer_se)
return
end
$game_temp.menu_command_index = @command_window.index
$game_system.se_play($data_system.decision_se)
if commands[2][@command_window.index]
@command_window.active = false
@status_window.active = true
@status_window.index = 0
else
$scene = eval("#{commands[1][@command_window.index]}.new")
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when status window is active)
#--------------------------------------------------------------------------
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)
$game_system.se_play($data_system.decision_se)
$scene = eval("#{commands[1][@command_window.index]}.new(@status_window.index)")
return
end
end
#--------------------------------------------------------------------------
# * Check Commands
#--------------------------------------------------------------------------
def commands
commands = []
next_scene = []
select_window = []
for command in Ayene::MENU_COMMANDS
commands.push(command[0])
next_scene.push(command[1])
select_window.push(command[2])
end
return commands, next_scene, select_window
end
#--------------------------------------------------------------------------
# * Check Command Enabled
#--------------------------------------------------------------------------
def command_enabled?(index)
if Ayene::DISABLE_COMMANDS.include?(index) and $game_party.actors.size == 0
return false
end
return true
end
end
tak aby ustawienie z menu powyżej było w tym cmsie
Kod:
# 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 = "Arial"
Rozmiar = 24
Napis_u_góry_ekranu = " Menu"
Liczba_kroków = "Liczba kroków"
Czas_gry = "Czas gry"
Poziom_1 = "Wieśniak"
Poziom_2 = "Chłop"
Poziom_3 = "Obywatel"
Poziom_4 = "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, Poziom_1, 1)
end
if @reputacja == 10
self.contents.draw_text(0, 0, 124, 32, Poziom_2, 1)
end
if @reputacja == 30
self.contents.draw_text(0, 0, 124, 32, Poziom_3, 1)
end
if @reputacja == 50
self.contents.draw_text(0, 0, 124, 32, Poziom_4, 1)
end
if @reputacja == 85
self.contents.draw_text(0, 0, 124, 32, Poziom_5, 1)
end
if @reputacja == 100
self.contents.draw_text(0, 0, 124, 32, Poziom_6, 1)
end
end
end
Dokładniej chodzi mi oto żeby te opcje #["Nazwa" , "Scena", Wybór postaci
["Ekwipunek", 'Scene_Equip', false],
["Przedmioty", 'Scene_Item', false],
["Rozdaj Pkt", 'Scene_Points', false],
["Umiejętności", 'Scene_Skill', false],
["Profil postaci", 'Scene_Status', false],
["Zadania", 'Scene_QuestLog', false],
["Opcje gry", 'Scene_Option', false],
["Zapisz", 'Scene_Save', false],
["Wyjście", 'Scene_End', false], były dostępne w cmsie.
RE: problem z cms - Ayene - 27-09-13 20:11
Sprawdź to:
Kod:
# 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 = "Arial"
Rozmiar = 24
Napis_u_góry_ekranu = " Menu"
Liczba_kroków = "Liczba kroków"
Czas_gry = "Czas gry"
Poziom_1 = "Wieśniak"
Poziom_2 = "Chłop"
Poziom_3 = "Obywatel"
Poziom_4 = "Rycerz"
Poziom_5 = "Szlachcic"
Poziom_6 = "Król"
module Ayene
# Lista poleceń w menu
MENU_COMMANDS = [
#["Nazwa" , "Scena", Wybór postaci
["Ekwipunek", 'Scene_Equip', false],
["Przedmioty", 'Scene_Item', false],
["Rozdaj Pkt", 'Scene_Points', false],
["Umiejętności", 'Scene_Skill', false],
["Profil postaci", 'Scene_Status', false],
["Zadania", 'Scene_QuestLog', false],
["Opcje gry", 'Scene_Option', false],
["Zapisz", 'Scene_Save', false],
["Wyjście", 'Scene_End', false],
]
# Wybór postaci, to opcja zaznaczenia okna statusu w menu, jak to ma miejsce
# w przypadku wyboru Umiejętności czy Ekwipunku - po ich wyborze bowiem można
# wybrać postać, której właściwości chcemy zobaczyć.
# Maksymalna liczba wierszy
ROW_MAX = 6
# Indeks poleceń (kolejność w MENU_COMMANDS), które mają być nieaktywne,
# gdy nie ma bohaterów w drużynie.
DISABLE_COMMANDS = [0, 1, 2, 3, 4]
end
#==============================================================================
# ** Game_Temp
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :menu_command_index
#--------------------------------------------------------------------------
# * Object Initialization (alias)
#--------------------------------------------------------------------------
alias aye_gametemp_ini initialize
def initialize
aye_gametemp_ini
@menu_command_index = 0
end
end
#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
alias aye_scmap_main main
def main
$game_temp.menu_command_index = 0
aye_scmap_main
end
end
#-------------------------------------------------------------------------------
# Scene_Menu -------------------------------------------------------------------
#-------------------------------------------------------------------------------
class Scene_Menu
def main
@command_window = Window_Command.new(160, commands[0])
@command_window.height = [@command_window.height, Ayene::ROW_MAX * 32 + 32].min
@command_window.index = $game_temp.menu_command_index
Ayene::DISABLE_COMMANDS.each{|i| @command_window.disable_item(i) if $game_party.actors.size == 0}
@command_window.x = -160 - @command_window.width / 30
@command_window.y = 58 - @command_window.height / 30
@command_window.back_opacity = Przezroczystość
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)
unless command_enabled?(@command_window.index)
$game_system.se_play($data_system.buzzer_se)
return
end
$game_temp.menu_command_index = @command_window.index
$game_system.se_play($data_system.decision_se)
if commands[2][@command_window.index]
@command_window.active = false
@status_window.active = true
@status_window.index = 0
else
$scene = eval("#{commands[1][@command_window.index]}.new")
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when status window is active)
#--------------------------------------------------------------------------
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)
$game_system.se_play($data_system.decision_se)
$scene = eval("#{commands[1][@command_window.index]}.new(@status_window.index)")
return
end
end
#--------------------------------------------------------------------------
# * Check Commands
#--------------------------------------------------------------------------
def commands
commands = []
next_scene = []
select_window = []
for command in Ayene::MENU_COMMANDS
commands.push(command[0])
next_scene.push(command[1])
select_window.push(command[2])
end
return commands, next_scene, select_window
end
#--------------------------------------------------------------------------
# * Check Command Enabled
#--------------------------------------------------------------------------
def command_enabled?(index)
if Ayene::DISABLE_COMMANDS.include?(index) and $game_party.actors.size == 0
return false
end
return true
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, Poziom_1, 1)
end
if @reputacja == 10
self.contents.draw_text(0, 0, 124, 32, Poziom_2, 1)
end
if @reputacja == 30
self.contents.draw_text(0, 0, 124, 32, Poziom_3, 1)
end
if @reputacja == 50
self.contents.draw_text(0, 0, 124, 32, Poziom_4, 1)
end
if @reputacja == 85
self.contents.draw_text(0, 0, 124, 32, Poziom_5, 1)
end
if @reputacja == 100
self.contents.draw_text(0, 0, 124, 32, Poziom_6, 1)
end
end
end
RE: problem z cms - M4t3us2 - 28-09-13 17:26
Jak mogłoby nie działać, w końcu to twoja robota :D
Dzięki.
|