Skip to content

Commit

Permalink
move hswidget => pkg/widgets
Browse files Browse the repository at this point in the history
replacer.sh:
\#!/bin/bash
OLD="$1"
NEW="$2"
for i in `find . -iname \*go`; do
        echo "Proceed for $i"
        sed -i \
                -e "s/\\/$OLD/\\/pkg\\/$NEW/g" \
                -e "s/package $OLD/package $NEW/g" \
                -e "s/$OLD\\./$NEW\\./g" $i
done
  • Loading branch information
gucio321 committed Nov 27, 2024
1 parent 27797c1 commit 9c8c04b
Show file tree
Hide file tree
Showing 115 changed files with 6,225 additions and 72 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2animdata"

"github.com/gucio321/HellSpawner/pkg/common"
"github.com/gucio321/HellSpawner/hswidget"
"github.com/gucio321/HellSpawner/pkg/widget"

Check failure on line 15 in pkg/widget/animdatawidget/widget.go

View workflow job for this annotation

GitHub Actions / Building (ubuntu-latest)

other declaration of widget

Check failure on line 15 in pkg/widget/animdatawidget/widget.go

View workflow job for this annotation

GitHub Actions / Building (macos-latest)

other declaration of widget

Check failure on line 15 in pkg/widget/animdatawidget/widget.go

View workflow job for this annotation

GitHub Actions / Building (windows-latest)

other declaration of widget
)

