Code: ## Skillmenu requested by user ## Author: D.T. Linkey ## Date: 03.03.2018 module LDT_SKILL_MENU #Confirmation texts CONFIRM_TITLE = " aufwerten?" CONFIRM_TRUE = "Ja" CONFIRM_FALSE = "Nein" #Headline/Title SKILL_TITLE = "Skillpunkte insg." #skill names SKILL_NAMES = ["Skillname1", "Skillname2", "Skillname3", "Skillname4"] #skill icon ids ICON_IDS = [4, 8, 9, 26] #skill costs SKILL_COSTS = [[3,7,11,24,49,-1], [3,15,33,-1], [4,60,-1], [7,23,59,-1]] #variable for each skill (e.g. 1 = $game_variables[1]) SKILL_VARS = [1,2,3,4] #variable for each skillcosts (e.g. 1 = $game_variables[1]) COST_VARS = [5,6,7,8] #variable for total skill points (e.g. 1 = $game_variables[1]) SKILL_TOTAL_POINT_VAR = 9 #Symbol displayed if max Level is reached MAX_LEVEL_SIGN = "-" #Graphics #Start position vertical (0 = top, 480 = botton) G_START_Y = 0 #start position horizontal (0 = left, 640 = right) G_START_X = 0 #Width of the first Window G_WIDTH_1 = 280 #Width of the second Window G_WIDTH_2 = 240 #Confirmation window alignment (1 = horiz., 2= vert.) G_CONFIRM_ALIGN = 2 end class LDT_Skill_Scene < Scene_Base def start super create_title_window create_skill_window create_confirmation_windows create_background end def create_title_window() @title_window = LDT_Skill_Window_Title.new(LDT_SKILL_MENU::G_START_X,LDT_SKILL_MENU::G_START_Y,1,LDT_SKILL_MENU::G_WIDTH_1) @title_window.set_text(LDT_SKILL_MENU::SKILL_TITLE) end def create_skill_window() ty = LDT_SKILL_MENU::G_START_Y + @title_window.height th = LDT_SKILL_MENU::SKILL_NAMES.size * 24 + 32 @skill_window = LDT_Skill_Window.new(LDT_SKILL_MENU::G_START_X,ty,LDT_SKILL_MENU::G_WIDTH_1,th) @skill_window.viewport = @viewport @skill_window.set_handler(:ok, method(:on_menu_ok)) @skill_window.set_handler(:cancel, method(:return_scene)) @skill_window.activate @skill_window.select(0) @skill_window.show end def create_background @background_sprite = Sprite.new @background_sprite.bitmap = SceneManager.background_bitmap @background_sprite.color.set(16, 16, 16, 128) end def create_confirmation_windows() if(LDT_SKILL_MENU::G_CONFIRM_ALIGN == 1) tx = LDT_SKILL_MENU::G_START_X + LDT_SKILL_MENU::G_WIDTH_1 ty = LDT_SKILL_MENU::G_START_Y else tx = LDT_SKILL_MENU::G_START_X ty = LDT_SKILL_MENU::G_START_Y + @title_window.height + @skill_window.height end @confirm_title_window = LDT_Confirm_Window_Title.new(tx,ty,1,LDT_SKILL_MENU::G_WIDTH_2) @confirm_title_window.set_text("") @confirm_title_window.hide th = 2 * 24 + 32 ty = ty + @confirm_title_window.height @confirm_window = LDT_Skill_Window_Confirmation.new(tx,ty,LDT_SKILL_MENU::G_WIDTH_2,th) @confirm_window.viewport = @viewport @confirm_window.set_handler(:ok, method(:on_conf_ok)) @confirm_window.set_handler(:cancel, method(:on_conf_cancel)) @confirm_window.hide end def on_menu_ok ti = @skill_window.index if(@skill_window.current_item_enabled?) ttext = LDT_SKILL_MENU::SKILL_NAMES[ti] + LDT_SKILL_MENU::CONFIRM_TITLE @confirm_title_window.set_text(ttext) @confirm_title_window.show @confirm_window.activate @confirm_window.select(0) @confirm_window.show else @skill_window.activate end end def on_conf_ok if(@confirm_window.index >= 1) on_conf_cancel else ti = @skill_window.index $game_variables[LDT_SKILL_MENU::SKILL_VARS[ti]] += 1 $game_variables[LDT_SKILL_MENU::SKILL_TOTAL_POINT_VAR] -= $game_variables[LDT_SKILL_MENU::COST_VARS[ti]] refresh_windows on_conf_cancel end end def refresh_windows @skill_window.refresh @title_window.refresh end def on_conf_cancel @confirm_window.deactivate @confirm_window.hide @confirm_title_window.hide @skill_window.activate end end class LDT_Skill_Window < Window_Selectable def initialize(x, y, width, height) super(x,y,width,height) @skills = LDT_SKILL_MENU::SKILL_NAMES refresh end def item_max @skills ? @skills.size : 1 end def item @skills && index >= 0 ? @skills[index] : nil end def refresh set_costs() create_contents draw_all_items end def draw_item(index) rect = item_rect(index) rect.width -= 4 if(current_item_enabled?(index)) contents.font.color.alpha = 255 else contents.font.color.alpha = translucent_alpha end draw_icon(LDT_SKILL_MENU::ICON_IDS[index], rect.x, rect.y, current_item_enabled?(index)) draw_text(rect.x + 26, rect.y, rect.width - 26, rect.height, get_skill_name(index))#, rect.x, rect.y) draw_text(rect,get_costs(index),2) end def get_skill_name(index) return @skills[index] end def set_costs() LDT_SKILL_MENU::COST_VARS.each_with_index do |tcv,ti| tskill = $game_variables[LDT_SKILL_MENU::SKILL_VARS[ti]] $game_variables[tcv] = LDT_SKILL_MENU::SKILL_COSTS[ti][tskill] end end def current_item_enabled?(tindex = index) return false if(tindex < 0) tc = get_costs(tindex) return false if(tc == LDT_SKILL_MENU::MAX_LEVEL_SIGN) return ($game_variables[LDT_SKILL_MENU::SKILL_TOTAL_POINT_VAR] >= tc) end def get_costs(index) tcosts = $game_variables[LDT_SKILL_MENU::COST_VARS[index]] return tcosts >= 0 ? tcosts : LDT_SKILL_MENU::MAX_LEVEL_SIGN end end class LDT_Skill_Window_Confirmation < Window_Selectable def initialize(x, y, width, height) super(x,y,width,height) @items = [LDT_SKILL_MENU::CONFIRM_TRUE,LDT_SKILL_MENU::CONFIRM_FALSE] refresh end def item_max @items ? @items.size : 1 end def item @items && index >= 0 ? @items[index] : nil end def refresh create_contents draw_all_items end def draw_item(index) rect = item_rect(index) rect.width -= 4 draw_text(rect,get_item_name(index)) end def get_item_name(index) return @items[index] end def get_costs(index) return $game_variables[LDT_SKILL_MENU::COST_VARS[index]] end end class LDT_Skill_Window_Title < Window_Base def initialize(x,y,line_number = 1, tw = nil) tw = (tw ? tw : Graphics.width) super(x, y, tw, fitting_height(line_number)) end def refresh contents.clear draw_text_ex(4, 0, @text) draw_text(4, 0, width - 32, line_height, get_second_text(), 2) end def get_second_text() return $game_variables[LDT_SKILL_MENU::SKILL_TOTAL_POINT_VAR] end def set_text(text) if text != @text @text = text refresh end end end class LDT_Confirm_Window_Title < Window_Base def initialize(x,y,line_number = 1, tw = nil) tw = (tw ? tw : Graphics.width) super(x, y, tw, fitting_height(line_number)) @text2 = "" end def refresh contents.clear draw_text_ex(4, 0, @text) end def set_text(text) if text != @text @text = text refresh end end end Passt das so? In den ersten 50 Zeilen kannst du die ganzen Einstellungen vornehmen (Texte, Icons, Variable-Nummern, Fenstergröße, etc.). Aufgerufen wird das Script über: SceneManager.call(LDT_Skill_Scene)
## Skillmenu requested by user ## Author: D.T. Linkey ## Date: 03.03.2018 module LDT_SKILL_MENU #Confirmation texts CONFIRM_TITLE = " aufwerten?" CONFIRM_TRUE = "Ja" CONFIRM_FALSE = "Nein" #Headline/Title SKILL_TITLE = "Skillpunkte insg." #skill names SKILL_NAMES = ["Skillname1", "Skillname2", "Skillname3", "Skillname4"] #skill icon ids ICON_IDS = [4, 8, 9, 26] #skill costs SKILL_COSTS = [[3,7,11,24,49,-1], [3,15,33,-1], [4,60,-1], [7,23,59,-1]] #variable for each skill (e.g. 1 = $game_variables[1]) SKILL_VARS = [1,2,3,4] #variable for each skillcosts (e.g. 1 = $game_variables[1]) COST_VARS = [5,6,7,8] #variable for total skill points (e.g. 1 = $game_variables[1]) SKILL_TOTAL_POINT_VAR = 9 #Symbol displayed if max Level is reached MAX_LEVEL_SIGN = "-" #Graphics #Start position vertical (0 = top, 480 = botton) G_START_Y = 0 #start position horizontal (0 = left, 640 = right) G_START_X = 0 #Width of the first Window G_WIDTH_1 = 280 #Width of the second Window G_WIDTH_2 = 240 #Confirmation window alignment (1 = horiz., 2= vert.) G_CONFIRM_ALIGN = 2 end class LDT_Skill_Scene < Scene_Base def start super create_title_window create_skill_window create_confirmation_windows create_background end def create_title_window() @title_window = LDT_Skill_Window_Title.new(LDT_SKILL_MENU::G_START_X,LDT_SKILL_MENU::G_START_Y,1,LDT_SKILL_MENU::G_WIDTH_1) @title_window.set_text(LDT_SKILL_MENU::SKILL_TITLE) end def create_skill_window() ty = LDT_SKILL_MENU::G_START_Y + @title_window.height th = LDT_SKILL_MENU::SKILL_NAMES.size * 24 + 32 @skill_window = LDT_Skill_Window.new(LDT_SKILL_MENU::G_START_X,ty,LDT_SKILL_MENU::G_WIDTH_1,th) @skill_window.viewport = @viewport @skill_window.set_handler(:ok, method(:on_menu_ok)) @skill_window.set_handler(:cancel, method(:return_scene)) @skill_window.activate @skill_window.select(0) @skill_window.show end def create_background @background_sprite = Sprite.new @background_sprite.bitmap = SceneManager.background_bitmap @background_sprite.color.set(16, 16, 16, 128) end def create_confirmation_windows() if(LDT_SKILL_MENU::G_CONFIRM_ALIGN == 1) tx = LDT_SKILL_MENU::G_START_X + LDT_SKILL_MENU::G_WIDTH_1 ty = LDT_SKILL_MENU::G_START_Y else tx = LDT_SKILL_MENU::G_START_X ty = LDT_SKILL_MENU::G_START_Y + @title_window.height + @skill_window.height end @confirm_title_window = LDT_Confirm_Window_Title.new(tx,ty,1,LDT_SKILL_MENU::G_WIDTH_2) @confirm_title_window.set_text("") @confirm_title_window.hide th = 2 * 24 + 32 ty = ty + @confirm_title_window.height @confirm_window = LDT_Skill_Window_Confirmation.new(tx,ty,LDT_SKILL_MENU::G_WIDTH_2,th) @confirm_window.viewport = @viewport @confirm_window.set_handler(:ok, method(:on_conf_ok)) @confirm_window.set_handler(:cancel, method(:on_conf_cancel)) @confirm_window.hide end def on_menu_ok ti = @skill_window.index if(@skill_window.current_item_enabled?) ttext = LDT_SKILL_MENU::SKILL_NAMES[ti] + LDT_SKILL_MENU::CONFIRM_TITLE @confirm_title_window.set_text(ttext) @confirm_title_window.show @confirm_window.activate @confirm_window.select(0) @confirm_window.show else @skill_window.activate end end def on_conf_ok if(@confirm_window.index >= 1) on_conf_cancel else ti = @skill_window.index $game_variables[LDT_SKILL_MENU::SKILL_VARS[ti]] += 1 $game_variables[LDT_SKILL_MENU::SKILL_TOTAL_POINT_VAR] -= $game_variables[LDT_SKILL_MENU::COST_VARS[ti]] refresh_windows on_conf_cancel end end def refresh_windows @skill_window.refresh @title_window.refresh end def on_conf_cancel @confirm_window.deactivate @confirm_window.hide @confirm_title_window.hide @skill_window.activate end end class LDT_Skill_Window < Window_Selectable def initialize(x, y, width, height) super(x,y,width,height) @skills = LDT_SKILL_MENU::SKILL_NAMES refresh end def item_max @skills ? @skills.size : 1 end def item @skills && index >= 0 ? @skills[index] : nil end def refresh set_costs() create_contents draw_all_items end def draw_item(index) rect = item_rect(index) rect.width -= 4 if(current_item_enabled?(index)) contents.font.color.alpha = 255 else contents.font.color.alpha = translucent_alpha end draw_icon(LDT_SKILL_MENU::ICON_IDS[index], rect.x, rect.y, current_item_enabled?(index)) draw_text(rect.x + 26, rect.y, rect.width - 26, rect.height, get_skill_name(index))#, rect.x, rect.y) draw_text(rect,get_costs(index),2) end def get_skill_name(index) return @skills[index] end def set_costs() LDT_SKILL_MENU::COST_VARS.each_with_index do |tcv,ti| tskill = $game_variables[LDT_SKILL_MENU::SKILL_VARS[ti]] $game_variables[tcv] = LDT_SKILL_MENU::SKILL_COSTS[ti][tskill] end end def current_item_enabled?(tindex = index) return false if(tindex < 0) tc = get_costs(tindex) return false if(tc == LDT_SKILL_MENU::MAX_LEVEL_SIGN) return ($game_variables[LDT_SKILL_MENU::SKILL_TOTAL_POINT_VAR] >= tc) end def get_costs(index) tcosts = $game_variables[LDT_SKILL_MENU::COST_VARS[index]] return tcosts >= 0 ? tcosts : LDT_SKILL_MENU::MAX_LEVEL_SIGN end end class LDT_Skill_Window_Confirmation < Window_Selectable def initialize(x, y, width, height) super(x,y,width,height) @items = [LDT_SKILL_MENU::CONFIRM_TRUE,LDT_SKILL_MENU::CONFIRM_FALSE] refresh end def item_max @items ? @items.size : 1 end def item @items && index >= 0 ? @items[index] : nil end def refresh create_contents draw_all_items end def draw_item(index) rect = item_rect(index) rect.width -= 4 draw_text(rect,get_item_name(index)) end def get_item_name(index) return @items[index] end def get_costs(index) return $game_variables[LDT_SKILL_MENU::COST_VARS[index]] end end class LDT_Skill_Window_Title < Window_Base def initialize(x,y,line_number = 1, tw = nil) tw = (tw ? tw : Graphics.width) super(x, y, tw, fitting_height(line_number)) end def refresh contents.clear draw_text_ex(4, 0, @text) draw_text(4, 0, width - 32, line_height, get_second_text(), 2) end def get_second_text() return $game_variables[LDT_SKILL_MENU::SKILL_TOTAL_POINT_VAR] end def set_text(text) if text != @text @text = text refresh end end end class LDT_Confirm_Window_Title < Window_Base def initialize(x,y,line_number = 1, tw = nil) tw = (tw ? tw : Graphics.width) super(x, y, tw, fitting_height(line_number)) @text2 = "" end def refresh contents.clear draw_text_ex(4, 0, @text) end def set_text(text) if text != @text @text = text refresh end end end
--
Foren-Regeln