Skip to content

Commit

Permalink
Fixes broken help texts
Browse files Browse the repository at this point in the history
- Made sure we're extracting platform specific text properly
- Re-imported bitmap icons that are higher res and includes VR icons
  • Loading branch information
Odie committed Oct 8, 2018
1 parent 55cffbc commit bc68ee5
Show file tree
Hide file tree
Showing 3 changed files with 174 additions and 113 deletions.
56 changes: 56 additions & 0 deletions misc/rename-png
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#! env ruby

def toWinPath(wslPath)
cmd = "wslpath -w '#{wslPath}'"
return `#{cmd}`.strip
end

# This is a one-off utility to rename png files in a directory.
# We're exporting icon pngs from the VR version of the game
# to use in the help text.
#
# Ideally, we would export all the known button art as png
# and import them again. I'm being lazy and skipping that for now.

require('optparse')
require('pathname')
require('fileutils')

options = {}
optParser = OptionParser.new do |opts|
opts.banner = "Usage: decompile-pex [options] target_dir"

# opts.on("-w", "--watch", "Watch built directory") do
# options[:watch] = true
# end

opts.on_tail("-h", "--help", "Show this message") do
puts opts
exit
end
end

optParser.parse!

targetDir = ARGV.pop
if not targetDir then
puts optParser
exit
end

targetDirPath = Pathname.new(targetDir)
if !targetDirPath.exist? or !targetDirPath.directory? then
puts "Cannot locate target directory: " + targetDirPath;
exit 1
end

def transformName(oldName)
oldName = oldName.to_s
firstUnderscore = oldName.to_s.index('_')
return oldName.slice(firstUnderscore+1, oldName.length - 4 - firstUnderscore - 1)
end

