ng release and blank controls

This commit is contained in:
Brandon
2020-11-01 14:16:22 -05:00
parent 968a001a36
commit 5fa4bc458e
65 changed files with 3468 additions and 126 deletions

View File

@@ -0,0 +1,44 @@
package io.newgrounds.components;
import io.newgrounds.objects.events.Result;
import io.newgrounds.objects.events.Result.SessionResult;
import io.newgrounds.NGLite;
class AppComponent extends Component {
public function new (core:NGLite) { super(core); }
public function startSession(force:Bool = false):Call<SessionResult> {
return new Call<SessionResult>(_core, "App.startSession")
.addComponentParameter("force", force, false);
}
public function checkSession():Call<SessionResult> {
return new Call<SessionResult>(_core, "App.checkSession", true);
}
public function endSession():Call<SessionResult> {
return new Call<SessionResult>(_core, "App.endSession", true);
}
public function getCurrentVersion(version:String):Call<GetCurrentVersionResult> {
return new Call<GetCurrentVersionResult>(_core, "App.getCurrentVersion")
.addComponentParameter("version", version);
}
public function getHostLicense():Call<GetHostResult> {
return new Call<GetHostResult>(_core, "App.getHostLicense")
.addComponentParameter("host", _core.host);
}
public function logView():Call<ResultBase> {
return new Call<ResultBase>(_core, "App.logView")
.addComponentParameter("host", _core.host);
}
}

View File

@@ -0,0 +1,13 @@
package io.newgrounds.components;
import io.newgrounds.NGLite;
class Component {
var _core:NGLite;
public function new(core:NGLite) {
this._core = core;
}
}

View File

@@ -0,0 +1,25 @@
package io.newgrounds.components;
class ComponentList {
var _core:NGLite;
// --- COMPONENTS
public var medal : MedalComponent;
public var app : AppComponent;
public var event : EventComponent;
public var scoreBoard: ScoreBoardComponent;
public var loader : LoaderComponent;
public var gateway : GatewayComponent;
public function new(core:NGLite) {
_core = core;
medal = new MedalComponent (_core);
app = new AppComponent (_core);
event = new EventComponent (_core);
scoreBoard = new ScoreBoardComponent(_core);
loader = new LoaderComponent (_core);
gateway = new GatewayComponent (_core);
}
}

View File

@@ -0,0 +1,16 @@
package io.newgrounds.components;
import io.newgrounds.objects.events.Result.LogEventResult;
import io.newgrounds.NGLite;
class EventComponent extends Component {
public function new (core:NGLite){ super(core); }
public function logEvent(eventName:String):Call<LogEventResult> {
return new Call<LogEventResult>(_core, "Event.logEvent")
.addComponentParameter("event_name", eventName)
.addComponentParameter("host", _core.host);
}
}

View File

@@ -0,0 +1,25 @@
package io.newgrounds.components;
import io.newgrounds.objects.events.Result;
import io.newgrounds.NGLite;
class GatewayComponent extends Component {
public function new (core:NGLite){ super(core); }
public function getDatetime():Call<GetDateTimeResult> {
return new Call<GetDateTimeResult>(_core, "Gateway.getDatetime");
}
public function getVersion():Call<GetVersionResult> {
return new Call<GetVersionResult>(_core, "Gateway.getVersion");
}
public function ping():Call<PingResult> {
return new Call<PingResult>(_core, "Gateway.ping");
}
}

View File

@@ -0,0 +1,44 @@
package io.newgrounds.components;
import io.newgrounds.objects.events.Result;
import io.newgrounds.NGLite;
class LoaderComponent extends Component {
public function new (core:NGLite){ super(core); }
public function loadAuthorUrl(redirect:Bool = false):Call<ResultBase> {
return new Call<ResultBase>(_core, "Loader.loadAuthorUrl")
.addComponentParameter("host", _core.host)
.addComponentParameter("redirect", redirect, true);
}
public function loadMoreGames(redirect:Bool = false):Call<ResultBase> {
return new Call<ResultBase>(_core, "Loader.loadMoreGames")
.addComponentParameter("host", _core.host)
.addComponentParameter("redirect", redirect, true);
}
public function loadNewgrounds(redirect:Bool = false):Call<ResultBase> {
return new Call<ResultBase>(_core, "Loader.loadNewgrounds")
.addComponentParameter("host", _core.host)
.addComponentParameter("redirect", redirect, true);
}
public function loadOfficialUrl(redirect:Bool = false):Call<ResultBase> {
return new Call<ResultBase>(_core, "Loader.loadOfficialUrl")
.addComponentParameter("host", _core.host)
.addComponentParameter("redirect", redirect, true);
}
public function loadReferral(redirect:Bool = false):Call<ResultBase> {
return new Call<ResultBase>(_core, "Loader.loadReferral")
.addComponentParameter("host", _core.host)
.addComponentParameter("redirect", redirect, true);
}
}

