RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Simple Word Processing

0 Members and 2 Guests are viewing this topic.

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
Simple Word Processing
Version: 1.0a
Author: cozziekuns
Date: June 20, 2011

Version History


  • <Version 1.0a> 2011.21.07 - Updated visibility (thanks Pacman).
  • <Version 1.0> 2011.20.07 - Original Release

Planned Future Versions

  • No limit on text.

Description


A simple word processer which lets the player create, store and open various pieces of text. Not really practical, as I did this more as a challenge than as a utility, but it could be useful for things like player journals, organizers and the like.

Features

  • Mostly plug and play.
  • Can store an infinite amount of "files".
  • Can allow the player to save, edit and open any piece of text.
  • Not much else to say, has less features than Notepad as of now.
  • CTRL Button to switch between Ribbon Window and Word Window.

Screenshots





Instructions

See Script.

Script

THIS SCRIPT REQUIRES WIJFLY'S KEYBOARD INPUT SCRIPT AND MODERN ALGEBRA'S PARAGRAPH FORMATTER.

WIJFLY'S KEYBOARD INPUT SCRIPT: http://pastebin.com/aRCVaGiT
MA'S PARAGRAPH FORMATTER: http://rmrk.net/index.php/topic,25129.0.html

SORRY ABOUT THE ALL CAPS, IT'S THAT IMPORTANT.


Code: [Select]
#
# THIS SCRIPT REQUIRES WIJFLY'S KEYBOARD INPUT SCRIPT AND MODERN ALGEBRA'S
# PARAGRAPH FORMATTER.
#
# WIJFLY'S KEYBOARD INPUT SCRIPT : http://pastebin.com/aRCVaGiT
# MA'S PARAGRAPH FORMATTER : http://rmrk.net/index.php/topic,25129.0.html
#
#===============================================================================
# Simple Word Processing
#-------------------------------------------------------------------------------
# Version: 1.0a
# Author: cozziekuns (rmrk)
# Last Date Updated: 7/16/2011
#===============================================================================
# Description:
#-------------------------------------------------------------------------------
# A simple word processer which lets the player create, store and open various
# pieces of text. Not really practical, as I did this more as a challenge than
# as a utility, but it could be useful for things like player journals,
# organizers and the like.
#===============================================================================
# Updates
# ------------------------------------------------------------------------------
# o 7/21/2011 - Small update with visibility (Thanks Pacman).
# o 7/20/2011 - Started Script.
#===============================================================================
# To-do List
#-------------------------------------------------------------------------------
# o Nothing. Post some ideas.
#===============================================================================
# Instructions
#-------------------------------------------------------------------------------
# Copy and paste this script above ? Main Process but below ? Materials, and
# edit the modules to your liking. Some difficult modules have links to the
# instructions. To call this scene, make a call script with the command $scene =
# Scene_WordProcess.new
#===============================================================================
# Return Scene
#-------------------------------------------------------------------------------
# For people unexperienced with RGSS2, a list of built in scenes:
#
# Scene_Map.new (Map Screen)
# Scene_Menu.new (Menu Screen)
# Scene_Item.new (Item Screen)
#===============================================================================

module COZZIEKUNS
  module SWP
    RETURN_SCENE = (Scene_Item.new) # See Line 37
    TITLE = "Journal" # Text you want to show in the Top Window
  end
end

#==============================================================================
# *** Paragrapher
#==============================================================================

