first skeleton
This commit is contained in:
commit
182709a531
9 changed files with 385 additions and 0 deletions
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
*/.DS_Store
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
*/thumbs.db
|
||||
thumbs.db
|
||||
.thumbs.db?
|
||||
.luxe/
|
||||
_luxe.data/
|
||||
_luxe.deploy/
|
||||
log.txt
|
||||
133
colorpicker.wren
Normal file
133
colorpicker.wren
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
import "luxe: world" for Entity, UIClear
|
||||
import "luxe: ui/control" for Control
|
||||
import "luxe: ui/list" for UIList
|
||||
import "luxe: ui/button" for UIButton
|
||||
|
||||
var Color_spaces = [
|
||||
{
|
||||
"name": "RGB",
|
||||
"components": ["r", "g", "b"],
|
||||
"componentsFull": ["Red", "Green", "Blue"],
|
||||
},
|
||||
{
|
||||
"name": "HSV",
|
||||
"components": ["h", "s", "v"],
|
||||
"componentsFull": ["Hue", "Saturation", "Value"],
|
||||
},
|
||||
{
|
||||
"name": "HSL",
|
||||
"components": ["h", "s", "l"],
|
||||
"componentsFull": ["Hue", "Saturation", "Lightness"],
|
||||
},
|
||||
{
|
||||
"name": "Oklab",
|
||||
"components": ["L", "a", "b"],
|
||||
"componentsFull": ["Lightness", "red/green", "blue/yellow"],
|
||||
}
|
||||
]
|
||||
|
||||
var Modes = [
|
||||
//I wanted to do unicode icons but it doesnt render with the current font
|
||||
{
|
||||
"name": "Triangle",
|
||||
"icon": "tri", //▲
|
||||
},
|
||||
{
|
||||
"name": "Square",
|
||||
"icon": "box", //■
|
||||
},
|
||||
{
|
||||
"name": "Circle",
|
||||
"icon": "round" //●
|
||||
}
|
||||
]
|
||||
|
||||
class ColorPicker{
|
||||
static create(ui: Entity) : Control{
|
||||
//setup root
|
||||
var root = Control.create(ui)
|
||||
Control.set_size(root, 350, 400)
|
||||
|
||||
//setup colorspace buttons
|
||||
//todo: this should be a dropdown???
|
||||
var colorspace_list = UIList.create(ui) //could use naked control but logically its a list?
|
||||
Control.child_add(root, colorspace_list)
|
||||
//base button size is 92x32 btw
|
||||
var space_button_height = 30
|
||||
var space_button_width = 50
|
||||
for(i in 0...Color_spaces.count){
|
||||
var space = Color_spaces[i]
|
||||
var colorspace_button = UIButton.create(ui)
|
||||
Control.set_size(colorspace_button, space_button_width, space_button_height)
|
||||
UIList.add(colorspace_list, colorspace_button)
|
||||
UIButton.set_text(colorspace_button, space["name"])
|
||||
Control.set_pos(colorspace_button, i * space_button_width, 0) //manually set position
|
||||
//todo: add event to actually do stuff here
|
||||
}
|
||||
Control.set_size(colorspace_list, Control.get_width(root).min(space_button_width * Color_spaces.count), space_button_height)
|
||||
//UIList.refresh(colorspace_list) //uilist can only do vertical ordering so far :(
|
||||
|
||||
//setup uimode buttons
|
||||
//todo: this should be a dropdown???
|
||||
var mode_list = UIList.create(ui)
|
||||
Control.child_add(root, mode_list)
|
||||
Control.set_pos(mode_list, 0, space_button_height)
|
||||
//base button size is 92x32 btw
|
||||
var mode_button_height = 30
|
||||
var mode_button_width = 50
|
||||
for(i in 0...Modes.count){
|
||||
var mode = Modes[i]
|
||||
var mode_button = UIButton.create(ui)
|
||||
Control.set_size(mode_button, mode_button_width, mode_button_height)
|
||||
UIList.add(mode_list, mode_button)
|
||||
UIButton.set_text(mode_button, mode["icon"])
|
||||
Control.set_pos(mode_button, i * mode_button_width, 0) //manually set position
|
||||
//todo: add event to actually do stuff here
|
||||
}
|
||||
Control.set_size(mode_list, Control.get_width(root).min(mode_button_width * Modes.count), mode_button_height)
|
||||
|
||||
//setup main editor
|
||||
var main_editor_root = Control.create(ui)
|
||||
Control.child_add(root, main_editor_root)
|
||||
Control.set_size(main_editor_root, 200, 200)
|
||||
Control.set_pos(main_editor_root, 0, mode_button_height + space_button_height)
|
||||
//todo: configurable default editor
|
||||
build_triangle_editor(ui, main_editor_root)
|
||||
|
||||
//setup sliders
|
||||
var sliders_root = Control.create(ui)
|
||||
Control.child_add(root, sliders_root)
|
||||
Control.set_size(sliders_root, 300, 140)
|
||||
Control.set_pos(sliders_root, 0, mode_button_height + space_button_height + 200)
|
||||
|
||||
//setup text input/output
|
||||
var text_io_root = Control.create(ui)
|
||||
Control.child_add(root, text_io_root)
|
||||
Control.set_size(text_io_root, 150, 100)
|
||||
Control.set_pos(text_io_root, 200, 160)
|
||||
|
||||
//setup preview field (old => new)
|
||||
var preview_root = Control.create(ui)
|
||||
Control.child_add(root, preview_root)
|
||||
Control.set_size(preview_root, 150, 100)
|
||||
Control.set_pos(preview_root, 200, 60)
|
||||
|
||||
|
||||
//other stuff? gamma/linear? scene color pick? range toggle (0-1/0-255)? HDR??
|
||||
//todo
|
||||
|
||||
return root
|
||||
}
|
||||
|
||||
static build_triangle_editor(ui: Entity, root: Control){
|
||||
Control.clear(root, UIClear.destroy)
|
||||
}
|
||||
|
||||
static build_square_editor(ui: Entity, root: Control){
|
||||
Control.clear(root, UIClear.destroy)
|
||||
}
|
||||
|
||||
static build_circle_editor(ui: Entity, root: Control){
|
||||
Control.clear(root, UIClear.destroy)
|
||||
}
|
||||
}
|
||||
58
game.wren
Normal file
58
game.wren
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import "luxe: game" for Ready
|
||||
import "luxe: assets" for Assets
|
||||
import "luxe: input" for Input, Key
|
||||
import "luxe: world" for World, Entity, Transform, Sprite, Values, Tags, Camera, UI
|
||||
import "luxe: math" for Math
|
||||
import "luxe: draw" for Draw
|
||||
import "luxe: io" for IO
|
||||
import "luxe: ui/control" for Control
|
||||
|
||||
import "outline/app" for App
|
||||
import "colorpicker" for ColorPicker
|
||||
|
||||
class Game is Ready {
|
||||
|
||||
construct ready() {
|
||||
|
||||
super("ready!")
|
||||
|
||||
app = App.new()
|
||||
app.color.r = app.color.g = app.color.b = 0.7
|
||||
|
||||
System.print("render size: %(app.width) x %(app.height) @ %(app.scale)x")
|
||||
|
||||
_logo = Entity.create(app.world, "sprite")
|
||||
Transform.create(_logo)
|
||||
Transform.set_pos(_logo, app.width/2, app.height/2, 0)
|
||||
Sprite.create(_logo, Assets.material("luxe: material/logo"), 128, 128)
|
||||
|
||||
var ui = Entity.create(app.ui, "ui")
|
||||
UI.create(ui, 0, 0, app.width, app.height, 0, app.ui_camera)
|
||||
var picker = ColorPicker.create(ui)
|
||||
Control.set_pos(picker, 100, 100)
|
||||
} //ready
|
||||
|
||||
tick(delta) {
|
||||
|
||||
var pos = Camera.screen_point_to_world(app.camera, Input.mouse_x(), Input.mouse_y())
|
||||
Transform.set_pos(_logo, pos.x, pos.y, 0)
|
||||
|
||||
if(Input.key_state_released(Key.escape)) {
|
||||
IO.shutdown()
|
||||
}
|
||||
|
||||
//app.color.r = app.color.g = app.color.b = (IO.timestamp()/20 % 1)
|
||||
|
||||
} //tick
|
||||
|
||||
destroy() {
|
||||
|
||||
System.print("unready!")
|
||||
app.destroy()
|
||||
|
||||
} //destroy
|
||||
|
||||
app { _app }
|
||||
app=(v) { _app=v }
|
||||
|
||||
} //Game
|
||||
74
outline/app.wren
Normal file
74
outline/app.wren
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
import "luxe: world" for World, Camera, Entity, Transform
|
||||
import "luxe: render" for Render
|
||||
import "luxe: game" for Frame
|
||||
|
||||
class App {
|
||||
|
||||
world { _world }
|
||||
ui { _ui_world }
|
||||
|
||||
camera { _camera }
|
||||
ui_camera { _ui_camera }
|
||||
|
||||
color { _color }
|
||||
color=(v) { _color = v }
|
||||
|
||||
width { Render.window_w() }
|
||||
height { Render.window_h() }
|
||||
scale { Render.drawable_ratio() }
|
||||
|
||||
construct new() {
|
||||
|
||||
_color = [1,1,1,1]
|
||||
|
||||
//create worlds
|
||||
|
||||
_world = World.create("game")
|
||||
_ui_world = World.create("ui")
|
||||
|
||||
//create cameras
|
||||
|
||||
_camera = Entity.create(_world, "app.camera")
|
||||
Transform.create(_camera)
|
||||
Camera.create(_camera)
|
||||
Camera.set_default(_world, _camera)
|
||||
|
||||
_ui_camera = Entity.create(_ui_world, "app.ui_camera")
|
||||
Transform.create(_ui_camera)
|
||||
Camera.create(_ui_camera)
|
||||
Camera.set_default(_ui_world, _ui_camera)
|
||||
|
||||
//update our worlds
|
||||
|
||||
Frame.on(Frame.sim) {|delta|
|
||||
World.tick(_world, delta)
|
||||
World.tick(_ui_world, delta)
|
||||
}
|
||||
|
||||
//render our worlds
|
||||
|
||||
Frame.on(Frame.visual) {|delta|
|
||||
World.render(_world, _camera, "game", {"clear_color":_color})
|
||||
World.render(_ui_world, _ui_camera, "ui")
|
||||
}
|
||||
|
||||
} //new
|
||||
|
||||
destroy() {
|
||||
|
||||
//destroy cameras
|
||||
|
||||
Camera.destroy(_camera)
|
||||
Camera.destroy(_ui_camera)
|
||||
|
||||
Entity.destroy(_camera)
|
||||
Entity.destroy(_ui_camera)
|
||||
|
||||
//destroy worlds
|
||||
|
||||
World.destroy(_ui_world)
|
||||
World.destroy(_world)
|
||||
|
||||
} //destroy
|
||||
|
||||
} //
|
||||
23
outline/inputs.input.lx
Normal file
23
outline/inputs.input.lx
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
input = {
|
||||
nodes = [
|
||||
{ name = "ui" where = "front" channels = ["c01"] }
|
||||
{ name = "game" where = "after: ui" channels = ["c02"] }
|
||||
]
|
||||
|
||||
map = {
|
||||
left = { keys = ["key_a", "left"] }
|
||||
right = { keys = ["key_d", "right"] }
|
||||
up = { keys = ["key_w", "up"] }
|
||||
down = { keys = ["key_s", "down"] }
|
||||
jump = {
|
||||
keys = ["key_x", "up", "key_w", "space"]
|
||||
mouse = ["left"]
|
||||
gamepad = [0]
|
||||
}
|
||||
|
||||
next = {
|
||||
keys = ["key_x", "up", "key_w", "space", "enter", "escape"]
|
||||
mouse = ["left", "right"]
|
||||
}
|
||||
}
|
||||
}
|
||||
51
outline/renderer.wren
Normal file
51
outline/renderer.wren
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
import "luxe: render" for Render, RenderLayerDesc, PassLayerDesc, LoadAction
|
||||
import "luxe: render" for SortType, ImageDesc, ImageType, PixelFormat
|
||||
|
||||
class Renderer {
|
||||
|
||||
construct new() {
|
||||
|
||||
System.print("game / render / init / ok")
|
||||
|
||||
} //new
|
||||
|
||||
ready() {
|
||||
|
||||
}
|
||||
|
||||
tick(delta) {
|
||||
|
||||
}
|
||||
|
||||
render_path(ctx) {
|
||||
|
||||
if(ctx.path == "game") {
|
||||
game_render_path(ctx)
|
||||
} else if(ctx.path == "ui") {
|
||||
ui_render_path(ctx)
|
||||
}
|
||||
|
||||
} //render_path
|
||||
|
||||
game_render_path(ctx) {
|
||||
|
||||
var layer = RenderLayerDesc.new()
|
||||
layer.dest.color[0].clear_color = ctx.get("clear_color", [1,1,1,1])
|
||||
layer.dest.color[0].load_action = LoadAction.clear
|
||||
layer.dest.depth.load_action = LoadAction.clear
|
||||
|
||||
ctx.layer_render("default", layer)
|
||||
|
||||
} //game_render_path
|
||||
|
||||
ui_render_path(ctx) {
|
||||
|
||||
var layer = RenderLayerDesc.new()
|
||||
layer.dest.color[0].load_action = LoadAction.dont_care
|
||||
layer.dest.depth.load_action = LoadAction.clear
|
||||
|
||||
ctx.layer_render("default", layer)
|
||||
|
||||
} //ui_render_path
|
||||
|
||||
} //Renderer
|
||||
19
outline/settings.settings.lx
Normal file
19
outline/settings.settings.lx
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
engine = {
|
||||
input.entry = "outline/inputs"
|
||||
runtime = {
|
||||
window = {
|
||||
width = 960
|
||||
height = 640
|
||||
resizable = false
|
||||
fullscreen = false
|
||||
}
|
||||
}
|
||||
|
||||
render = {
|
||||
antialiasing = 2
|
||||
stencil = 8
|
||||
depth = 24
|
||||
}
|
||||
|
||||
ui.debug_vis = true
|
||||
}
|
||||
14
project.luxe
Normal file
14
project.luxe
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import "luxe: project" for Entry
|
||||
|
||||
class Project is Entry {
|
||||
|
||||
construct entry(target) {
|
||||
|
||||
name = "ColorPicker"
|
||||
version = "0.0.1"
|
||||
renderer = "outline/renderer"
|
||||
settings = "outline/settings"
|
||||
|
||||
} //new
|
||||
|
||||
} //Project
|
||||
3
project.modules.lx
Normal file
3
project.modules.lx
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
modules = {
|
||||
luxe = "2021.0.2"
|
||||
} //modules
|
||||
Loading…
Reference in a new issue