diff --git a/misc/cp-built-files b/misc/cp-built-files new file mode 100644 index 00000000..52e6436f --- /dev/null +++ b/misc/cp-built-files @@ -0,0 +1,157 @@ +#! env ruby + +# This utility copys the newly built files in ../build to the +# `destination_dir`. It's also possible to watch the directory +# so built files are copied automatically. +# +# This was written for ruby 2.5 and requires WSL and the 'listen' +# gem for the directory watching capability. + +require('optparse') +require('pathname') +require('fileutils') + +options = {} +optParser = OptionParser.new do |opts| + opts.banner = "Usage: cpBuiltFiles [options] destination_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! + +destDir = ARGV.pop +if not destDir then + puts optParser + exit +end + +# This is where we'll be trying to copy files from +srcDirPath = Pathname.new(__FILE__).parent + "../build" + +# This is where we'll be trying to copy files to +destDirPath = Pathname.new(destDir) + +puts("Checking: #{destDir}\n\n") +filesCopied = 0 + +# For each file in the destination directory... +Pathname.glob("#{destDir}/**/*").each do |destPath| + + # For all files (not a directory)... + next if destPath.directory? + + srcPath = srcDirPath + destPath.relative_path_from(destDirPath) + + # If the a matching file from the build (src) directory exists, and it appears + # to be newer... + # This should mean that the file was newly built. + if srcPath.exist? && srcPath.mtime() > destPath.mtime() then + + # Copy the file over to the destination + puts("#{srcPath} => #{destPath}") + FileUtils::copy_file(srcPath.realpath, destPath.realpath) + filesCopied = filesCopied + 1 + + end +end + +if filesCopied != 0 then + puts +end +puts("#{filesCopied} files copied") + + +def getDestPath(srcBaseDirPath, srcFilePath, destBaseDirPath) + return destBaseDirPath + srcFilePath.relative_path_from(srcBaseDirPath) +end + +if options[:watch] then + require('listen') + require('thread') + + def waitFileStopsGrowing(filename) + oldSize = 0 + newSize = File.size(filename) + while oldSize != newSize do + oldSize = newSize + sleep(1) + newSize = File.size(filename) + end + end + + puts("Watching #{srcDirPath} for changes...") + + # Create a set that records which files we're waiting for to finish writing + semaphore = Mutex.new + filesBeingWritten = Set.new + + # Wait for a file to finish being written then copy it to the destination + copierThread = Thread.new do + while true do + + # Wait until we found a file that has been modified + sleep(0.25) + files = filesBeingWritten.to_a + if files.length == 0 then + next + end + + # Wait for the file to stop growing + modifiedFile = files[0] + modifiedPath = Pathname.new(modifiedFile) + waitFileStopsGrowing(modifiedPath) + + # Copy the file + srcPath = modifiedPath + destPath = getDestPath(srcDirPath.realpath, srcPath, destDirPath) + time = Time.new + + while true do + begin + puts("[#{time.strftime("%H:%M")}] #{srcPath} => #{destPath}") + FileUtils::copy_file(srcPath, destPath) + break + rescue + puts("File wasn't ready. Retrying.") + sleep(1) + next + end + end + + # Make sure we stop waiting for the file the next iteration + semaphore.synchronize do + filesBeingWritten.delete(modifiedFile) + end + end + end + + listenThread = Thread.new do + listener = Listen.to(srcDirPath) do |modified, added, removed| + if modified then + semaphore.synchronize do + modified.each do |f| + filesBeingWritten.add(f) + end + end + end + end + listener.start + sleep + end + + # notifier = INotify::Notifier.new + # notifier.watch(srcDirPath.to_s, :close) do |event| + # # The #name field of the event object contains the name of the affected file + # puts "#{event.name} modified" + # end + # notifier.run + sleep +end diff --git a/src/.gitignore b/src/.gitignore index 824613c1..bd0b9851 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1,3 +1,2 @@ - .flashProjectProperties -/Common/mx/transitions/Tween.as +.snippets diff --git a/src/Common/mx/transitions/Tween.as b/src/Common/mx/transitions/Tween.as new file mode 100644 index 00000000..ddf13073 --- /dev/null +++ b/src/Common/mx/transitions/Tween.as @@ -0,0 +1,252 @@ +class mx.transitions.Tween +{ + var obj; + var prop; + var begin; + var useSeconds; + var _time; + var prevTime; + var looping; + var _duration; + var _fps; + var isPlaying; + var prevPos; + var _pos; + var change; + var _intervalID; + var _startTime; + + public var onMotionStarted; + public var onMotionFinished; + public var onMotionStopped; + public var onMotionLooped; + public var onMotionChanged; + public var onMotionResumed; + + function Tween(obj, prop, func, begin, finish, duration, useSeconds) + { + if(!arguments.length) + { + return; + } + this.obj = obj; + this.prop = prop; + this.begin = begin; + this.position = begin; + this.duration = duration; + this.useSeconds = useSeconds; + if(func) + { + this.func = func; + } + this.finish = finish; + this.FPS = 30; + start(); + } + function set time(t) + { + prevTime = _time; + if(t > this.duration) + { + if(looping) + { + this.rewind(t - this._duration); + this.update(); + if(this.onMotionLooped) + { + this.onMotionLooped(); + } + } + else + { + if(this.useSeconds) + { + this._time = this._duration; + this.update(); + } + this.stop(); + if(this.onMotionFinished) + { + this.onMotionFinished(); + } + } + } + else if(t < 0) + { + this.rewind(); + this.update(); + } + else + { + this._time = t; + this.update(); + } + //return this.time; + } + function get time() + { + return _time; + } + function set duration(d) + { + _duration = !(d == null || d <= 0)?d:_global.Infinity; + //return this.duration; + } + function get duration() + { + return _duration; + } + function set FPS(fps) + { + var _loc2_ = this.isPlaying; + this.stopEnterFrame(); + this._fps = fps; + if(_loc2_) + { + this.startEnterFrame(); + } + //return this.__get__FPS(); + } + function __get__FPS() + { + return this._fps; + } + function set position(p) + { + this.setPosition(p); + //return this.__get__position(); + } + function setPosition(p) + { + this.prevPos = this._pos; + this.obj[this.prop] = this._pos = p; + if(this.onMotionChanged) + { + this.onMotionChanged(this._pos); + } + updateAfterEvent(); + } + function get position() + { + return this.getPosition(); + } + function getPosition(t) + { + if(t == undefined) + { + t = this._time; + } + return this.func(t,this.begin,this.change,this._duration); + } + function set finish(f) + { + this.change = f - this.begin; + //return this.finish; + } + function get finish() + { + return this.begin + this.change; + } + function continueTo(finish, duration) + { + this.begin = this.position; + this.finish = finish; + if(duration != undefined) + { + this.duration = duration; + } + this.start(); + } + function yoyo() + { + this.continueTo(this.begin,this.time); + } + function startEnterFrame() + { + this._intervalID = setInterval(this,"onEnterFrame",1000 / this._fps); + this.isPlaying = true; + } + function stopEnterFrame() + { + clearInterval(this._intervalID); + this.isPlaying = false; + } + function start() + { + this.rewind(); + this.startEnterFrame(); + if(this.onMotionStarted) + { + this.onMotionStarted(); + } + } + function stop() + { + this.stopEnterFrame(); + if(this.onMotionStopped) + { + this.onMotionStopped(); + } + } + function resume() + { + this.fixTime(); + this.startEnterFrame(); + if(this.onMotionResumed) + { + this.onMotionResumed(); + } + } + function rewind(t) + { + this._time = t != undefined?t:0; + this.fixTime(); + this.update(); + } + function fforward() + { + this.time = _duration; + this.fixTime(); + } + function nextFrame() + { + if(this.useSeconds) + { + this.time = (getTimer() - this._startTime) / 1000; + } + else + { + this.time = this._time + 1; + } + } + function onEnterFrame() + { + this.nextFrame(); + } + function prevFrame() + { + if(!this.useSeconds) + { + this.time = this._time - 1; + } + } + function toString() + { + return "[Tween]"; + } + function fixTime() + { + if(this.useSeconds) + { + this._startTime = getTimer() - this._time * 1000; + } + } + function update() + { + this.position = getPosition(this._time); + } + function func(t, b, c, d) + { + return c * t / d + b; + } +} diff --git a/src/CraftingMenu/CraftingMenu.as b/src/CraftingMenu/CraftingMenu.as index 2c2b99a5..74d3d9ab 100644 --- a/src/CraftingMenu/CraftingMenu.as +++ b/src/CraftingMenu/CraftingMenu.as @@ -1,5 +1,6 @@ import gfx.managers.FocusHandler; import gfx.io.GameDelegate; +import gfx.ui.InputDetails; import Shared.GlobalFunc; import skyui.components.list.ListLayoutManager; @@ -11,7 +12,7 @@ import skyui.util.Debug; import skyui.util.GlobalFunctions; import skyui.defines.Input; - +import flash.utils.getTimer; class CraftingMenu extends MovieClip { @@ -61,8 +62,10 @@ class CraftingMenu extends MovieClip private var _config: Object; private var _subtypeName: String; - - + + private var _handleInputRateLimiter: Boolean; + + /* PROPERTIES */ public var AdditionalDescriptionHolder: MovieClip; @@ -233,24 +236,33 @@ class CraftingMenu extends MovieClip public function UpdateButtonText(): Void { navPanel.clearButtons(); - + + var activateControls = skyui.util.Input.pickControls(_platform, + {PCArt:"E",XBoxArt:"360_A",PS3Art:"PS3_A",ViveArt:"trigger",MoveArt:"PS3_MOVE",OculusArt:"trigger",WindowsMRArt:"trigger"}); + var exitControls = skyui.util.Input.pickControls(_platform, + {PCArt:"Tab",XBoxArt:"360_B",PS3Art:"PS3_B",ViveArt:"grip",MoveArt:"PS3_B",OculusArt:"grab",WindowsMRArt:"grab"}); + var auxControls = skyui.util.Input.pickControls(_platform, + {PCArt:"F",XBoxArt:"360_Y",PS3Art:"PS3_Y",ViveArt:"radial_Either_Up",MoveArt:"PS3_Y",OculusArt:"OCC_Y",WindowsMRArt:"radial_Either_Up"}); + var craftControls = skyui.util.Input.pickControls(_platform, + {PCArt:"R",XBoxArt:"360_X",PS3Art:"PS3_X",ViveArt:"radial_Either_Down",MoveArt:"PS3_X",OculusArt:"OCC_B",WindowsMRArt:"radial_Either_Down"}); + if (getItemShown()) { - navPanel.addButton({text: ButtonText[CraftingMenu.SELECT_BUTTON], controls: Input.Activate}); + navPanel.addButton({text: ButtonText[CraftingMenu.SELECT_BUTTON], controls: activateControls}); } else { - navPanel.addButton({text: "$Exit", controls: _cancelControls}); + navPanel.addButton({text: "$Exit", controls: exitControls}); navPanel.addButton({text: "$Search", controls: _searchControls}); if (_platform != 0) { navPanel.addButton({text: "$Column", controls: _sortColumnControls}); navPanel.addButton({text: "$Order", controls: _sortOrderControls}); } } - + if (bCanCraft && ButtonText[CraftingMenu.CRAFT_BUTTON] != "") { - navPanel.addButton({text: ButtonText[CraftingMenu.CRAFT_BUTTON], controls: Input.XButton}); + navPanel.addButton({text: ButtonText[CraftingMenu.CRAFT_BUTTON], controls: craftControls}); } - + if (bCanCraft && ButtonText[CraftingMenu.AUX_BUTTON] != "") { - navPanel.addButton({text: ButtonText[CraftingMenu.AUX_BUTTON], controls: Input.YButton}); + navPanel.addButton({text: ButtonText[CraftingMenu.AUX_BUTTON], controls: auxControls}); } // BottomBarInfo["Button" + CraftingMenu.AUX_BUTTON].addEventListener("click", this, "onAuxButtonPress"); @@ -424,10 +436,19 @@ class CraftingMenu extends MovieClip } // @GFx - public function handleInput(aInputEvent: Object, aPathToFocus: Array): Boolean + public function handleInput(details: InputDetails, pathToFocus: Array): Boolean { - aPathToFocus[0].handleInput(aInputEvent, aPathToFocus.slice(1)); - + // Don't process input too quickly + if(_handleInputRateLimiter) { + return; + } + skyui.util.Input.rateLimit(this, "_handleInputRateLimiter", 10); + + pathToFocus[0].handleInput(details, pathToFocus.slice(1)); + + // Always answer `true` or even `undefined`. + // Answering false may cause the Scaleform player to locate another + // component to focus on. return true; } @@ -595,7 +616,10 @@ class CraftingMenu extends MovieClip private function onShowItemsList(event: Object): Void { - if (_platform == 0) { + if (_platform == Shared.Platforms.CONTROLLER_PC || + _platform == Shared.Platforms.CONTROLLER_VIVE || + _platform == Shared.Platforms.CONTROLLER_OCULUS || + _platform == Shared.Platforms.CONTROLLER_VIVE_KNUCKLES) { GameDelegate.call("SetSelectedCategory", [CategoryList.CategoriesList.selectedIndex]); } @@ -612,8 +636,10 @@ class CraftingMenu extends MovieClip private function onCategoryListChange(event: Object): Void { - if (_platform != 0) - { + if (_platform != Shared.Platforms.CONTROLLER_PC || + _platform != Shared.Platforms.CONTROLLER_VIVE || + _platform != Shared.Platforms.CONTROLLER_OCULUS || + _platform != Shared.Platforms.CONTROLLER_VIVE_KNUCKLES) { GameDelegate.call("SetSelectedCategory", [event.index]); } } diff --git a/src/ItemMenus/itemcard.fla b/src/ItemMenus/itemcard.fla index 247e7b5f..00344a77 100644 Binary files a/src/ItemMenus/itemcard.fla and b/src/ItemMenus/itemcard.fla differ