UserPath for Linux OS
#1
UserPath for Linux OS

UPFLOS Version 0.3.1

Add-On by Kyonides Arkanthes

Based on DerVVulfman's Commercial System Script Pack


Introduction

This scriptlet allows you to ignore a few errors that might show up if you try to run a gamethat includes DerVVulfman's Commercial System script pack on any Linux distro. Most of them are caused by any call to the Win32API that does not exist in other OS's like Linux. Besides they use different symbols as separators for path names. Now that should not be a problem anymore!

First Step

Ignore this step if using Commercial System version 1.2 or later.

Copy and paste this snippet in a section before the Commercial System scripts. This will let the system ignore all calls to the non existing Win32API on Linux distros.

Code:
# * Void Win32API

# Use this scriptlet if you want to let Linux users run your games.
# It will ignore all script calls meant to be executed on any Windows OS.

class Win32API
 def initialize(*args) end
 def call(*args) end
end

Second Step

Mandatory Step!

Now just follow the instructions included in the scriptlet to let it run on your favorite Linux OS.

NOTE If you're using HiddenChest, you can also set the starting values for fullscreen and F12 options.

XP Script

Code:
# * UserPath For Linux OS ** UPFLOS **
#   Scripter : Kyonides Arkanthes
#   v. 0.3.1 - 2019-11-17

# On a Linux distro it is a common thing to find a game's save files in the
# $HOME directory aka /home/username plus a custom directory where the game
# developer usually hide it. This preserves encapsulation and prevents you from
# invoking the sudo command and entering the corresponding password just to
# create or save any given data.

# Paste this scriptlet in any section below DerVVulfman's UserPath script and
# above the Main script.

# Input Fix for both MKXP and HiddenChest - disables Wulfo's code blocking it.

module ThisOS
  IS_LINUX = OS_Detect.version == 3
end

if $HIDDENCHEST
  Graphics.block_fullscreen = false # Blocks Alt+Enter?
  Graphics.block_f12 = true # Blocks F12 aka Game Reset?
  Graphics.block_f1 = true # Blocks F1 aka Input Menu?
end

module UserPath
  SEPARATOR = ThisOS::IS_LINUX ? '/' : ' \\' # Do Not Touch This!
  HIDE_DIR = true # Hide Save Games Directory?
  def self.save_filename(save_index)
    return "Save#{save_index + 1}.rxdata" if @path == nil
    @path + SEPARATOR + "Save#{save_index + 1}.rxdata"
  end

  def self.join_file(fn) @path + SEPARATOR + fn end

  def self.on_linux
    @path = ENV['HOME'] + '/'
    @path += '.' if HIDE_DIR # If hiding directory add a dot
    @path += ProSettings::GAME_FOLDER_NAME
    Dir.mkdir(@path) unless Dir.exists?(@path)
    p @path if ProSettings::DEBUG_FOLDER_NAME
  end
  on_linux if ThisOS::IS_LINUX
end

module MessageIntercept
  Flag_Deactivate = [1] if ThisOS::IS_LINUX
end

# Redefining Path for Saved Files
class Scene_File
  def make_filename(file_index) UserPath.save_filename(file_index + 1) end
end

class Scene_Map
  def update_title_window
    # Continue enabled determinant
    # Check if at least one save file exists
    # If enabled, make @continue_enabled true; if disabled, make it false
    @continue_enabled = false
    for i in 0..3
      @continue_enabled = FileTest.exist?(UserPath.save_filename(i+1))
      break if @continue_enabled
    end
    # Make command window
    count = ProSettings::OPTIONS.size
    window_array = []
    for i in 0...count
      window_array.push(ProSettings::OPTIONS[i][0])
    end
    @command_window = Window_Command.new(192, window_array)
    # Choose between Image or Text options
    show_img = ProSettings::IMAGE_ENABLED
    show_img ? update_title_window_image : update_title_window_text
    # Make title options window active
    @command_window.z       = 1000
    @command_window.active  = true
    # Hide Command Window if Chose to Display Images Instead
    @command_window.visible = !show_img
    # If continue is enabled, move cursor to "Continue"
    # If disabled, display "Continue" text in gray
    if @continue_enabled
      @command_window.index = 1
    else
      ProSettings::NOSAVE_DISABLE.each{|i| @command_window.disable_item(i) }
    end
  end
