Skip to content

Commit

Permalink
docs ingame
Browse files Browse the repository at this point in the history
  • Loading branch information
Vortex2Oblivion committed Feb 17, 2024
1 parent 618a209 commit 136e661
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 16 deletions.
4 changes: 4 additions & 0 deletions docs/docs.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /bin/sh

haxe docs/docs.hxml
haxelib run dox -i docs -o pages --title "Leather Engine Documentation" -ex .*^ -in /*
32 changes: 17 additions & 15 deletions source/docs/DocState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,30 @@ package docs;
import states.LoadingState;
import states.MainMenuState;
import flixel.FlxG;
import flixel.FlxSprite;
import lime.app.Application;
import states.MusicBeatState;
import flixel.util.FlxColor;
import webview.WebView;
import sys.thread.Thread;

class DocState extends MusicBeatState {
var w:WebView = new WebView();
override function create() {
var bg:FlxSprite = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, FlxColor.WHITE);
bg.screenCenter();
add(bg);
w.setSize(FlxG.width, FlxG.height, NONE);
w.setTitle("Youtube");
w.navigate("https://www.youtube.com/");
w.run();
Thread.createWithEventLoop(() ->
{
var w:WebView = new WebView(#if debug true #else false #end);

w.setTitle("Documentation");
w.setSize(FlxG.width, FlxG.height, NONE);
w.navigate("https://vortex2oblivion.github.io/Leather-Engine-Docs/");

Application.current.onExit.add((_) ->
{
w.terminate();
w.destroy();
});
w.run();
});
super.create();
}
override function update(elapsed:Float){
if (FlxG.keys.justPressed.ESCAPE){
LoadingState.loadAndSwitchState(new MainMenuState());
}
super.update(elapsed);
}
}
#end
35 changes: 34 additions & 1 deletion source/toolbox/ToolboxPlaceholder.hx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ class ToolboxPlaceholder extends states.MusicBeatState {
public static var inMenu = false;

public var pages:Map<String, Array<Dynamic>> = [
"Categories" => [
new ToolboxPageOption("Tools", 0, "Tools",),
#if windows
new ToolboxPageOption("Documentation", 1, "Documentation")
#end
],
"Tools" => [
new GameStateOption("Charter", 0, new ChartingState()),
new CharacterCreatorOption("Character Creator", 1, new CharacterCreator("dad", "stage")),
Expand All @@ -48,6 +54,12 @@ class ToolboxPlaceholder extends states.MusicBeatState {
new GameStateOption("Modchart Editor", 3, new modcharting.ModchartEditorState()),
#end
new GameSubstateOption("Import Old Scores", 4, substates.ImportHighscoresSubstate)
],
"Documentation" => [
new WebViewOption("Wiki", 0, "Wiki", "https://github.com/Leather128/LeatherEngine/wiki"),
new WebViewOption("HScript Api", 1, "HScript Api", "https://vortex2oblivion.github.io/Leather-Engine-Docs/"),
new WebViewOption("Lua Api", 2, "Lua Api", "https://github.com/Leather128/LeatherEngine/wiki/Lua-API#lua-api-documentation"),
new WebViewOption("Polymod Docs", 3, "Polymod Docs", "https://polymod.io/docs/")
]
];

Expand Down Expand Up @@ -85,7 +97,7 @@ class ToolboxPlaceholder extends states.MusicBeatState {

add(page);

LoadPage("Tools");
LoadPage("Categories");

if (FlxG.sound.music == null)
FlxG.sound.playMusic(MusicUtilities.GetOptionsMenuMusic(), 0.7, true);
Expand Down Expand Up @@ -162,4 +174,25 @@ class ToolboxPlaceholder extends states.MusicBeatState {
}
}
}
}
/**
* Very simple option that transfers you to a different page when selecting it.
*/
class ToolboxPageOption extends ui.Option {
// OPTIONS //
public var Page_Name:String = "Categories";

override public function new(_Option_Name:String = "", _Option_Row:Int = 0, _Page_Name:String = "Categories", _Description:String = "Test Description") {
super(_Option_Name, _Page_Name, _Option_Row);

// SETTING VALUES //
this.Page_Name = _Page_Name;
}

override function update(elapsed:Float) {
super.update(elapsed);

if (FlxG.keys.justPressed.ENTER && Std.int(Alphabet_Text.targetY) == 0 && !ToolboxPlaceholder.inMenu)
ToolboxPlaceholder.LoadPage(Page_Name);
}
}
42 changes: 42 additions & 0 deletions source/ui/Option.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ui;

import lime.app.Application;
import webview.WebView;
import lime.graphics.Image;
import utilities.CoolUtil;
import states.TitleState;
Expand Down Expand Up @@ -411,3 +413,43 @@ class DisplayFontOption extends StringSaveOption {
}
}

/**
* Very simple option that renders a webpage when selected
*/
class WebViewOption extends Option {
// OPTIONS //
public var Title:String;
public var Url:String;

public function new(_Option_Name:String = "", _Option_Row:Int = 0, Title:String, Url:String) {
super(_Option_Name, null, _Option_Row);

// SETTING VALUES //
this.Url = Url;
this.Title = Title;
}

override function update(elapsed:Float) {
super.update(elapsed);


#if windows
if (FlxG.keys.justPressed.ENTER && Alphabet_Text.targetY == 0)
sys.thread.Thread.createWithEventLoop(() ->
{
var w:webview.WebView = new webview.WebView(#if debug true #else false #end);

w.setTitle(Title);
w.setSize(FlxG.width, FlxG.height, NONE);
w.navigate(Url);

Application.current.onExit.add((_) ->
{
w.terminate();
w.destroy();
});
w.run();
});
#end
}
}

0 comments on commit 136e661

Please sign in to comment.