-
Notifications
You must be signed in to change notification settings - Fork 6
/
tilemap_menu.go
110 lines (102 loc) · 2.65 KB
/
tilemap_menu.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package menu
import (
"fmt"
"os"
"strconv"
"fyne.io/fyne/v2"
w "github.com/jeromelesaux/fyne-io/widget"
"github.com/jeromelesaux/martine/export/sprite"
"github.com/jeromelesaux/martine/gfx/transformation"
"github.com/jeromelesaux/martine/log"
)
var TileSize float32 = 20.
type TilemapMenu struct {
*ImageMenu
Result *transformation.AnalyzeBoard
TileImages *w.ImageTable
ExportDsk bool
ExportText bool
ExportWithAmsdosHeader bool
ExportZigzag bool
ExportJson bool
ExportCompression int
ExportFolderPath string
ExportImpdraw bool
ExportFlat bool
Historic *sprite.TilesHistorical
}
func (tm *TilemapMenu) ResetExport() {
tm.ExportDsk = false
tm.ExportText = false
tm.ExportWithAmsdosHeader = false
tm.ExportZigzag = false
tm.ExportJson = false
tm.ExportCompression = -1
tm.ExportImpdraw = false
}
func NewTilemapMenu() *TilemapMenu {
return &TilemapMenu{
ImageMenu: NewImageMenu(),
Result: &transformation.AnalyzeBoard{},
TileImages: w.NewEmptyImageTable(fyne.NewSize(TileSize, TileSize)),
}
}
func (i *TilemapMenu) CmdLine() string {
exec, err := os.Executable()
if err != nil {
log.GetLogger().Error("error while getting executable path :%v\n", err)
return exec
}
if i.OriginalImagePath() != "" {
exec += " -in " + i.OriginalImagePath()
}
if i.IsCpcPlus {
exec += " -plus"
}
if i.IsFullScreen {
exec += " -fullscreen"
}
if i.IsSprite {
width, widthText, err := i.GetWidth()
if err != nil {
log.GetLogger().Error("cannot convert width value :%s error :%v\n", widthText, err)
} else {
exec += " -width " + strconv.Itoa(width)
}
height, heightText, err := i.GetHeight()
if err != nil {
log.GetLogger().Error("cannot convert height value :%s error :%v\n", heightText, err)
} else {
exec += " -height " + strconv.Itoa(height)
}
}
if i.IsHardSprite {
exec += " -spritehard"
}
if i.ApplyDithering {
if i.WithQuantification {
exec += " -quantization"
} else {
exec += " -multiplier " + fmt.Sprintf("%.2f", i.DitheringMultiplier)
}
exec += " -dithering " + strconv.Itoa(i.DitheringAlgoNumber)
// stockage du numéro d'algo
}
exec += " -mode " + strconv.Itoa(i.Mode)
if i.Reducer != 0 {
exec += " -reducer " + strconv.Itoa(i.Reducer)
}
// resize algo
if i.ResizeAlgoNumber != 0 {
exec += " -algo " + strconv.Itoa(i.ResizeAlgoNumber)
}
if i.Brightness != 0 {
exec += " -brightness " + fmt.Sprintf("%.2f", i.Brightness)
}
if i.Saturation != 0 {
exec += " -saturation " + fmt.Sprintf("%.2f", i.Saturation)
}
exec += " -tilemap"
i.CmdLineGenerate = exec
return exec
}