end

# Modifying DerVVulfman's Scene
class Scene_VVulfSplash
  def main
    load_config
    # IF F12 not been pressed, check config
    unless $f12_jump
      # Added for config start
      if $HIDDENCHEST or $MKXP
        Graphics.fullscreen = $data_config.fullscreen
      else
        button_combo = "System/F1AltEnterF12"
        if $data_config.fullscreen
          kb = ProSettings::DISABLE_F1
          kb = 1 if $DEBUG != true
          Win32API.new(button_combo, "hook", "III", "").call(kb,1,0)
          $showm = Win32API.new 'user32', 'keybd_event', %w(l l l l), ''
          $showm.call(18,0,0,0)
          $showm.call(13,0,0,0)
          $showm.call(13,0,2,0)
          $showm.call(18,0,2,0)
          Graphics.update
          kb = ProSettings::DISABLE_F1
          kb = 1 if $DEBUG != true
          Win32API.new(button_combo, "hook", "III", "").call(kb,1,1)
        else
          kb = ProSettings::DISABLE_F1
          kb = 1 if $DEBUG != true
          Win32API.new(button_combo, "hook", "III", "").call(kb,1,1)
        end
      end
    end
    if $DEBUG && ProSettings::PLAYTEST == false    # If Debug and Playtest off
      $scene = Scene_Title.new                     # Go to Title Screen
    end
    Audio.me_stop                                  # Stop playing ME
    Audio.bgs_stop                                 # Stop playing BGS
    main_variables                                 # Instance Variables
    if $data_config.fullscreen                     # If Fullscreen, add delay
      # Delay for fullscreen trans. Update game screen
      80.times{ Graphics.update }
    end
    Graphics.transition                            # Execute transition
    loop do                                        # Main loop
      Graphics.update                              # Update game screen
      Input.update                                 # Update input information
      update                                       # Frame update
      break if $scene != self                      # Abort loop if changed
    end
    Graphics.freeze                                # Prepare for transition
    @splash.dispose                                # Dispose of Sprites
  end

  def load_config
    # Establish default config values
    $data_config.bgm_volume = ProSettings::MUSIC
    $data_config.se_volume  = ProSettings::SOUND
    $data_config.fullscreen = ProSettings::FULLSCREEN
    # Create config filename for test
    path = ProSettings::SCS_FILE
    path = UserPath.join_file(path) if UserPath.folder
    # Load Config if config file exists # MKXP and HiddenChest Modification
    if FileTest.exist?(path)
      $data_config = File.open(path, "rb"){|f| Marshal.load(f) }
    else
      # Write config data
      File.open(path, "wb"){|f| Marshal.dump($data_config, f) }
    end
  end
end

module SCS_Options
  def command_toggle_fullscreen
    # Disable Fullscreen feature or call HiddenChest's method
    Graphics.fullscreen = !Graphics.fullscreen if $HIDDENCHEST
    return jump2index2 if $HIDDENCHEST or $MKXP or ThisOS::IS_LINUX
    kb = ProSettings::DISABLE_F1
    kb = 1 if $DEBUG != true
    Win32API.new("System/F1AltEnterF12", "hook", "III", "").call(kb,1,0)
    $showm = Win32API.new 'user32', 'keybd_event', %w(l l l l), ''
    $showm.call(18,0,0,0)
    $showm.call(13,0,0,0)
    $showm.call(13,0,2,0)
    $showm.call(18,0,2,0)
    Graphics.update
    kb = ProSettings::DISABLE_F1
    kb = 1 if $DEBUG != true
    Win32API.new("System/F1AltEnterF12", "hook", "III", "").call(kb,1,1)
    # Set the fullscreen flag in the config data
    jump2index2
  end

  def jump2index2
    $data_config.fullscreen = !$data_config.fullscreen
    call_options_window
    @options_window.index = 2
  end
end

Terms & Conditions

They are the same as in the Commercial System script pack.
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }


Messages In This Thread
UserPath for Linux OS - by kyonides - 11-16-2019, 01:45 AM
RE: UserPath for Linux OS - by kyonides - 11-16-2019, 03:51 AM
RE: UserPath for Linux OS - by kyonides - 11-17-2019, 11:06 PM



Users browsing this thread: 1 Guest(s)