added BinStore
This commit is contained in:
parent
16b7db779f
commit
94d02d60af
@ -1,5 +1,6 @@
|
||||
package kernel;
|
||||
|
||||
import kernel.binstore.BinStore;
|
||||
import kernel.gps.INS;
|
||||
import kernel.fs.FS;
|
||||
import kernel.gps.GPS;
|
||||
@ -27,6 +28,8 @@ class Init {
|
||||
WindowManager.instance = new WindowManager();
|
||||
MainTerm.instance = new MainTerm();
|
||||
|
||||
BinStore.instance = new BinStore();
|
||||
|
||||
if (Turtle.isTurtle()){
|
||||
Turtle.instance = new Turtle();
|
||||
}
|
||||
|
12
src/kernel/binstore/Bin.hx
Normal file
12
src/kernel/binstore/Bin.hx
Normal file
@ -0,0 +1,12 @@
|
||||
package kernel.binstore;
|
||||
|
||||
import kernel.ps.Process;
|
||||
|
||||
/**
|
||||
Represents a callable program.
|
||||
**/
|
||||
typedef Bin = {
|
||||
c: Class<Process>,
|
||||
name: String,
|
||||
aliases: Array<String>,
|
||||
}
|
51
src/kernel/binstore/BinStore.hx
Normal file
51
src/kernel/binstore/BinStore.hx
Normal file
@ -0,0 +1,51 @@
|
||||
package kernel.binstore;
|
||||
|
||||
import bin.Turtle;
|
||||
import bin.Terminal;
|
||||
import haxe.ds.ReadOnlyArray;
|
||||
import bin.Redstone;
|
||||
import bin.Net;
|
||||
import bin.KernelLog;
|
||||
import bin.HelloWorld;
|
||||
import bin.GPS;
|
||||
import bin.Disk;
|
||||
|
||||
class BinStore {
|
||||
public static var instance: BinStore;
|
||||
|
||||
private final store:ReadOnlyArray<Bin> = [
|
||||
{c: Disk, name: "Disk", aliases: ["disk"]},
|
||||
{c: GPS, name: "GPS", aliases: ["gps"]},
|
||||
{c: HelloWorld, name: "HelloWorld", aliases: ["hello"]},
|
||||
{c: KernelLog, name: "KernelLog", aliases: ["log"]},
|
||||
{c: Net, name: "Net", aliases: ["net"]},
|
||||
{c: Redstone, name: "Redstone", aliases: ["redstone","rs"]},
|
||||
{c: Terminal, name: "Terminal", aliases: ["terminal","term"]},
|
||||
{c: Turtle, name: "Turtle", aliases: ["turtle"]}
|
||||
];
|
||||
|
||||
@:allow(kernel.Init)
|
||||
private function new() {
|
||||
|
||||
}
|
||||
|
||||
public function getBinByName(name:String):Null<Bin> {
|
||||
for (bin in store) {
|
||||
if (bin.name == name) {
|
||||
return bin;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getBinByAlias(alias:String):Null<Bin> {
|
||||
for (bin in store) {
|
||||
for (a in bin.aliases) {
|
||||
if (a == alias) {
|
||||
return bin;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user