Ergebnis 1 bis 20 von 39

Thema: Fenster, das Variablen mit Werten und Beschreibung anzeigt

Hybrid-Darstellung

Vorheriger Beitrag Vorheriger Beitrag   Nächster Beitrag Nächster Beitrag
  1. #1
    Dann stelle ich dir das Skript mit genügend Kommentaren fertig

    Beim implementieren helfe ich dir so gut wie ich kann, Linkey hat ja auch Hilfe angeboten.

    Denke damit werde ich morgen fertig sein.

    PS: Ich kann dir nur empfehlen etwas Programmier-Sprache zu beherrschen es ist wirklich sehr nützlich und Ruby ist nicht allzu schwer (finde ich aufjedenfall). Das aktuelle Skript hat mich 1 1/2h Zeit gekostet, also sind solche Kleinigkeiten schnell erledigt

  2. #2
    OKi

  3. #3
    Hmm, hat hier noch jemand Bock drauf?

  4. #4
    Woran scheitert es denn? Das Script von Maniglo zu übersetzen oder hast du es erst gar nicht von ihm bekommen?

  5. #5
    Ich hab kein Script von ihm bekommen. Er scheint aber auch gar nicht mehr hier aktiv zu sein, denn der letzte Login ist über einen Monat her. Aber selbst wenn, würde ich ihn auch nicht mit PMs nerven wollen, wenn er gerade wichtigeres zu tun hat.

  6. #6
    Leider habe ich für so etwas momentan eigentlich überhaupt keine Zeit. Ich hab sie mir gerade trotzdem genommen um auf die schnelle etwas für dich bereitzustellen.
    In den ersten gut 50 Zeilen kannst du diverse Einstellungen vornehmen. Ich habe diese einmal beispielhaft ausgefüllt, damit du eine Idee davon bekommst, wie du es eintragen musst.

    Das Upgrade-Menü rufst du über folgenden Scriptcall im Event auf:
    Code:
    call_upgrade_menu([Upgrade1,Upgrade2,...])
    Code:
    module LDT_UPGRADE_MENU
      #Confirmation texts
      CONFIRM_TITLE = " upgrade?"
      CONFIRM_TRUE = "Yes"
      CONFIRM_FALSE = "No"
      
      #icon ids
      #upgrade icons (villager, house,...)
      ICON_IDS = [121,232,292,281] 
      #cost icons (wood, gold, ...)
      ICON_COST_IDS = [331,262,350,147]
      #resource names
      UPGRADE_NAMES = ["Villagers","House","Fisherman","Church"] 
      
      #cost names
      COST_NAMES = ["Wood","Gold","Stone","Sword"]
      
      #upgrade costs
      UPGRADE_COSTS = [[{0=>5,1=>10},{0=>10,1=>25},{0=>20,1=>50},{0=>50,1=>200}],#villager
                       [{0=>5,1=>10,2=>5},{0=>10,1=>25,2=>15},{0=>20,1=>50,2=>50}],#house
                       [{0=>10,1=>5}],#fisherman
                       [{0=>50,1=>500,2=>50}],#church
                       ]
      
      #variable for each upgrade (e.g. 1 = $game_variables[1])
      UPGRADE_VARS = [101,102,103,104]
      
      #variable for each cost (e.g. 1 = $game_variables[1])
      COST_VARS = [105,106,107,108]
      
      #Symbol displayed if max Level is reached
      MAX_LEVEL_TEXT = "MAX"
      #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
      #color if condition is not met
      BAD_COLOR = 2
    end
    
    # call the upgrade menu
    # items needs to be an array 
    # e.g. call_upgrade_menu([0]) will call the menu for villager upgrades
    # e.g. call_upgrade_menu([0,3]) will call the menu for villager & church upgr.
    def call_upgrade_menu(items)
      return false unless(items.is_a?(Array))
      $upgrade_items = items
      SceneManager.call(LDT_Upgrade_Scene)
    end
    
    class LDT_Upgrade_Scene < Scene_Base
      def start
        super
        @ui = 0
        create_selection_window
        create_cost_window
        create_confirmation_windows
        create_background
      end
      
      
      def create_selection_window()
        ty = LDT_UPGRADE_MENU::G_START_Y
        th = $upgrade_items.size * 24 + 32
        @upgrade_window = LDT_Upgrade_Window.new(LDT_UPGRADE_MENU::G_START_X,ty,LDT_UPGRADE_MENU::G_WIDTH_1,th)
        @upgrade_window.viewport = @viewport
    
        @upgrade_window.set_handler(:ok,     method(:on_menu_ok))
        @upgrade_window.set_handler(:cancel, method(:return_scene))
        @upgrade_window.activate    
        @upgrade_window.select(0)
        @upgrade_window.show
      end
      
      def create_cost_window()
        ty = LDT_UPGRADE_MENU::G_START_Y
        tx = LDT_UPGRADE_MENU::G_START_X + LDT_UPGRADE_MENU::G_WIDTH_1
        tw = Graphics.width - tx
        @cost_window = LDT_Upgrade_Cost_Window.new(tx,ty,tw)
        @cost_window.viewport = @viewport
        
        @cost_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_UPGRADE_MENU::G_CONFIRM_ALIGN == 1)
          tx = LDT_UPGRADE_MENU::G_START_X + LDT_UPGRADE_MENU::G_WIDTH_1
          ty = LDT_UPGRADE_MENU::G_START_Y
        else
          tx = LDT_UPGRADE_MENU::G_START_X
          ty = LDT_UPGRADE_MENU::G_START_Y + @upgrade_window.height
        end
        @confirm_title_window = LDT_Confirm_Window_Title.new(tx,ty,1,LDT_UPGRADE_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_Upgrade_Window_Confirmation.new(tx,ty,LDT_UPGRADE_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 = @upgrade_window.index
        if(@upgrade_window.current_item_enabled?)
          ttext = get_upgrade_name(ti) + LDT_UPGRADE_MENU::CONFIRM_TITLE
          @confirm_title_window.set_text(ttext)
          @confirm_title_window.show
          
          @confirm_window.activate
          @confirm_window.select(0)
          @confirm_window.show
        else
          @upgrade_window.activate
        end
      end
      
      def on_conf_ok
        if(@confirm_window.index >= 1)
          on_conf_cancel
        else
          ti = $upgrade_items[@upgrade_window.index]
          #loop on all costs of current upgrade level and reduce cor. variable
          LDT_UPGRADE_MENU::UPGRADE_COSTS[ti][$game_variables[LDT_UPGRADE_MENU::UPGRADE_VARS[ti]]].each do |tk,tv|
            $game_variables[LDT_UPGRADE_MENU::COST_VARS[tk]]-= tv
          end
          #increase upgrade variable by 1
          $game_variables[LDT_UPGRADE_MENU::UPGRADE_VARS[ti]] += 1
          refresh_windows
          on_conf_cancel
        end
      end
      
      def refresh_windows
        @upgrade_window.refresh
        @cost_window.refresh
      end
      
      def update()
        super()
        if(@upgrade_window.index != @ui)
          @ui = @upgrade_window.index
          @cost_window.set_upgrade_index($upgrade_items[@ui])
          @cost_window.refresh
        end
      end
      def on_conf_cancel
        @confirm_window.deactivate
        @confirm_window.hide
        @confirm_title_window.hide
        @upgrade_window.activate
      end
      
      def get_upgrade_name(index)
        return LDT_UPGRADE_MENU::UPGRADE_NAMES[$upgrade_items[index]]
      end
    end
    
    class LDT_Upgrade_Cost_Window < Window_Base
      def initialize(x, y, width)
        super(x,y,width,get_uc_height)
        @iu = 0
        refresh
      end
      
      def set_upgrade_index(index)
        @iu = index
      end
      
      def refresh
        contents.clear
        LDT_UPGRADE_MENU::COST_NAMES.each_with_index do |tn,ti|
          draw_costs(ti)
        end
      end
      
      def draw_costs(index)
        tx = 0
        ty = 0 + index * 24
        tw = self.width - 24
        if(cost_relevant?(index))
          contents.font.color.alpha = 255
        else
          contents.font.color.alpha = translucent_alpha
        end
        draw_icon(get_icon_num(index), tx, ty, cost_relevant?(index))
        draw_text(tx + 26, ty, tw - 26, 24, get_cost_name(index))
        if(cost_relevant?(index))
          if(get_resource(index) < get_upgrade_cost(index))
            change_color(text_color(LDT_UPGRADE_MENU::BAD_COLOR))
          end
          draw_text(tx,ty,tw,24,get_upgrade_cost_text(index),2)       
          change_color(normal_color())
        end
      end
      
      def get_uc_height()
        return LDT_UPGRADE_MENU::COST_NAMES.size * 24 + 32
      end
      
      def cost_relevant?(index)
        return false unless(LDT_UPGRADE_MENU::UPGRADE_COSTS[@iu][$game_variables[LDT_UPGRADE_MENU::UPGRADE_VARS[@iu]]])
        return LDT_UPGRADE_MENU::UPGRADE_COSTS[@iu][$game_variables[LDT_UPGRADE_MENU::UPGRADE_VARS[@iu]]].has_key?(index)
      end
      
      def get_icon_num(index)
        return LDT_UPGRADE_MENU::ICON_COST_IDS[index]
      end
      
      def get_cost_name(index)
        text = LDT_UPGRADE_MENU::COST_NAMES[index] + "("
        text = text + get_resource(index).to_s + ")"
        return text
      end
      
      def get_resource(index)
        return $game_variables[LDT_UPGRADE_MENU::COST_VARS[index]]
      end
      
      def get_upgrade_cost_text(index)
        return get_upgrade_cost(index).to_s
      end
      
      def get_upgrade_cost(index)
        LDT_UPGRADE_MENU::UPGRADE_COSTS[@iu][$game_variables[LDT_UPGRADE_MENU::UPGRADE_VARS[@iu]]][index]
      end
    end
    
    class LDT_Upgrade_Window < Window_Selectable
    
      def initialize(x, y, width, height)
        super(x,y,width,height)
        refresh
      end
      
      def item_max
        $upgrade_items ? $upgrade_items.size : 1
      end
    
      def item
        $upgrade_items && index >= 0 ? LDT_UPGRADE_MENU::UPGRADE_NAMES[$upgrade_items[index]] : nil
      end
      
      def refresh
        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(get_icon_num(index), rect.x, rect.y, current_item_enabled?(index))
          draw_text(rect.x + 26, rect.y, rect.width - 26, rect.height, get_upgrade_name(index))#, rect.x, rect.y)
          draw_text(rect,get_upgrade_lvl(index),2)
      end
      
      def get_upgrade_lvl(index)
        return $game_variables[LDT_UPGRADE_MENU::UPGRADE_VARS[up_index(index)]]
      end
      
      def up_index(index)
        return $upgrade_items[index]
      end
      
      def get_icon_num(index)
        return LDT_UPGRADE_MENU::ICON_IDS[up_index(index)]
      end
      
      def get_upgrade_name(index)
        return LDT_UPGRADE_MENU::UPGRADE_NAMES[up_index(index)]
      end
          
      def current_item_enabled?(tindex = index)
        return false if(tindex < 0)
        tc = get_costs(tindex)
        return false if(tc == LDT_UPGRADE_MENU::MAX_LEVEL_TEXT)
        tc.each do |tk,tv|
         return false if($game_variables[LDT_UPGRADE_MENU::COST_VARS[tk]] < tv)
        end
        return true
      end
      
      def get_costs(index)
        tcosts = LDT_UPGRADE_MENU::UPGRADE_COSTS[up_index(index)][$game_variables[LDT_UPGRADE_MENU::UPGRADE_VARS[up_index(index)]]]
        return tcosts ? tcosts : LDT_UPGRADE_MENU::MAX_LEVEL_TEXT
      end
    end
    
    class LDT_Upgrade_Window_Confirmation < Window_Selectable
       def initialize(x, y, width, height)
        super(x,y,width,height)
        @items = [LDT_UPGRADE_MENU::CONFIRM_TRUE,LDT_UPGRADE_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_UPGRADE_MENU::COST_VARS[index]]
      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

  7. #7
    WOW, danke dir ich werde es gleich ausprobieren

    Edit: Gibt es denn eine Möglichkeit mit dem Maker, wie ich die Schrift farbig und zusätzlich eine Beschreibung der Unterpunkte einfügen kann?

    zB Villager. Beschreibung: Das sind die Bewohner deines Dorfes

    Geändert von Ken der Kot (16.06.2019 um 17:46 Uhr)

  8. #8
    Hier das Update, wie gewünscht:
    - Fenstergröße maximiert
    - Titelwindow für Beschreibung hinzugefügt

    Farbliche markierungen kannst du mit \\C[0] setzen. Nicht vergessen, die Schriftfarbe danach wieder auf 0 zu setzen:
    "Dies ist ein \\C[2]Beispiel\\C[0] mit roter Farbe."

    Falls du im oberen Teil schon Einstellungen vorgenommen hast, habe ich dir die dort neu hinzugefügte Zeile extra farblich gekennzeichnet, sodass du nicht deine Anpassungen mit copy&paste überschreiben musst.
    Es reicht wenn du das blaue kopierst und den enstprechenden Teil im alten Script damit überschreibst.

    Code:
    module LDT_UPGRADE_MENU
      #Confirmation texts
      CONFIRM_TITLE = " upgrade?"
      CONFIRM_TRUE = "Yes"
      CONFIRM_FALSE = "No"
      
      #icon ids
      #upgrade icons (villager, house,...)
      ICON_IDS = [121,232,292,281] 
      #cost icons (wood, gold, ...)
      ICON_COST_IDS = [331,262,350,147]
      #resource names
      UPGRADE_NAMES = ["Villagers","House","Fisherman","Church"] 
      
      #cost names
      COST_NAMES = ["Wood","Gold","Stone","Sword"]
      
      #upgrade costs
      UPGRADE_COSTS = [[{0=>5,1=>10},{0=>10,1=>25},{0=>20,1=>50},{0=>50,1=>200}],#villager
                       [{0=>5,1=>10,2=>5},{0=>10,1=>25,2=>15},{0=>20,1=>50,2=>50}],#house
                       [{0=>10,1=>5}],#fisherman
                       [{0=>50,1=>500,2=>50}],#church
                       ]
      
      #upgrade description
      UPGRADE_DESCR = ["The \\C[5]inhabitants\\C[0] of your village.","This is your residence.","The guy who provides you with fish.","The place your inhabitants can pray."]
      
      #variable for each upgrade (e.g. 1 = $game_variables[1])
      UPGRADE_VARS = [101,102,103,104]
      
      #variable for each cost (e.g. 1 = $game_variables[1])
      COST_VARS = [105,106,107,108]
      
      #Symbol displayed if max Level is reached
      MAX_LEVEL_TEXT = "MAX"
      #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
      #color if condition is not met
      BAD_COLOR = 2
    end
    
    # call the upgrade menu
    # items needs to be an array 
    # e.g. call_upgrade_menu([0]) will call the menu for villager upgrades
    # e.g. call_upgrade_menu([0,3]) will call the menu for villager & church upgr.
    def call_upgrade_menu(items)
      return false unless(items.is_a?(Array))
      $upgrade_items = items
      SceneManager.call(LDT_Upgrade_Scene)
    end
    
    class LDT_Upgrade_Scene < Scene_Base
      def start
        super
        @ui = 0
        create_title_window()
        create_selection_window
        create_cost_window
        create_confirmation_windows
        create_background
        @title_window.set_text(LDT_UPGRADE_MENU::UPGRADE_DESCR[$upgrade_items[@ui]])
      end
      
      def create_title_window()
        @title_window = LDT_Upgrade_Window_Title.new(LDT_UPGRADE_MENU::G_START_X,LDT_UPGRADE_MENU::G_START_Y,1,Graphics.width)
        @title_window.set_text("")
      end
      
      def create_selection_window()
        ty = LDT_UPGRADE_MENU::G_START_Y + @title_window.height
        th = Graphics.height - @title_window.height#$upgrade_items.size * 24 + 32
        @upgrade_window = LDT_Upgrade_Window.new(LDT_UPGRADE_MENU::G_START_X,ty,LDT_UPGRADE_MENU::G_WIDTH_1,th)
        @upgrade_window.viewport = @viewport
    
        @upgrade_window.set_handler(:ok,     method(:on_menu_ok))
        @upgrade_window.set_handler(:cancel, method(:return_scene))
        @upgrade_window.activate    
        @upgrade_window.select(0)
        @upgrade_window.show
      end
      
      def create_cost_window()
        ty = LDT_UPGRADE_MENU::G_START_Y + @title_window.height
        tx = LDT_UPGRADE_MENU::G_START_X + LDT_UPGRADE_MENU::G_WIDTH_1
        tw = Graphics.width - tx
        th = Graphics.height - @title_window.height
        @cost_window = LDT_Upgrade_Cost_Window.new(tx,ty,tw,th)
        @cost_window.viewport = @viewport
        
        @cost_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()
        tx = LDT_UPGRADE_MENU::G_START_X + ( LDT_UPGRADE_MENU::G_WIDTH_1 - LDT_UPGRADE_MENU::G_WIDTH_2 ) / 2
        ty = LDT_UPGRADE_MENU::G_START_Y
        @confirm_title_window = LDT_Confirm_Window_Title.new(tx,ty,1,LDT_UPGRADE_MENU::G_WIDTH_2)
        @confirm_title_window.set_text("")
        @confirm_title_window.hide
        @confirm_title_window.viewport = @viewport
        
        th = 2 * 24 + 32
        ty = ty + @confirm_title_window.height
        @confirm_window = LDT_Upgrade_Window_Confirmation.new(tx,ty,LDT_UPGRADE_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 = @upgrade_window.index
        if(@upgrade_window.current_item_enabled?)
          ttext = get_upgrade_name(ti) + LDT_UPGRADE_MENU::CONFIRM_TITLE
          @confirm_title_window.set_text(ttext)
          tth = @upgrade_window.index * 24 + 40 + @title_window.height
          if((tth + @confirm_title_window.height + @confirm_window.height) > Graphics.height)
            tth = tth - 24 - @confirm_title_window.height - @confirm_window.height
          end
          @confirm_title_window.y = tth 
          @confirm_window.y = tth + @confirm_title_window.height
          @confirm_title_window.show
          
          @confirm_window.activate
          @confirm_window.select(0)
          @confirm_window.show
        else
          @upgrade_window.activate
        end
      end
      
      def on_conf_ok
        if(@confirm_window.index >= 1)
          on_conf_cancel
        else
          ti = $upgrade_items[@upgrade_window.index]
          #loop on all costs of current upgrade level and reduce cor. variable
          LDT_UPGRADE_MENU::UPGRADE_COSTS[ti][$game_variables[LDT_UPGRADE_MENU::UPGRADE_VARS[ti]]].each do |tk,tv|
            $game_variables[LDT_UPGRADE_MENU::COST_VARS[tk]]-= tv
          end
          #increase upgrade variable by 1
          $game_variables[LDT_UPGRADE_MENU::UPGRADE_VARS[ti]] += 1
          refresh_windows
          on_conf_cancel
        end
      end
      
      def refresh_windows
        @upgrade_window.refresh
        @cost_window.refresh
      end
      
      def update()
        super()
        if(@upgrade_window.index != @ui)
          @ui = @upgrade_window.index
          @cost_window.set_upgrade_index($upgrade_items[@ui])
          @cost_window.refresh
          @title_window.set_text(LDT_UPGRADE_MENU::UPGRADE_DESCR[$upgrade_items[@ui]])
        end
      end
      def on_conf_cancel
        @confirm_window.deactivate
        @confirm_window.hide
        @confirm_title_window.hide
        @upgrade_window.activate
      end
      
      def get_upgrade_name(index)
        return LDT_UPGRADE_MENU::UPGRADE_NAMES[$upgrade_items[index]]
      end
    end
    
    class LDT_Upgrade_Cost_Window < Window_Base
      def initialize(x, y, width,height)
        super(x,y,width,height)#get_uc_height)
        @iu = 0
        refresh
      end
      
      def set_upgrade_index(index)
        @iu = index
      end
      
      def refresh
        contents.clear
        LDT_UPGRADE_MENU::COST_NAMES.each_with_index do |tn,ti|
          draw_costs(ti)
        end
      end
      
      def draw_costs(index)
        tx = 0
        ty = 0 + index * 24
        tw = self.width - 24
        if(cost_relevant?(index))
          contents.font.color.alpha = 255
        else
          contents.font.color.alpha = translucent_alpha
        end
        draw_icon(get_icon_num(index), tx, ty, cost_relevant?(index))
        draw_text(tx + 26, ty, tw - 26, 24, get_cost_name(index))
        if(cost_relevant?(index))
          if(get_resource(index) < get_upgrade_cost(index))
            change_color(text_color(LDT_UPGRADE_MENU::BAD_COLOR))
          end
          draw_text(tx,ty,tw,24,get_upgrade_cost_text(index),2)       
          change_color(normal_color())
        end
      end
      
      def get_uc_height()
        return LDT_UPGRADE_MENU::COST_NAMES.size * 24 + 32
      end
      
      def cost_relevant?(index)
        return false unless(LDT_UPGRADE_MENU::UPGRADE_COSTS[@iu][$game_variables[LDT_UPGRADE_MENU::UPGRADE_VARS[@iu]]])
        return LDT_UPGRADE_MENU::UPGRADE_COSTS[@iu][$game_variables[LDT_UPGRADE_MENU::UPGRADE_VARS[@iu]]].has_key?(index)
      end
      
      def get_icon_num(index)
        return LDT_UPGRADE_MENU::ICON_COST_IDS[index]
      end
      
      def get_cost_name(index)
        text = LDT_UPGRADE_MENU::COST_NAMES[index] + "("
        text = text + get_resource(index).to_s + ")"
        return text
      end
      
      def get_resource(index)
        return $game_variables[LDT_UPGRADE_MENU::COST_VARS[index]]
      end
      
      def get_upgrade_cost_text(index)
        return get_upgrade_cost(index).to_s
      end
      
      def get_upgrade_cost(index)
        LDT_UPGRADE_MENU::UPGRADE_COSTS[@iu][$game_variables[LDT_UPGRADE_MENU::UPGRADE_VARS[@iu]]][index]
      end
    end
    
    class LDT_Upgrade_Window < Window_Selectable
    
      def initialize(x, y, width, height)
        super(x,y,width,height)
        refresh
      end
      
      def item_max
        $upgrade_items ? $upgrade_items.size : 1
      end
    
      def item
        $upgrade_items && index >= 0 ? LDT_UPGRADE_MENU::UPGRADE_NAMES[$upgrade_items[index]] : nil
      end
      
      def refresh
        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(get_icon_num(index), rect.x, rect.y, current_item_enabled?(index))
          draw_text(rect.x + 26, rect.y, rect.width - 26, rect.height, get_upgrade_name(index))#, rect.x, rect.y)
          draw_text(rect,get_upgrade_lvl(index),2)
      end
      
      def get_upgrade_lvl(index)
        return $game_variables[LDT_UPGRADE_MENU::UPGRADE_VARS[up_index(index)]]
      end
      
      def up_index(index)
        return $upgrade_items[index]
      end
      
      def get_icon_num(index)
        return LDT_UPGRADE_MENU::ICON_IDS[up_index(index)]
      end
      
      def get_upgrade_name(index)
        return LDT_UPGRADE_MENU::UPGRADE_NAMES[up_index(index)]
      end
          
      def current_item_enabled?(tindex = index)
        return false if(tindex < 0)
        tc = get_costs(tindex)
        return false if(tc == LDT_UPGRADE_MENU::MAX_LEVEL_TEXT)
        tc.each do |tk,tv|
         return false if($game_variables[LDT_UPGRADE_MENU::COST_VARS[tk]] < tv)
        end
        return true
      end
      
      def get_costs(index)
        tcosts = LDT_UPGRADE_MENU::UPGRADE_COSTS[up_index(index)][$game_variables[LDT_UPGRADE_MENU::UPGRADE_VARS[up_index(index)]]]
        return tcosts ? tcosts : LDT_UPGRADE_MENU::MAX_LEVEL_TEXT
      end
    end
    
    class LDT_Upgrade_Window_Confirmation < Window_Selectable
       def initialize(x, y, width, height)
        super(x,y,width,height)
        @items = [LDT_UPGRADE_MENU::CONFIRM_TRUE,LDT_UPGRADE_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_UPGRADE_MENU::COST_VARS[index]]
      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
    
    class LDT_Upgrade_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)
      end
      
      def set_text(text)
        if text != @text
          @text = text
          refresh
        end
      end
    end

  9. #9
    Wow, das isses. Grad getestet und so hab ich mir das vorgestellt. Herzlichen Dank, Linkey. Bist ein Guter. <3

    Edit: Nur das zB 5/50 anstelle von (5) 50 in der Anzeige wär noch gut. Weißt ja was ich mein.

  10. #10
    Klar, hier (Zeile 1-50 kannst du wieder stehen lassen, den rest hiermit ersetzen):
    Code:
    # call the upgrade menu
    # items needs to be an array 
    # e.g. call_upgrade_menu([0]) will call the menu for villager upgrades
    # e.g. call_upgrade_menu([0,3]) will call the menu for villager & church upgr.
    def call_upgrade_menu(items)
      return false unless(items.is_a?(Array))
      $upgrade_items = items
      SceneManager.call(LDT_Upgrade_Scene)
    end
    
    class LDT_Upgrade_Scene < Scene_Base
      def start
        super
        @ui = 0
        create_title_window()
        create_selection_window
        create_cost_window
        create_confirmation_windows
        create_background
        @title_window.set_text(LDT_UPGRADE_MENU::UPGRADE_DESCR[$upgrade_items[@ui]])
      end
      
      def create_title_window()
        @title_window = LDT_Upgrade_Window_Title.new(LDT_UPGRADE_MENU::G_START_X,LDT_UPGRADE_MENU::G_START_Y,1,Graphics.width)
        @title_window.set_text("")
      end
      
      def create_selection_window()
        ty = LDT_UPGRADE_MENU::G_START_Y + @title_window.height
        th = Graphics.height - @title_window.height#$upgrade_items.size * 24 + 32
        @upgrade_window = LDT_Upgrade_Window.new(LDT_UPGRADE_MENU::G_START_X,ty,LDT_UPGRADE_MENU::G_WIDTH_1,th)
        @upgrade_window.viewport = @viewport
    
        @upgrade_window.set_handler(:ok,     method(:on_menu_ok))
        @upgrade_window.set_handler(:cancel, method(:return_scene))
        @upgrade_window.activate    
        @upgrade_window.select(0)
        @upgrade_window.show
      end
      
      def create_cost_window()
        ty = LDT_UPGRADE_MENU::G_START_Y + @title_window.height
        tx = LDT_UPGRADE_MENU::G_START_X + LDT_UPGRADE_MENU::G_WIDTH_1
        tw = Graphics.width - tx
        th = Graphics.height - @title_window.height
        @cost_window = LDT_Upgrade_Cost_Window.new(tx,ty,tw,th)
        @cost_window.viewport = @viewport
        
        @cost_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()
        tx = LDT_UPGRADE_MENU::G_START_X + ( LDT_UPGRADE_MENU::G_WIDTH_1 - LDT_UPGRADE_MENU::G_WIDTH_2 ) / 2
        ty = LDT_UPGRADE_MENU::G_START_Y
        @confirm_title_window = LDT_Confirm_Window_Title.new(tx,ty,1,LDT_UPGRADE_MENU::G_WIDTH_2)
        @confirm_title_window.set_text("")
        @confirm_title_window.hide
        @confirm_title_window.viewport = @viewport
        
        th = 2 * 24 + 32
        ty = ty + @confirm_title_window.height
        @confirm_window = LDT_Upgrade_Window_Confirmation.new(tx,ty,LDT_UPGRADE_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 = @upgrade_window.index
        if(@upgrade_window.current_item_enabled?)
          ttext = get_upgrade_name(ti) + LDT_UPGRADE_MENU::CONFIRM_TITLE
          @confirm_title_window.set_text(ttext)
          tth = @upgrade_window.index * 24 + 40 + @title_window.height
          if((tth + @confirm_title_window.height + @confirm_window.height) > Graphics.height)
            tth = tth - 24 - @confirm_title_window.height - @confirm_window.height
          end
          @confirm_title_window.y = tth 
          @confirm_window.y = tth + @confirm_title_window.height
          @confirm_title_window.show
          
          @confirm_window.activate
          @confirm_window.select(0)
          @confirm_window.show
        else
          @upgrade_window.activate
        end
      end
      
      def on_conf_ok
        if(@confirm_window.index >= 1)
          on_conf_cancel
        else
          ti = $upgrade_items[@upgrade_window.index]
          #loop on all costs of current upgrade level and reduce cor. variable
          LDT_UPGRADE_MENU::UPGRADE_COSTS[ti][$game_variables[LDT_UPGRADE_MENU::UPGRADE_VARS[ti]]].each do |tk,tv|
            $game_variables[LDT_UPGRADE_MENU::COST_VARS[tk]]-= tv
          end
          #increase upgrade variable by 1
          $game_variables[LDT_UPGRADE_MENU::UPGRADE_VARS[ti]] += 1
          refresh_windows
          on_conf_cancel
        end
      end
      
      def refresh_windows
        @upgrade_window.refresh
        @cost_window.refresh
      end
      
      def update()
        super()
        if(@upgrade_window.index != @ui)
          @ui = @upgrade_window.index
          @cost_window.set_upgrade_index($upgrade_items[@ui])
          @cost_window.refresh
          @title_window.set_text(LDT_UPGRADE_MENU::UPGRADE_DESCR[$upgrade_items[@ui]])
        end
      end
      def on_conf_cancel
        @confirm_window.deactivate
        @confirm_window.hide
        @confirm_title_window.hide
        @upgrade_window.activate
      end
      
      def get_upgrade_name(index)
        return LDT_UPGRADE_MENU::UPGRADE_NAMES[$upgrade_items[index]]
      end
    end
    
    class LDT_Upgrade_Cost_Window < Window_Base
      def initialize(x, y, width,height)
        super(x,y,width,height)#get_uc_height)
        @iu = 0
        refresh
      end
      
      def set_upgrade_index(index)
        @iu = index
      end
      
      def refresh
        contents.clear
        LDT_UPGRADE_MENU::COST_NAMES.each_with_index do |tn,ti|
          draw_costs(ti)
        end
      end
      
      def draw_costs(index)
        tx = 0
        ty = 0 + index * 24
        tw = self.width - 24
        if(cost_relevant?(index))
          contents.font.color.alpha = 255
        else
          contents.font.color.alpha = translucent_alpha
        end
        draw_icon(get_icon_num(index), tx, ty, cost_relevant?(index))
        draw_text(tx + 26, ty, tw - 26, 24, get_cost_name(index))
        if(cost_relevant?(index))
          if(get_resource(index) < get_upgrade_cost(index))
            change_color(text_color(LDT_UPGRADE_MENU::BAD_COLOR))
          end
          draw_text(tx,ty,tw,24,get_upgrade_cost_text(index),2)       
          change_color(normal_color())
        end
      end
      
      def get_uc_height()
        return LDT_UPGRADE_MENU::COST_NAMES.size * 24 + 32
      end
      
      def cost_relevant?(index)
        return false unless(LDT_UPGRADE_MENU::UPGRADE_COSTS[@iu][$game_variables[LDT_UPGRADE_MENU::UPGRADE_VARS[@iu]]])
        return LDT_UPGRADE_MENU::UPGRADE_COSTS[@iu][$game_variables[LDT_UPGRADE_MENU::UPGRADE_VARS[@iu]]].has_key?(index)
      end
      
      def get_icon_num(index)
        return LDT_UPGRADE_MENU::ICON_COST_IDS[index]
      end
      
      def get_cost_name(index)
        text = LDT_UPGRADE_MENU::COST_NAMES[index] #+ "("
        #text = text + get_resource(index).to_s + ")"
        return text
      end
      
      def get_resource(index)
        return $game_variables[LDT_UPGRADE_MENU::COST_VARS[index]]
      end
      
      def get_upgrade_cost_text(index)
        return get_resource(index).to_s + "/" + get_upgrade_cost(index).to_s
      end
      
      def get_upgrade_cost(index)
        LDT_UPGRADE_MENU::UPGRADE_COSTS[@iu][$game_variables[LDT_UPGRADE_MENU::UPGRADE_VARS[@iu]]][index]
      end
    end
    
    class LDT_Upgrade_Window < Window_Selectable
    
      def initialize(x, y, width, height)
        super(x,y,width,height)
        refresh
      end
      
      def item_max
        $upgrade_items ? $upgrade_items.size : 1
      end
    
      def item
        $upgrade_items && index >= 0 ? LDT_UPGRADE_MENU::UPGRADE_NAMES[$upgrade_items[index]] : nil
      end
      
      def refresh
        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(get_icon_num(index), rect.x, rect.y, current_item_enabled?(index))
          draw_text(rect.x + 26, rect.y, rect.width - 26, rect.height, get_upgrade_name(index))#, rect.x, rect.y)
          draw_text(rect,get_upgrade_lvl(index),2)
      end
      
      def get_upgrade_lvl(index)
        return $game_variables[LDT_UPGRADE_MENU::UPGRADE_VARS[up_index(index)]]
      end
      
      def up_index(index)
        return $upgrade_items[index]
      end
      
      def get_icon_num(index)
        return LDT_UPGRADE_MENU::ICON_IDS[up_index(index)]
      end
      
      def get_upgrade_name(index)
        return LDT_UPGRADE_MENU::UPGRADE_NAMES[up_index(index)]
      end
          
      def current_item_enabled?(tindex = index)
        return false if(tindex < 0)
        tc = get_costs(tindex)
        return false if(tc == LDT_UPGRADE_MENU::MAX_LEVEL_TEXT)
        tc.each do |tk,tv|
         return false if($game_variables[LDT_UPGRADE_MENU::COST_VARS[tk]] < tv)
        end
        return true
      end
      
      def get_costs(index)
        tcosts = LDT_UPGRADE_MENU::UPGRADE_COSTS[up_index(index)][$game_variables[LDT_UPGRADE_MENU::UPGRADE_VARS[up_index(index)]]]
        return tcosts ? tcosts : LDT_UPGRADE_MENU::MAX_LEVEL_TEXT
      end
    end
    
    class LDT_Upgrade_Window_Confirmation < Window_Selectable
       def initialize(x, y, width, height)
        super(x,y,width,height)
        @items = [LDT_UPGRADE_MENU::CONFIRM_TRUE,LDT_UPGRADE_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_UPGRADE_MENU::COST_VARS[index]]
      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
    
    class LDT_Upgrade_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)
      end
      
      def set_text(text)
        if text != @text
          @text = text
          refresh
        end
      end
    end

  11. #11
    Perfekt so, danke.

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •