Ergebnis 1 bis 17 von 17

Thema: [RMXP] Kann ich die Macken des Makers bei Animation und Textbox beheben?

Baum-Darstellung

Vorheriger Beitrag Vorheriger Beitrag   Nächster Beitrag Nächster Beitrag
  1. #14
    Hier noch eine kleine Anpassung (mit dem Befehl #nl kann man einen Zeilenumbruch erzwingen)

    Code:
    class Interpreter
    
      # call command_108 method if comment command is used
      alias org_execute_command execute_command
      def execute_command
        if(@index < @list.size)
          if(@list[@index].code == 108) #comment command
            return command_108
          else
            return org_execute_command
          end
        else
          command_end
          return true
        end
      end
      
      def command_108
        mls = 448 # max textsize per line
        text = @list[@index].parameters[0] # first line of the comment command
        
        #for every addtional command line (code = 408) // max. 5 additional lines
        for i in 1..5
          if(@list[@index+i].code == 408)
            text += @list[@index+i].parameters[0]
          else
            break
          end
        end
        
        #after extracting texts, delete old comment lines from event command list
        for i in 0..4
          if(@list[@index+5-i].code == 408)
            @list.delete_at(@index+5-i)
          else
            break
          end
        end
        
        tmsgbx = Bitmap.new(1,1)
        
        # multiple lines needed?
        if(tmsgbx.text_size(text).width>mls)
          iLength = 0
          textarray = [""]
          ## create Substrings
          substrings = text.scan(/\S+|\s+/)
          ## check if line size limit is reached and switch to next line
          substrings.each do |ttext|
            if(ttext == "#nl")
              iLength = iLength + 1
              textarray << ""
              next
            end
            
            subsize = tmsgbx.text_size(ttext).width
            linesize = tmsgbx.text_size(textarray[iLength]).width
            if(( subsize + linesize) > mls)
              iLength = iLength + 1
            end
            
            if(textarray[iLength]!=nil)
              textarray[iLength]= textarray[iLength]+ttext
            else
              ttext.slice!(/\s*/)
              textarray[iLength]= ttext
            end
          end
          ## insert every line as command list element
          added = 1
          textarray.each_with_index do |msgtext,indx|
            if(indx == 0)
              @parameters = msgtext
              @list[@index].code = 101
              @list[@index].parameters[0] = msgtext
            else
              @list.insert(@index+added, RPG::EventCommand.new()) 
              @list[@index+added].parameters[0] = msgtext
              @list[@index+added].code = (indx % 4) == 0 ? 101 : 401
              added += 1
            end
          end
          command_101
        else
        ## one-liner
          command_101
        end    
      end
    end

    Geändert von Linkey (22.07.2014 um 06:18 Uhr) Grund: Testbefehl "p(substrings)" aus dem Skript entfernt.

Berechtigungen

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