module Paragrapher
  #============================================================================
  # ** Formatter_Coz
  #============================================================================
 
  class Formatter_Coz < Formatter
    #--------------------------------------------------------------------------
    # * Format
    #--------------------------------------------------------------------------
    def format (string, specifications)
      @string = string
      # Checks whether specifications is a bitmap or a number. It then sets
      # max_width and f.bitmap accordingly
      if specifications.is_a? (Bitmap)
        bitmap = specifications
        @max_width = specifications.width
      elsif specifications.is_a? (Numeric)
        @max_width = specifications
        bitmap = Bitmap.new (@max_width, 32)
      else
        # Error Catching: Incorrect Specifications
        f = format ('Specifications Error', Bitmap.new (200, 64))
        p 'Specifications Error: Please Pass Numeric or Bitmap'
        return f
      end
      # Initializes Formatted_Text object
      @format_text = Formatted_Text.new ([], [], bitmap)
      @line_break = 0
      @last_word = 0
      for i in 0...@string.size
        format_character (i)
      end
      fm_text = @string[@line_break, @string.size - @line_break]
      fm_text == nil ? fm_text = "" : fm_text = fm_text
      # Adds the last line to f.lines
      @format_text.lines.push ( fm_text.scan (/./) )
      # Since the last line is drawn normally, blank_width should be 0
      @format_text.blank_width.push (0)
      height = @format_text.lines.size * Window_Base::WLH
      @format_text.bitmap = Bitmap.new (@max_width, height) if specifications.is_a? (Numeric)
      # Returns the Formatted_Text object
      formatted_text = @format_text.dup
      @format_text = nil
      return formatted_text
    end
  end
end

#==============================================================================
# ** Game_System
#==============================================================================

class Game_System
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :journal_text
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias coz_wp_gs_initialize_73481 initialize
  def initialize
    coz_wp_gs_initialize_73481
    @journal_text = []
  end
end

#==============================================================================
# ** Window_TextType
#==============================================================================

class Window_TextType < Window_Base
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :text
  attr_accessor :cursor_position
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : window X coordinate
  #     y : window Y coordinate
  #--------------------------------------------------------------------------
  def initialize(x, y)
    super(x, y, 160, WLH + 32)
    @text = ""
    @cursor_position = 0
    @blink = false
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.draw_text(4, 0, 120, WLH, @text)
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update(allow_typing = true)
    happenings = false
    if (Graphics.frame_count % 30 == 0)
      @blink = !@blink
      @clear = true
      happenings = true
    end
    if Input.repeat?(Input::LEFT) and @cursor_position > 0
      @text.gsub!(/\¦/) {""}
      @blink = true
      @clear = true
      @cursor_position -= 1
      happenings = true
    elsif Input.repeat?(Input::RIGHT)
      happenings = true
      if @blink
        if @cursor_position < @text.size - "¦".size
          @text.gsub!(/\¦/) {""}
          @blink = true
          @clear = true
          @cursor_position += 1
        end
      else
        if @cursor_position < @text.size
          @text.gsub!(/\¦/) {""}
          @blink = true
          @clear = true
          @cursor_position += 1
        end
      end
    elsif Input.typing? and allow_typing
      if self.contents.text_size(@text).width > 100
        Sound.play_buzzer
        return
      end
      happenings = true
      @blink = false
      @clear = true
      @text.insert(@cursor_position, Input.key_type)
      @cursor_position += 1
    elsif Input.repeat?(Input::BACK) and @cursor_position > 0
      happenings = true
      @blink = true
      @clear = true
      @text.gsub!(/\¦/) {""}
      @text[@cursor_position - 1] = ""
      @cursor_position -= 1
    end
    if @clear
      @blink ? @text.insert(@cursor_position, "¦") : @text.gsub!(/\¦/) {""}
      @clear = false
      happenings = true
    end
    refresh if happenings
  end
end

#==============================================================================
# ** Window_Word
#==============================================================================