View File

@@ -0,0 +1,21 @@
package io.newgrounds.components;
import io.newgrounds.objects.events.Result;
import io.newgrounds.Call;
import io.newgrounds.NGLite;
class MedalComponent extends Component {
public function new(core:NGLite):Void { super(core); }
public function unlock(id:Int):Call<MedalUnlockResult> {
return new Call<MedalUnlockResult>(_core, "Medal.unlock", true, true)
.addComponentParameter("id", id);
}
public function getList():Call<MedalListResult> {
return new Call<MedalListResult>(_core, "Medal.getList");
}
}

View File

@@ -0,0 +1,114 @@
package io.newgrounds.components;
import io.newgrounds.objects.User;
import io.newgrounds.objects.events.Response;
import io.newgrounds.objects.events.Result;
import io.newgrounds.objects.events.Result.ScoreBoardResult;
import io.newgrounds.objects.events.Result.ScoreResult;
import io.newgrounds.NGLite;
import io.newgrounds.objects.ScoreBoard;
import haxe.ds.IntMap;
class ScoreBoardComponent extends Component {
public var allById:IntMap<ScoreBoard>;
public function new (core:NGLite){ super(core); }
// -------------------------------------------------------------------------------------------
// GET SCORES
// -------------------------------------------------------------------------------------------
public function getBoards():Call<ScoreBoardResult> {
return new Call<ScoreBoardResult>(_core, "ScoreBoard.getBoards");
}
/*function onBoardsReceive(response:Response<ScoreBoardResult>):Void {
if (!response.result.success)
return;
allById = new IntMap<ScoreBoard>();
for (boardData in response.result.scoreboards)
createBoard(boardData);
_core.log('${response.result.scoreboards.length} ScoreBoards loaded');
}*/
// -------------------------------------------------------------------------------------------
// GET SCORES
// -------------------------------------------------------------------------------------------
public function getScores
( id :Int
, limit :Int = 10
, skip :Int = 0
, period:Period = Period.DAY
, social:Bool = false
, tag :String = null
, user :Dynamic = null
):Call<ScoreResult> {
if (user != null && !Std.is(user, String) && !Std.is(user, Int))
user = user.id;
return new Call<ScoreResult>(_core, "ScoreBoard.getScores")
.addComponentParameter("id" , id )
.addComponentParameter("limit" , limit , 10)
.addComponentParameter("skip" , skip , 0)
.addComponentParameter("period", period, Period.DAY)
.addComponentParameter("social", social, false)
.addComponentParameter("tag" , tag , null)
.addComponentParameter("user" , user , null);
}
// -------------------------------------------------------------------------------------------
// POST SCORE
// -------------------------------------------------------------------------------------------
public function postScore(id:Int, value:Int, tag:String = null):Call<PostScoreResult> {
return new Call<PostScoreResult>(_core, "ScoreBoard.postScore", true, true)
.addComponentParameter("id" , id)
.addComponentParameter("value", value)
.addComponentParameter("tag" , tag , null);
}
/*function onScorePosted(response:Response<ResultBase>):Void {
if (!response.result.success)
return;
allById = new IntMap<ScoreBoard>();
//createBoard(data.data.scoreBoard).parseScores(data.data.scores);
}*/
inline function createBoard(data:Dynamic):ScoreBoard {
var board = new ScoreBoard(_core, data);
_core.logVerbose('created $board');
allById.set(board.id, board);
return board;
}
}
@:enum
abstract Period(String) to String from String{
/** Indicates scores are from the current day. */
var DAY = "D";
/** Indicates scores are from the current week. */
var WEEK = "W";
/** Indicates scores are from the current month. */
var MONTH = "M";
/** Indicates scores are from the current year. */
var YEAR = "Y";
/** Indicates scores are from all-time. */
var ALL = "A";
}