First commit
This commit is contained in:
321
bin/fennec.js
Normal file
321
bin/fennec.js
Normal file
@@ -0,0 +1,321 @@
|
||||
const BackgroundTypes = {
|
||||
IMAGE: 0,
|
||||
SOLID: 1,
|
||||
GRADIENT: 2
|
||||
}
|
||||
|
||||
const BorderTypes = {
|
||||
NONE: 0,
|
||||
SOLID: 1
|
||||
}
|
||||
|
||||
const Colors = {
|
||||
WHITE: new N3DSColorRGBA(255, 255, 255, 1),
|
||||
BLACK: new N3DSColorRGBA(0, 0, 0, 1)
|
||||
}
|
||||
|
||||
const FontStyles = {
|
||||
NORMAL: 0,
|
||||
ITALIC: 1,
|
||||
OBLIQUE: 2
|
||||
}
|
||||
|
||||
const Screens = {
|
||||
TOP: 0,
|
||||
BOTTOM: 1
|
||||
}
|
||||
|
||||
const Languages = {
|
||||
DEFAULT: "FR"
|
||||
}
|
||||
|
||||
class Fennec {
|
||||
constructor() {
|
||||
this.screens = {
|
||||
Top: new N3DSScreen(Screens.TOP),
|
||||
Bottom: new N3DSScreen(Screens.Bottom)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function} callback
|
||||
*/
|
||||
onGameLoop(callback) {
|
||||
callback()
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function} callback
|
||||
*/
|
||||
onControlClicked(callback) {
|
||||
callback()
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function} callback
|
||||
*/
|
||||
onTouched(callback) {
|
||||
callback()
|
||||
}
|
||||
|
||||
invokeKeyboard() {
|
||||
return null
|
||||
}
|
||||
|
||||
getSystemLanguage() {
|
||||
return Languages.DEFAULT
|
||||
}
|
||||
}
|
||||
|
||||
class N3DSAsset {
|
||||
constructor(location) {
|
||||
this.location = location
|
||||
}
|
||||
}
|
||||
|
||||
class Background {
|
||||
/**
|
||||
* @param {BackgroundTypes.IMAGE | BackgroundTypes.SOLID | BackgroundTypes} type
|
||||
* @param {N3DSColorHEX | N3DSColorRGB | N3DSColorRGBA | N3DSAsset} source
|
||||
*/
|
||||
constructor(type, source) {
|
||||
this.type = type
|
||||
this.source = source
|
||||
}
|
||||
|
||||
draw(x, y, z, width, height) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class N3DSColorRGBA {
|
||||
/**
|
||||
* @param {Number} red
|
||||
* @param {Number} green
|
||||
* @param {Number} blue
|
||||
* @param {Number} alpha
|
||||
*/
|
||||
constructor(red, green, blue, alpha) {
|
||||
this.red = red
|
||||
this.green = green
|
||||
this.blue = blue
|
||||
this.alpha = alpha
|
||||
}
|
||||
}
|
||||
|
||||
class N3DSColorRGB {
|
||||
/**
|
||||
*
|
||||
* @param {Number} red
|
||||
* @param {Number} green
|
||||
* @param {Number} blue
|
||||
*/
|
||||
constructor(red, green, blue) {
|
||||
this.red = red
|
||||
this.green = green
|
||||
this.blue = blue
|
||||
this.alpha = 1
|
||||
}
|
||||
}
|
||||
|
||||
class N3DSColorHEX {
|
||||
/**
|
||||
* @param {string} hexCode
|
||||
*/
|
||||
constructor(hexCode) {
|
||||
this.hexCode = hexCode
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {N3DSColorRGB}
|
||||
*/
|
||||
toRGB() {
|
||||
const convertedColor = ColorsHelper.fromHexToRGB(this.hexCode)
|
||||
return convertedColor
|
||||
}
|
||||
|
||||
toRGBA() {
|
||||
const convertedColor = ColorsHelper.fromHexToRGBA(this.hexCode)
|
||||
return convertedColor
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Border {
|
||||
/**
|
||||
* @param {Number} top
|
||||
* @param {Number} left
|
||||
* @param {Number} right
|
||||
* @param {Number} bottom
|
||||
* @param {BorderTypes.DOTTED | BorderTypes.DASHED | BorderTypes.SOLID | BorderTypes.DOUBLE | BorderTypes.RIDGE | BorderTypes.INSET | BorderTypes.OUTSET | BorderTypes.NONE | BorderTypes.MIXED} type
|
||||
* @param {Background} background
|
||||
*/
|
||||
constructor(top, left, right, bottom, type, background, radius) {
|
||||
this.top = top
|
||||
this.left = left
|
||||
this.right = right
|
||||
this.bottom = bottom
|
||||
this.type = type || BorderTypes.SOLID
|
||||
this.background = background || new Background(BackgroundTypes.SOLID, Colors.BLACK)
|
||||
}
|
||||
}
|
||||
|
||||
class Font {
|
||||
/**
|
||||
* @param {N3DSAsset} source
|
||||
* @param {string} name
|
||||
*/
|
||||
constructor(source, name) {
|
||||
this.source = source
|
||||
this.name = name
|
||||
}
|
||||
}
|
||||
|
||||
class FontSetting {
|
||||
/**
|
||||
* @param {Font} font
|
||||
* @param {Number} weight
|
||||
* @param {FontStyles.NORMAL | FontStyles.ITALIC | FontStyles.OBLIQUE} style
|
||||
*/
|
||||
constructor(font, weight, style) {
|
||||
this.font = font
|
||||
this.weight = weight
|
||||
this.style = style
|
||||
}
|
||||
}
|
||||
|
||||
class N3DSText {
|
||||
/**
|
||||
* @param {string} value
|
||||
* @param {FontSetting} fontSpec
|
||||
*/
|
||||
constructor(value, fontSpec) {
|
||||
this.value = value
|
||||
this.fontSpec = fontSpec
|
||||
}
|
||||
}
|
||||
|
||||
class Placeholder {
|
||||
/**
|
||||
* @param {Text} title
|
||||
* @param {N3DSColorHEX | N3DSColorRGB | N3DSColorRGBA} color
|
||||
* @param {Number} x
|
||||
* @param {Number} y
|
||||
* @param {Number} z
|
||||
* @param {Background | null} background
|
||||
* @param {Border} border
|
||||
*/
|
||||
constructor(title, color, background, border) {
|
||||
this.title = title || new N3DSText()
|
||||
this.color = color || Colors.BLACK
|
||||
this.background = background || new Background(BackgroundTypes.SOLID, Colors.WHITE)
|
||||
this.border = border || new Border(10, )
|
||||
}
|
||||
|
||||
draw(x, y, z, width, height) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class InputField {
|
||||
/**
|
||||
* @param {Placeholder} placeholder
|
||||
*/
|
||||
constructor(placeholder) {
|
||||
this.placeholder = placeholder || new Placeholder("Enter your text here", Colors.BLACK, 0, null, 0, new Background(BackgroundTypes.SOLID, Colors.WHITE))
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function} callback
|
||||
*/
|
||||
onChanged(callback) {
|
||||
callback()
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function} callback
|
||||
*/
|
||||
onKeypressed(callback) {
|
||||
callback()
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function} callback
|
||||
*/
|
||||
onClicked(callback) {
|
||||
callback()
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function} callback
|
||||
*/
|
||||
onCoordinatesChanges(callback) {
|
||||
callback()
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function} callback
|
||||
*/
|
||||
onReset(callback) {
|
||||
callback()
|
||||
}
|
||||
|
||||
|
||||
draw(x, y, z, width, height) {
|
||||
this.placeholder.draw(x, y, z, width, height)
|
||||
}
|
||||
}
|
||||
|
||||
class Graphics2D {
|
||||
/**
|
||||
* @param {N3DSText} text
|
||||
*/
|
||||
drawText(text) {
|
||||
return text
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Number} x
|
||||
* @param {Number} y
|
||||
* @param {Number} z
|
||||
* @param {Number} width
|
||||
* @param {Number} height
|
||||
* @param {Background} background
|
||||
* @param {Border} border
|
||||
*/
|
||||
drawRect(x, y, z, width, height, background, border) {
|
||||
return { x, y, z, width, height, background, border }
|
||||
}
|
||||
}
|
||||
|
||||
class N3DSScreen {
|
||||
/**
|
||||
* @param {Screens.TOP | Screens.BOTTOM} position
|
||||
*/
|
||||
constructor(position) {
|
||||
this.position = position
|
||||
this.graphics2d = new Graphics2D()
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
Background,
|
||||
BackgroundTypes,
|
||||
Border,
|
||||
BorderTypes,
|
||||
Colors,
|
||||
Fennec,
|
||||
Font,
|
||||
FontSetting,
|
||||
FontStyles,
|
||||
Graphics2D,
|
||||
InputField,
|
||||
Languages,
|
||||
N3DSAsset,
|
||||
N3DSColorHEX,
|
||||
N3DSColorRGB,
|
||||
N3DSColorRGBA,
|
||||
N3DSScreen,
|
||||
N3DSText,
|
||||
Placeholder
|
||||
}
|
||||
Reference in New Issue
Block a user