mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-02-17 19:51:06 +00:00
console start
This commit is contained in:
parent
fbeed31da2
commit
eb08a1e18a
15 changed files with 655 additions and 1 deletions
108
data/font/Lucida Console.fnt
Normal file
108
data/font/Lucida Console.fnt
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
<?xml version="1.0"?>
|
||||
<font>
|
||||
<info face="Lucida Console" size="42" bold="0" italic="0" charset="" unicode="1" stretchH="100" smooth="1" aa="1" padding="2,2,2,2" spacing="0,0" outline="0"/>
|
||||
<common lineHeight="45" base="35" scaleW="512" scaleH="256" pages="1" packed="0" alphaChnl="0" redChnl="0" greenChnl="0" blueChnl="0"/>
|
||||
<pages>
|
||||
<page id="0" file="LucidaConsole.png"/>
|
||||
</pages>
|
||||
<distanceField fieldType="msdf" distanceRange="4"/>
|
||||
<chars count="96">
|
||||
<char id="106" index="77" char="j" width="19" height="45" xoffset="1" yoffset="3" xadvance="25" chnl="15" x="0" y="0" page="0"/>
|
||||
<char id="40" index="11" char="(" width="19" height="42" xoffset="5" yoffset="3" xadvance="25" chnl="15" x="0" y="46" page="0"/>
|
||||
<char id="41" index="12" char=")" width="19" height="42" xoffset="1" yoffset="3" xadvance="25" chnl="15" x="0" y="89" page="0"/>
|
||||
<char id="91" index="62" char="[" width="17" height="42" xoffset="7" yoffset="3" xadvance="25" chnl="15" x="0" y="132" page="0"/>
|
||||
<char id="93" index="64" char="]" width="17" height="42" xoffset="2" yoffset="3" xadvance="25" chnl="15" x="0" y="175" page="0"/>
|
||||
<char id="92" index="63" char="\" width="26" height="42" xoffset="0" yoffset="3" xadvance="25" chnl="15" x="18" y="132" page="0"/>
|
||||
<char id="123" index="94" char="{" width="20" height="42" xoffset="3" yoffset="3" xadvance="25" chnl="15" x="18" y="175" page="0"/>
|
||||
<char id="125" index="96" char="}" width="20" height="42" xoffset="2" yoffset="3" xadvance="25" chnl="15" x="39" y="175" page="0"/>
|
||||
<char id="124" index="95" char="|" width="7" height="42" xoffset="9" yoffset="3" xadvance="25" chnl="15" x="20" y="0" page="0"/>
|
||||
<char id="47" index="18" char="/" width="26" height="42" xoffset="0" yoffset="3" xadvance="25" chnl="15" x="20" y="43" page="0"/>
|
||||
<char id="36" index="7" char="$" width="21" height="39" xoffset="2" yoffset="2" xadvance="25" chnl="15" x="28" y="0" page="0"/>
|
||||
<char id="81" index="52" char="Q" width="28" height="38" xoffset="-1" yoffset="8" xadvance="25" chnl="15" x="0" y="218" page="0"/>
|
||||
<char id="194" index="198" char="Â" width="29" height="37" xoffset="-2" yoffset="2" xadvance="25" chnl="15" x="29" y="218" page="0"/>
|
||||
<char id="100" index="71" char="d" width="23" height="37" xoffset="1" yoffset="3" xadvance="25" chnl="15" x="59" y="218" page="0"/>
|
||||
<char id="102" index="73" char="f" width="26" height="37" xoffset="1" yoffset="2" xadvance="25" chnl="15" x="20" y="86" page="0"/>
|
||||
<char id="98" index="69" char="b" width="23" height="37" xoffset="2" yoffset="3" xadvance="25" chnl="15" x="45" y="124" page="0"/>
|
||||
<char id="51" index="22" char="3" width="21" height="36" xoffset="3" yoffset="4" xadvance="25" chnl="15" x="60" y="162" page="0"/>
|
||||
<char id="54" index="25" char="6" width="24" height="36" xoffset="1" yoffset="4" xadvance="25" chnl="15" x="47" y="40" page="0"/>
|
||||
<char id="56" index="27" char="8" width="23" height="36" xoffset="1" yoffset="4" xadvance="25" chnl="15" x="50" y="0" page="0"/>
|
||||
<char id="57" index="28" char="9" width="24" height="36" xoffset="1" yoffset="4" xadvance="25" chnl="15" x="47" y="77" page="0"/>
|
||||
<char id="48" index="19" char="0" width="25" height="36" xoffset="0" yoffset="4" xadvance="25" chnl="15" x="69" y="114" page="0"/>
|
||||
<char id="64" index="35" char="@" width="28" height="36" xoffset="0" yoffset="4" xadvance="25" chnl="15" x="82" y="151" page="0"/>
|
||||
<char id="37" index="8" char="%" width="29" height="36" xoffset="-2" yoffset="4" xadvance="25" chnl="15" x="83" y="188" page="0"/>
|
||||
<char id="38" index="9" char="&" width="29" height="36" xoffset="-2" yoffset="4" xadvance="25" chnl="15" x="72" y="37" page="0"/>
|
||||
<char id="105" index="76" char="i" width="17" height="36" xoffset="2" yoffset="3" xadvance="25" chnl="15" x="74" y="0" page="0"/>
|
||||
<char id="104" index="75" char="h" width="22" height="36" xoffset="2" yoffset="3" xadvance="25" chnl="15" x="92" y="0" page="0"/>
|
||||
<char id="107" index="78" char="k" width="24" height="36" xoffset="2" yoffset="3" xadvance="25" chnl="15" x="72" y="74" page="0"/>
|
||||
<char id="108" index="79" char="l" width="17" height="36" xoffset="2" yoffset="3" xadvance="25" chnl="15" x="95" y="111" page="0"/>
|
||||
<char id="49" index="20" char="1" width="24" height="35" xoffset="2" yoffset="4" xadvance="25" chnl="15" x="97" y="74" page="0"/>
|
||||
<char id="50" index="21" char="2" width="21" height="35" xoffset="1" yoffset="4" xadvance="25" chnl="15" x="102" y="37" page="0"/>
|
||||
<char id="53" index="24" char="5" width="20" height="35" xoffset="4" yoffset="5" xadvance="25" chnl="15" x="115" y="0" page="0"/>
|
||||
<char id="63" index="34" char="?" width="23" height="35" xoffset="1" yoffset="4" xadvance="25" chnl="15" x="111" y="148" page="0"/>
|
||||
<char id="113" index="84" char="q" width="23" height="35" xoffset="0" yoffset="12" xadvance="25" chnl="15" x="113" y="110" page="0"/>
|
||||
<char id="112" index="83" char="p" width="23" height="35" xoffset="2" yoffset="12" xadvance="25" chnl="15" x="122" y="73" page="0"/>
|
||||
<char id="103" index="74" char="g" width="24" height="35" xoffset="1" yoffset="12" xadvance="25" chnl="15" x="124" y="36" page="0"/>
|
||||
<char id="52" index="23" char="4" width="24" height="34" xoffset="0" yoffset="5" xadvance="25" chnl="15" x="136" y="0" page="0"/>
|
||||
<char id="55" index="26" char="7" width="22" height="34" xoffset="2" yoffset="5" xadvance="25" chnl="15" x="113" y="184" page="0"/>
|
||||
<char id="33" index="4" char="!" width="9" height="34" xoffset="8" yoffset="5" xadvance="25" chnl="15" x="113" y="219" page="0"/>
|
||||
<char id="35" index="6" char="#" width="27" height="34" xoffset="-1" yoffset="5" xadvance="25" chnl="15" x="135" y="146" page="0"/>
|
||||
<char id="121" index="92" char="y" width="26" height="34" xoffset="0" yoffset="13" xadvance="25" chnl="15" x="137" y="109" page="0"/>
|
||||
<char id="59" index="30" char=";" width="10" height="33" xoffset="8" yoffset="13" xadvance="25" chnl="15" x="146" y="72" page="0"/>
|
||||
<char id="79" index="50" char="O" width="27" height="32" xoffset="-1" yoffset="8" xadvance="25" chnl="15" x="149" y="35" page="0"/>
|
||||
<char id="83" index="54" char="S" width="24" height="32" xoffset="1" yoffset="8" xadvance="25" chnl="15" x="161" y="0" page="0"/>
|
||||
<char id="71" index="42" char="G" width="26" height="32" xoffset="0" yoffset="8" xadvance="25" chnl="15" x="123" y="219" page="0"/>
|
||||
<char id="67" index="38" char="C" width="26" height="32" xoffset="0" yoffset="8" xadvance="25" chnl="15" x="136" y="181" page="0"/>
|
||||
<char id="85" index="56" char="U" width="23" height="31" xoffset="1" yoffset="9" xadvance="25" chnl="15" x="83" y="225" page="0"/>
|
||||
<char id="74" index="45" char="J" width="19" height="31" xoffset="2" yoffset="9" xadvance="25" chnl="15" x="157" y="68" page="0"/>
|
||||
<char id="116" index="87" char="t" width="24" height="31" xoffset="1" yoffset="8" xadvance="25" chnl="15" x="150" y="214" page="0"/>
|
||||
<char id="87" index="58" char="W" width="29" height="30" xoffset="-2" yoffset="9" xadvance="25" chnl="15" x="163" y="144" page="0"/>
|
||||
<char id="69" index="40" char="E" width="23" height="30" xoffset="2" yoffset="9" xadvance="25" chnl="15" x="163" y="175" page="0"/>
|
||||
<char id="82" index="53" char="R" width="25" height="30" xoffset="2" yoffset="9" xadvance="25" chnl="15" x="164" y="100" page="0"/>
|
||||
<char id="84" index="55" char="T" width="28" height="30" xoffset="-1" yoffset="9" xadvance="25" chnl="15" x="175" y="206" page="0"/>
|
||||
<char id="89" index="60" char="Y" width="29" height="30" xoffset="-1" yoffset="9" xadvance="25" chnl="15" x="187" y="175" page="0"/>
|
||||
<char id="73" index="44" char="I" width="22" height="30" xoffset="2" yoffset="9" xadvance="25" chnl="15" x="204" y="206" page="0"/>
|
||||
<char id="80" index="51" char="P" width="23" height="30" xoffset="3" yoffset="9" xadvance="25" chnl="15" x="177" y="33" page="0"/>
|
||||
<char id="65" index="36" char="A" width="29" height="30" xoffset="-2" yoffset="9" xadvance="25" chnl="15" x="186" y="0" page="0"/>
|
||||
<char id="68" index="39" char="D" width="25" height="30" xoffset="1" yoffset="9" xadvance="25" chnl="15" x="177" y="64" page="0"/>
|
||||
<char id="70" index="41" char="F" width="23" height="30" xoffset="3" yoffset="9" xadvance="25" chnl="15" x="201" y="31" page="0"/>
|
||||
<char id="72" index="43" char="H" width="23" height="30" xoffset="1" yoffset="9" xadvance="25" chnl="15" x="216" y="0" page="0"/>
|
||||
<char id="75" index="46" char="K" width="25" height="30" xoffset="1" yoffset="9" xadvance="25" chnl="15" x="190" y="95" page="0"/>
|
||||
<char id="76" index="47" char="L" width="22" height="30" xoffset="3" yoffset="9" xadvance="25" chnl="15" x="203" y="62" page="0"/>
|
||||
<char id="90" index="61" char="Z" width="25" height="30" xoffset="0" yoffset="9" xadvance="25" chnl="15" x="225" y="31" page="0"/>
|
||||
<char id="88" index="59" char="X" width="29" height="30" xoffset="-2" yoffset="9" xadvance="25" chnl="15" x="240" y="0" page="0"/>
|
||||
<char id="86" index="57" char="V" width="29" height="30" xoffset="-2" yoffset="9" xadvance="25" chnl="15" x="193" y="126" page="0"/>
|
||||
<char id="66" index="37" char="B" width="23" height="30" xoffset="2" yoffset="9" xadvance="25" chnl="15" x="216" y="93" page="0"/>
|
||||
<char id="78" index="49" char="N" width="23" height="30" xoffset="1" yoffset="9" xadvance="25" chnl="15" x="226" y="62" page="0"/>
|
||||
<char id="77" index="48" char="M" width="25" height="30" xoffset="0" yoffset="9" xadvance="25" chnl="15" x="217" y="157" page="0"/>
|
||||
<char id="95" index="66" char="_" width="29" height="7" xoffset="-2" yoffset="35" xadvance="25" chnl="15" x="150" y="246" page="0"/>
|
||||
<char id="119" index="90" char="w" width="29" height="26" xoffset="-2" yoffset="13" xadvance="25" chnl="15" x="223" y="124" page="0"/>
|
||||
<char id="94" index="65" char="^" width="26" height="28" xoffset="0" yoffset="5" xadvance="25" chnl="15" x="240" y="93" page="0"/>
|
||||
<char id="101" index="72" char="e" width="24" height="27" xoffset="1" yoffset="12" xadvance="25" chnl="15" x="250" y="62" page="0"/>
|
||||
<char id="114" index="85" char="r" width="20" height="27" xoffset="4" yoffset="12" xadvance="25" chnl="15" x="251" y="31" page="0"/>
|
||||
<char id="117" index="88" char="u" width="22" height="27" xoffset="2" yoffset="13" xadvance="25" chnl="15" x="270" y="0" page="0"/>
|
||||
<char id="111" index="82" char="o" width="25" height="27" xoffset="0" yoffset="12" xadvance="25" chnl="15" x="272" y="28" page="0"/>
|
||||
<char id="97" index="68" char="a" width="25" height="27" xoffset="1" yoffset="12" xadvance="25" chnl="15" x="293" y="0" page="0"/>
|
||||
<char id="115" index="86" char="s" width="22" height="27" xoffset="2" yoffset="12" xadvance="25" chnl="15" x="227" y="188" page="0"/>
|
||||
<char id="99" index="70" char="c" width="23" height="27" xoffset="1" yoffset="12" xadvance="25" chnl="15" x="243" y="151" page="0"/>
|
||||
<char id="118" index="89" char="v" width="27" height="26" xoffset="-1" yoffset="13" xadvance="25" chnl="15" x="253" y="122" page="0"/>
|
||||
<char id="110" index="81" char="n" width="22" height="27" xoffset="2" yoffset="12" xadvance="25" chnl="15" x="267" y="90" page="0"/>
|
||||
<char id="109" index="80" char="m" width="26" height="27" xoffset="0" yoffset="12" xadvance="25" chnl="15" x="275" y="56" page="0"/>
|
||||
<char id="61" index="32" char="=" width="26" height="15" xoffset="0" yoffset="19" xadvance="25" chnl="15" x="180" y="237" page="0"/>
|
||||
<char id="43" index="14" char="+" width="26" height="26" xoffset="0" yoffset="13" xadvance="25" chnl="15" x="298" y="28" page="0"/>
|
||||
<char id="126" index="97" char="~" width="26" height="11" xoffset="0" yoffset="20" xadvance="25" chnl="15" x="164" y="131" page="0"/>
|
||||
<char id="58" index="29" char=":" width="10" height="26" xoffset="8" yoffset="13" xadvance="25" chnl="15" x="319" y="0" page="0"/>
|
||||
<char id="60" index="31" char="<" width="26" height="26" xoffset="0" yoffset="13" xadvance="25" chnl="15" x="227" y="216" page="0"/>
|
||||
<char id="62" index="33" char=">" width="26" height="26" xoffset="0" yoffset="13" xadvance="25" chnl="15" x="250" y="179" page="0"/>
|
||||
<char id="122" index="93" char="z" width="24" height="26" xoffset="1" yoffset="13" xadvance="25" chnl="15" x="267" y="149" page="0"/>
|
||||
<char id="120" index="91" char="x" width="26" height="26" xoffset="0" yoffset="13" xadvance="25" chnl="15" x="281" y="118" page="0"/>
|
||||
<char id="42" index="13" char="*" width="23" height="22" xoffset="1" yoffset="5" xadvance="25" chnl="15" x="290" y="84" page="0"/>
|
||||
<char id="45" index="16" char="-" width="21" height="7" xoffset="2" yoffset="21" xadvance="25" chnl="15" x="20" y="124" page="0"/>
|
||||
<char id="34" index="5" char=""" width="19" height="15" xoffset="3" yoffset="3" xadvance="25" chnl="15" x="207" y="237" page="0"/>
|
||||
<char id="39" index="10" char="'" width="10" height="17" xoffset="8" yoffset="3" xadvance="25" chnl="15" x="193" y="157" page="0"/>
|
||||
<char id="44" index="15" char="," width="10" height="17" xoffset="8" yoffset="29" xadvance="25" chnl="15" x="204" y="157" page="0"/>
|
||||
<char id="96" index="67" char="`" width="14" height="9" xoffset="6" yoffset="2" xadvance="25" chnl="15" x="45" y="162" page="0"/>
|
||||
<char id="46" index="17" char="." width="10" height="10" xoffset="8" yoffset="29" xadvance="25" chnl="15" x="69" y="151" page="0"/>
|
||||
<char id="32" index="3" char=" " width="0" height="0" xoffset="-2" yoffset="35" xadvance="25" chnl="15" x="82" y="188" page="0"/>
|
||||
</chars>
|
||||
<kernings count="0"/>
|
||||
</font>
|
||||
BIN
data/font/LucidaConsole.png
Normal file
BIN
data/font/LucidaConsole.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 86 KiB |
|
|
@ -10,6 +10,7 @@ import src.Settings;
|
|||
import hxd.snd.ChannelGroup;
|
||||
import src.Resource;
|
||||
import src.ResourceLoaderWorker;
|
||||
import src.Console;
|
||||
|
||||
class AudioManager {
|
||||
static var manager:hxd.snd.Manager;
|
||||
|
|
@ -23,6 +24,7 @@ class AudioManager {
|
|||
static var currentMusicResource:Resource<Sound>;
|
||||
|
||||
public static function init() {
|
||||
Console.log("Initializing Audio System");
|
||||
AudioManager.manager = hxd.snd.Manager.get();
|
||||
AudioManager.soundGroup = new SoundGroup("sound");
|
||||
soundGroup.volume = Settings.optionsSettings.soundVolume;
|
||||
|
|
|
|||
88
src/Console.hx
Normal file
88
src/Console.hx
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
package src;
|
||||
|
||||
@:publicFields
|
||||
class ConsoleEntry {
|
||||
var time:Float;
|
||||
var type:String;
|
||||
var text:String;
|
||||
|
||||
public function new(time:Float, type:String, text:String) {
|
||||
this.time = time;
|
||||
this.type = type;
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
|
||||
class Console {
|
||||
public static var instance:Console;
|
||||
|
||||
public var entries:Array<ConsoleEntry>;
|
||||
|
||||
var consumers:Array<ConsoleEntry->Void>;
|
||||
var timeSinceStart:Float;
|
||||
|
||||
public function new() {
|
||||
if (instance == null) {
|
||||
instance = this;
|
||||
}
|
||||
entries = [];
|
||||
consumers = [];
|
||||
timeSinceStart = haxe.Timer.stamp();
|
||||
}
|
||||
|
||||
public function clear() {
|
||||
entries = [];
|
||||
}
|
||||
|
||||
function getTime() {
|
||||
return Std.int((haxe.Timer.stamp() - timeSinceStart) * 1000) / 1000;
|
||||
}
|
||||
|
||||
function addEntry(type:String, msg:String) {
|
||||
var e = new ConsoleEntry(getTime(), type, msg);
|
||||
entries.push(e);
|
||||
for (c in consumers) {
|
||||
c(e);
|
||||
}
|
||||
}
|
||||
|
||||
function _log(t:String) {
|
||||
addEntry("log", t);
|
||||
}
|
||||
|
||||
function _warn(t:String) {
|
||||
addEntry("warn", t);
|
||||
}
|
||||
|
||||
function _error(t:String) {
|
||||
addEntry("error", t);
|
||||
}
|
||||
|
||||
function _debug(t:String) {
|
||||
addEntry("debug", t);
|
||||
}
|
||||
|
||||
public static function log(t:String) {
|
||||
instance._log(t);
|
||||
}
|
||||
|
||||
public static function warn(t:String) {
|
||||
instance._warn(t);
|
||||
}
|
||||
|
||||
public static function error(t:String) {
|
||||
instance._error(t);
|
||||
}
|
||||
|
||||
public static function debug(t:String) {
|
||||
instance._debug(t);
|
||||
}
|
||||
|
||||
public static function addConsumer(c:ConsoleEntry->Void) {
|
||||
instance.consumers.push(c);
|
||||
}
|
||||
|
||||
public static function removeConsumer(c:ConsoleEntry->Void) {
|
||||
instance.consumers.remove(c);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package;
|
||||
|
||||
import src.Console;
|
||||
import hxd.Key;
|
||||
import src.Util;
|
||||
import src.ResourceLoader;
|
||||
|
|
@ -23,6 +24,8 @@ class Main extends hxd.App {
|
|||
|
||||
var loaded:Bool = false;
|
||||
|
||||
var frameByFrame:Bool = false;
|
||||
|
||||
override function init() {
|
||||
super.init();
|
||||
|
||||
|
|
@ -56,6 +59,12 @@ class Main extends hxd.App {
|
|||
});
|
||||
#end
|
||||
|
||||
new Console(); // Singleton
|
||||
Console.log("Initializing MBHaxe");
|
||||
#if hl
|
||||
Console.log("System: " + Sys.systemName());
|
||||
#end
|
||||
|
||||
Settings.init();
|
||||
ResourceLoader.init(s2d, () -> {
|
||||
AudioManager.init();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package src;
|
||||
|
||||
import gui.ConsoleDlg;
|
||||
import src.Replay;
|
||||
import touch.TouchInput;
|
||||
import src.ResourceLoader;
|
||||
|
|
@ -17,6 +18,7 @@ import gui.Canvas;
|
|||
import src.Util;
|
||||
import src.ProfilerUI;
|
||||
import src.Settings;
|
||||
import src.Console;
|
||||
|
||||
@:publicFields
|
||||
class MarbleGame {
|
||||
|
|
@ -36,7 +38,11 @@ class MarbleGame {
|
|||
|
||||
var touchInput:TouchInput;
|
||||
|
||||
var consoleShown:Bool = false;
|
||||
var console:ConsoleDlg;
|
||||
|
||||
public function new(scene2d:h2d.Scene, scene:h3d.scene.Scene) {
|
||||
Console.log("Initializing the game...");
|
||||
canvas = new Canvas(scene2d, cast this);
|
||||
this.scene = scene;
|
||||
this.scene2d = scene2d;
|
||||
|
|
@ -183,6 +189,19 @@ class MarbleGame {
|
|||
}
|
||||
}
|
||||
if (canvas != null) {
|
||||
if (Key.isPressed(Key.QWERTY_TILDE)) {
|
||||
consoleShown = !consoleShown;
|
||||
if (consoleShown) {
|
||||
if (console == null)
|
||||
console = new ConsoleDlg();
|
||||
@:privateAccess console.isShowing = true;
|
||||
canvas.pushDialog(console);
|
||||
} else {
|
||||
@:privateAccess console.isShowing = false;
|
||||
canvas.popDialog(console, false);
|
||||
}
|
||||
}
|
||||
|
||||
var mouseState:MouseState = {
|
||||
position: new Vector(canvas.scene2d.mouseX, canvas.scene2d.mouseY)
|
||||
}
|
||||
|
|
@ -193,6 +212,7 @@ class MarbleGame {
|
|||
|
||||
public function handlePauseGame() {
|
||||
if (paused && world._ready) {
|
||||
Console.log("Game paused");
|
||||
world.setCursorLock(false);
|
||||
exitGameDlg = new ExitGameDlg((sender) -> {
|
||||
canvas.popDialog(exitGameDlg);
|
||||
|
|
@ -210,6 +230,7 @@ class MarbleGame {
|
|||
canvas.pushDialog(exitGameDlg);
|
||||
} else {
|
||||
if (world._ready) {
|
||||
Console.log("Game unpaused");
|
||||
if (exitGameDlg != null)
|
||||
canvas.popDialog(exitGameDlg);
|
||||
world.setCursorLock(true);
|
||||
|
|
@ -218,6 +239,7 @@ class MarbleGame {
|
|||
}
|
||||
|
||||
public function quitMission() {
|
||||
Console.log("Quitting mission");
|
||||
world.setCursorLock(false);
|
||||
paused = false;
|
||||
var pmg = new PlayMissionGui();
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ import src.Resource;
|
|||
import src.ProfilerUI;
|
||||
import src.ResourceLoaderWorker;
|
||||
import haxe.io.Path;
|
||||
import src.Console;
|
||||
|
||||
class MarbleWorld extends Scheduler {
|
||||
public var collisionWorld:CollisionWorld;
|
||||
|
|
@ -197,6 +198,7 @@ class MarbleWorld extends Scheduler {
|
|||
}
|
||||
|
||||
public function initLoading() {
|
||||
Console.log("*** LOADING MISSION: " + mission.path);
|
||||
this.loadingGui = new LoadingGui(this.mission.title, this.mission.game);
|
||||
MarbleGame.canvas.setContent(this.loadingGui);
|
||||
|
||||
|
|
@ -260,6 +262,7 @@ class MarbleWorld extends Scheduler {
|
|||
}
|
||||
|
||||
public function initScene(onFinish:Void->Void) {
|
||||
Console.log("Starting scene");
|
||||
this.collisionWorld = new CollisionWorld();
|
||||
this.playGui = new PlayGui();
|
||||
this.instanceManager = new InstanceManager(scene);
|
||||
|
|
@ -330,6 +333,7 @@ class MarbleWorld extends Scheduler {
|
|||
}
|
||||
|
||||
public function initMarble(onFinish:Void->Void) {
|
||||
Console.log("Initializing marble");
|
||||
var worker = new ResourceLoaderWorker(onFinish);
|
||||
var marblefiles = [
|
||||
"particles/star.png",
|
||||
|
|
@ -390,6 +394,7 @@ class MarbleWorld extends Scheduler {
|
|||
}
|
||||
|
||||
public function start() {
|
||||
Console.log("LEVEL START");
|
||||
restart(true);
|
||||
for (interior in this.interiors)
|
||||
interior.onLevelStart();
|
||||
|
|
@ -502,20 +507,25 @@ class MarbleWorld extends Scheduler {
|
|||
|
||||
AudioManager.playSound(ResourceLoader.getResource('data/sound/spawn.wav', ResourceLoader.getAudio, this.soundResources));
|
||||
|
||||
Console.log("State Start");
|
||||
this.clearSchedule();
|
||||
this.schedule(0.5, () -> {
|
||||
// setCenterText('ready');
|
||||
Console.log("State Ready");
|
||||
AudioManager.playSound(ResourceLoader.getResource('data/sound/ready.wav', ResourceLoader.getAudio, this.soundResources));
|
||||
return 0;
|
||||
});
|
||||
this.schedule(2, () -> {
|
||||
// setCenterText('set');
|
||||
Console.log("State Set");
|
||||
AudioManager.playSound(ResourceLoader.getResource('data/sound/set.wav', ResourceLoader.getAudio, this.soundResources));
|
||||
return 0;
|
||||
});
|
||||
this.schedule(3.5, () -> {
|
||||
// setCenterText('go');
|
||||
Console.log("State Go");
|
||||
AudioManager.playSound(ResourceLoader.getResource('data/sound/go.wav', ResourceLoader.getAudio, this.soundResources));
|
||||
Console.log("State Play");
|
||||
return 0;
|
||||
});
|
||||
|
||||
|
|
@ -570,6 +580,7 @@ class MarbleWorld extends Scheduler {
|
|||
this.addPathedInterior(pathedInterior, () -> {
|
||||
if (pathedInterior == null) {
|
||||
fwd();
|
||||
Console.error("Unable to load pathed interior");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -736,6 +747,7 @@ class MarbleWorld extends Scheduler {
|
|||
else if (["clear", "cloudy", "dusk", "wintry"].contains(dataBlockLowerCase))
|
||||
shape = new shapes.Sky(dataBlockLowerCase);
|
||||
else {
|
||||
Console.error("Unable to create static shape with data block '" + element.datablock + "'");
|
||||
onFinish();
|
||||
return;
|
||||
}
|
||||
|
|
@ -849,6 +861,7 @@ class MarbleWorld extends Scheduler {
|
|||
else if (["clear", "cloudy", "dusk", "wintry"].contains(dataBlockLowerCase))
|
||||
shape = new shapes.Sky(dataBlockLowerCase);
|
||||
else {
|
||||
Console.error("Unknown item: " + element.datablock);
|
||||
onFinish();
|
||||
return;
|
||||
}
|
||||
|
|
@ -920,12 +933,14 @@ class MarbleWorld extends Scheduler {
|
|||
var shapeName = element.shapename;
|
||||
var index = shapeName.indexOf('data/');
|
||||
if (index == -1) {
|
||||
Console.error("Unable to parse shape path: " + shapeName);
|
||||
onFinish();
|
||||
return;
|
||||
}
|
||||
|
||||
var dtsPath = 'data/' + shapeName.substring(index + 'data/'.length);
|
||||
if (ResourceLoader.getProperFilepath(dtsPath) == "") {
|
||||
Console.error("DTS path does not exist: " + dtsPath);
|
||||
onFinish();
|
||||
return;
|
||||
}
|
||||
|
|
@ -969,6 +984,7 @@ class MarbleWorld extends Scheduler {
|
|||
}
|
||||
|
||||
public function addParticleEmitterNode(element:MissionElementParticleEmitterNode) {
|
||||
Console.warn("Unimplemented method addParticleEmitterNode");
|
||||
// TODO THIS SHIT
|
||||
}
|
||||
|
||||
|
|
@ -1265,6 +1281,7 @@ class MarbleWorld extends Scheduler {
|
|||
return;
|
||||
if (!_ready && !postInited) {
|
||||
postInited = true;
|
||||
Console.log("Finished loading, starting mission");
|
||||
postInit();
|
||||
}
|
||||
}
|
||||
|
|
@ -1623,6 +1640,7 @@ class MarbleWorld extends Scheduler {
|
|||
}
|
||||
|
||||
function showFinishScreen() {
|
||||
Console.log("State End");
|
||||
var egg:EndGameGui = null;
|
||||
#if js
|
||||
var pointercontainer = js.Browser.document.querySelector("#pointercontainer");
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import src.ResourceLoader;
|
|||
import hxd.res.Image;
|
||||
import src.Resource;
|
||||
import src.Util;
|
||||
import src.Console;
|
||||
|
||||
class Mission {
|
||||
public var root:MissionElementSimGroup;
|
||||
|
|
@ -146,11 +147,13 @@ class Mission {
|
|||
});
|
||||
return imgFileEntry.path;
|
||||
}
|
||||
Console.error("Preview image not found for " + this.path);
|
||||
var img = new BitmapData(1, 1);
|
||||
img.setPixel(0, 0, 0);
|
||||
onLoaded(Tile.fromBitmap(img));
|
||||
return null;
|
||||
} else {
|
||||
Console.error("Preview image not found for " + this.path);
|
||||
var img = new BitmapData(1, 1);
|
||||
img.setPixel(0, 0, 0);
|
||||
onLoaded(Tile.fromBitmap(img));
|
||||
|
|
@ -181,6 +184,7 @@ class Mission {
|
|||
return path;
|
||||
if (ResourceLoader.fileSystem.exists(dirpath + fname))
|
||||
return dirpath + fname;
|
||||
Console.error("Interior resource not found: " + rawElementPath);
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package src;
|
||||
|
||||
import src.Console;
|
||||
|
||||
class Resource<T> {
|
||||
public var resource:T;
|
||||
public var identifier:String;
|
||||
|
|
@ -23,6 +25,7 @@ class Resource<T> {
|
|||
public function release() {
|
||||
this.referenceCount--;
|
||||
if (this.referenceCount == 0) {
|
||||
Console.log("Freeing: " + identifier);
|
||||
disposeFunc(this.resource);
|
||||
this.resourceMap.remove(this.identifier);
|
||||
// trace('Releasing Resource ${this.identifier}');
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import src.Resource;
|
|||
import src.ResourceLoaderWorker;
|
||||
import fs.TorqueFileSystem;
|
||||
import src.Settings;
|
||||
import src.Console;
|
||||
|
||||
class ResourceLoader {
|
||||
#if (hl && !android)
|
||||
|
|
@ -46,6 +47,10 @@ class ResourceLoader {
|
|||
// static var threadPool:FixedThreadPool = new FixedThreadPool(4);
|
||||
|
||||
public static function init(scene2d:h2d.Scene, onLoadedFunc:Void->Void) {
|
||||
Console.log("Initializing filesystem");
|
||||
#if hl
|
||||
Console.log("Filesystem Path: " + @:privateAccess cast(fileSystem, TorqueFileSystem).baseDir);
|
||||
#end
|
||||
hxd.res.Resource.LIVE_UPDATE = false; // Disable live update to save frames
|
||||
@:privateAccess hxd.res.Image.ENABLE_AUTO_WATCH = false;
|
||||
@:privateAccess hxd.res.Sound.ENABLE_AUTO_WATCH = false;
|
||||
|
|
@ -275,6 +280,7 @@ class ResourceLoader {
|
|||
if (interiorResources.exists(path))
|
||||
return interiorResources.get(path);
|
||||
else {
|
||||
Console.log("Load Interior: " + path);
|
||||
var itr:Dif;
|
||||
// var lock = new Lock();
|
||||
// threadPool.run(() -> {
|
||||
|
|
@ -293,6 +299,7 @@ class ResourceLoader {
|
|||
if (dtsResources.exists(path))
|
||||
return dtsResources.get(path);
|
||||
else {
|
||||
Console.log("Load DTS: " + path);
|
||||
var dts = new DtsFile();
|
||||
// var lock = new Lock();
|
||||
// threadPool.run(() -> {
|
||||
|
|
@ -311,6 +318,7 @@ class ResourceLoader {
|
|||
if (textureCache.exists(path))
|
||||
return textureCache.get(path);
|
||||
if (fileSystem.exists(path)) {
|
||||
Console.log("Load Texture: " + path);
|
||||
var img = loader.load(path).toImage();
|
||||
Image.setupTextureFlags = (texObj) -> {
|
||||
texObj.flags.set(MipMapped);
|
||||
|
|
@ -333,6 +341,7 @@ class ResourceLoader {
|
|||
if (imageCache.exists(path))
|
||||
return imageCache.get(path);
|
||||
if (fileSystem.exists(path)) {
|
||||
Console.log("Load Image: " + path);
|
||||
var tex = loader.load(path).toImage();
|
||||
var imageresource = new Resource(tex, path, imageCache, img -> {});
|
||||
imageCache.set(path, imageresource);
|
||||
|
|
@ -348,6 +357,7 @@ class ResourceLoader {
|
|||
if (audioCache.exists(path))
|
||||
return audioCache.get(path);
|
||||
if (fileSystem.exists(path)) {
|
||||
Console.log("Load Audio: " + path);
|
||||
var snd = loader.load(path).toSound();
|
||||
// @:privateAccess snd.watchCallb();
|
||||
var audioresource = new Resource(snd, path, audioCache, snd -> snd.dispose());
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import haxe.io.Path;
|
|||
import src.ResourceLoader;
|
||||
import haxe.Json;
|
||||
import src.Util;
|
||||
import src.Console;
|
||||
|
||||
typedef Score = {
|
||||
var name:String;
|
||||
|
|
@ -268,6 +269,7 @@ class Settings {
|
|||
}
|
||||
|
||||
public static function load() {
|
||||
Console.log("Loading settings");
|
||||
var settingsExists = false;
|
||||
#if hl
|
||||
settingsExists = FileSystem.exists(Path.join([settingsDir, "settings.json"]));
|
||||
|
|
@ -334,6 +336,7 @@ class Settings {
|
|||
#end
|
||||
highscoreName = json.highscoreName;
|
||||
} else {
|
||||
Console.warn("Settings file does not exist");
|
||||
save();
|
||||
}
|
||||
#if hl
|
||||
|
|
@ -376,6 +379,9 @@ class Settings {
|
|||
canvasElement.style.height = "100%";
|
||||
#end
|
||||
|
||||
Console.log("Window resized to " + Settings.optionsSettings.screenWidth + "x" + Settings.optionsSettings.screenHeight + " (Zoom " + zoomRatio +
|
||||
")");
|
||||
|
||||
MarbleGame.canvas.scene2d.scaleMode = Zoom(zoomRatio);
|
||||
|
||||
MarbleGame.canvas.render(MarbleGame.canvas.scene2d);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package gui;
|
||||
|
||||
import src.Console;
|
||||
import src.MarbleGame;
|
||||
import h3d.Vector;
|
||||
import h2d.Scene;
|
||||
|
|
@ -12,6 +13,7 @@ class Canvas extends GuiControl {
|
|||
|
||||
public function new(scene, marbleGame:MarbleGame) {
|
||||
super();
|
||||
Console.log("Creating canvas");
|
||||
this.scene2d = scene;
|
||||
this.marbleGame = marbleGame;
|
||||
|
||||
|
|
|
|||
108
src/gui/ConsoleDlg.hx
Normal file
108
src/gui/ConsoleDlg.hx
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
package gui;
|
||||
|
||||
import src.Console.ConsoleEntry;
|
||||
import h2d.Graphics;
|
||||
import h2d.Tile;
|
||||
import h3d.mat.Texture;
|
||||
import hxd.res.BitmapFont;
|
||||
import src.ResourceLoader;
|
||||
import h3d.Vector;
|
||||
import src.Settings;
|
||||
import src.Console;
|
||||
|
||||
class ConsoleDlg extends GuiControl {
|
||||
var onConsoleEntry:(e:ConsoleEntry) -> Void;
|
||||
var isShowing = false;
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
this.position = new Vector(0, 0);
|
||||
this.extent = new Vector(640, 370);
|
||||
|
||||
var white = Tile.fromColor(0xFFFFFF);
|
||||
var black = Tile.fromColor(0x000000);
|
||||
var consoleWhite = new GuiImage(white);
|
||||
consoleWhite.position = new Vector(0, 0);
|
||||
consoleWhite.extent = new Vector(640, 350);
|
||||
consoleWhite.horizSizing = Width;
|
||||
consoleWhite.vertSizing = Top;
|
||||
this.addChild(consoleWhite);
|
||||
|
||||
var scroll = new GuiConsoleScrollCtrl(ResourceLoader.getResource("data/ui/common/darkscroll.png", ResourceLoader.getImage, this.imageResources)
|
||||
.toTile());
|
||||
scroll.position = new Vector(0, 0);
|
||||
scroll.extent = new Vector(640, 350);
|
||||
scroll.horizSizing = Width;
|
||||
scroll.vertSizing = Height;
|
||||
|
||||
consoleWhite.addChild(scroll);
|
||||
|
||||
var consolefontdata = ResourceLoader.getFileEntry("data/font/Lucida Console.fnt");
|
||||
var consoleb = new BitmapFont(consolefontdata.entry);
|
||||
@:privateAccess consoleb.loader = ResourceLoader.loader;
|
||||
var consoleb = consoleb.toSdfFont(cast 11.7 * Settings.uiScale, MultiChannel);
|
||||
|
||||
function mlFontLoader(text:String) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var consoleContent = new GuiMLText(consoleb, mlFontLoader);
|
||||
consoleContent.position = new Vector(0, 0);
|
||||
consoleContent.extent = new Vector(640, 350);
|
||||
consoleContent.horizSizing = Width;
|
||||
consoleContent.vertSizing = Top;
|
||||
consoleContent.text.textColor = 0;
|
||||
consoleContent.scrollable = true;
|
||||
scroll.addChild(consoleContent);
|
||||
|
||||
consoleContent.text.text = "";
|
||||
|
||||
// Generate console text
|
||||
for (entry in Console.instance.entries) {
|
||||
var txt = '[${entry.time}] ${StringTools.htmlEscape(entry.text)}<br/>';
|
||||
consoleContent.text.text += txt;
|
||||
}
|
||||
|
||||
scroll.setScrollMax(consoleContent.text.textHeight);
|
||||
scroll.updateScrollVisual();
|
||||
|
||||
var arial14fontdata = ResourceLoader.getFileEntry("data/font/arial.fnt");
|
||||
var arial14b = new BitmapFont(arial14fontdata.entry);
|
||||
@:privateAccess arial14b.loader = ResourceLoader.loader;
|
||||
var arial14 = arial14b.toSdfFont(cast 14 * Settings.uiScale, MultiChannel);
|
||||
|
||||
var bord = new GuiImage(black);
|
||||
bord.position = new Vector(0, 350);
|
||||
bord.extent = new Vector(640, 18);
|
||||
bord.horizSizing = Width;
|
||||
consoleContent.addChild(bord);
|
||||
|
||||
var consoleInput = new GuiTextInput(arial14);
|
||||
consoleInput.position = new Vector(1, 351);
|
||||
consoleInput.extent = new Vector(638, 20);
|
||||
consoleInput.horizSizing = Width;
|
||||
consoleInput.vertSizing = Top;
|
||||
consoleInput.text.textColor = 0;
|
||||
consoleInput.text.backgroundColor = 0xFFFFFFFF;
|
||||
consoleInput.text.selectionColor.set(1, 1, 1);
|
||||
consoleInput.text.selectionTile = h2d.Tile.fromColor(0x808080, 0, hxd.Math.ceil(consoleInput.text.font.lineHeight));
|
||||
|
||||
consoleContent.addChild(consoleInput);
|
||||
|
||||
onConsoleEntry = (e) -> {
|
||||
var txt = '[${e.time}] ${StringTools.htmlEscape(e.text)}<br/>';
|
||||
consoleContent.text.text += txt;
|
||||
if (isShowing) {
|
||||
scroll.setScrollMax(consoleContent.text.textHeight);
|
||||
haxe.Timer.delay(() -> scroll.setScrollPercentage(1), 1);
|
||||
}
|
||||
};
|
||||
|
||||
Console.addConsumer(onConsoleEntry);
|
||||
}
|
||||
|
||||
override function dispose() {
|
||||
super.dispose();
|
||||
Console.removeConsumer(onConsoleEntry);
|
||||
}
|
||||
}
|
||||
273
src/gui/GuiConsoleScrollCtrl.hx
Normal file
273
src/gui/GuiConsoleScrollCtrl.hx
Normal file
|
|
@ -0,0 +1,273 @@
|
|||
package gui;
|
||||
|
||||
import h2d.Bitmap;
|
||||
import h3d.Vector;
|
||||
import src.Settings;
|
||||
import gui.GuiControl.MouseState;
|
||||
import h2d.Interactive;
|
||||
import h2d.Scene;
|
||||
import h2d.Tile;
|
||||
import h2d.Graphics;
|
||||
import src.MarbleGame;
|
||||
import src.Util;
|
||||
|
||||
class GuiConsoleScrollCtrl extends GuiControl {
|
||||
public var scrollY:Float = 0;
|
||||
|
||||
var maxScrollY:Float;
|
||||
|
||||
var scrollBarY:Graphics;
|
||||
var scrollTrack:Bitmap;
|
||||
|
||||
var scrollTopTile:Tile;
|
||||
var scrollBottomTile:Tile;
|
||||
var scrollFillTile:Tile;
|
||||
|
||||
var scrollTopPressedTile:Tile;
|
||||
var scrollBottomPressedTile:Tile;
|
||||
var scrollFillPressedTile:Tile;
|
||||
|
||||
var scrollTrackTile:Tile;
|
||||
|
||||
var clickInteractive:Interactive;
|
||||
|
||||
var pressed:Bool = false;
|
||||
var dirty:Bool = true;
|
||||
var prevMousePos:Vector;
|
||||
|
||||
var scrollUpButton:GuiButton;
|
||||
var scrollDownButton:GuiButton;
|
||||
|
||||
public function new(scrollBar:Tile) {
|
||||
super();
|
||||
this.scrollTopTile = scrollBar.sub(0, 37, 18, 8);
|
||||
this.scrollBottomTile = scrollBar.sub(0, 55, 18, 8);
|
||||
this.scrollFillTile = scrollBar.sub(0, 46, 18, 1);
|
||||
this.scrollTopPressedTile = scrollBar.sub(19, 37, 18, 8);
|
||||
this.scrollBottomPressedTile = scrollBar.sub(19, 46, 18, 8);
|
||||
this.scrollFillPressedTile = scrollBar.sub(19, 55, 18, 1);
|
||||
this.scrollTrackTile = scrollBar.sub(0, 64, 18, 1);
|
||||
var scrollUpTile = scrollBar.sub(0, 1, 18, 17);
|
||||
var scrollDownTile = scrollBar.sub(0, 19, 18, 17);
|
||||
var scrollUpPressedTile = scrollBar.sub(19, 1, 18, 17);
|
||||
var scrollDownPressedTile = scrollBar.sub(19, 19, 18, 17);
|
||||
var scrollUpDisabledTile = scrollBar.sub(38, 1, 18, 17);
|
||||
var scrollDownDisabledTile = scrollBar.sub(38, 19, 18, 17);
|
||||
|
||||
scrollUpButton = new GuiButton([scrollUpTile, scrollUpTile, scrollUpPressedTile, scrollUpDisabledTile]);
|
||||
scrollUpButton.position = new Vector(0, 0);
|
||||
scrollUpButton.extent = new Vector(18, 17);
|
||||
scrollUpButton.horizSizing = Right;
|
||||
scrollUpButton.pressedAction = (e) -> {
|
||||
this.scrollY -= 10;
|
||||
this.updateScrollVisual();
|
||||
}
|
||||
this.addChild(scrollUpButton);
|
||||
|
||||
scrollDownButton = new GuiButton([scrollDownTile, scrollDownTile, scrollDownPressedTile, scrollDownDisabledTile]);
|
||||
scrollDownButton.position = new Vector(0, 0);
|
||||
scrollDownButton.extent = new Vector(18, 17);
|
||||
scrollDownButton.horizSizing = Right;
|
||||
scrollDownButton.pressedAction = (e) -> {
|
||||
this.scrollY += 10;
|
||||
this.updateScrollVisual();
|
||||
}
|
||||
this.addChild(scrollDownButton);
|
||||
|
||||
this.scrollBarY = new Graphics();
|
||||
this.scrollBarY.scale(Settings.uiScale);
|
||||
this.clickInteractive = new Interactive(10 * Settings.uiScale, 1);
|
||||
this.clickInteractive.onPush = (e) -> {
|
||||
if (!this.pressed) {
|
||||
this.pressed = true;
|
||||
this.dirty = true;
|
||||
this.updateScrollVisual();
|
||||
|
||||
var prevEY:Null<Float> = null;
|
||||
|
||||
this.clickInteractive.startCapture(e2 -> {
|
||||
if (e2.kind == ERelease) {
|
||||
this.clickInteractive.stopCapture();
|
||||
}
|
||||
if (e2.kind == EMove) {
|
||||
if (prevEY == null) {
|
||||
prevEY = e2.relY;
|
||||
} else {
|
||||
this.scrollY += (e2.relY - prevEY);
|
||||
prevEY = e2.relY;
|
||||
this.updateScrollVisual();
|
||||
}
|
||||
}
|
||||
}, () -> {
|
||||
if (this.pressed) {
|
||||
this.pressed = false;
|
||||
this.dirty = true;
|
||||
this.updateScrollVisual();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
this.scrollTrack = new Bitmap(scrollTrackTile);
|
||||
}
|
||||
|
||||
public function setScrollMax(max:Float) {
|
||||
this.scrollY = 0;
|
||||
this.maxScrollY = max;
|
||||
this.dirty = true;
|
||||
this.updateScrollVisual();
|
||||
}
|
||||
|
||||
public override function getRenderRectangle():Rect {
|
||||
var rrec = super.getRenderRectangle();
|
||||
rrec.scroll.y = scrollY * this.maxScrollY / (rrec.extent.y - 34 * Settings.uiScale);
|
||||
return rrec;
|
||||
}
|
||||
|
||||
public override function render(scene2d:Scene) {
|
||||
this.dirty = true;
|
||||
|
||||
scrollUpButton.position = new Vector(this.extent.x - 18, 0);
|
||||
scrollDownButton.position = new Vector(this.extent.x - 18, this.extent.y - 17);
|
||||
|
||||
if (scene2d.contains(scrollTrack))
|
||||
scene2d.removeChild(scrollTrack);
|
||||
|
||||
if (scene2d.contains(scrollBarY))
|
||||
scene2d.removeChild(scrollBarY);
|
||||
|
||||
if (scene2d.contains(clickInteractive))
|
||||
scene2d.removeChild(clickInteractive);
|
||||
|
||||
scene2d.addChild(scrollTrack);
|
||||
scene2d.addChild(scrollBarY);
|
||||
scene2d.addChild(clickInteractive);
|
||||
|
||||
updateScrollVisual();
|
||||
|
||||
super.render(scene2d);
|
||||
}
|
||||
|
||||
public function updateScrollVisual() {
|
||||
var renderRect = this.getRenderRectangle();
|
||||
|
||||
if (maxScrollY < renderRect.extent.y) {
|
||||
scrollBarY.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
this.scrollTrack.setPosition(renderRect.position.x + renderRect.extent.x - 18 * Settings.uiScale, renderRect.position.y);
|
||||
|
||||
var scrollExtentY = renderRect.extent.y - 34 * Settings.uiScale;
|
||||
|
||||
var scrollBarYSize = (scrollExtentY * scrollExtentY / (maxScrollY * Settings.uiScale - 34 * Settings.uiScale));
|
||||
|
||||
this.scrollTrack.scaleY = renderRect.extent.y;
|
||||
|
||||
this.scrollY = Util.clamp(scrollY, 0, scrollExtentY - scrollBarYSize * Settings.uiScale);
|
||||
|
||||
this.scrollBarY.setPosition(renderRect.position.x
|
||||
+ renderRect.extent.x
|
||||
- 18 * Settings.uiScale,
|
||||
18 * Settings.uiScale
|
||||
+ renderRect.position.y
|
||||
+ scrollY);
|
||||
|
||||
this.clickInteractive.setPosition(renderRect.position.x + renderRect.extent.x - 18 * Settings.uiScale, 18 * Settings.uiScale + renderRect.position.y);
|
||||
|
||||
this.clickInteractive.height = scrollExtentY;
|
||||
|
||||
if (this.dirty) {
|
||||
if (scrollBarYSize > scrollExtentY) {
|
||||
scrollBarYSize = scrollExtentY;
|
||||
scrollBarY.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
scrollBarY.clear();
|
||||
|
||||
scrollBarY.tileWrap = true;
|
||||
|
||||
scrollBarY.drawTile(0, 0, pressed ? scrollTopPressedTile : scrollTopTile);
|
||||
|
||||
// :skull:
|
||||
for (i in 0...cast(scrollBarYSize - 12)) {
|
||||
scrollBarY.drawTile(0, i + 8, pressed ? scrollFillPressedTile : scrollFillTile);
|
||||
}
|
||||
|
||||
scrollBarY.drawTile(0, scrollBarYSize - 8, pressed ? scrollBottomPressedTile : scrollBottomTile);
|
||||
|
||||
this.dirty = false;
|
||||
}
|
||||
|
||||
for (c in this.children) {
|
||||
c.onScroll(0, scrollY * (this.maxScrollY - 34 * Settings.uiScale) / scrollExtentY);
|
||||
}
|
||||
}
|
||||
|
||||
public override function dispose() {
|
||||
super.dispose();
|
||||
this.scrollBarY.remove();
|
||||
this.scrollTrack.remove();
|
||||
this.clickInteractive.remove();
|
||||
}
|
||||
|
||||
public function setScrollPercentage(f:Float) {
|
||||
var renderRect = this.getRenderRectangle();
|
||||
var scrollExtentY = renderRect.extent.y - 34 * Settings.uiScale;
|
||||
var scrollBarYSize = (scrollExtentY * scrollExtentY / (maxScrollY * Settings.uiScale - 34 * Settings.uiScale));
|
||||
|
||||
this.scrollY = Util.lerp(0, scrollExtentY - scrollBarYSize * Settings.uiScale, f);
|
||||
updateScrollVisual();
|
||||
}
|
||||
|
||||
public override function onRemove() {
|
||||
super.onRemove();
|
||||
if (MarbleGame.canvas.scene2d.contains(scrollTrack)) {
|
||||
MarbleGame.canvas.scene2d.removeChild(scrollTrack); // Refresh "layer"
|
||||
}
|
||||
if (MarbleGame.canvas.scene2d.contains(scrollBarY)) {
|
||||
MarbleGame.canvas.scene2d.removeChild(scrollBarY); // Refresh "layer"
|
||||
}
|
||||
if (MarbleGame.canvas.scene2d.contains(clickInteractive)) {
|
||||
MarbleGame.canvas.scene2d.removeChild(clickInteractive); // Refresh "layer"
|
||||
}
|
||||
}
|
||||
|
||||
public override function onMousePress(mouseState:MouseState) {
|
||||
if (Util.isTouchDevice()) {
|
||||
this.pressed = true;
|
||||
this.dirty = true;
|
||||
this.updateScrollVisual();
|
||||
this.prevMousePos = mouseState.position;
|
||||
}
|
||||
}
|
||||
|
||||
public override function onMouseRelease(mouseState:MouseState) {
|
||||
if (Util.isTouchDevice()) {
|
||||
this.pressed = false;
|
||||
this.dirty = true;
|
||||
this.updateScrollVisual();
|
||||
}
|
||||
}
|
||||
|
||||
public override function onMouseMove(mouseState:MouseState) {
|
||||
if (Util.isTouchDevice()) {
|
||||
super.onMouseMove(mouseState);
|
||||
if (this.pressed) {
|
||||
var dy = mouseState.position.y - this.prevMousePos.y;
|
||||
this.scrollY -= dy;
|
||||
this.prevMousePos = mouseState.position;
|
||||
this.updateScrollVisual();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// public override function onMouseDown(mouseState:MouseState) {
|
||||
// var renderRect = this.getHitTestRect();
|
||||
// if (mouseState.position.x >= renderRect.position.x + renderRect.extent.x - 10) {
|
||||
// this.scrollY = mouseState.position.y - renderRect.position.y;
|
||||
// this.updateScrollVisual();
|
||||
// }
|
||||
// super.onMouseDown(mouseState);
|
||||
// }
|
||||
}
|
||||
|
|
@ -23,6 +23,7 @@ import mis.MissionElement.MissionElementScriptObject;
|
|||
import src.Util;
|
||||
import h3d.Vector;
|
||||
import h3d.Quat;
|
||||
import src.Console;
|
||||
|
||||
final elementHeadRegEx = ~/new (\w+)\((\w*)\) *{/g;
|
||||
final blockCommentRegEx = ~/\/\*(.|\n)*?\*\//g;
|
||||
|
|
@ -175,7 +176,7 @@ class MisParser {
|
|||
case "ParticleEmitterNode":
|
||||
MisParserMacros.parseObject(name, MissionElementParticleEmitterNode, MissionElementType.ParticleEmitterNode);
|
||||
default:
|
||||
trace("Unknown element type! " + type);
|
||||
Console.warn("Unknown element type! " + type);
|
||||
// Still advance the index
|
||||
var endingBraceIndex = Util.indexOfIgnoreStringLiterals(this.text, '};', this.index);
|
||||
if (endingBraceIndex == -1)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue