diff --git a/d2common/d2data/d2datadict/level_presets.go b/d2common/d2data/d2datadict/level_presets.go index d87c780be..9077df640 100644 --- a/d2common/d2data/d2datadict/level_presets.go +++ b/d2common/d2data/d2datadict/level_presets.go @@ -4,7 +4,7 @@ import ( "log" "strings" - dh "github.com/OpenDiablo2/OpenDiablo2/d2common/d2helper" + dh "github.com/OpenDiablo2/OpenDiablo2/d2common" ) type LevelPresetRecord struct { diff --git a/d2common/d2data/d2datadict/level_types.go b/d2common/d2data/d2datadict/level_types.go index aed8c0d87..2ed92de89 100644 --- a/d2common/d2data/d2datadict/level_types.go +++ b/d2common/d2data/d2datadict/level_types.go @@ -4,7 +4,7 @@ import ( "log" "strings" - dh "github.com/OpenDiablo2/OpenDiablo2/d2common/d2helper" + dh "github.com/OpenDiablo2/OpenDiablo2/d2common" ) type LevelTypeRecord struct { diff --git a/d2common/d2data/d2datadict/map_helper.go b/d2common/d2data/d2datadict/map_helper.go index d6e267950..54711c2a6 100644 --- a/d2common/d2data/d2datadict/map_helper.go +++ b/d2common/d2data/d2datadict/map_helper.go @@ -3,7 +3,7 @@ package d2datadict import ( "strings" - dh "github.com/OpenDiablo2/OpenDiablo2/d2common/d2helper" + dh "github.com/OpenDiablo2/OpenDiablo2/d2common" ) func MapHeaders(line string) map[string]int { diff --git a/d2common/d2data/d2datadict/missiles.go b/d2common/d2data/d2datadict/missiles.go index 13c6e7219..4037c3e73 100644 --- a/d2common/d2data/d2datadict/missiles.go +++ b/d2common/d2data/d2datadict/missiles.go @@ -5,8 +5,7 @@ import ( "strings" "github.com/OpenDiablo2/OpenDiablo2/d2common" - - dh "github.com/OpenDiablo2/OpenDiablo2/d2common/d2helper" + dh "github.com/OpenDiablo2/OpenDiablo2/d2common" ) type MissileCalcParam struct { diff --git a/d2common/d2data/d2datadict/objects.go b/d2common/d2data/d2datadict/objects.go index 15b8a09c5..3e30e9bac 100644 --- a/d2common/d2data/d2datadict/objects.go +++ b/d2common/d2data/d2datadict/objects.go @@ -4,7 +4,7 @@ import ( "log" "strings" - dh "github.com/OpenDiablo2/OpenDiablo2/d2common/d2helper" + dh "github.com/OpenDiablo2/OpenDiablo2/d2common" ) // An ObjectRecord represents the settings for one type of object from objects.txt diff --git a/d2common/d2data/d2datadict/sounds.go b/d2common/d2data/d2datadict/sounds.go index 71f5d3a2b..61e4a8e0c 100644 --- a/d2common/d2data/d2datadict/sounds.go +++ b/d2common/d2data/d2datadict/sounds.go @@ -4,7 +4,7 @@ import ( "log" "strings" - dh "github.com/OpenDiablo2/OpenDiablo2/d2common/d2helper" + dh "github.com/OpenDiablo2/OpenDiablo2/d2common" ) // SoundEntry represents a sound entry diff --git a/d2common/d2data/d2datadict/unique_items.go b/d2common/d2data/d2datadict/unique_items.go index 2450a3aa8..bb73b75ad 100644 --- a/d2common/d2data/d2datadict/unique_items.go +++ b/d2common/d2data/d2datadict/unique_items.go @@ -6,7 +6,7 @@ import ( "github.com/OpenDiablo2/OpenDiablo2/d2common" - dh "github.com/OpenDiablo2/OpenDiablo2/d2common/d2helper" + dh "github.com/OpenDiablo2/OpenDiablo2/d2common" ) type UniqueItemRecord struct { diff --git a/d2common/d2fileformats/d2dcc/dcc_direction.go b/d2common/d2fileformats/d2dcc/dcc_direction.go index fcb04e915..9a482f69c 100644 --- a/d2common/d2fileformats/d2dcc/dcc_direction.go +++ b/d2common/d2fileformats/d2dcc/dcc_direction.go @@ -4,7 +4,6 @@ import ( "log" "github.com/OpenDiablo2/OpenDiablo2/d2common" - "github.com/OpenDiablo2/OpenDiablo2/d2common/d2helper" ) type DCCDirection struct { @@ -50,10 +49,10 @@ func CreateDCCDirection(bm *d2common.BitMuncher, file DCC) DCCDirection { // Load the frame headers for frameIdx := 0; frameIdx < file.FramesPerDirection; frameIdx++ { result.Frames[frameIdx] = CreateDCCDirectionFrame(bm, result) - minx = int(d2helper.MinInt32(int32(result.Frames[frameIdx].Box.Left), int32(minx))) - miny = int(d2helper.MinInt32(int32(result.Frames[frameIdx].Box.Top), int32(miny))) - maxx = int(d2helper.MaxInt32(int32(result.Frames[frameIdx].Box.Right()), int32(maxx))) - maxy = int(d2helper.MaxInt32(int32(result.Frames[frameIdx].Box.Bottom()), int32(maxy))) + minx = int(d2common.MinInt32(int32(result.Frames[frameIdx].Box.Left), int32(minx))) + miny = int(d2common.MinInt32(int32(result.Frames[frameIdx].Box.Top), int32(miny))) + maxx = int(d2common.MaxInt32(int32(result.Frames[frameIdx].Box.Right()), int32(maxx))) + maxy = int(d2common.MaxInt32(int32(result.Frames[frameIdx].Box.Bottom()), int32(maxy))) } result.Box = d2common.Rectangle{minx, miny, (maxx - minx), (maxy - miny)} if result.OptionalDataBits > 0 { diff --git a/d2common/d2fileformats/d2ds1/ds1.go b/d2common/d2fileformats/d2ds1/ds1.go index ee76b4e11..6e15ffdec 100644 --- a/d2common/d2fileformats/d2ds1/ds1.go +++ b/d2common/d2fileformats/d2ds1/ds1.go @@ -5,7 +5,6 @@ import ( "github.com/OpenDiablo2/OpenDiablo2/d2common/d2data" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2datadict" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum" - "github.com/OpenDiablo2/OpenDiablo2/d2common/d2helper" ) type DS1 struct { @@ -37,7 +36,7 @@ func LoadDS1(fileData []byte) DS1 { ds1.Width = br.GetInt32() + 1 ds1.Height = br.GetInt32() + 1 if ds1.Version >= 8 { - ds1.Act = d2helper.MinInt32(5, br.GetInt32()+1) + ds1.Act = d2common.MinInt32(5, br.GetInt32()+1) } if ds1.Version >= 10 { ds1.SubstitutionType = br.GetInt32() diff --git a/d2common/d2fileformats/d2mpq/mpq_stream.go b/d2common/d2fileformats/d2mpq/mpq_stream.go index 9442fa9b9..21f140390 100644 --- a/d2common/d2fileformats/d2mpq/mpq_stream.go +++ b/d2common/d2fileformats/d2mpq/mpq_stream.go @@ -10,9 +10,9 @@ import ( "log" "strings" - "github.com/OpenDiablo2/OpenDiablo2/d2common/d2helper" - "github.com/JoshVarga/blast" + + "github.com/OpenDiablo2/OpenDiablo2/d2common" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2compression" ) @@ -104,7 +104,7 @@ func (v *Stream) readInternalSingleUnit(buffer []byte, offset, count uint32) uin v.loadSingleUnit() } - bytesToCopy := d2helper.Min(uint32(len(v.CurrentData))-v.CurrentPosition, count) + bytesToCopy := d2common.Min(uint32(len(v.CurrentData))-v.CurrentPosition, count) copy(buffer[offset:offset+bytesToCopy], v.CurrentData[v.CurrentPosition:v.CurrentPosition+bytesToCopy]) v.CurrentPosition += bytesToCopy return bytesToCopy @@ -113,7 +113,7 @@ func (v *Stream) readInternalSingleUnit(buffer []byte, offset, count uint32) uin func (v *Stream) readInternal(buffer []byte, offset, count uint32) uint32 { v.bufferData() localPosition := v.CurrentPosition % v.BlockSize - bytesToCopy := d2helper.MinInt32(int32(len(v.CurrentData))-int32(localPosition), int32(count)) + bytesToCopy := d2common.MinInt32(int32(len(v.CurrentData))-int32(localPosition), int32(count)) if bytesToCopy <= 0 { return 0 } @@ -127,7 +127,7 @@ func (v *Stream) bufferData() { if requiredBlock == v.CurrentBlockIndex { return } - expectedLength := d2helper.Min(v.BlockTableEntry.UncompressedFileSize-(requiredBlock*v.BlockSize), v.BlockSize) + expectedLength := d2common.Min(v.BlockTableEntry.UncompressedFileSize-(requiredBlock*v.BlockSize), v.BlockSize) v.CurrentData = v.loadBlock(requiredBlock, expectedLength) v.CurrentBlockIndex = requiredBlock } diff --git a/d2common/d2helper/math.go b/d2common/math.go similarity index 99% rename from d2common/d2helper/math.go rename to d2common/math.go index 60bd2aa47..973bf3e7a 100644 --- a/d2common/d2helper/math.go +++ b/d2common/math.go @@ -1,4 +1,4 @@ -package d2helper +package d2common import "math" diff --git a/d2common/d2helper/stringutils.go b/d2common/stringutils.go similarity index 98% rename from d2common/d2helper/stringutils.go rename to d2common/stringutils.go index 33145f1ae..739747ee9 100644 --- a/d2common/d2helper/stringutils.go +++ b/d2common/stringutils.go @@ -1,4 +1,4 @@ -package d2helper +package d2common import ( "bytes" @@ -141,7 +141,7 @@ func SplitIntoLinesWithMaxWidth(fullSentence string, maxChars int) []string { } func splitCjkIntoChunks(str string, chars int) []string { - chunks := make([]string, chars / len(str)) + chunks := make([]string, chars/len(str)) i, count := 0, 0 for j, ch := range str { if ch < unicode.MaxLatin1 { diff --git a/d2common/d2helper/timeutils.go b/d2common/timeutils.go similarity index 84% rename from d2common/d2helper/timeutils.go rename to d2common/timeutils.go index b49e21161..5c5dfd85e 100644 --- a/d2common/d2helper/timeutils.go +++ b/d2common/timeutils.go @@ -1,4 +1,4 @@ -package d2helper +package d2common import "time" diff --git a/d2core/d2asset/animation.go b/d2core/d2asset/animation.go index f5a7826ba..6a6ddd028 100644 --- a/d2core/d2asset/animation.go +++ b/d2core/d2asset/animation.go @@ -5,10 +5,10 @@ import ( "image/color" "math" + "github.com/OpenDiablo2/OpenDiablo2/d2common" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2datadict" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2dc6" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2dcc" - "github.com/OpenDiablo2/OpenDiablo2/d2common/d2helper" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2render" ) @@ -60,10 +60,10 @@ func createAnimationFromDCC(dcc *d2dcc.DCC, palette *d2datadict.PaletteRec, tran minX, minY := math.MaxInt32, math.MaxInt32 maxX, maxY := math.MinInt32, math.MinInt32 for _, dccFrame := range dccDirection.Frames { - minX = d2helper.MinInt(minX, dccFrame.Box.Left) - minY = d2helper.MinInt(minY, dccFrame.Box.Top) - maxX = d2helper.MaxInt(maxX, dccFrame.Box.Right()) - maxY = d2helper.MaxInt(maxY, dccFrame.Box.Bottom()) + minX = d2common.MinInt(minX, dccFrame.Box.Left) + minY = d2common.MinInt(minY, dccFrame.Box.Top) + maxX = d2common.MaxInt(maxX, dccFrame.Box.Right()) + maxY = d2common.MaxInt(maxY, dccFrame.Box.Bottom()) } frameWidth := maxX - minX @@ -222,8 +222,8 @@ func (a *Animation) GetFrameBounds() (int, int) { direction := a.directions[a.directionIndex] for _, frame := range direction.frames { - maxWidth = d2helper.MaxInt(maxWidth, frame.width) - maxHeight = d2helper.MaxInt(maxHeight, frame.height) + maxWidth = d2common.MaxInt(maxWidth, frame.width) + maxHeight = d2common.MaxInt(maxHeight, frame.height) } return maxWidth, maxHeight diff --git a/d2core/d2asset/archive_manager.go b/d2core/d2asset/archive_manager.go index a3864543f..c358806ec 100644 --- a/d2core/d2asset/archive_manager.go +++ b/d2core/d2asset/archive_manager.go @@ -6,8 +6,8 @@ import ( "sync" "github.com/OpenDiablo2/OpenDiablo2/d2common" - "github.com/OpenDiablo2/OpenDiablo2/d2common/d2config" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2mpq" + "github.com/OpenDiablo2/OpenDiablo2/d2core/d2config" ) type archiveEntry struct { diff --git a/d2core/d2asset/d2asset.go b/d2core/d2asset/d2asset.go index 50f596563..b314df3f9 100644 --- a/d2core/d2asset/d2asset.go +++ b/d2core/d2asset/d2asset.go @@ -3,10 +3,10 @@ package d2asset import ( "log" - "github.com/OpenDiablo2/OpenDiablo2/d2common/d2config" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2datadict" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2mpq" + "github.com/OpenDiablo2/OpenDiablo2/d2core/d2config" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2term" ) diff --git a/d2core/d2asset/file_manager.go b/d2core/d2asset/file_manager.go index a2e65b55f..850ea24df 100644 --- a/d2core/d2asset/file_manager.go +++ b/d2core/d2asset/file_manager.go @@ -4,8 +4,9 @@ import ( "strings" "github.com/OpenDiablo2/OpenDiablo2/d2common" - "github.com/OpenDiablo2/OpenDiablo2/d2common/d2config" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource" + + "github.com/OpenDiablo2/OpenDiablo2/d2core/d2config" ) const ( diff --git a/d2common/d2config/config.go b/d2core/d2config/config.go similarity index 100% rename from d2common/d2config/config.go rename to d2core/d2config/config.go diff --git a/d2common/d2config/d2config.go b/d2core/d2config/d2config.go similarity index 100% rename from d2common/d2config/d2config.go rename to d2core/d2config/d2config.go diff --git a/d2core/d2map/animated_entity.go b/d2core/d2map/animated_entity.go index ef4bd116f..49207cd22 100644 --- a/d2core/d2map/animated_entity.go +++ b/d2core/d2map/animated_entity.go @@ -4,9 +4,9 @@ import ( "math" "math/rand" + "github.com/OpenDiablo2/OpenDiablo2/d2common" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2datadict" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum" - "github.com/OpenDiablo2/OpenDiablo2/d2common/d2helper" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2render" ) @@ -87,7 +87,7 @@ func (v *AnimatedEntity) getStepLength(tickTime float64) (float64, float64) { speed := 6.0 length := tickTime * speed - angle := 359 - d2helper.GetAngleBetween( + angle := 359 - d2common.GetAngleBetween( v.LocationX, v.LocationY, v.TargetX, @@ -102,10 +102,10 @@ func (v *AnimatedEntity) getStepLength(tickTime float64) (float64, float64) { func (v *AnimatedEntity) Step(tickTime float64) { stepX, stepY := v.getStepLength(tickTime) - if d2helper.AlmostEqual(v.LocationX, v.TargetX, stepX) { + if d2common.AlmostEqual(v.LocationX, v.TargetX, stepX) { v.LocationX = v.TargetX } - if d2helper.AlmostEqual(v.LocationY, v.TargetY, stepY) { + if d2common.AlmostEqual(v.LocationY, v.TargetY, stepY) { v.LocationY = v.TargetY } if v.LocationX != v.TargetX { @@ -145,7 +145,7 @@ func (v *AnimatedEntity) Step(tickTime float64) { // SetTarget sets target coordinates and changes animation based on proximity and direction func (v *AnimatedEntity) SetTarget(tx, ty float64, action int32) { - angle := 359 - d2helper.GetAngleBetween( + angle := 359 - d2common.GetAngleBetween( v.LocationX, v.LocationY, tx, diff --git a/d2core/d2map/region.go b/d2core/d2map/region.go index 4b24409f0..6c7d7cb1f 100644 --- a/d2core/d2map/region.go +++ b/d2core/d2map/region.go @@ -7,17 +7,14 @@ import ( "math/rand" "strconv" - "github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset" - "github.com/OpenDiablo2/OpenDiablo2/d2common" - - "github.com/OpenDiablo2/OpenDiablo2/d2common/d2helper" - "github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2datadict" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2ds1" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2dt1" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource" + + "github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2render" ) @@ -490,10 +487,10 @@ func (mr *MapRegion) generateFloorCache(tile *d2ds1.FloorShadowRecord, tileX, ti } tileYMinimum := int32(0) for _, block := range tileData[i].Blocks { - tileYMinimum = d2helper.MinInt32(tileYMinimum, int32(block.Y)) + tileYMinimum = d2common.MinInt32(tileYMinimum, int32(block.Y)) } - tileYOffset := d2helper.AbsInt32(tileYMinimum) - tileHeight := d2helper.AbsInt32(tileData[i].Height) + tileYOffset := d2common.AbsInt32(tileYMinimum) + tileHeight := d2common.AbsInt32(tileData[i].Height) _, image := d2render.NewSurface(int(tileData[i].Width), int(tileHeight), d2render.FilterNearest) pixels := make([]byte, 4*tileData[i].Width*tileHeight) mr.decodeTileGfxData(tileData[i].Blocks, &pixels, tileYOffset, tileData[i].Width) @@ -517,8 +514,8 @@ func (mr *MapRegion) generateShadowCache(tile *d2ds1.FloorShadowRecord, tileX, t tileMinY := int32(0) tileMaxY := int32(0) for _, block := range tileData.Blocks { - tileMinY = d2helper.MinInt32(tileMinY, int32(block.Y)) - tileMaxY = d2helper.MaxInt32(tileMaxY, int32(block.Y+32)) + tileMinY = d2common.MinInt32(tileMinY, int32(block.Y)) + tileMaxY = d2common.MaxInt32(tileMaxY, int32(block.Y+32)) } tileYOffset := -tileMinY tileHeight := int(tileMaxY - tileMinY) @@ -566,11 +563,11 @@ func (mr *MapRegion) generateWallCache(tile *d2ds1.WallRecord, tileX, tileY int) } for _, block := range target.Blocks { - tileMinY = d2helper.MinInt32(tileMinY, int32(block.Y)) - tileMaxY = d2helper.MaxInt32(tileMaxY, int32(block.Y+32)) + tileMinY = d2common.MinInt32(tileMinY, int32(block.Y)) + tileMaxY = d2common.MaxInt32(tileMaxY, int32(block.Y+32)) } - realHeight := d2helper.MaxInt32(d2helper.AbsInt32(tileData.Height), tileMaxY-tileMinY) + realHeight := d2common.MaxInt32(d2common.AbsInt32(tileData.Height), tileMaxY-tileMinY) tileYOffset := -tileMinY //tileHeight := int(tileMaxY - tileMinY) diff --git a/d2core/d2render/ebiten/ebiten_renderer.go b/d2core/d2render/ebiten/ebiten_renderer.go index 5ffca872f..a5ba25acd 100644 --- a/d2core/d2render/ebiten/ebiten_renderer.go +++ b/d2core/d2render/ebiten/ebiten_renderer.go @@ -4,12 +4,11 @@ import ( "image" "log" - "github.com/OpenDiablo2/OpenDiablo2/d2core/d2render" - - "github.com/OpenDiablo2/OpenDiablo2/d2common/d2config" - "github.com/hajimehoshi/ebiten" "github.com/hajimehoshi/ebiten/ebitenutil" + + "github.com/OpenDiablo2/OpenDiablo2/d2core/d2config" + "github.com/OpenDiablo2/OpenDiablo2/d2core/d2render" ) type EbitenRenderer struct { diff --git a/d2core/d2term/terminal.go b/d2core/d2term/terminal.go index 5a6bbba62..f86647ce1 100644 --- a/d2core/d2term/terminal.go +++ b/d2core/d2term/terminal.go @@ -13,7 +13,7 @@ import ( "strconv" "strings" - "github.com/OpenDiablo2/OpenDiablo2/d2common/d2helper" + "github.com/OpenDiablo2/OpenDiablo2/d2common" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2input" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2render" ) @@ -130,7 +130,7 @@ func (t *terminal) advance(elapsed float64) error { } func (t *terminal) OnKeyDown(event d2input.KeyEvent) bool { - maxOutputIndex := d2helper.MaxInt(0, len(t.outputHistory)-t.lineCount) + maxOutputIndex := d2common.MaxInt(0, len(t.outputHistory)-t.lineCount) if t.visState == termVisHiding || t.visState == termVisHidden { if event.Key == d2input.KeyGraveAccent { @@ -180,7 +180,7 @@ func (t *terminal) OnKeyDown(event d2input.KeyEvent) bool { if event.Key == d2input.KeyUp { if event.KeyMod == d2input.KeyModControl { - t.lineCount = d2helper.MaxInt(0, t.lineCount-1) + t.lineCount = d2common.MaxInt(0, t.lineCount-1) } else if len(t.commandHistory) > 0 { t.command = t.commandHistory[t.commandIndex] if t.commandIndex == 0 { @@ -194,7 +194,7 @@ func (t *terminal) OnKeyDown(event d2input.KeyEvent) bool { } if event.Key == d2input.KeyDown && event.KeyMod == d2input.KeyModControl { - t.lineCount = d2helper.MinInt(t.lineCount+1, termRowCountMax) + t.lineCount = d2common.MinInt(t.lineCount+1, termRowCountMax) return true } diff --git a/d2core/d2ui/font.go b/d2core/d2ui/font.go index bc7520f17..49236c9ad 100644 --- a/d2core/d2ui/font.go +++ b/d2core/d2ui/font.go @@ -1,17 +1,14 @@ package d2ui import ( + "encoding/binary" "image/color" "strings" + "unicode" + "github.com/OpenDiablo2/OpenDiablo2/d2common" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2render" - - "github.com/OpenDiablo2/OpenDiablo2/d2common/d2helper" - - "encoding/binary" - - "unicode" ) var fontCache = map[string]*Font{} @@ -91,7 +88,7 @@ func (v *Font) GetTextMetrics(text string) (width, height int) { _, maxCharHeight := v.fontSprite.GetFrameBounds() for _, ch := range text { if ch == '\n' { - width = d2helper.MaxInt(width, curWidth) + width = d2common.MaxInt(width, curWidth) curWidth = 0 height += maxCharHeight + 6 continue @@ -99,7 +96,7 @@ func (v *Font) GetTextMetrics(text string) (width, height int) { curWidth += v.getCharWidth(ch) } - width = d2helper.MaxInt(width, curWidth) + width = d2common.MaxInt(width, curWidth) height += maxCharHeight return } @@ -111,7 +108,7 @@ func (v *Font) Render(x, y int, text string, color color.Color, target d2render. maxCharHeight := uint32(0) for _, m := range v.metrics { - maxCharHeight = d2helper.Max(maxCharHeight, uint32(m.Height)) + maxCharHeight = d2common.Max(maxCharHeight, uint32(m.Height)) } targetWidth, _ := target.GetSize() diff --git a/d2core/d2ui/sprite.go b/d2core/d2ui/sprite.go index e6b687616..8d7ce7214 100644 --- a/d2core/d2ui/sprite.go +++ b/d2core/d2ui/sprite.go @@ -4,10 +4,9 @@ import ( "errors" "image/color" + "github.com/OpenDiablo2/OpenDiablo2/d2common" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2render" - - "github.com/OpenDiablo2/OpenDiablo2/d2common/d2helper" ) type Sprite struct { @@ -53,7 +52,7 @@ func (s *Sprite) RenderSegmented(target d2render.Surface, segmentsX, segmentsY, } frameWidth, frameHeight := s.GetCurrentFrameSize() - maxFrameHeight = d2helper.MaxInt(maxFrameHeight, frameHeight) + maxFrameHeight = d2common.MaxInt(maxFrameHeight, frameHeight) currentX += frameWidth } diff --git a/d2game/d2game.go b/d2game/d2game.go index 6efc06aef..4ca7b034a 100644 --- a/d2game/d2game.go +++ b/d2game/d2game.go @@ -5,15 +5,13 @@ import ( "runtime" "strconv" - "github.com/OpenDiablo2/OpenDiablo2/d2core/d2ui" - - "github.com/OpenDiablo2/OpenDiablo2/d2core/d2scene" + "github.com/OpenDiablo2/OpenDiablo2/d2common" - "github.com/OpenDiablo2/OpenDiablo2/d2common/d2helper" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2input" - "github.com/OpenDiablo2/OpenDiablo2/d2core/d2term" - "github.com/OpenDiablo2/OpenDiablo2/d2core/d2render" + "github.com/OpenDiablo2/OpenDiablo2/d2core/d2scene" + "github.com/OpenDiablo2/OpenDiablo2/d2core/d2term" + "github.com/OpenDiablo2/OpenDiablo2/d2core/d2ui" ) var loadingSprite *d2ui.Sprite // The sprite shown when loading stuff @@ -30,7 +28,7 @@ func Initialize(loadingSpr *d2ui.Sprite) error { bsHandler = &bsForInputHanding{} loadingSprite = loadingSpr timeScale = 1.0 - lastTime = d2helper.Now() + lastTime = d2common.Now() d2input.BindHandler(bsHandler) return nil @@ -83,7 +81,7 @@ func Advance() { return } - currentTime := d2helper.Now() + currentTime := d2common.Now() deltaTime := (currentTime - lastTime) * timeScale lastTime = currentTime @@ -96,8 +94,8 @@ func Advance() { // Draw draws the game func render(target d2render.Surface) { if d2scene.GetLoadingProgress() < 1.0 { - loadingSprite.SetCurrentFrame(int(d2helper.Max(0, - d2helper.Min(uint32(loadingSprite.GetFrameCount()-1), + loadingSprite.SetCurrentFrame(int(d2common.Max(0, + d2common.Min(uint32(loadingSprite.GetFrameCount()-1), uint32(float64(loadingSprite.GetFrameCount()-1)*d2scene.GetLoadingProgress()))))) loadingSprite.Render(target) } else { diff --git a/d2game/d2gamescene/character_select.go b/d2game/d2gamescene/character_select.go index 93c1a7998..f7bb27c44 100644 --- a/d2game/d2gamescene/character_select.go +++ b/d2game/d2gamescene/character_select.go @@ -6,21 +6,20 @@ import ( "os" "strings" + "github.com/hajimehoshi/ebiten" + + "github.com/OpenDiablo2/OpenDiablo2/d2common" + dh "github.com/OpenDiablo2/OpenDiablo2/d2common" + "github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource" + "github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset" + "github.com/OpenDiablo2/OpenDiablo2/d2core/d2audio" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2gamestate" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2inventory" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2map" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2render" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2scene" - - "github.com/OpenDiablo2/OpenDiablo2/d2core/d2audio" - - "github.com/OpenDiablo2/OpenDiablo2/d2common" - - dh "github.com/OpenDiablo2/OpenDiablo2/d2common/d2helper" - "github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2ui" - "github.com/hajimehoshi/ebiten" ) type CharacterSelect struct { @@ -63,19 +62,19 @@ func (v *CharacterSelect) Load() []func() { v.background.SetPosition(0, 0) }, func() { - v.newCharButton = d2ui.CreateButton(d2ui.ButtonTypeTall, dh.CombineStrings(dh.SplitIntoLinesWithMaxWidth(d2common.TranslateString("#831"), 15))) + v.newCharButton = d2ui.CreateButton(d2ui.ButtonTypeTall, d2common.CombineStrings(dh.SplitIntoLinesWithMaxWidth(d2common.TranslateString("#831"), 15))) v.newCharButton.SetPosition(33, 468) v.newCharButton.OnActivated(func() { v.onNewCharButtonClicked() }) d2ui.AddWidget(&v.newCharButton) }, func() { - v.convertCharButton = d2ui.CreateButton(d2ui.ButtonTypeTall, dh.CombineStrings(dh.SplitIntoLinesWithMaxWidth(d2common.TranslateString("#825"), 15))) + v.convertCharButton = d2ui.CreateButton(d2ui.ButtonTypeTall, d2common.CombineStrings(dh.SplitIntoLinesWithMaxWidth(d2common.TranslateString("#825"), 15))) v.convertCharButton.SetPosition(233, 468) v.convertCharButton.SetEnabled(false) d2ui.AddWidget(&v.convertCharButton) }, func() { - v.deleteCharButton = d2ui.CreateButton(d2ui.ButtonTypeTall, dh.CombineStrings(dh.SplitIntoLinesWithMaxWidth(d2common.TranslateString("#832"), 15))) + v.deleteCharButton = d2ui.CreateButton(d2ui.ButtonTypeTall, d2common.CombineStrings(dh.SplitIntoLinesWithMaxWidth(d2common.TranslateString("#832"), 15))) v.deleteCharButton.OnActivated(func() { v.onDeleteCharButtonClicked() }) v.deleteCharButton.SetPosition(433, 468) d2ui.AddWidget(&v.deleteCharButton) diff --git a/d2game/d2gamescene/credits.go b/d2game/d2gamescene/credits.go index b4232e0fd..f8b0636f4 100644 --- a/d2game/d2gamescene/credits.go +++ b/d2game/d2gamescene/credits.go @@ -17,7 +17,7 @@ import ( "github.com/OpenDiablo2/OpenDiablo2/d2common" - dh "github.com/OpenDiablo2/OpenDiablo2/d2common/d2helper" + dh "github.com/OpenDiablo2/OpenDiablo2/d2common" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2ui" ) diff --git a/d2game/d2gamescene/select_hero_class.go b/d2game/d2gamescene/select_hero_class.go index 1cc27708d..5a0c7671c 100644 --- a/d2game/d2gamescene/select_hero_class.go +++ b/d2game/d2gamescene/select_hero_class.go @@ -17,7 +17,7 @@ import ( "github.com/OpenDiablo2/OpenDiablo2/d2common" - dh "github.com/OpenDiablo2/OpenDiablo2/d2common/d2helper" + dh "github.com/OpenDiablo2/OpenDiablo2/d2common" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2audio" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2ui" ) diff --git a/main.go b/main.go index 7f2d63a0f..6a3bbba30 100644 --- a/main.go +++ b/main.go @@ -6,7 +6,6 @@ import ( "gopkg.in/alecthomas/kingpin.v2" "github.com/OpenDiablo2/OpenDiablo2/d2common" - "github.com/OpenDiablo2/OpenDiablo2/d2common/d2config" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2data" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2datadict" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum" @@ -17,6 +16,7 @@ import ( "github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2audio" ebiten2 "github.com/OpenDiablo2/OpenDiablo2/d2core/d2audio/ebiten" + "github.com/OpenDiablo2/OpenDiablo2/d2core/d2config" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2input" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2render" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2render/ebiten"