const (
Expand Down Expand Up @@ -82,7 +82,7 @@ func (p *widget) buildAnimationsList() {
for idx, name := range keys {
currentIdx := idx
list[idx] = giu.Row(
hswidget.MakeImageButton(
widget.MakeImageButton(
"##"+p.id+"deleteEntry"+giu.ID(strconv.Itoa(currentIdx)),
imageButtonSize, imageButtonSize,
state.deleteIcon,
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions hswidget/cofwidget/state.go → pkg/widget/cofwidget/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2cof"

"github.com/gucio321/HellSpawner/pkg/assets"
"github.com/gucio321/HellSpawner/hswidget"
"github.com/gucio321/HellSpawner/pkg/widget"
)

type mode int32
Expand Down Expand Up @@ -46,7 +46,7 @@ type viewerState struct {
DirectionIndex int32
FrameIndex int32
layer *d2cof.CofLayer
confirmDialog *hswidget.PopUpConfirmDialog
confirmDialog *widget.PopUpConfirmDialog
}

// Dispose clears viewer's layers
Expand Down Expand Up @@ -100,7 +100,7 @@ func (p *widget) initState() {
state := &widgetState{
Mode: modeViewer,
viewerState: &viewerState{
confirmDialog: &hswidget.PopUpConfirmDialog{},
confirmDialog: &widget.PopUpConfirmDialog{},
},
newLayerFields: &newLayerFields{
Selectable: true,
Expand Down
18 changes: 9 additions & 9 deletions hswidget/cofwidget/widget.go → pkg/widget/cofwidget/widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2cof"

"github.com/gucio321/HellSpawner/pkg/common"
"github.com/gucio321/HellSpawner/hswidget"
"github.com/gucio321/HellSpawner/pkg/widget"
)

const (
Expand Down Expand Up @@ -108,7 +108,7 @@ func (p *widget) makeAnimationTab(state *widgetState) giu.Layout {
}

speedLabel := giu.Label(strSpeed)
speedInput := hswidget.MakeInputInt(
speedInput := widget.MakeInputInt(
speedInputW,
&p.cof.Speed,
setSpeed,
Expand Down Expand Up @@ -161,7 +161,7 @@ func (p *widget) makeLayerTab(state *widgetState) giu.Layout {
}

id := giu.ID(fmt.Sprintf("##%sDeleteLayerConfirm", p.id))
state.viewerState.confirmDialog = hswidget.NewPopUpConfirmDialog(id, strPrompt, strMessage, fnYes, fnNo)
state.viewerState.confirmDialog = widget.NewPopUpConfirmDialog(id, strPrompt, strMessage, fnYes, fnNo)

state.Mode = modeConfirm
})
Expand Down Expand Up @@ -236,7 +236,7 @@ func (p *widget) makePriorityTab(state *widgetState) giu.Layout {

popupID := giu.ID(fmt.Sprintf("%sDeleteLayerConfirm", p.id))

state.confirmDialog = hswidget.NewPopUpConfirmDialog(popupID, strPrompt, strMessage, fnYes, fnNo)
state.confirmDialog = widget.NewPopUpConfirmDialog(popupID, strPrompt, strMessage, fnYes, fnNo)
state.Mode = modeConfirm
})

Expand Down Expand Up @@ -277,9 +277,9 @@ func (p *widget) layoutAnimFrames(state *widgetState) *giu.RowWidget {
leftButtonID := giu.ID(fmt.Sprintf("##%sDecreaseFramesPerDirection", p.id))
rightButtonID := giu.ID(fmt.Sprintf("##%sIncreaseFramesPerDirection", p.id))

left := hswidget.MakeImageButton(giu.ID(leftButtonID), buttonWidthHeight, buttonWidthHeight, state.textures.left, fnDecrease)
left := widget.MakeImageButton(giu.ID(leftButtonID), buttonWidthHeight, buttonWidthHeight, state.textures.left, fnDecrease)
frameCount := giu.Label(fmt.Sprintf("%d", numFrames))
right := hswidget.MakeImageButton(rightButtonID, buttonWidthHeight, buttonWidthHeight, state.textures.right, fnIncrease)
right := widget.MakeImageButton(rightButtonID, buttonWidthHeight, buttonWidthHeight, state.textures.right, fnIncrease)

return giu.Row(label, left, frameCount, right)
}
Expand Down Expand Up @@ -374,8 +374,8 @@ func (p *widget) makeDirectionLayout() giu.Layout {
fnIncPriority := makeIncPriorityFn(currentIdx)
fnDecPriority := makeDecPriorityFn(currentIdx)

increasePriority := hswidget.MakeImageButton(strIncPri, buttonWidthHeight, buttonWidthHeight, state.textures.up, fnIncPriority)
decreasePriority := hswidget.MakeImageButton(strDecPri, buttonWidthHeight, buttonWidthHeight, state.textures.down, fnDecPriority)
increasePriority := widget.MakeImageButton(strIncPri, buttonWidthHeight, buttonWidthHeight, state.textures.up, fnIncPriority)
decreasePriority := widget.MakeImageButton(strDecPri, buttonWidthHeight, buttonWidthHeight, state.textures.down, fnDecPriority)

strLayerName := layers[idx].Name()
strLayerLabel := fmt.Sprintf(fmtLayerLabel, idx, strLayerName)
Expand Down Expand Up @@ -447,7 +447,7 @@ func (p *widget) makeAddLayerLayout() giu.Layout {
),
giu.Row(
giu.Label("Shadow: "),
hswidget.MakeCheckboxFromByte("##"+p.id+"AddLayerShadow", &state.newLayerFields.Shadow),
widget.MakeCheckboxFromByte("##"+p.id+"AddLayerShadow", &state.newLayerFields.Shadow),
),
giu.Row(
giu.Label("Selectable: "),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package hswidget
package widget

import (
"fmt"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

"github.com/gucio321/HellSpawner/pkg/common"
"github.com/gucio321/HellSpawner/pkg/common/hsutil"
"github.com/gucio321/HellSpawner/hswidget"
"github.com/gucio321/HellSpawner/pkg/widget"
)

const (
Expand Down Expand Up @@ -162,7 +162,7 @@ func (p *widget) makePlayerLayout(state *widgetState) giu.Layout {
giu.InputInt(&state.TickTime).Label("Tick time").Size(inputIntW).OnChange(func() {
state.ticker.Reset(time.Second * time.Duration(state.TickTime) / miliseconds)
}),
hswidget.PlayPauseButton("##"+p.id+"PlayPauseAnimation", &state.IsPlaying, p.textureLoader).
widget.PlayPauseButton("##"+p.id+"PlayPauseAnimation", &state.IsPlaying, p.textureLoader).
Size(playPauseButtonSize, playPauseButtonSize),
giu.Button("Export GIF##"+p.id+"exportGif").OnClick(func() {
err := p.exportGif(state)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

"github.com/gucio321/HellSpawner/pkg/common"
"github.com/gucio321/HellSpawner/pkg/common/hsutil"
"github.com/gucio321/HellSpawner/hswidget"
"github.com/gucio321/HellSpawner/pkg/widget"
)

const (
Expand Down Expand Up @@ -144,7 +144,7 @@ func (p *widget) makePlayerLayout(state *widgetState) giu.Layout {
giu.InputInt(&state.TickTime).Label("Tick time").Size(inputIntW).OnChange(func() {
state.ticker.Reset(time.Second * time.Duration(state.TickTime) / miliseconds)
}),
hswidget.PlayPauseButton("##"+p.id+"PlayPauseAnimation", &state.IsPlaying, p.textureLoader).
widget.PlayPauseButton("##"+p.id+"PlayPauseAnimation", &state.IsPlaying, p.textureLoader).
Size(playPauseButtonSize, playPauseButtonSize),
giu.Button("Export GIF##"+p.id+"exportGif").OnClick(func() {
err := p.exportGif(state)
Expand Down
2 changes: 1 addition & 1 deletion hswidget/doc.go → pkg/widget/doc.go
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// Package hswidget contains a generic editor widget implementation, along with with concrete editor implementations.
package hswidget
package widget
File renamed without changes.
4 changes: 2 additions & 2 deletions hswidget/ds1widget/state.go → pkg/widget/ds1widget/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/AllenDang/giu"

"github.com/gucio321/HellSpawner/pkg/assets"
"github.com/gucio321/HellSpawner/hswidget"
"github.com/gucio321/HellSpawner/pkg/widget"
)

type widgetMode int32
Expand Down Expand Up @@ -59,7 +59,7 @@ func (t *ds1AddPathState) Dispose() {
type widgetState struct {
*ds1Controls
Mode widgetMode
confirmDialog *hswidget.PopUpConfirmDialog
confirmDialog *widget.PopUpConfirmDialog
NewFilePath string
addObjectState ds1AddObjectState
addPathState ds1AddPathState
Expand Down
File renamed without changes.
40 changes: 20 additions & 20 deletions hswidget/ds1widget/widget.go → pkg/widget/ds1widget/widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2ds1"

"github.com/gucio321/HellSpawner/pkg/common"
"github.com/gucio321/HellSpawner/hswidget"
"github.com/gucio321/HellSpawner/pkg/widget"
)

const (
Expand Down Expand Up @@ -110,7 +110,7 @@ func (p *widget) makeDataLayout() giu.Layout {
giu.Row(
giu.Label("Version: "),
giu.InputInt(&version).Size(inputIntW).OnChange(func() {
state.confirmDialog = hswidget.NewPopUpConfirmDialog(
state.confirmDialog = widget.NewPopUpConfirmDialog(
"##"+p.id+"confirmVersionChange",
"Are you sure, you want to change DS1 Version?",
"This value is used while decoding and encoding ds1 file\n"+
Expand All @@ -133,7 +133,7 @@ func (p *widget) makeDataLayout() giu.Layout {
giu.Row(
giu.Label("\tWidth: "),
giu.InputInt(&w).Size(inputIntW).OnChange(func() {
state.confirmDialog = hswidget.NewPopUpConfirmDialog(
state.confirmDialog = widget.NewPopUpConfirmDialog(
"##"+p.id+"confirmWidthChange",
"Are you really sure, you want to change size of DS1 tiles?",
"This will affect all your tiles in Tile tab.\n"+
Expand All @@ -152,7 +152,7 @@ func (p *widget) makeDataLayout() giu.Layout {
giu.Row(
giu.Label("\tHeight: "),
giu.InputInt(&h).Size(inputIntW).OnChange(func() {
state.confirmDialog = hswidget.NewPopUpConfirmDialog(
state.confirmDialog = widget.NewPopUpConfirmDialog(
"##"+p.id+"confirmWidthChange",
"Are you really sure, you want to change size of DS1 tiles?",
"This will affect all your tiles in Tile tab.\n"+
Expand Down Expand Up @@ -194,7 +194,7 @@ func (p *widget) makeFilesLayout() giu.Layout {

l = append(l, giu.Layout{
giu.Row(
hswidget.MakeImageButton(
widget.MakeImageButton(
"##"+p.id+"DeleteFile"+giu.ID(strconv.Itoa(currentIdx)),
deleteButtonSize, deleteButtonSize,
p.deleteButtonTexture,
Expand Down Expand Up @@ -267,7 +267,7 @@ func (p *widget) makeObjectsLayout(state *widgetState) giu.Layout {
giu.Button("").ID("Add path to this Object...##"+p.id+"AddPath").Size(actionButtonW, actionButtonH).OnClick(func() {
state.Mode = widgetModeAddPath
}),
hswidget.MakeImageButton(
widget.MakeImageButton(
"##"+p.id+"deleteObject",
layerDeleteButtonSize, layerDeleteButtonSize,
p.deleteButtonTexture,
Expand Down Expand Up @@ -297,15 +297,15 @@ func (p *widget) makeObjectLayout(state *widgetState) giu.Layout {
l := giu.Layout{
giu.Row(
giu.Label("Type: "),
hswidget.MakeInputInt(
widget.MakeInputInt(
inputIntW,
&obj.Type,
nil,
),
),
giu.Row(
giu.Label("ID: "),
hswidget.MakeInputInt(
widget.MakeInputInt(
inputIntW,
&obj.ID,
nil,
Expand All @@ -314,23 +314,23 @@ func (p *widget) makeObjectLayout(state *widgetState) giu.Layout {
giu.Label("Position (tiles): "),
giu.Row(
giu.Label("\tX: "),
hswidget.MakeInputInt(
widget.MakeInputInt(
inputIntW,
&obj.X,
nil,
),
),
giu.Row(
giu.Label("\tY: "),
hswidget.MakeInputInt(
widget.MakeInputInt(
inputIntW,
&obj.Y,
nil,
),
),
giu.Row(
giu.Label("Flags: 0x"),
hswidget.MakeInputInt(
widget.MakeInputInt(
inputIntW,
&obj.Flags,
nil,
Expand Down Expand Up @@ -413,7 +413,7 @@ func (p *widget) makePathLayout(state *widgetState, obj *d2ds1.Object) giu.Layou
giu.Label(fmt.Sprintf("%d", idx)),
giu.Label(fmt.Sprintf("(%d, %d)", int(x), int(y))),
giu.Label(fmt.Sprintf("%d", obj.Paths[idx].Action)),
hswidget.MakeImageButton(
widget.MakeImageButton(
"##"+p.id+"deletePath"+giu.ID(strconv.Itoa(currentIdx)),
deleteButtonSize, deleteButtonSize,
p.deleteButtonTexture,
Expand Down Expand Up @@ -518,7 +518,7 @@ func (p *widget) makeTilesGroupLayout(state *widgetState, x, y int, t d2ds1.Laye

var deleteBtn giu.Widget
if deleteCb != nil {
deleteBtn = hswidget.MakeImageButton(
deleteBtn = widget.MakeImageButton(
"##"+p.id+"delete"+giu.ID(t.String()),
layerDeleteButtonSize, layerDeleteButtonSize,
p.deleteButtonTexture,
Expand Down Expand Up @@ -583,47 +583,47 @@ func (p *widget) makeTileLayout(record *d2ds1.Tile, t d2ds1.LayerGroupType) giu.
l := giu.Layout{
giu.Row(
giu.Label("Prop1: "),
hswidget.MakeInputInt(
widget.MakeInputInt(
inputIntW,
&record.Prop1,
nil,
),
),
giu.Row(
giu.Label("Sequence: "),
hswidget.MakeInputInt(
widget.MakeInputInt(
inputIntW,
&record.Sequence,
nil,
),
),
giu.Row(
giu.Label("Unknown1: "),
hswidget.MakeInputInt(
widget.MakeInputInt(
inputIntW,
&record.Unknown1,
nil,
),
),
giu.Row(
giu.Label("Style: "),
hswidget.MakeInputInt(
widget.MakeInputInt(
inputIntW,
&record.Style,
nil,
),
),
giu.Row(
giu.Label("Unknown2: "),
hswidget.MakeInputInt(
widget.MakeInputInt(
inputIntW,
&record.Unknown2,
nil,
),
),
giu.Row(
giu.Label("Hidden: "),
hswidget.MakeCheckboxFromByte(
widget.MakeCheckboxFromByte(
"##"+p.id+"floorHidden",
&record.HiddenBytes,
),
Expand All @@ -641,7 +641,7 @@ func (p *widget) makeTileLayout(record *d2ds1.Tile, t d2ds1.LayerGroupType) giu.
l = append(l,
giu.Row(
giu.Label("Zero: "),
hswidget.MakeInputInt(
widget.MakeInputInt(
inputIntW,
&record.Zero,
nil,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package dt1widget
import (
"github.com/AllenDang/giu"

"github.com/gucio321/HellSpawner/hswidget/dt1widget/tiletypeimage"
"github.com/gucio321/HellSpawner/pkg/widget/dt1widget/tiletypeimage"

"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math"

"github.com/gucio321/HellSpawner/pkg/common"
"github.com/gucio321/HellSpawner/hswidget/dt1widget/tiletypeimage"
"github.com/gucio321/HellSpawner/pkg/widget/dt1widget/tiletypeimage"
)

const (
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2font/d2fontglyph"

"github.com/gucio321/HellSpawner/pkg/common"
"github.com/gucio321/HellSpawner/hswidget"
"github.com/gucio321/HellSpawner/pkg/widget"
)

const (
Expand Down Expand Up @@ -124,7 +124,7 @@ func (p *widget) makeGlyphLayout(r rune) *giu.TableRowWidget {
height32 := int32(h)

row := giu.TableRow(
hswidget.MakeImageButton("##"+p.id+"deleteFrame"+giu.ID(r),
widget.MakeImageButton("##"+p.id+"deleteFrame"+giu.ID(r),
delSize, delSize,
state.deleteButtonTexture,
func() { p.deleteRow(r) },
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 9c8c04b

Please sign in to comment.