Skip to content

Commit 1f55fe8

Browse files
committed
Add class to manage slash commands
1 parent bf13800 commit 1f55fe8

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

src/wowhaxe/FontString.hx

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package wowhaxe;
2+
3+
import wowhaxe.data.*;
4+
5+
extern class FontString {
6+
public function GetFont(): FontInfo;
7+
public function GetFontObject(): FontInstance;
8+
public function GetJustifyH(): String;
9+
public function GetJustifyV(): String;
10+
public function GetShadowColor(): FontColor;
11+
public function GetShadowOffset(): FontOffset;
12+
public function GetSpacing(): Float;
13+
public function GetTextColor(): FontColor;
14+
public function SetFont(path: String, height: Float, ?flags: String): Void;
15+
public function SetJustifyH(justifyH: String): Void;
16+
public function SetJustifyV(justifyV: String): Void;
17+
public function SetShadowColor(r: Float, g: Float, b: Float, ?a: Float): Void;
18+
public function SetShadowOffset(x: Float, y: Float): Void;
19+
public function SetSpacing(spacing: Float): Void;
20+
public function SetTextColor(r: Float, g: Float, b: Float, ?a: Float): Void;
21+
}

src/wowhaxe/Main.hx

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ class Main {
3030
frame.RegisterEvent("ADDON_LOADED");
3131
frame.RegisterEvent("PLAYER_ENTERING_WORLD");
3232
frame.RegisterEvent("ZONE_CHANGED_NEW_AREA");
33+
34+
SlashCommands.register("WOWHAXE", ["wowhaxe"], function(msg, editBox) {
35+
trace(msg);
36+
});
3337
}
3438

3539
private static function addonLoaded(name: String) {

src/wowhaxe/SlashCommands.hx

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package wowhaxe;
2+
3+
typedef SlashCommandHandler = String -> EditBox -> Void;
4+
5+
class SlashCommands {
6+
public static function get(key: String): SlashCommandHandler {
7+
return untyped __lua__("_G.SlashCmdList[key]");
8+
}
9+
10+
public static function register(key: String, aliases: Array<String>, handler: SlashCommandHandler) {
11+
for (i in 0...aliases.length) {
12+
var name = 'SLASH_$key${i + 1}';
13+
var slash = '/${aliases[i]}';
14+
untyped __lua__("_G[name] = slash");
15+
}
16+
17+
untyped __lua__("_G.SlashCmdList[key] = handler");
18+
}
19+
}

0 commit comments

Comments
 (0)