class Window_Word < Window_Base
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :text
  attr_accessor :cursor_position
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : window X coordinate
  #     y : window Y coordinate
  #--------------------------------------------------------------------------
  def initialize
    super(160, 56, 384, 360)
    @text = ""
    @cursor_position = 0
    @blink = false
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.paragraph_formatter = Paragrapher::Formatter_Coz
    self.contents.draw_paragraph(4, 0, 344, 376, @text)
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update(allow_typing = true)
    happenings = false
    if (Graphics.frame_count % 30 == 0)
      @blink = !@blink
      @clear = true
      happenings = true
    end
    if Input.repeat?(Input::LEFT) and @cursor_position > 0
      @text.gsub!(/\¦/) {""}
      @blink = true
      @clear = true
      @cursor_position -= 1
      happenings = true
    elsif Input.repeat?(Input::RIGHT)
      happenings = true
      if @blink
        if @cursor_position < @text.size - "¦".size and @text[@cursor_position + 1] != nil
          @text.gsub!(/\¦/) {""}
          @blink = true
          @clear = true
          @cursor_position += 1
        end
      else
        if @cursor_position < @text.size and @text[@cursor_position + 1] != nil
          @text.gsub!(/\¦/) {""}
          @blink = true
          @clear = true
          @cursor_position += 1
        end
      end
    elsif Input.typing? and allow_typing
      if dupe
        Sound.play_buzzer
      else
        happenings = true
        @blink = false
        @clear = true
        @text.insert(@cursor_position, Input.key_type)
        @cursor_position += 1
      end
    elsif Input.repeat?(Input::BACK) and @cursor_position > 0
      happenings = true
      @blink = true
      @clear = true
      @text.gsub!(/\¦/) {""}
      @text[@cursor_position - 1] = ""
      @cursor_position -= 1
    elsif Input.repeat?(Input::ENTER) and allow_typing
      if dupe
        Sound.play_buzzer
      else
        happenings = true
        @text.insert(@cursor_position, "\n")
        @cursor_position += 1
      end
    end
    if @clear
      (@blink ? @text.insert(@cursor_position, "¦") : @text.gsub!(/\¦/) {""}) rescue @cursor_position -= 1
      @clear = false
      happenings = true
    end
    refresh if happenings
  end
  #-------------------------------------------------------------------------
  # * Dupe
  #-------------------------------------------------------------------------
  def dupe
    dup_text = @text.dup
    dup_text.gsub!(/\n/m) {"oooooooooooooooooooooooooooooooooo"}
    dup_text.gsub!(/\¦/) {""}
    return self.contents.text_size(dup_text).width > 4008
  end
end

#==============================================================================
# ** Scene_WordProcess
#==============================================================================

class Scene_WordProcess < Scene_Base
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    super
    @sloppy_timer = 0
    create_menu_background
    create_ribbon_window
    @word_window = Window_Word.new
    @help_window = Window_Help.new
    @help_window.set_text(COZZIEKUNS::SWP::TITLE, 1)
    @typing_window = Window_TextType.new(192, 180)
    @typing_window.visible = false
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_menu_background
    @ribbon_window.dispose
    @word_window.dispose
    @help_window.dispose
    @typing_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Create Ribbon Window
  #--------------------------------------------------------------------------
  def create_ribbon_window
    @ribbon_window = Window_Command.new(160, ["New", "Save", "Open", "Quit"])
    @ribbon_window.height = 360
    @ribbon_window.y = 56
  end
  #--------------------------------------------------------------------------
  # * Create Open Window
  #--------------------------------------------------------------------------
  def create_open_window
    commands = []
    for entry in $game_system.journal_text
      commands.push(entry[0])
    end
    @open_window = Window_Command.new(160, commands)
    @open_window.height = 360
    @open_window.y = 56
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    if @sloppy_timer > 0
      @sloppy_timer -= 1
      sloppy = false
    else
      sloppy = true
    end
    update_menu_background
    openwin = (@open_window != nil and !@open_window.disposed?)
    @word_window.update unless @ribbon_window.active or openwin or @typing_window.visible
    @ribbon_window.update
    @ribbon_index = @ribbon_window.index
    @open_window.update if openwin
    @typing_window.update if @typing_window.visible
    if Input.trigger?(Input::CTRL) and not openwin and not @typing_window.visible
      Sound.play_cursor
      @ribbon_window.active = !@ribbon_window.active
    end
    if @ribbon_window.active and Input.trigger?(Input::C)
      case @ribbon_window.index
      when 0
        Sound.play_decision
        @word_window.text = ""
        @word_window.cursor_position = 0
        @word_window.update(false)
        @ribbon_window.active = false
      when 1
        Sound.play_decision
        @ribbon_window.active = false
        @typing_window.text = ""
        @typing_window.cursor_position = 0
        @typing_window.visible = true
        @typing_window.update(false)
        sloppy = false
        @sloppy_timer = 5
      when 2
        if $game_system.journal_text.empty?
          Sound.play_buzzer
        else
          Sound.play_decision
          @ribbon_window.active = false
          create_open_window
        end
      when 3
        Sound.play_decision
        $scene = COZZIEKUNS::SWP::RETURN_SCENE
      end
    elsif @typing_window.visible and sloppy
      if Input.trigger?(Input::ENTER)
        text = @typing_window.text.gsub(/\¦/) {""}
        words = @word_window.text.gsub(/\¦/) {""}
        value = false
        Sound.play_decision
        for data in $game_system.journal_text
          if text == data[0]
            data = [text, words]
            value = true
            break
          end
        end
        $game_system.journal_text.push([text, words]) unless value
        @ribbon_window.active = true
        @typing_window.visible = false
      end
    elsif openwin
      @ribbon_window.visible = false
      if Input.trigger?(Input::C)
        Sound.play_decision
        @ribbon_window.visible = true
        @word_window.text = ""
        @word_window.text = $game_system.journal_text[@open_window.index][1]
        @word_window.cursor_position = 0
        @word_window.update(false)
        @open_window.dispose
      elsif Input.trigger?(Input::B)
        Sound.play_cancel
        @ribbon_window.visible = true
        @ribbon_window.active = true
        @open_window.dispose
      end
    end
    @help_window.update
    super
  end
