make everything run!

fixed a few minor issues where i changed the library and there were some breaking changes. everything now compiles and the editor will now run and close properly, still no key input but events are somewhat properly handled.
This commit is contained in:
Felix Angell 2017-11-04 14:20:13 +00:00
parent 5ad1c514b4
commit 0756852058
2 changed files with 33 additions and 16 deletions

View File

@ -101,6 +101,11 @@ func (b *Buffer) processTextInput() {
}
func (b *Buffer) processActionKey() {
// we dont process key input so
// these are a bunch of stupid dummy case statements but
// the logic for them should work! we just need to handle
// key events which hasn't been implemented properly in the
// strife library yet.
switch {
case 2 == 6:
initial_x := b.curs.x

44
main.go
View File

@ -22,7 +22,7 @@ type NateEditor struct {
func (n *NateEditor) init(cfg *cfg.TomlConfig) {
n.AddComponent(gui.NewView(800, 600, cfg))
font, err := strife.LoadFont("./res/firacode.ttf")
font, err := strife.LoadFont("./res/firacode.ttf", 14)
if err != nil {
panic(err)
}
@ -42,29 +42,29 @@ func (n *NateEditor) update() {
}
func (n *NateEditor) render(ctx *strife.Renderer) {
ctx.Clear()
ctx.SetFont(n.defaultFont)
for _, child := range n.GetComponents() {
gui.Render(child, ctx)
}
ctx.Display()
}
func main() {
config := cfg.Setup()
windowWidth, windowHeight := 800, 600
window, err := strife.CreateRenderWindow(windowWidth, windowHeight, &strife.RenderConfig{
Alias: true,
Accelerated: false,
VerticalSync: false,
ww, wh := 800, 600
window := strife.SetupRenderWindow(ww, wh, strife.DefaultConfig())
window.SetTitle("Hello world!")
window.SetResizable(true)
window.Create()
window.HandleEvents(func (evt strife.StrifeEvent) {
switch evt.(type) {
case *strife.CloseEvent:
window.Close()
}
})
if err != nil {
panic(err)
}
{
size := "16"
@ -83,7 +83,8 @@ func main() {
if err != nil {
panic(err)
}
window.SetIcon(icon)
window.SetIconImage(icon)
defer icon.Destroy()
}
editor := &NateEditor{running: true}
@ -92,9 +93,20 @@ func main() {
timer := strife.CurrentTimeMillis()
num_frames := 0
for !window.CloseRequested() {
for {
window.PollEvents()
if window.CloseRequested() {
break
}
editor.update()
editor.render(window.GetRenderContext())
{
ctx := window.GetRenderContext()
ctx.Clear()
editor.render(ctx)
ctx.Display()
}
num_frames += 1
if strife.CurrentTimeMillis()-timer > 1000 {