Code Layout Refactor
* All private Doodle source code into the pkg/ folder. * Potentially public code into the lib/ folder. * Centralize the logger into a subpackage.
This commit is contained in:
parent
d0ff137b04
commit
2b42a072a0
2
Makefile
2
Makefile
|
@ -1,6 +1,6 @@
|
|||
SHELL := /bin/bash
|
||||
|
||||
VERSION=$(shell grep -e 'Version =' doodle.go | head -n 1 | cut -d '"' -f 2)
|
||||
VERSION=$(shell grep -e 'Version =' pkg/doodle.go | head -n 1 | cut -d '"' -f 2)
|
||||
BUILD=$(shell git describe --always)
|
||||
CURDIR=$(shell curdir)
|
||||
|
||||
|
|
|
@ -11,10 +11,11 @@ import (
|
|||
|
||||
"image/png"
|
||||
|
||||
"git.kirsle.net/apps/doodle"
|
||||
"git.kirsle.net/apps/doodle/doodads"
|
||||
"git.kirsle.net/apps/doodle/level"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
doodle "git.kirsle.net/apps/doodle/pkg"
|
||||
"git.kirsle.net/apps/doodle/pkg/doodads"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"github.com/urfave/cli"
|
||||
"golang.org/x/image/bmp"
|
||||
)
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
package commands
|
||||
|
||||
import "github.com/kirsle/golog"
|
||||
|
||||
var log *golog.Logger
|
||||
|
||||
func init() {
|
||||
log = golog.GetLogger("doodad")
|
||||
log.Configure(&golog.Config{
|
||||
Level: golog.InfoLevel,
|
||||
Theme: golog.DarkTheme,
|
||||
Colors: golog.ExtendedColor,
|
||||
})
|
||||
}
|
|
@ -6,8 +6,8 @@ import (
|
|||
"os"
|
||||
"sort"
|
||||
|
||||
"git.kirsle.net/apps/doodle"
|
||||
"git.kirsle.net/apps/doodle/cmd/doodad/commands"
|
||||
doodle "git.kirsle.net/apps/doodle/pkg"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
|
|
@ -4,11 +4,11 @@ import (
|
|||
"flag"
|
||||
"runtime"
|
||||
|
||||
"git.kirsle.net/apps/doodle"
|
||||
"git.kirsle.net/apps/doodle/balance"
|
||||
"git.kirsle.net/apps/doodle/render/sdl"
|
||||
|
||||
_ "image/png"
|
||||
|
||||
"git.kirsle.net/apps/doodle/lib/render/sdl"
|
||||
doodle "git.kirsle.net/apps/doodle/pkg"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
)
|
||||
|
||||
// Build number is the git commit hash.
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
package level
|
||||
|
||||
import "github.com/kirsle/golog"
|
||||
|
||||
var log *golog.Logger
|
||||
|
||||
func init() {
|
||||
log = golog.GetLogger("doodle")
|
||||
}
|
|
@ -3,7 +3,7 @@ package draw
|
|||
import (
|
||||
"math"
|
||||
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
)
|
||||
|
||||
// Line is a generator that returns the X,Y coordinates to draw a line.
|
|
@ -4,8 +4,8 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"git.kirsle.net/apps/doodle/draw"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/draw"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
)
|
||||
|
||||
func TestLine(t *testing.T) {
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
"math"
|
||||
|
||||
"git.kirsle.net/apps/doodle/events"
|
||||
"git.kirsle.net/apps/doodle/lib/events"
|
||||
)
|
||||
|
||||
// Engine is the interface for the rendering engine, keeping SDL-specific stuff
|
|
@ -4,7 +4,7 @@ import (
|
|||
"strconv"
|
||||
"testing"
|
||||
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
)
|
||||
|
||||
func TestPointInside(t *testing.T) {
|
|
@ -4,7 +4,7 @@ import (
|
|||
"strconv"
|
||||
"testing"
|
||||
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
)
|
||||
|
||||
func TestIntersection(t *testing.T) {
|
|
@ -2,7 +2,7 @@
|
|||
package sdl
|
||||
|
||||
import (
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
)
|
||||
|
|
@ -3,7 +3,7 @@ package sdl
|
|||
import (
|
||||
"errors"
|
||||
|
||||
"git.kirsle.net/apps/doodle/events"
|
||||
"git.kirsle.net/apps/doodle/lib/events"
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
)
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
package sdl
|
||||
|
||||
import (
|
||||
"git.kirsle.net/apps/doodle/level"
|
||||
)
|
||||
import "git.kirsle.net/apps/doodle/pkg/level"
|
||||
|
||||
// Frames to cache for FPS calculation.
|
||||
const (
|
|
@ -4,8 +4,8 @@ package sdl
|
|||
import (
|
||||
"time"
|
||||
|
||||
"git.kirsle.net/apps/doodle/events"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/events"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
)
|
|
@ -4,8 +4,8 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.kirsle.net/apps/doodle/events"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/events"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
)
|
|
@ -3,7 +3,7 @@ package sdl
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package sdl
|
||||
|
||||
import (
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
)
|
||||
|
|
@ -4,8 +4,8 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/ui/theme"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/lib/ui/theme"
|
||||
)
|
||||
|
||||
// Button is a clickable button.
|
|
@ -4,8 +4,8 @@ import (
|
|||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/ui/theme"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/lib/ui/theme"
|
||||
)
|
||||
|
||||
// CheckButton implements a checkbox and radiobox widget. It's based on a
|
|
@ -1,6 +1,6 @@
|
|||
package ui
|
||||
|
||||
import "git.kirsle.net/apps/doodle/render"
|
||||
import "git.kirsle.net/apps/doodle/lib/render"
|
||||
|
||||
// Checkbox combines a CheckButton with a widget like a Label.
|
||||
type Checkbox struct {
|
|
@ -3,7 +3,7 @@ package ui
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
)
|
||||
|
||||
// Frame is a widget that contains other widgets.
|
|
@ -1,6 +1,8 @@
|
|||
package ui
|
||||
|
||||
import "git.kirsle.net/apps/doodle/render"
|
||||
import (
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
)
|
||||
|
||||
// Pack provides configuration fields for Frame.Pack().
|
||||
type Pack struct {
|
||||
|
@ -223,7 +225,7 @@ func (w *Frame) computePacked(e render.Engine) {
|
|||
moved = true
|
||||
}
|
||||
} else {
|
||||
log.Error("unsupported pack.Anchor")
|
||||
panic("unsupported pack.Anchor")
|
||||
}
|
||||
|
||||
if resized && size != resize {
|
|
@ -1,6 +1,6 @@
|
|||
package ui
|
||||
|
||||
import "git.kirsle.net/apps/doodle/render"
|
||||
import "git.kirsle.net/apps/doodle/lib/render"
|
||||
|
||||
// AbsolutePosition computes a widget's absolute X,Y position on the
|
||||
// window on screen by crawling its parent widget tree.
|
|
@ -5,7 +5,7 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
)
|
||||
|
||||
// ImageType for supported image formats.
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
)
|
||||
|
||||
// DefaultFont is the default font settings used for a Label.
|
||||
|
@ -71,7 +71,7 @@ func (w *Label) Compute(e render.Engine) {
|
|||
text.Text = line // only this line at this time.
|
||||
rect, err := e.ComputeTextRect(text)
|
||||
if err != nil {
|
||||
log.Error("%s: failed to compute text rect: %s", w, err)
|
||||
panic(fmt.Sprintf("%s: failed to compute text rect: %s", w, err)) // TODO return an error
|
||||
return
|
||||
}
|
||||
|
|
@ -4,8 +4,8 @@ import (
|
|||
"errors"
|
||||
"sync"
|
||||
|
||||
"git.kirsle.net/apps/doodle/events"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/events"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
)
|
||||
|
||||
// Event is a named event that the supervisor will send.
|
||||
|
@ -95,7 +95,6 @@ func (s *Supervisor) Loop(ev *events.State) error {
|
|||
if s.dd.IsDragging() {
|
||||
if !ev.Button1.Now && !ev.Button2.Now {
|
||||
// The mouse has been released. TODO: make mouse button important?
|
||||
log.Info("Supervisor: STOP DRAGGING")
|
||||
for _, child := range hovering {
|
||||
child.widget.Event(Drop, XY)
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package theme
|
||||
|
||||
import "git.kirsle.net/apps/doodle/render"
|
||||
import "git.kirsle.net/apps/doodle/lib/render"
|
||||
|
||||
// Color schemes.
|
||||
var (
|
|
@ -1,8 +1,8 @@
|
|||
package ui
|
||||
|
||||
import (
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/ui/theme"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/lib/ui/theme"
|
||||
)
|
||||
|
||||
// BorderStyle options for widget.SetBorderStyle()
|
|
@ -3,7 +3,7 @@ package ui
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
)
|
||||
|
||||
// Window is a frame with a title bar.
|
15
log.go
15
log.go
|
@ -1,15 +0,0 @@
|
|||
package doodle
|
||||
|
||||
import "github.com/kirsle/golog"
|
||||
|
||||
var log *golog.Logger
|
||||
|
||||
func init() {
|
||||
log = golog.GetLogger("doodle")
|
||||
log.Configure(&golog.Config{
|
||||
Level: golog.DebugLevel,
|
||||
Theme: golog.DarkTheme,
|
||||
Colors: golog.ExtendedColor,
|
||||
TimeFormat: "2006-01-02 15:04:05.000000",
|
||||
})
|
||||
}
|
|
@ -5,7 +5,7 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
)
|
||||
|
||||
// Debug related variables that can toggle on or off certain features and
|
|
@ -1,8 +1,6 @@
|
|||
package balance
|
||||
|
||||
import (
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
)
|
||||
import "git.kirsle.net/apps/doodle/lib/render"
|
||||
|
||||
// Shell related variables.
|
||||
var (
|
|
@ -1,8 +1,8 @@
|
|||
package balance
|
||||
|
||||
import (
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/ui"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/lib/ui"
|
||||
)
|
||||
|
||||
// Theme and appearance variables.
|
|
@ -5,7 +5,7 @@ import (
|
|||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"git.kirsle.net/apps/doodle/enum"
|
||||
"git.kirsle.net/apps/doodle/pkg/enum"
|
||||
)
|
||||
|
||||
// Command is a parsed shell command.
|
|
@ -7,6 +7,7 @@ import (
|
|||
"regexp"
|
||||
"strings"
|
||||
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"git.kirsle.net/apps/doodle/pkg/userdir"
|
||||
)
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package doodads
|
||||
|
||||
import (
|
||||
"git.kirsle.net/apps/doodle/level"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
)
|
||||
|
||||
// Actor is a reusable run-time drawing component used in Doodle. Actors are an
|
|
@ -1,8 +1,8 @@
|
|||
package doodads
|
||||
|
||||
import (
|
||||
"git.kirsle.net/apps/doodle/level"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
)
|
||||
|
||||
// Collide describes how a collision occurred.
|
|
@ -1,9 +1,9 @@
|
|||
package doodads
|
||||
|
||||
import (
|
||||
"git.kirsle.net/apps/doodle/balance"
|
||||
"git.kirsle.net/apps/doodle/level"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
)
|
||||
|
||||
// Doodad is a reusable component for Levels that have scripts and graphics.
|
|
@ -1,8 +1,6 @@
|
|||
package doodads
|
||||
|
||||
import (
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
)
|
||||
import "git.kirsle.net/apps/doodle/lib/render"
|
||||
|
||||
// PlayerID is the Doodad ID for the player character.
|
||||
const PlayerID = "PLAYER"
|
|
@ -5,10 +5,11 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"git.kirsle.net/apps/doodle/balance"
|
||||
"git.kirsle.net/apps/doodle/enum"
|
||||
"git.kirsle.net/apps/doodle/events"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/events"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/enum"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"github.com/kirsle/golog"
|
||||
)
|
||||
|
||||
|
@ -58,7 +59,7 @@ func New(debug bool, engine render.Engine) *Doodle {
|
|||
d.shell = NewShell(d)
|
||||
|
||||
if !debug {
|
||||
log.Config.Level = golog.InfoLevel
|
||||
log.Logger.Config.Level = golog.InfoLevel
|
||||
}
|
||||
|
||||
return d
|
||||
|
@ -200,7 +201,7 @@ func (d *Doodle) EditDrawing(filename string) error {
|
|||
switch ext {
|
||||
case "level":
|
||||
case "map":
|
||||
log.Info("is a LEvel type")
|
||||
log.Info("is a Level type")
|
||||
scene.DrawingType = enum.LevelDrawing
|
||||
case "doodad":
|
||||
scene.DrawingType = enum.DoodadDrawing
|
|
@ -7,12 +7,13 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
|
||||
"git.kirsle.net/apps/doodle/doodads"
|
||||
"git.kirsle.net/apps/doodle/enum"
|
||||
"git.kirsle.net/apps/doodle/events"
|
||||
"git.kirsle.net/apps/doodle/level"
|
||||
"git.kirsle.net/apps/doodle/lib/events"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/doodads"
|
||||
"git.kirsle.net/apps/doodle/pkg/enum"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"git.kirsle.net/apps/doodle/pkg/userdir"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
)
|
||||
|
||||
// EditorScene manages the "Edit Level" game mode.
|
|
@ -1,6 +1,6 @@
|
|||
package doodle
|
||||
|
||||
import "git.kirsle.net/apps/doodle/uix"
|
||||
import "git.kirsle.net/apps/doodle/pkg/uix"
|
||||
|
||||
// TODO: build flags to not include this in production builds.
|
||||
// This adds accessors for private variables from the dev console.
|
|
@ -5,15 +5,16 @@ import (
|
|||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"git.kirsle.net/apps/doodle/balance"
|
||||
"git.kirsle.net/apps/doodle/doodads"
|
||||
"git.kirsle.net/apps/doodle/enum"
|
||||
"git.kirsle.net/apps/doodle/events"
|
||||
"git.kirsle.net/apps/doodle/level"
|
||||
"git.kirsle.net/apps/doodle/lib/events"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/lib/ui"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/doodads"
|
||||
"git.kirsle.net/apps/doodle/pkg/enum"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"git.kirsle.net/apps/doodle/pkg/uix"
|
||||
"git.kirsle.net/apps/doodle/pkg/userdir"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/ui"
|
||||
"git.kirsle.net/apps/doodle/uix"
|
||||
)
|
||||
|
||||
// Width of the panel frame.
|
|
@ -7,12 +7,13 @@ package doodle
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"git.kirsle.net/apps/doodle/balance"
|
||||
"git.kirsle.net/apps/doodle/doodads"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/lib/ui"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/doodads"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"git.kirsle.net/apps/doodle/pkg/uix"
|
||||
"git.kirsle.net/apps/doodle/pkg/userdir"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/ui"
|
||||
"git.kirsle.net/apps/doodle/uix"
|
||||
)
|
||||
|
||||
// DraggableActor is a Doodad being dragged from the Doodad palette.
|
|
@ -1,9 +1,10 @@
|
|||
package doodle
|
||||
|
||||
import (
|
||||
"git.kirsle.net/apps/doodle/balance"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/ui"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/lib/ui"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
)
|
||||
|
||||
// setupPaletteFrame configures the Color Palette tab for Edit Mode.
|
|
@ -4,10 +4,10 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.kirsle.net/apps/doodle/balance"
|
||||
"git.kirsle.net/apps/doodle/doodads"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/ui"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/lib/ui"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/doodads"
|
||||
)
|
||||
|
||||
// Frames to cache for FPS calculation.
|
|
@ -3,10 +3,11 @@ package doodle
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"git.kirsle.net/apps/doodle/balance"
|
||||
"git.kirsle.net/apps/doodle/events"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/ui"
|
||||
"git.kirsle.net/apps/doodle/lib/events"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/lib/ui"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
)
|
||||
|
||||
// GUITestScene implements the main menu of Doodle.
|
|
@ -1,7 +1,7 @@
|
|||
package level
|
||||
|
||||
import (
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
)
|
||||
|
|
@ -7,9 +7,10 @@ import (
|
|||
"math"
|
||||
"os"
|
||||
|
||||
"git.kirsle.net/apps/doodle/balance"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"git.kirsle.net/apps/doodle/pkg/userdir"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"github.com/satori/go.uuid"
|
||||
"golang.org/x/image/bmp"
|
||||
)
|
|
@ -5,7 +5,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
)
|
||||
|
||||
// MapAccessor implements a chunk accessor by using a map of points to their
|
|
@ -4,8 +4,8 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"git.kirsle.net/apps/doodle/level"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
)
|
||||
|
||||
// Test the high level Chunker.
|
|
@ -5,7 +5,8 @@ import (
|
|||
"fmt"
|
||||
"math"
|
||||
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
)
|
||||
|
||||
// Chunker is the data structure that manages the chunks of a level, and
|
|
@ -4,8 +4,8 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"git.kirsle.net/apps/doodle/level"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
)
|
||||
|
||||
func TestWorldSize(t *testing.T) {
|
|
@ -1,8 +1,6 @@
|
|||
package level
|
||||
|
||||
import (
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
)
|
||||
import "git.kirsle.net/apps/doodle/lib/render"
|
||||
|
||||
// DefaultPalette returns a sensible default palette.
|
||||
func DefaultPalette() *Palette {
|
|
@ -3,7 +3,7 @@ package level
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
)
|
||||
|
||||
// Swatch holds details about a single value in the palette.
|
|
@ -4,8 +4,8 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"git.kirsle.net/apps/doodle/balance"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
)
|
||||
|
||||
// Useful variables.
|
36
pkg/log/log.go
Normal file
36
pkg/log/log.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
package log
|
||||
|
||||
import "github.com/kirsle/golog"
|
||||
|
||||
// Logger is the public golog.Logger object.
|
||||
var Logger *golog.Logger
|
||||
|
||||
func init() {
|
||||
Logger = golog.GetLogger("doodle")
|
||||
Logger.Configure(&golog.Config{
|
||||
Level: golog.DebugLevel,
|
||||
Theme: golog.DarkTheme,
|
||||
Colors: golog.ExtendedColor,
|
||||
TimeFormat: "2006-01-02 15:04:05.000000",
|
||||
})
|
||||
}
|
||||
|
||||
// Debug logger function.
|
||||
func Debug(msg string, v ...interface{}) {
|
||||
Logger.Debug(msg, v...)
|
||||
}
|
||||
|
||||
// Info logger function.
|
||||
func Info(msg string, v ...interface{}) {
|
||||
Logger.Info(msg, v...)
|
||||
}
|
||||
|
||||
// Warn logger function.
|
||||
func Warn(msg string, v ...interface{}) {
|
||||
Logger.Warn(msg, v...)
|
||||
}
|
||||
|
||||
// Error logger function.
|
||||
func Error(msg string, v ...interface{}) {
|
||||
Logger.Error(msg, v...)
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
package doodle
|
||||
|
||||
import (
|
||||
"git.kirsle.net/apps/doodle/balance"
|
||||
"git.kirsle.net/apps/doodle/events"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/ui"
|
||||
"git.kirsle.net/apps/doodle/lib/events"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/lib/ui"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
)
|
||||
|
||||
// MainScene implements the main menu of Doodle.
|
|
@ -3,12 +3,13 @@ package doodle
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"git.kirsle.net/apps/doodle/balance"
|
||||
"git.kirsle.net/apps/doodle/doodads"
|
||||
"git.kirsle.net/apps/doodle/events"
|
||||
"git.kirsle.net/apps/doodle/level"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/uix"
|
||||
"git.kirsle.net/apps/doodle/lib/events"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/doodads"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"git.kirsle.net/apps/doodle/pkg/uix"
|
||||
)
|
||||
|
||||
// PlayScene manages the "Edit Level" game mode.
|
|
@ -1,6 +1,9 @@
|
|||
package doodle
|
||||
|
||||
import "git.kirsle.net/apps/doodle/events"
|
||||
import (
|
||||
"git.kirsle.net/apps/doodle/lib/events"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
)
|
||||
|
||||
// Scene is an abstraction for a game mode in Doodle. The app points to one
|
||||
// scene at a time and that scene has control over the main loop, and its own
|
|
@ -5,10 +5,11 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.kirsle.net/apps/doodle/balance"
|
||||
"git.kirsle.net/apps/doodle/events"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/ui"
|
||||
"git.kirsle.net/apps/doodle/lib/events"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/lib/ui"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"github.com/robertkrimen/otto"
|
||||
)
|
||||
|
||||
|
@ -73,7 +74,7 @@ func NewShell(d *Doodle) Shell {
|
|||
// Make the Doodle instance available to the shell.
|
||||
bindings := map[string]interface{}{
|
||||
"d": d,
|
||||
"log": log,
|
||||
"log": log.Logger,
|
||||
"RGBA": render.RGBA,
|
||||
"Point": render.NewPoint,
|
||||
"Rect": render.NewRect,
|
|
@ -5,14 +5,15 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
|
||||
"git.kirsle.net/apps/doodle/balance"
|
||||
"git.kirsle.net/apps/doodle/doodads"
|
||||
"git.kirsle.net/apps/doodle/events"
|
||||
"git.kirsle.net/apps/doodle/level"
|
||||
"git.kirsle.net/apps/doodle/lib/events"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/lib/ui"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/doodads"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"git.kirsle.net/apps/doodle/pkg/userdir"
|
||||
"git.kirsle.net/apps/doodle/pkg/wallpaper"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/ui"
|
||||
)
|
||||
|
||||
// Canvas is a custom ui.Widget that manages a single drawing.
|
|
@ -1,10 +1,10 @@
|
|||
package uix
|
||||
|
||||
import (
|
||||
"git.kirsle.net/apps/doodle/events"
|
||||
"git.kirsle.net/apps/doodle/level"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/ui"
|
||||
"git.kirsle.net/apps/doodle/lib/events"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/lib/ui"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
)
|
||||
|
||||
// loopEditable handles the Loop() part for editable canvases.
|
|
@ -1,9 +1,9 @@
|
|||
package uix
|
||||
|
||||
import (
|
||||
"git.kirsle.net/apps/doodle/level"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
"git.kirsle.net/apps/doodle/pkg/wallpaper"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
)
|
||||
|
||||
// Wallpaper configures the wallpaper in a Canvas.
|
|
@ -7,8 +7,8 @@ import (
|
|||
"image"
|
||||
"os"
|
||||
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/userdir"
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"golang.org/x/image/bmp"
|
||||
)
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"git.kirsle.net/apps/doodle/render"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
)
|
||||
|
||||
// Wallpaper is a repeatable background image to go behind levels.
|
||||
|
|
14
uix/log.go
14
uix/log.go
|
@ -1,14 +0,0 @@
|
|||
package uix
|
||||
|
||||
import "github.com/kirsle/golog"
|
||||
|
||||
var log *golog.Logger
|
||||
|
||||
func init() {
|
||||
log = golog.GetLogger("uix")
|
||||
log.Configure(&golog.Config{
|
||||
Level: golog.DebugLevel,
|
||||
Theme: golog.DarkTheme,
|
||||
Colors: golog.ExtendedColor,
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user