Pathname.glob(targetDirPath + "*.png.png").each do |f|
puts "#{f} => #{targetDirPath + transformName(f)}"
f.rename(targetDirPath + transformName(f))
end
231 changes: 118 additions & 113 deletions src/Common/Shared/ExtractPlatformText.as
Original file line number Diff line number Diff line change
@@ -1,117 +1,122 @@
class Shared.ExtractPlatformText
{
function ExtractPlatformText()
{
}
static function IsWhitespace(str)
{
return str == " " || str == "\n" || str == "\r";
}
static function Trim(str)
{
var i = undefined;
var j = undefined;
i = 0;
j = str.length - 1;
while(i < str.length)
{
if(Shared.ExtractPlatformText.IsWhitespace(str.charAt(i) == false))
{
break;
}
i++;
}
j = str.length - 1;
while(j >= 0)
{
if(Shared.ExtractPlatformText.IsWhitespace(str.charAt(j)) == false)
{
break;
}
j--;
}
return str.substr(i, j - i + 1);
}
function ExtractPlatformText()
{
}
static function IsWhitespace(str)
{
return str == " " || str == "\n" || str == "\r";
}
static function Trim(str)
{
var i = 0; // Start at the beginning of the string
var j = str.length - 1; // Start at the end of the string
while(i < str.length)
{
if(Shared.ExtractPlatformText.IsWhitespace(str.charAt(i)) == false)
{
break;
}
i++;
}
j = str.length - 1;
while(j >= 0)
{
if(Shared.ExtractPlatformText.IsWhitespace(str.charAt(j)) == false)
{
break;
}
j--;
}
return str.substr(i, j - i + 1);
}

// This looks to be processing a long string that looks like:
// <<PlatformName <<string>>>> <<PlatformName <<string>>>>
// The function takes this string and returns string text associated with 'aiPlatform'
static function Extract(asText, aiPlatform)
{
if(asText.indexOf("<<") < 0)
{
return asText;
}
var platformName = undefined;
switch(aiPlatform)
{
case Shared.Platforms.CONTROLLER_PCGAMEPAD:
platformName = "PCGAMEPAD";
break;
case Shared.Platforms.CONTROLLER_VIVE:
platformName = "VIVE";
break;
case Shared.Platforms.CONTROLLER_OCULUS:
platformName = "OCULUS";
break;
case Shared.Platforms.CONTROLLER_WINDOWS_MR:
platformName = "WINDOWS_MR";
break;
case Shared.Platforms.CONTROLLER_ORBIS_MOVE:
platformName = "ORBIS_MOVE";
break;
case Shared.Platforms.CONTROLLER_ORBIS:
platformName = "ORBIS";
break;
default:
return asText;
}
var remainingText = asText;
while(remainingText.length > 0)
{
var startMarker = remainingText.indexOf("<<");
var endMarker = remainingText.indexOf(">>");
if(startMarker >= 0 && endMarker >= 0)
{
var enclosedText = remainingText.substr(startMarker + 2,endMarker - startMarker - 2);
remainingText = remainingText.substr(endMarker + 2);
if(enclosedText == platformName)
{
var keepProcessing = true;
while(keepProcessing)
{
var nextStartMarker = remainingText.indexOf("<<");
if(nextStartMarker < 0)
{
break;
}
var i = 0;
while(i < nextStartMarker)
{
if(Shared.ExtractPlatformText.IsWhitespace(remainingText.charAt(i)) == false)
{
keepProcessing = false;
break;
}
i++;
}
if(keepProcessing)
{
var nextEndMarker = remainingText.indexOf(">>");
remainingText = remainingText.substr(nextEndMarker + 2);
}
}
return Shared.ExtractPlatformText.Trim(remainingText);
}
endMarker = remainingText.indexOf("<<");
if(endMarker < 0)
{
return asText;
}
remainingText = remainingText.substr(endMarker);
continue;
}
return asText;
}
}
// This looks to be processing a long string that looks like:
// <<PlatformName <<string>>>> <<PlatformName <<string>>>>
// The function takes this string and returns string text associated with 'aiPlatform'
static function Extract(asText, aiPlatform)
{
// If there are no platform markers, all platforms will share the same text
if(asText.indexOf("<<") < 0)
{
return asText;
}

// Determine the name of the platform we're looking for
var platformName = undefined;
switch(aiPlatform)
{
case Shared.Platforms.CONTROLLER_PCGAMEPAD:
platformName = "PCGAMEPAD";
break;
case Shared.Platforms.CONTROLLER_VIVE:
platformName = "VIVE";
break;
case Shared.Platforms.CONTROLLER_OCULUS:
platformName = "OCULUS";
break;
case Shared.Platforms.CONTROLLER_WINDOWS_MR:
platformName = "WINDOWS_MR";
break;
case Shared.Platforms.CONTROLLER_ORBIS_MOVE:
platformName = "ORBIS_MOVE";
break;
case Shared.Platforms.CONTROLLER_ORBIS:
platformName = "ORBIS";
break;
default:
return asText;
}

// Attempt to extract the text marked by the platformName
var remainingText = asText;
while(remainingText.length > 0)
{
// Look for the next platform marker
var startMarker = remainingText.indexOf("<<");
var endMarker = remainingText.indexOf(">>");

// If ther are no platform markers, then we use the text for all platforms
if(startMarker < 0 || endMarker < 0) {
return remainingText;
}

// We located a platform marker...
// What is the name of the platform we've located?
var enclosedText = remainingText.substr(startMarker + 2,endMarker - startMarker - 2);
remainingText = remainingText.substr(endMarker + 2);

// Did we find the platform we're looking for?
if(enclosedText == platformName)
{
var text = "";

// Grab all the text up to the next platform marker
var nextStartMarker = remainingText.indexOf("<<");

if(nextStartMarker < 0)
text = remainingText;
else
text = remainingText.substr(0, nextStartMarker);

return Shared.ExtractPlatformText.Trim(text);
}

// We didn't find the platform we're looking for...
// Does it look like there is another platform marker?
// If not, whatever remaining text will be used as the text.
// This means the very last piece of text is the default text
var nextStartMarker = remainingText.indexOf("<<");
if(nextStartMarker < 0)
{
return remainingText;
}

// There is more platform text left...
// Prep for the next iteration by moving to the beginning of the next
// platform marker
remainingText = remainingText.substr(nextStartMarker);
continue;
}
}
}
Binary file modified src/PauseMenu/quest_journal.fla
Binary file not shown.

0 comments on commit bc68ee5

Please sign in to comment.