end

Credit


  • cozziekuns
  • WijFly (OriginalWij and Yanfly) for their Keyboard Input Script.
  • Modern Algebra and Zeriab, for their PF2 base code.

Thanks

  • WijFly (OriginalWij and Yanfly), for their Keyboard Input script and being amazing scripters in their own right.
  • Modern Algebra, for making an easy to edit Paragraph Formatter and generally being an awesome guy.
  • Zeriab, for helping Modern Algebra with his Paragraph Formatter and his Guide to REGEXP in RGSS.
  • Pacman, for pointing out a visibility issue.

Support


Just post down below.

Known Compatibility Issues

None as of yet.

Author's Notes


I really doubt that this script is very practical, but I'm posting it anyways. Who knows?
« Last Edit: August 30, 2011, 10:28:06 PM by cozziekuns »

*
Rep:
Level 82
GIAW 14: 1st Place (Easy Mode)2013 Most Promising Project2013 Best RPG Maker User (Programming)2013 Project of the YearParticipant - GIAW 11Bronze - GIAW 10

UPDATED 05-29-14


IS YOUR PROJECT OPTIMIZED?
UPDATED 07/04/15 - v2.5

RPG MAKER TOOLBOX
UPDATED 07/04/15 - v1.5

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Most Missed Member2014 Zero to Hero2014 Best IRC Quote2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
Code: [Select]
dup_text.gsub!(/\n/m) {"oooooooooooooooooooooooooooooooooo"}
... why?
So, this is why you wrote that thing for the formatter. Righto.
You should change @ribbon_window.visible to false when you open the @open_window. It looks kinda weird. Maybe even change the opacity to 100 or something. Yeah.
it's like a metaphor or something i don't know

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
Thanks for the comments, guys.

@Pacman: The dup_text is a terrible piece of code that I wrote because I have no idea how to gauge line breaks with the PF2, and got a bit lazy. "ooooo..."
is the width of a regular line break, so issues will pop up if you do something like:

 a
 a
 a
 a

Your text will be limited rather quickly (7-8 lines) compared to what the actual limit should be (10-11 lines). But overall it shouldn't be too bad. If anyone knows how to make this code better, feel free to chip in. Some of the parts are a very sloppy and a little embarassing.

*
Rep: +0/-0Level 66
RMRK Junior
I'm not sure if this is easily fixable or something, but a message box with a 0 in it keeps popping up every second when I have the wordbox openned. It also pops up when I call the script

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
Even though I don't think that it should have done anything, I took out all the debugging stuff. Check if it works now.

*
Rep: +0/-0Level 66
RMRK Junior
thanks, is works now

***
Rep:
Level 74
I'm baaack!
Thank you! This is a perfect way for people to memorize important things if they think they might not be playing a game for a while. I'm using it.

***
Rep:
Level 75
Yeah all the time in games I have played have I wish I had this so I did not have to get a pen a paper out everytime i need to remember a password or something.

Spoiler for:



Spoiler for:
John 3:16: For God loved the world so much that he gave his one and only Son, so that everyone who believes in him will not perish but have eternal life