Commit Graph

444 Commits

Author SHA1 Message Date
lord 7e3aff557b
Decouple asset manager from renderer (#730)
* improve AssetManager implementation

Notable changes are:
 * removed the individual managers inside of d2asset, only one asset manager
 * AssetManager now has caches for the types of files it loads
 * created a type for TextDictionary (the txt file structs)
 * fixed a file path bug in d2loader Source
 * fixed a asset stream bug in d2loader Asset
 * d2loader.Loader now needs a d2config.Config on creation (for resolving locale files)
 * updated the mpq file in d2asset test data, added test case for "sub-directory"
 * added a Data method to d2asset.Asset. The data is cached on first full read.
 * renamed ArchiveDataStream to DataStream in d2interface
 * moved palette utility func out of d2asset and into d2util
 * bugfix for MacOS mpq loader issue

* lint fixes, added data caching to filesystem asset

* adding comment for mpq asset close

* Decouple d2asset from d2render

Notable changes in d2common:
 * d2dcc.Load now fully decodes the dcc and stores the directions/frames in the dcc struct
 * un-exported dcc.decodeDirection, it is only used in d2dcc
 * removed font interface from d2interface, we only have one font implementation
 * added `Renderer` method to d2interface.Surface, animations use this to bind to a renderer and create surfaces as they need
 * added `BindRenderer` method to animation interface

Notable changes in d2common/d2asset:
 * **d2asset.NewAssetManager only needs to be passed a d2config.Config**, it is decoupled from d2render
 * exported Animation
 * Animation implementation binds to the renderer to create surfaces only on the first time it is rendered
 * font, dcc, dc6 initialization logic moved out of asset_manager.go
 * for dc6 and dcc animations, the process of decoding and creating render surfaces has been broken into different methods
 * the d2asset.Font struct now stores font table data for initialization purposes

Notable changes in d2core/d2render:
 * Surfaces store a renderer reference, this allows animations to bind to the renderer and create a surface just-in-time

**These last changes should have been a separate PR, sorry.**
Notable changes in d2core/d2ui:
 * ui.NewSprite now handles creating an animation internally, only needs image and palette path as arguments

Notable Changes in d2game:
Because of the change in d2ui, all instances of this code pattern...
```golang
animation, err := screen.asset.LoadAnimation(imgPath, palettePath)
sprite, err := screen.ui.NewSprite(animation)
```
... becomes this ...
```golang
sprite, err := screen.ui.NewSprite(imgPath, palettePath)
```
2020-09-14 17:31:45 -04:00
presiyan-ivanov 8a670d7482
Prevent player movement and casting if current spell cast is not fini… (#729)
* Prevent player movement and casting if current spell cast is not finished yet

* Properly format the fields of Player struct

Co-authored-by: Presiyan Ivanov <presiyan-ivanov@users.noreply.github.com>
2020-09-14 14:49:31 -04:00
lord 7f6ae1b785
improve AssetManager implementation (#728)
* improve AssetManager implementation

Notable changes are:
 * removed the individual managers inside of d2asset, only one asset manager
 * AssetManager now has caches for the types of files it loads
 * created a type for TextDictionary (the txt file structs)
 * fixed a file path bug in d2loader Source
 * fixed a asset stream bug in d2loader Asset
 * d2loader.Loader now needs a d2config.Config on creation (for resolving locale files)
 * updated the mpq file in d2asset test data, added test case for "sub-directory"
 * added a Data method to d2asset.Asset. The data is cached on first full read.
 * renamed ArchiveDataStream to DataStream in d2interface
 * moved palette utility func out of d2asset and into d2util
 * bugfix for MacOS mpq loader issue

* minor lint fixes

* removed obsolete interfaces from d2interface

* lint fixes, added data caching to filesystem asset

* adding comment for mpq asset close

* adding comment for mpq asset close
2020-09-14 14:47:11 -04:00
lord 854fce3b14
remove d2asset singleton (#726)
* export d2asset singleton

* add *d2asset.AssetManager to d2app

- d2app now has a reference to an asset manager which it will use for loading
- added asset loader methods to the asset manager
- functions in d2asset are now wrappers for asset manager methods

* add asset manager reference to audio provider

- d2app asset manager reference is now passed to audio provider
- asset manager is created in main.go for now to pass into audio provider
- CreateSoundEffect is now a method, no longer exported, uses the asset manager reference

* d2app passes asset manager refence to map engine test

* in d2asset, all calls to LoadFile replaced with call to Singleton.Loadfile

* blizzard intro and credits screen

- d2app passes reference to the asset manager to these screens

* asset manager for d2map

- adding MapStampFactory, takes an asset manager reference
- embedded MapStampFactory into the MapEngine
- LoadStamp is now a method of the MapStampFactory

* d2asset: removed LoadFileStream, LoadFile, and FileExists

* d2gui changes

- singleton now has an asset manager reference
- calls to d2asset loader functions removed
- createButton is now a method of LayoutManager
- moved LayoutEntry to its own file

* map entity factory

- Map engine has an embedded map entity factory
- Map stamp factory gets a reference to the map engine's entity factory
- Stamps are given a reference to the map engine entity factory when created
- Character select gets a map entity factory
- Embedded the stamp factory into the MapEngine

* asset manager for d2ui

- d2ui is passed an asset manager reference when created
- all calls to d2asset loader functions in d2ui now refer to the asset manager
- d2gamescreen gets a ui manager when created
- help overlay is now passed a ui manager when created

* d2gamescreen + d2player: asset manager references

added an asset manager reference to
- inventory panel + inventory grid
- mini panel
- game controls
- help overlay
- character select
- main menu
- select hero class
- hero stats panel

* Removed d2asset.LoadAnimation

all references to this function have been replaced with calls to the asset manager method

* adding asset to help overlay, bugfix for 4d59c91

* Removed d2asset.LoadFont and d2asset.LoadAnimationWithEffect

all references to these have been replaced with calls to the asset manager methods

* MapRenderer now gets an asset manager reference

* removed d2asset.LoadPalette

all references have been replaced with calls to an asset manager instance

* merged d2object with d2mapentity

d2object was only being used to create objects in the map, so the provider
function is now a method of the map entity factory. calls to d2asset have
been removed.

* removed d2asset.LoadComposite

all calls are now made to the asset manager method

* removed d2asset singleton

all singleton references have been removed, a single instance of the
asset manager is passed around the entire app

* rename Initialize to NewAssetManager
2020-09-12 16:51:30 -04:00
Gürkan Kaymak f4a71c72e4
lint fixes (#727) 2020-09-12 16:25:09 -04:00
lord 0218cad717
organize d2common pakage (#716)
* move music path enumerations into d2resource

* move text dictionary (.tbl) loader into d2fileformats sub-package d2tbl

* lint fix, add doc file for d2tbl

* moved data_dictionary.go into d2fileformats sub-package d2txt, added doc file

* added sub-packages d2geom for geometry-related things, and d2path for path-related things

* moved calcstring.go to d2calculation

* move bitmuncher, bitstream, stream reader/writer from d2common into sub-package d2datautils

* fix lint errors in d2datadict loaders (caused by moving stuf around in d2common)

* move size.go into d2geom

* move d2common/cache.go into sub-package d2common/d2cache

* renamed d2debugutil to d2util, moved utility functions from d2common into d2util
2020-09-08 15:58:35 -04:00
Ziemas dccb930f5c
Only draw shadows for layers that should have them (#704)
* Don't draw shadows for transparent layers

* Also use cof shadow setting
2020-08-16 14:59:34 -04:00
Ziemas 8d87c19532
Draw entities back to front within tiles (#705)
* Draw entities per subtile for correct depth order

* Use a temporary entity slice for depth sorting

Speeds things up quite a bit
2020-08-16 14:59:03 -04:00
Gürkan Kaymak 858fa18068
lint fixes (#703) 2020-08-11 18:01:33 -04:00
lord 0ea6bd5b92
add rare prefix+suffix loaders, d2items use rare item names (#702)
* adding loaders for rare prefix/suffix records

* switch to slices instead of maps for storing rare prefix/suffix records

* rare items now use the rare prefix/suffix names
2020-08-06 22:32:40 -04:00
lord acc4c7a13e
d2ui refactor (#699)
* fixed lint errors in button.go

* fixed lint errors in checkbox.go

* Removed d2ui singleton, fixed nearly all lint errors

- Changed `UI` struct to `UIManager`, removed singleton
- UI element provider functions are now methods of the UI Manager
- Screens now use the UI manager to create UI elements
- game panels in d2player now use the UI Manager to create UI elements
- Only the UI manager knows about "widgets"; calls to `d2ui.AddWidget` in Screen instances have been removed

* changed ui element provider methods from `Create` to `New`
2020-08-06 10:30:23 -04:00
lord c1ed5a2381
fixed a couple lint errors in d2term (#697) 2020-08-05 22:32:23 -04:00
lord ca7412aea6
removed singleton screen manager instance (#696) 2020-08-05 22:31:56 -04:00
lord 4507b1e1c1
fixed lint errors in d2render (#695) 2020-08-05 22:04:36 -04:00
lord 8b2b991b12
D2mapengine remove entity, minor edits (#694)
* implement entity removal

* add rgba color func, fix some lint errors in d2map

* bugfix for map entity tests
2020-08-05 21:27:45 -04:00
lord 0a6915a040
fixed lint errors in d2input (#693) 2020-08-05 13:51:35 -04:00
lord 04275eb8b6
fixed lint errors in d2gui (#692) 2020-08-05 13:51:19 -04:00
lord e73299b99e
fixed lint errors in d2audio (#691) 2020-08-05 01:17:25 -04:00
lord 8e41133f39
lint and minor refactor of d2common (#690)
- moved contents of `d2common/math.go` into `d2math/math.go`
- removed lint errors from files in d2common
2020-08-05 00:03:33 -04:00
lord fe992699b5
fix lint errors in d2interface (#684)
- fixed lint errors in d2interface
- removed `archived_` from interface names, was not necessary
- removed the Bitmuncher and Bitstream interfaces, as they are too specific and unnecessary
2020-08-04 22:53:36 -04:00
lord 120afe51a1
fixed lint errors in d2debututil (#678) 2020-08-04 22:23:15 -04:00
lord 76ed8ff180
simple inventory item descriptions (#672)
* adding simple inventory item descriptions

* adding method to identify items

* offset description so it doesn't overlap with item in inventory grid
2020-08-03 13:44:00 -04:00
lord 8560956f7f
added background color to labels (#671) 2020-08-03 00:48:17 -04:00
lord 50a070d7b0
unidentified items should use common record name for label (#670) 2020-08-02 23:01:06 -04:00
lord 524132c122
D2datadict unique items bugfix (#669)
* d2ui.Label: add support for color tokens in labels, multiple colors per label

* unique items should use the item name as the map key
2020-08-02 21:26:07 -04:00
lord 6a8b9aada1
Minor edits: debug entity frame bounds, debug `spawnmon` command (#666)
* adding debug printing boxes for entity bounds

* minor edits

- adding `spawnmon` command. currently does not have a netpacket, just for debug
- adding `GetSize` method to map entities for getting frame bounds (for debug printing)

* bug fix
2020-08-01 19:03:09 -04:00
Ziemas 39ab8d19f5
Set proper sizes for DCC frames (#663) 2020-07-31 21:22:56 -04:00
lord 1275a7f654
D2item hover highlight + name (#656)
* added highlight to animated entity

* moving provider functions for item, missile, npc, player into package export file d2mapentity.go

* changed `Create` to `New` in map entity provider functions

* add item highlight on hover

* add Name method to item entity
2020-07-31 17:55:11 -04:00
Ziemas c840e140f7
Stereo panning for sound effects (#654)
Randomly pan event sounds

Adapted from ebiten example
2020-07-30 21:50:27 -04:00
Ziemas 29ea71489d
Sound engine and sound environments (#652)
* Working sound engine and sound environments

* Clean up sounds.txt loader

* Make global volume settings apply properly

Als shuffle some stuff around

* Reset sound engine on game unload
2020-07-30 16:17:26 -04:00
lord 78ecc3557e
simple item spawning in map (#651)
* wip d2items system and item properties

* added loader for TreasureClassEx.txt

* wip item spawn from treasure class records

* wip items

* add call to init item equivalencies, remove treasure class test from d2app

* made item affix records global var a map of affix codes to the records

* changed how item to item common record equivalency is determined

* changed set items records export to a map of their codes to the records, grouped property params into a struct

* changed property parameter field from calcstring to string

* fixed bug in stat value clone

* adding equipper interface as part of stat context, eventually to be used to resolve set bonus (among other things)

* made the item interface simpler, only needs name and description methods

* adding equipper interface, for anything that will equip or have active items

* handle case where min and max are swapped, removed commented code

* added property/stat resolution for magic, rare, set, and unique items

* adding item generator which can roll for items using treasure class records

* fixed item equivalency func being called in the wrong spot

* added item spawning

- added packet type for spawning items
- added client/server handlers for SpawnItem packets
- added map entity for items
- added simpler item provider function in diablo2item package
- added debug terminal command for spawning items
2020-07-30 15:04:05 -04:00
lord bfd3f1046d
D2items WIP (#646)
* wip d2items system and item properties

* added loader for TreasureClassEx.txt

* wip item spawn from treasure class records

* wip items

* add call to init item equivalencies, remove treasure class test from d2app

* made item affix records global var a map of affix codes to the records

* changed how item to item common record equivalency is determined

* changed set items records export to a map of their codes to the records, grouped property params into a struct

* changed property parameter field from calcstring to string

* fixed bug in stat value clone

* adding equipper interface as part of stat context, eventually to be used to resolve set bonus (among other things)

* made the item interface simpler, only needs name and description methods

* adding equipper interface, for anything that will equip or have active items

* handle case where min and max are swapped, removed commented code

* added property/stat resolution for magic, rare, set, and unique items

* adding item generator which can roll for items using treasure class records

* fixed item equivalency func being called in the wrong spot
2020-07-30 10:14:15 -04:00
Tim Sarbin 460e821a5e
Started work on shadows (#630) 2020-07-26 19:29:37 -04:00
Tim Sarbin 856043d8ac
Updated music logic (#629) 2020-07-26 15:17:00 -04:00
Tim Sarbin 7da1843f49
Lint cleanup (#628) 2020-07-26 14:52:54 -04:00
Tim Sarbin 53599928f7
re-ordered structures to optimize memory layout (#627) 2020-07-26 13:23:46 -04:00
Tim Sarbin 63aa1eebe9
Fix bad file names (#626)
* Fixed bad capitalization in names

* More bad name fixes

* temp rename for case sensitivity issues

* Temporary rename to fix capitalization
2020-07-26 13:06:37 -04:00
danhale-git 259c6e7e76
Vector method pointers (#621)
* All Vector methods which operate on the vector return pointers to it.

* All Vector methods which take vectors take Vector pointers.
2020-07-25 09:36:54 -04:00
Benjamin Maisonnas 89b031d2b7
fix(camera): focus the local player on viewport init (#620)
Thanks!
2020-07-25 09:36:15 -04:00
Gürkan Kaymak 1ce81f1aec
fixed Id renaming in strings (#618) 2020-07-24 07:54:52 -04:00
lord 9e61079e93
Stats refactor (#617)
* add interface for stats, d2 is an implementation

* fix incorrect comment, remove ennecessary int

* simplified description functions, remove duplicates

* moved default stringer functions

* fixed incorrect stat combine method

* change `Create` to `New` in method names

* d2stats + diablo2stats refactored again

- simplified `NewStat` provider function
- added initializer for stat values that sets the stringer functions, value types, and combination types for values when created
- removed redundant description functions
- added stat value combination types `sum` and `static`

`static` stat values which are not altered when stats are combined. this makes sense for stats like proc-on-hit or +skills to class

example:
	Stat A: `10% reanimate as: skeleton mage`
	Stat B: `8% reanimate as: skeleton archer`
	Stat C: `6% reanimate as: skeleton archer`

	A and B can not be combined
	B and C can be combined to `14% reanimate as: skeleton archer`
2020-07-23 22:12:48 -04:00
lord c114ab9eb7
add interfaces for stats, added diablo 2 implementation (#614)
* add interface for stats, d2 is an implementation

* fix incorrect comment, remove ennecessary int

* simplified description functions, remove duplicates

* moved default stringer functions

* fixed incorrect stat combine method

* change `Create` to `New` in method names
2020-07-23 19:03:58 -04:00
Gürkan Kaymak 7a49f3637f
lint fixes (#615) 2020-07-23 12:56:50 -04:00
Gürkan Kaymak 80e655964e
Removed some global variables (#611)
* removed some global variables

* fixed tests
2020-07-22 15:03:03 -04:00
lord 362147848d
entity debug rendering (#609)
* entity debug rendering, with command

needed to add getter method to MapEntity interface, so that's the reasoning for changing objects/npcs/player/etc

this currently brings allocs/s up to 10 (you can check by running `fps` command, se we need to look into d2debugutils and how it handles drawing text

* reverting velocity copy, broke the map entity tests. debug display wont show velocity currently.

* adding velocity debug
2020-07-21 08:51:09 -04:00
Ziemas d0c6cd61dd
Simple LOS pathfinding without walkmesh (#610)
* Reorganize MapEngine

This is already turning into a mess...

* Map engine selects tile index to use

Still very ugly

* Fix subtile flag combination

* Prepare randomly generated base tiles

* Restore collision viewer

* Movement works again, searches for straight paths

Paths are now d2vector slices

* Fix LOS calculation

* Fix test (I think)
2020-07-21 08:50:45 -04:00
lord aadfa35e6b
Smooth camera targetting (#607)
* smooth camera with vectors

* add smooth cam  support to map engine test

smooth cam now works in map engine test.
clicking or holding the left-mouse button will move the camera.

also works with freecam mode in single-player.

* Update ebiten_renderer.go

did not mean to edit this file
2020-07-18 23:37:35 -04:00
danhale-git 727e8244c6
Implemented Position in Path and PathTile (#605)
* Unnecessary constructor assignments removed.

* Position implemented in d2common.Path

* Position implemented in mapEntity.Step.

* Position implemented in d2common.PathTile.
2020-07-18 18:07:13 -04:00
lord dbc07e2ce8
removed most lint errors in d2gui (#604) 2020-07-18 18:06:36 -04:00
dk fc31594277
removing magic numbers, adding rgba color creator func (#602) 2020-07-18 00:02:04 -04:00
dk d56c4387ff
delint_d2networking (#599)
* delint_d2networking

not sure what to do about lint error G110 on calls to `io.Copy`, warns
about gzip compression bomb possibility, leaving those.

all todo's have been left.

* removed duplicate const
2020-07-17 22:11:16 -04:00
dk ba89bf965a
removing lint errors from d2render (#598)
The edits outside of d2render or to fix the lint error for `DrawText`.
`DrawText` should be called `DrawTextf` because it formats the string.
2020-07-17 18:51:44 -04:00
dk 1654fd7e90
Removing lint errors in npc.go, mapstamp.go (#597)
- made an enum for NPCActionType to get rid of magic numbers
- moved the enum to d2enum
- fixed lint errors in npc.go
- fixed lint errors in mapstamp.go (because it was using npc.go)
2020-07-17 18:51:19 -04:00
dk cf6029eb95
Stat descriptions + tests, Skilldesc.txt loader (#590)
* adding ranged number type, for use in stats

* Loaded Skills.txt

* asset manager only binds terminal commands if terminal != nil

* WIP stats

* cache getter and clear methods were not implemented

* asset manager handles a nil terminal pointer

* adding skilldesc.txt loader (needs work)

* ctc stat descriptions functions working

* moving description functionality out of itemstatcost loader and into stats

* stats seem like a central part of diablo, moving into d2core.

* stats seem like a central part of diablo, moving into d2core.

* delint

* adding statlist, statlist reduction, unit tests

* minor edits to stat.go

* lint error in statlist.go

* Remove dependency on actual data from mpq files

stats unit tests now use mock data

* fixing some lint errors, formatting

Co-authored-by: Maxime Lavigne (malavv) <duguigne@gmail.com>
2020-07-17 18:50:45 -04:00
danhale-git 921d44a70c
mapEntity.Step() benchmark and improvements. (#593)
* Initial test and benchmark for mapEntity.Step().

* Removed `&& !m.hasPath()` from mapEntity.atTarget

* Direction is now updated when the path node changes mid-step and target is updated when path is set.

* Test improvements.

* Deleted old benchmark function and tidying.

* d2math.Abs added.

* Abs benchmark and optimisation.

* Negate and Distance benchmark.

* Length and SetLength benchmark.

* Lerp and Dot benchmark.

* Cross and Normalize benchmark.

* Angle and SignedAngle benchmark.

* Trivial change to Vector.Abs()
2020-07-16 12:06:08 -04:00
David Carrell 3bdbd5c358
rely on App to know how to navigate between screens using a callback interface with explicit methods (#592)
remove unused struct vars that were only stored in order to pass to the next screens

consolidate create game code to single method

export ScreenMode consts and SetScreenMode method to allow app to create the correct screens

Co-authored-by: carrelda <carrelda@git>
2020-07-14 13:11:23 -04:00
Ziemas abde829e88
Revert my accidentally included hack (#589) 2020-07-14 06:59:35 -04:00
Ziemas 09a6869aea
Use vectors for object positioning (#587)
* Use d2vector.Position in objects

* Remove arbitrary render offset

If things are actually wrong lets figure out why

* Remove arbitrary wall offset

This broke maggot lair
2020-07-14 00:25:23 -04:00
Ziemas a0c966eeeb
Show what components are present at a given tile (#588)
Ugly but works
2020-07-14 00:24:49 -04:00
dk 5458859faf
d2asset: init without terminal (#586)
* cache getter and clear methods were not implemented

* asset manager handles a nil terminal pointer
2020-07-13 20:30:30 -04:00
dk 5fdbb6a094
cache getter and clear methods were not implemented (#585) 2020-07-13 20:30:03 -04:00
David Carrell cc893e4dd4
504 - removes input singleton in favor of d2interface.InputManager constructor injection (#584)
Co-authored-by: carrelda <carrelda@git>
2020-07-13 20:29:17 -04:00
danhale-git 894c60f77a
Map entity rework - vectors in mapEntity (#579)
* Fixed NaN on normalize 0 vector.

* Tentative implementation in getStepLength.

* mapEntity.TileX/Y removed.

* Fixed Position and Target not being initialised in createMapEntity.

* mapEntity.Position is no longer embedded.

* mapEntity.LocationX/Y no longer used outside map_entity.go.

* mapEntity.subCellX/Y removed.

* mapEntity.LocationX/Y removed.

* mapEntity.OffsetX/Y and TargetX/Y removed.

* Direction method added to Vector, returns 0-64 direction.

* Moved Vector.Direction() to Position.DirectionTo and refactored.

* Renamed RenderOffset from SubCell and tested IsZero.

* d2math.WrapInt added for use with directions.

* Tidied up position and tests.

* Refactored d2common.AdjustWithRemainder into d2mapEntity.

* Tidying up d2mapEntity.

* Final cleanup.

* Lint warnings.

* Spelling correction.
2020-07-13 09:06:50 -04:00
Sunny Klair 41e7a5b28b
Add static checks to help ensure implementations conform to interfaces (#582) 2020-07-13 09:05:04 -04:00
thetogi 7b60882ba3
Replace ebitenUtil with d2DebugUtil and new charmap for debugger. (#577)
* lint updates for /d2astar

* png issue

* debug package

* load bmp properly

* debug draft

* Vector float64 (#565)

* Fixed nil pointer in Copy()

* Position added

Added Floor() and String() methods to Vector.

Also added Position which declares an embedded Vector2 and returns various forms of it.

* d2vector.Vector2 renamed to d2vector.BigFloat

* vector.go renamed to big_float.go

* Float64 stub and more renaming

* Vector value getters

* Separate vector types with initial methods.

* Divide and lint warnings.

* Distance and Length.

* Scale, Abs and Negate.

* CompareFloat64Fuzzy delta direction reversed.

* Refactor vector_test.go.

* Renamed Approx methods.

* Distance and Length.

* Distance and Length.

* Removed BigFloat and Vector, renamed Float64 to Vector, simplified tests.

* Angle, SignedAngle and other small functions.

* Receiver rename.

* SingedAngle and test fixed

* Rotate.

* SetLength.

* Cross.

* NinetyAnti and NinetyClock.

* Lerp and Clamp.

* Reflect and ReflectSurface.

* Cardinal convenience functions.

* Comments.

* Panic on NaN and Inf in Position.

* Lint warnings and comments.

* D2map lint warnings (#566)

* Comments and newlines in engine.go

* Comments and newlines in object.go

* Comments and newlines in animated_entity.go

* Comments and newlines in missile.go

* Comments and newlines in npc.go

* Comments and newlines in player.go

* Removed object.go (incorrectly merged it in during rebase).

* Comments and newlines in renderer.go.

* Comments and newlines in map_entity.go.

* Comments and newlines in walk_mesh.go.

* Comments and newlines in viewport.go and tile_cache.go.

* Comments and newlines in stamp.go and wilderness_tile_types.go.

* Comments and newlines in everything else.

* removing inventory grid test for now because it causes builds to fail on github (#570)

* Refactored d2enum (#567)

* Refactored animation mode enum

* More d2enum changes

* Refactored tile enum

* Refactored weapon class enum

* Refactored more enums

* Refactored item event enum

* Fixed init_functions animation mode

* Removed string2enum from MonsterAnimationMode

* Refactored ItemStatCost description

* Last enum lint errors

* Regenerated monster stringer file

* compressed image

* Replaced restruct with StreamReader (#574)

* Fixed bug in palette.go (#575)

* Javascript console commands (#572)

* Allow the execution of JS from the terminal when hosting a local game or playing a single game

Signed-off-by: William Claude <w.claude@thebeat.co>

* Reorganise imports on edited files

Signed-off-by: William Claude <w.claude@thebeat.co>

* Remove Reset

Signed-off-by: William Claude <w.claude@thebeat.co>

* Add inventory.txt loader, use the records (#573)

* adding resource entry for inventory.txt

* adding loader for inventory.txt

* adding call to inventory.txt loader in d2app

* d2game now uses the inventory.txt records for making the inventory panel

* removed comments

* remove unused files

* update go.mod

* lint updates for /d2astar

* png issue

* update go.mod

Co-authored-by: danhale-git <36298392+danhale-git@users.noreply.github.com>
Co-authored-by: dk <dknuth0101@gmail.com>
Co-authored-by: Intyre <Intyre@gmail.com>
Co-authored-by: William <1004323+aziule@users.noreply.github.com>
2020-07-11 18:12:20 -04:00
William d85e2bdd51
Javascript console commands (#572)
* Allow the execution of JS from the terminal when hosting a local game or playing a single game

Signed-off-by: William Claude <w.claude@thebeat.co>

* Reorganise imports on edited files

Signed-off-by: William Claude <w.claude@thebeat.co>

* Remove Reset

Signed-off-by: William Claude <w.claude@thebeat.co>
2020-07-11 11:24:04 -04:00
Intyre c66a3d5e7a
Fixed bug in palette.go (#575) 2020-07-10 23:04:35 -04:00
Intyre 9e58b134e5
Refactored d2enum (#567)
* Refactored animation mode enum

* More d2enum changes

* Refactored tile enum

* Refactored weapon class enum

* Refactored more enums

* Refactored item event enum

* Fixed init_functions animation mode

* Removed string2enum from MonsterAnimationMode

* Refactored ItemStatCost description

* Last enum lint errors

* Regenerated monster stringer file
2020-07-09 23:12:28 -04:00
danhale-git 6104adc700
D2map lint warnings (#566)
* Comments and newlines in engine.go

* Comments and newlines in object.go

* Comments and newlines in animated_entity.go

* Comments and newlines in missile.go

* Comments and newlines in npc.go

* Comments and newlines in player.go

* Removed object.go (incorrectly merged it in during rebase).

* Comments and newlines in renderer.go.

* Comments and newlines in map_entity.go.

* Comments and newlines in walk_mesh.go.

* Comments and newlines in viewport.go and tile_cache.go.

* Comments and newlines in stamp.go and wilderness_tile_types.go.

* Comments and newlines in everything else.
2020-07-09 16:11:01 -04:00
Ziemas e2e8a303c2
Use our own DrawEffects enum for draw effects (#564)
* Add PushEffect, handle effects in renderer

* Set effects instead of blend

* Stop using PushCompositeMode, use PushEffect

* Remove remaining composite mode things
2020-07-08 21:57:35 -04:00
Ziemas 1ad3c72211
Standardize indexed color to RGBA conversion to one function (#562)
* Common function for indexed color to rgba

* Use ImgIndexToRGBA when decoding tiles

* Pass DrawEffect down to animation
2020-07-08 17:46:45 -04:00
Maxime Lavigne (malavv) f18ede6e66
Removing Clone of Font() since all material is sharable, Fixes #515 (#561)
* Removing Clone of Font() since all material is sharable, Fixes #515

* Removed Clone() from the Font interface, as deep copies are not needed.
2020-07-08 11:25:40 -04:00
Intyre db5e844aac
Removed Configuration interface (#560) 2020-07-08 09:16:16 -04:00
Maxime Lavigne (malavv) f7e0912f5f
Fixing D2GUI based event propagation with d2input. #531 (#559)
d2input made the move to immutable events. (ex. MouseMove) but
d2gui was using "local events" for its recursive layouts. Meaning
when entering a sub-layout, the original event was modified to have
the cursor relative to the x, and y of the parent layout.

After tossing ideas with Grav, we considered (1) making events modifiable,
(2) having an event constructor, (3) changing sub-Layout to use screen layout.

We choose (3), and this is the relevant commit.
2020-07-08 09:15:20 -04:00
Ziemas 38213e749a
Some slight DC6 cleanup (#557) 2020-07-08 09:14:09 -04:00
Maxime Lavigne (malavv) 0a78a1adcc
Centralized usage of Fonts to fix cache #515 (#556)
The split between d2ui and d2asset Font version caused incorrect caching between the two. After looking at d2interface.Font, I saw the d2asset was the most recent and more tightly and cleanly packaged.

I therefore removed the old d2ui.Font and embedded the d2asset version in the d2ui.Label and d2ui.Button.

Looking at the code of d2ui, it would be logical to completly swap it for their d2gui version. But at least for the moment, the d2ui.Button as more functionality since it embeds a Label (instead of a font), and this label now has multiline horizontal alignement.
2020-07-07 20:16:22 -04:00
Ziemas 252e6c6c23
Clean up monstats2 (#555) 2020-07-07 15:04:18 -04:00
Gürkan Kaymak 76862b756c
cleaned globals of the d2render/ebiten package (#554) 2020-07-07 08:57:40 -04:00
Ziemas af0fb11a54
Apply NPC speed from monsats (#551) 2020-07-06 21:32:39 -04:00
dk 60e6fcb7ac
moving enumerations out of d2interface (#552)
* moved filter constants back to d2enum

* moving key and mouse button enums into d2enum

* moving render type enum into d2enum

* moving input even priority enums into d2enum

* moving terminal enums into d2enum
2020-07-06 21:26:08 -04:00
Ziemas 5212270c44
Split up DCC/DC6 animation implementations, decode directions on demand (#548)
* Split DCC and decode direction on demand

* Clean up

* More cleanup

* Make dc6 animation it's own type

* Make base animation private

* Also decode DC6 directions on demand
2020-07-06 20:13:06 -04:00
Ziemas e473dc2cc5
Apply some more object animation settings (#549)
* Init torches with random start mode

* Apply more object animation settings

Also add ability to start object animation on random frame
2020-07-06 20:12:53 -04:00
dk 321a353461
Font manager abstraction (#545)
* abstracted palettes, colors, and palette manager

* make asset manager use the palette manager interface

* added BGRA setter/getter, fixed lint errors

* abstraction for animation and animation manager

* abstracted font and font manager
2020-07-05 15:56:48 -04:00
dk c1a88c9cf7
Animation manager abstraction (#544)
* abstracted palettes, colors, and palette manager

* make asset manager use the palette manager interface

* added BGRA setter/getter, fixed lint errors

* abstraction for animation and animation manager
2020-07-05 13:01:44 -04:00
dk 8809fb2c22
Made abstractiong for the file manager (#542)
I realized that the file manager is actually managing file access
to the archives, but it's doing so through the archive manager.

I've renamed it, it's now called ArchivedFileManager because that
is really what it is.
2020-07-05 00:00:00 -04:00
dk 0a72ccaf16
Abstraction for archives and archive manager (#541)
* archive abstraction

* archive manager abstraction

* fixinglint errors

* archive abstraction

* archive manager abstraction

* fixinglint errors
2020-07-04 22:37:13 -04:00
dk cf35285b48
abstracted d2config to an interface (still have a singleton, though) (#538) 2020-07-04 00:49:16 -04:00
Ziemas 3757ff1ac5
New package d2object, first object initFun (#537)
* Move MapEntity to d2interface

* New package d2object, first object initFun

Moves objects out to their own package and implements the very first
init function, torches/braziers now gets their animation mode set at creation.

* Apply name again

* Turn on waypoints
2020-07-04 00:48:31 -04:00
Ziemas 6269726316
Composite work (#536)
* Quit using ObjectLookupRecord in composite

* Unexport SetMode in map entities

* Get rid of weaponClass from MapEntity

* Pass ObjectType to composite instead of string

* Use layer weaponclass from cof

* Manage more stuff directly in composite

* Explicitly index when picking equipment
2020-07-03 22:52:50 -04:00
dk 4c3ff12cba
abstracted cache to an interface (#535) 2020-07-03 21:23:44 -04:00
dk de116e8367
moving package comments into doc.go files (#534) 2020-07-03 18:33:46 -04:00
dk 62b8a610c0
D2input abstraction (#532)
* abstract d2input manager/service/events/keys/buttons to interface

* abstract d2input manager/service/events/keys/buttons to interface

* fixing lint error
2020-07-03 15:09:16 -04:00
Tim Sarbin 5bfec3ccb0 Removed render singleton. Updated refs. 2020-07-03 14:00:56 -04:00
Ziemas 7ce01ab694
Create objects by passing the object record to CreateObject (#530)
* Create object by Objects.txt entry

Get graphics token from objectType

* Unexport some unused ObjectRecord stuff.
2020-07-03 10:38:22 -04:00
Gürkan Kaymak 9c2b1dccaf
Lint fixes for the d2game/d2gamescreen (#516)
* more lint fixes for the d2core/d2term

* lint fixes for the escape_menu.go

* fixed lint issues of credits screen

* more lint fixes for the d2gamescreen

* lint fixes for the main menu of d2game/d2gamescreen package

* lint fixes for the main menu and map engine testing of d2game/d2gamescreen package

* more lint fixes for the main menu of d2game/d2gamescreen package

* lint fixes for the character select screen of d2game/d2gamescreen package
2020-07-02 13:55:43 -04:00
David Carrell c8ec4c018e
first pass at resolving linting issues in d2asset (#518) 2020-07-01 14:09:18 -04:00
Maxime Lavigne (malavv) 973e969002
Working on d2input.go for #487 (#514)
d2input/ is now clear of lint.
2020-07-01 14:03:40 -04:00
Ziemas 0272b593fb
Cof direction lookup (#517)
Generated these based on the d2dcc direction lookup hopefully they're
correct (they seem to be at least)
2020-07-01 14:02:47 -04:00
Natureknight 04ed9466f4
fixed linting issues in d2screen and d2render (#487) (#512) 2020-07-01 08:59:24 -04:00
Ziemas fa20b9ee51
Spawn monster by monstat record (#508)
* DS1 reader no longer looks up objects

* Start of enteties managing their own equipment

* stringer and string2enum CompositeType

String2enum

* Use CompositeType stringer to simplify composite

* Finally fix GetDelimitedList

And lint issues

* NPC selects random equipment
2020-07-01 00:06:06 -04:00
Gürkan Kaymak ae6bfb839e
Lint fixes for the following packages (#505)
* fixed lint issues of the package d2core/d2inventory

* fixed lint issues of the d2script package

* fixed lint issues of the d2common/d2interface package

* fixed lint issues of the d2common/d2resource package

* fixed lint issues of the d2core/d2term package

* fixed conflict errors
2020-06-30 17:04:41 -04:00
Maxime Lavigne (malavv) d15221c21c
d2hero is *nearly* lint free #487. (#506)
Only lint left are meaningful TODOs.

I also defaulted the level and exp parameters as if we were to handle non-default state, we would need much more information. It might be worth creating another function at that point.
2020-06-30 17:03:20 -04:00
Maxime Lavigne (malavv) 3990df3bac
Fixes #496 and improves memory consumption on render of game_controls (#501)
* Fixes #496 using ebiten.SubImage to Render Section of a Surface.

I had to add matching functions to both animation and sprite to get it to be called
for a sprite object.

* Fixed linter warning on comments for Sprite and Animation.

* Removing what's remaining of the old Sprite re-generation and caching.
2020-06-30 12:43:13 -04:00
Tim Sarbin e2572b8745
More linting (#500) 2020-06-30 09:58:53 -04:00
dk 4938ec1f44
Resolved most lint errors in d2data and d2datadict (#499)
* adding comments to d2interface for linter

* moved d2render renderer interfaces and types into d2interface

* fixed most lint errors for monstats loader

* de-lint d2data wip

* d2data: resolve linting errors
2020-06-30 09:17:07 -04:00
Ziemas aae565d528
Monstat2 loading and a bunch of lint issues (#491)
* MonStat2 loader

* Fix a bunch of lint issues in d2datadict
2020-06-29 12:37:11 -04:00
dk 55dc3e42ed
minor edits (#486)
* adding comments to d2interface for linter

* moved d2render renderer interfaces and types into d2interface
2020-06-29 00:41:58 -04:00
Ziemas 9f7f1ae072
Actually use renderpass2 (#485) 2020-06-29 00:30:27 -04:00
Tim Sarbin 255ffc75da
Fixed lint issues (#484) 2020-06-28 22:32:34 -04:00
dk 09a28c2822
removed d2term singleton (#483) 2020-06-28 21:40:52 -04:00
Tim Sarbin 3f575cf1d8
Removed audio singleton (#482) 2020-06-28 19:31:10 -04:00
Tim Sarbin 1b614ddb3a
Made animation loaders public. (#481)
* Updated ebiten reference

* Made animation loaders public
2020-06-28 12:10:25 -04:00
Ziemas 3f1fe538e2
Load monpreset and use that to find monstat entries for NPC's (#477)
* Load monpreset.txt

* Get monstat for npc's and their name from strings

Using monpreset to grab the key for monstat

* Object name tags
2020-06-27 23:15:20 -04:00
Ziemas b00fa58fc4
Object Highlights (#476)
* Add PushBrightness to surface

* Highlight selectable objects

Check if mapentity is selectable. (seems reasonable)
Request objects to highlight themselves is required (idk)
2020-06-27 18:58:41 -04:00
Ziemas 2937838839
Don't use object record speed if 0 (#475)
Seems weird to set it to 0, only saw it on one object.
2020-06-27 15:44:28 -04:00
Ziemas 11f743aa42
Get and use draw order and animation speed for objects (#473)
* String2enum ObjectAnimationMode

* Render objects at their assigned layer

Gets the orderflag from the object record and assign it to the mapentity
so the renderer can get at it.

This adds another render pass that loops through the objects.

* Get object animation speed from their txt entry
2020-06-27 14:30:23 -04:00
Tim Sarbin 490c00b7b2
Added audio streaming capabilities (#471) 2020-06-27 02:49:27 -04:00
David Carrell c6721432a6
412 missle animation (#470)
* 412 - move missle code to game_client and add animation, still buggy

* mostly working casting animation that cancels path

Co-authored-by: carrelda@Davids-MacBook-Pro.local <carrelda@Davids-MacBook-Pro.local>
2020-06-26 20:03:00 -04:00
Tim Sarbin 1ca534cc13
Revert "Refactor d2map (#468)" (#469)
This reverts commit fe47e51351.
2020-06-26 17:12:19 -04:00
dk fe47e51351
Refactor d2map (#468)
* WIP refactor of d2map stuff

* more d2map refactor

adding realm init to game client
passing map engine from client and server into realm at init
change `generate map packet` to have act and level index as data

* client explodes, but getting there

* realm now initializes, networking works, but map generators dont currently do anything

* changed the way that level type records are loaded

* fixed funcs for level data lookups

* started implementing level generator, currently crashing

* client no longer exploding

* d2networking refactor

put exports into d2client.go and d2server.go
kept GameClient and GameServer methods into their respective files
made methods for packet handlers instead of the giant switch statements

* bugfix: getting first level id by act

* minor refactor of gamescreen for readability

* towns now generate on server start, create player takes act and level id as args, levels have their own map engine
2020-06-26 16:50:24 -04:00
Natureknight 875081f6b2
fixed broken viewport while side menu is opened (#464) (#465) 2020-06-26 09:15:45 -04:00
Tim Sarbin 226181ffcc
UI fixes (#461) 2020-06-25 17:28:48 -04:00
William 48a193579f
Enhanced escape menu with options - d2gui bug remaining (#459)
* First improvements

Signed-off-by: William Claude <w.claude@thebeat.co>

* Make the menu more generic

Signed-off-by: William Claude <w.claude@thebeat.co>

* Handle mouse events

Signed-off-by: William Claude <w.claude@thebeat.co>

* Remove debug statement

Signed-off-by: William Claude <w.claude@thebeat.co>

* Handle left clicks better

Signed-off-by: William Claude <w.claude@thebeat.co>

* Remove unused file

Signed-off-by: William Claude <w.claude@thebeat.co>

* Handle titles in screens

Signed-off-by: William Claude <w.claude@thebeat.co>

* Improve the menu using layouts

Signed-off-by: William Claude <w.claude@thebeat.co>

* Add support for onOff labels

Signed-off-by: William Claude <w.claude@thebeat.co>

* Mutualise title creation

Signed-off-by: William Claude <w.claude@thebeat.co>

* Add gutter and mutualise things

Signed-off-by: William Claude <w.claude@thebeat.co>

* Improve menu, mutualise a lot of things and support animated sprites

Signed-off-by: William Claude <w.claude@thebeat.co>

* Use a cfg struct instead of independent handlers

Signed-off-by: William Claude <w.claude@thebeat.co>

* Fix hardcoded value

Signed-off-by: William Claude <w.claude@thebeat.co>

* Clean things a bit

Signed-off-by: William Claude <w.claude@thebeat.co>

* Remove unused property

Signed-off-by: William Claude <w.claude@thebeat.co>

* First support for hoverable elements

Signed-off-by: William Claude <w.claude@thebeat.co>

* Add support for label selection feedback

Signed-off-by: William Claude <w.claude@thebeat.co>

* Add support options

Signed-off-by: William Claude <w.claude@thebeat.co>

* Update print statement

Signed-off-by: William Claude <w.claude@thebeat.co>

* Update rendering and clean code

Signed-off-by: William Claude <w.claude@thebeat.co>

* Remove debug things

Signed-off-by: William Claude <w.claude@thebeat.co>

* Handle hovering

Signed-off-by: William Claude <w.claude@thebeat.co>

* Support enter key for labels

Signed-off-by: William Claude <w.claude@thebeat.co>

* Attach methods to layout

Signed-off-by: William Claude <w.claude@thebeat.co>

* Move things under EscapeMenu

Signed-off-by: William Claude <w.claude@thebeat.co>

* Some renaming

Signed-off-by: William Claude <w.claude@thebeat.co>

* Clean

Signed-off-by: William Claude <w.claude@thebeat.co>

* Set hovered element ID when using the mouse

Signed-off-by: William Claude <w.claude@thebeat.co>

* Clean

Signed-off-by: William Claude <w.claude@thebeat.co>

* Delete unused file

Signed-off-by: William Claude <w.claude@thebeat.co>

* Wire save & exit with a nasty hack

Signed-off-by: William Claude <w.claude@thebeat.co>

* Remove unused file

Signed-off-by: William Claude <w.claude@thebeat.co>

* Remove dead code

Signed-off-by: William Claude <w.claude@thebeat.co>

* Reorder the code a bit

Signed-off-by: William Claude <w.claude@thebeat.co>

* Rename hoverableElement into actionableElement

Signed-off-by: William Claude <w.claude@thebeat.co>

* Prevent regenerating the label if the text didn't change

Signed-off-by: William Claude <w.claude@thebeat.co>
2020-06-25 16:27:16 -04:00
presiyan-ivanov c64e9be78b
Character stats (#458)
* Save/load hero stats and display them in stats panel.

* Load default hero state for characters created before saving stats was introduced

Co-authored-by: Presiyan Ivanov <presiyan-ivanov@users.noreply.github.com>
2020-06-25 14:56:49 -04:00
Tim Sarbin 6778658606
Fixed possible crash when placing tiles outside of map (#453) 2020-06-25 14:53:22 -04:00
Tim Sarbin 6dae0097b9
Added npc labels. More mapgen stuff. (#449) 2020-06-25 00:39:09 -04:00
David Carrell 0cef1b0a73
fix right mouse button not triggering input events (#448) 2020-06-25 00:36:27 -04:00
David Carrell bed386be87
default done loading after OnLoad finishes (#447) 2020-06-24 22:41:18 -04:00
David Carrell 390f6a1234
351 - add progress handle and helper functions to ScreenLoadHandler:OnLoad to provide ability to asynchronously load data and animate the loading screen (#445)
Co-authored-by: carrelda@Davids-MacBook-Pro.local <carrelda@Davids-MacBook-Pro.local>
2020-06-24 18:46:03 -04:00
Natureknight b60465fd6c
render the run button the UI, and allow the user to toggle it with their mouse, in addition to the R key on the keyboard (#400) (#443) 2020-06-24 15:23:38 -04:00
Tim Sarbin d8a817eddf
fix stamp bug preventing maps from rendering properly (#441) 2020-06-24 14:35:49 -04:00
Ziemas 02605227c3
Various map entity reworks (#439)
* Use integer directions for rotating map entities

* Manage composite directly in npc

* Player manages its own composite

* Split up animation mode types

Players, monsters, objects all have their own types

* Clean up AnimatedEntity

* Rename AnimatedEntity -> Object

* Keep the object txt record on hand in Object
2020-06-24 13:49:13 -04:00
Tim Sarbin 954670da5f
Fixed linting issues (#438) 2020-06-24 10:13:11 -04:00
dk 46ccce56bd
minor edits to d2map engine, added methods for converting between index and tile coordinates (#433) 2020-06-24 08:10:48 -04:00
nicholas-eden 329e2f0fab
Use closest path if path not found (#431)
When clicking on the other side of a wall or in an an inaccessible area,
route the player the closest possible node.  This allows running along
walls and matches the original closely.

Co-authored-by: Nicholas Eden <neden@zigzagame.com>
2020-06-24 08:09:00 -04:00
Tim Sarbin a24c05efa9
Map generation and test fixes (#430)
* More mapgen updates

* Added east generation

* Added west town generation

* Fixed test errors
2020-06-24 00:04:27 -04:00
David Carrell 37ae98d81b
Abstract away remaining ebiten references (#409)
* 337 - remove ebiten from character selection

* 337 - abstract d2input away from ebiten implementation

* WIP 337 - remove ebiten use from d2ui

* 337 - fix accidental left->right change

* 337 - fix ui button selection bugs

* 337 - fix textbox bugs

* 337 - fix scrollbar bugs

* 337 - address PR comments

* 337 - fix invalid hero selection bug

Co-authored-by: David Carrell <carrelda@Davids-MacBook-Pro.local>
2020-06-23 18:12:08 -04:00
Ripolak f729ff6101
Feature/load misc items (#424)
* Add InventoryItemMisc struct

* Add GetMiscItemByCode function

* Implement InventoryItem interface for InventoryItemMisc

* Add rings and amulets to the example items loading.

* Fix Y of LeftHand and RightHand equipment slots.

* Add "Ripolak" name to CONTRIBUTORS

* Remove double item
2020-06-23 15:28:03 -04:00
nicholas-eden dd21809288
Pull go-astar code into the repo, improve perf (#411)
Copied go-astar into d2common/d2astar, made a few optimizations.  Runs
roughly 30% faster according to my benchmarking.

Added a `maxCost` param to prevent searching the entire map for a path.
This probably needs tweaked a bit, but follows the original game more
closely.

Co-authored-by: Nicholas Eden <neden@zigzagame.com>
2020-06-23 02:04:17 -04:00
Tim Sarbin c2db7ede66
Added basic map generation for first area of south town (#408)
* Map engine updates. Limited rendering to specific area.

* Added south town border generation
2020-06-23 01:05:01 -04:00
Ziemas 15b78372b2
Update textboxes in their advance function (#407)
Fixes wonky input
2020-06-22 23:51:23 -04:00
Tim Sarbin 4dc4654750
Fixed map stamp offset issue (#403) 2020-06-22 19:33:12 -04:00
dk 953271b8e6
minor edits (#401)
* make game update at 25fps, ui update at max fps

* minor edits to func names, d2resource constants

* renamed `loadDictionary` to `loadTextDictionary` to avoid confusion with `LoadDataDictionary`
* updated line in main.go that calls `loadTextDictionary`
* added tokens as constants inside of `d2resource/resource_paths.go` that are used in font/language paths
* moved locale string handling stuff into it's own func, now uses tokens defined in d2resource

* minor edits to func names, d2resource constants

* renamed `loadDictionary` to `loadTextDictionary` to avoid confusion with `LoadDataDictionary`
* updated line in main.go that calls `loadTextDictionary`
* added tokens as constants inside of `d2resource/resource_paths.go` that are used in font/language paths
* moved locale string handling stuff into it's own func, now uses tokens defined in d2resource

* fix: accidentally renamed func in d2asset

* git is hard

accidentally added changes not meant for this commit
2020-06-22 17:36:45 -04:00
presiyan-ivanov 2835ff4cf1
Improve run/walk/neutral animation handling. Initial parsing of Level… (#372)
* Improve run/walk/neutral animation handling. Initial parsing of LevelDetail records. Support for holding mouse buttons.

- Run/walk/neutral positions now map to a different animation mode(and speed) depending if in or out of town.

- Run/walk toggle which can be activated/deactivated with R key.

- Temporary(and incorrect) loading and mapping for LevelDetails records.

- Zone change label which shows the level name from LevelDetailsRecord when the player enters a different zone.

- Allow holding mouse left/right button to repeatedly generate an action.

* Remove duplicate load of LevelDetails. Replace numbers in zone change logic with their corresponding RegionIdType

* Move zone change check at the correct place

Co-authored-by: Presiyan Ivanov <presiyan-ivanov@users.noreply.github.com>
2020-06-22 15:55:32 -04:00
Haashi 5e1725dd7d
385/lintissues (#391)
* camera offset for ui panels :

added maprenderer viewport to be aligned left or right

calling alignement on keyPress in game_controls

* check if already aligned

* fix bugs

-forgot to assign alignement
-defaultScreenRect instead of screenRect because of issue mentionned in original comment

* remove config.json and replace go.mod line

* removing duplicate import of d2common

replacing all dh to d2common

* remove useless breaks from switch statement

* better range when value unused + prettying import

* item_affix rewrite

using return values instead of pointer references in arguments

* ebiten deprecated calls

* small fixes
2020-06-22 11:53:44 -04:00
Haashi 711cae2d69
fix for #358 from recent PRs (#390)
* camera offset for ui panels :

added maprenderer viewport to be aligned left or right

calling alignement on keyPress in game_controls

* check if already aligned

* fix bugs

-forgot to assign alignement
-defaultScreenRect instead of screenRect because of issue mentionned in original comment

* remove config.json and replace go.mod line

* update with new renderer and escape menu
2020-06-22 09:23:56 -04:00
Tim Sarbin e81450b9d5
Re-fix map starting location bug (#388) 2020-06-21 23:23:00 -04:00
Ziemas 75112ec736
Show special tiles in mapdebug (#386)
More useful than the floor stuff

Also method for testing if special
2020-06-21 22:14:06 -04:00
Tim Sarbin 4b6065b2bf
Fixed vertical centering for the player (#384) 2020-06-21 21:49:32 -04:00
dk 145aa92d20
hacky bugfix to keep game from crashing tf out with other languages (#383) 2020-06-21 20:45:34 -04:00
Tim Sarbin 912aaf044c
Re-tooled rendering engine (#379) 2020-06-21 18:40:37 -04:00
Haashi 7ba3cb702d
fix bug from PR#369 (#370)
* camera offset for ui panels :

added maprenderer viewport to be aligned left or right

calling alignement on keyPress in game_controls

* check if already aligned

* fix bugs

-forgot to assign alignement
-defaultScreenRect instead of screenRect because of issue mentionned in original comment

* remove config.json and replace go.mod line
2020-06-21 16:06:11 -04:00
Haashi afe4a3a25a
camera offset for ui panels : (#369)
* camera offset for ui panels :

added maprenderer viewport to be aligned left or right

calling alignement on keyPress in game_controls

* check if already aligned
2020-06-21 15:26:07 -04:00
Tim Sarbin 0de7516a53
Fixed entity and object position bug (#366)
* Performance improvements

* fix readbytes variable

* Fixed entity/object position bug.

* Fixed subTileY capitalization issue
2020-06-20 21:26:26 -04:00
Tim Sarbin b9f17f433f
Performance/Memory Improvements (#365)
* Performance improvements

* fix readbytes variable
2020-06-20 21:07:36 -04:00
Tim Sarbin e510674b42
Added more temporary mapgen. (#359) 2020-06-20 14:04:51 -04:00
Tim Sarbin 0a206ce024
Fixed issues from last merge (#346) 2020-06-20 01:06:42 -04:00
Tim Sarbin a8c6bbec9d
Fixed walking animations and pathing bugs. (#345) 2020-06-20 00:40:49 -04:00
Tim Sarbin 7b38a9d818
Updates (#340) 2020-06-19 02:19:27 -04:00
Tim Sarbin 2da08884c4
Added multiplayer support (#336) 2020-06-18 14:11:04 -04:00
Tim Sarbin 16dc775be1
Renamed scene to screen to avoid confusion of intent. (#334) 2020-06-13 20:36:20 -04:00
Tim Sarbin 52f8cd6d0c
Initial work to separate client and server logic (#330)
* Switched to json formatted characters

* Added infrastructure for networking

* Minor updates.

* more updates for map engine/rendering

* More map engine changes and fixes
2020-06-13 18:32:09 -04:00
Robin Eklind ff4f0b0bfa
all: use goimports to format code and fix two minor typos in comments (#326)
Typos located using misspell: https://github.com/client9/misspell

Formatting done using goimports: https://godoc.org/golang.org/x/tools/cmd/goimports
2020-04-11 14:56:47 -04:00
dk 019bb920c9
Feature pl2 asset manager (#319)
* adding pl2 as a fiel format and an asset manager for pl2 files

* adding pl2 as a file format and an asset manager for pl2 files

* pl2 asset manager and file format

* added call in main.go to load palette transforms
* removed incorrect PaletteTransformType declarations from main.go

* removingn bad resource path for palette transform

* PL2 file format added, added to asset management

PL2 files are beside palette files in the mpq
These files define palette transforms of their respective base palette.

I've bound a command to d2term (in d2asset.go)
	load_pl2 <path>

* Clean up PL2 asset stuff

removed pl2 stuff from d2datadict, didn't belong in there
removed d2term debug binding

* minor cleanup for d2pl2
2020-02-26 22:52:05 -05:00
Alex Yatskov 664b8416f1
Remove global palettes; everything goes through d2asset now (#322)
* Configuration cleanup

* Cleanup

* remove global palettes
2020-02-26 22:46:47 -05:00
nicholas-eden 1011b2f030
Add simple index to query map (#321)
`renderPass2` is looping over every entity for every frame, this updates the method so it only evaluates each entity once.

Adds ability to query by rectangle or circle.
2020-02-26 08:40:32 -05:00
Alex Yatskov a4efd41383
File format cleanup (#320)
* Configuration cleanup

* Cleanup

* cleanup file formats

* make palettes a proper fileformat
2020-02-26 08:39:38 -05:00
Ziemas 0f7571a5b9
Render animations from their origin in composite. (#318) 2020-02-25 09:49:21 -05:00
Alex Yatskov 418c798c2c
Add RenderFromOrigin method to Animation (#317)
* Configuration cleanup

* Cleanup

* Add RenderFromOrigin option
2020-02-24 23:04:01 -05:00
Alex Yatskov 6f2c212417
Continued work on GUI (#316)
* Configuration cleanup

* Cleanup

* Continued UI work
2020-02-24 22:35:21 -05:00
Ziemas 2285c31b53
Fix wall location by removing extraneous offset (#314) 2020-02-24 13:36:12 -05:00
nicholas-eden f6014498ba
Use missile range and subloop (#311)
Turn on blending.  Calculate target using based on range and angle of hero to click.
2020-02-23 03:23:18 -05:00
Alex Yatskov 423cef304d
Screenshot and GIF recording capability (#310)
* Configuration cleanup

* Cleanup

* Gif animation and screenshot support
2020-02-22 23:59:45 -05:00
Ziemas e4c84c4fb9
Direction changes. (#309)
* Take directions in the range of 0-63

* Shift direction handling in animation further back

* Don't need to get the DCC direction here.

Because it was added to animation.

* Check direction is within range
2020-02-22 22:33:58 -05:00
nicholas-eden bdfdeda67b
Add support for missiles (#308)
* WIP: Add support for missiles

Break AnimatedEntity into two parts to support single and composite animations.  Summon misssiles on right click.

* Break animated entity down further

Move npc only logic to npc struct, reduce duplication in map entities

* Change a bunch of int32s to int
2020-02-22 20:44:30 -05:00
Alex Yatskov 2953d2171b
Configuration improvements (#307)
* Configuration cleanup

* Cleanup
2020-02-20 08:41:41 -05:00
Alex Yatskov 810b168ebf
Work in progress on GUI (#304)
* Work in progress on GUI refactor

* Remove WIP file

* Remove WIP style
2020-02-17 22:11:52 -05:00
Alex Yatskov 1983ec395d Cleanup error handling (#303) 2020-02-09 14:12:04 -05:00
Tim Sarbin 9478e2c2be
Fixed pathfinding crash (#301) 2020-02-08 21:33:14 -05:00
Alex Yatskov 5e958b9174
Scene and GUI rework (#300) 2020-02-08 21:02:37 -05:00
Nick 99e6acf2bb
Write default configuration file if one is not found. (#298) 2020-02-07 22:21:15 -05:00
Alex Yatskov a04d2389c3
Fix terminal taking input when not visible, fix timescale command (#294) 2020-02-02 21:26:08 -05:00
Tim Sarbin 0c618bd31b
Fixed refactor bug for d2config (#293) 2020-02-02 18:58:26 -05:00
Ziemas 0b7a433ed2
Fix up subtile flag stuff (#288)
* Switch to a 2d array for looking up subtile flags

Also fix up the walkableArea generation

* Check correct tiletype for walls

And fix the subtile tooltip text.
2020-02-02 17:56:58 -05:00
Alex Yatskov f33535cd5d
Add commands for vsync, fullscreen; move timescale implementation (#286)
* Add commands for vsync, fullscreen; move timescale implementation

* add binding for mapdebugvis
2020-02-02 14:04:37 -05:00
Tim Sarbin 3412c4338c
Added pathfinding and (buggy) collision data. (#285) 2020-02-02 12:46:19 -05:00
Tim Sarbin 935789dccf
Added more debugging to map test (#284) 2020-02-02 02:57:23 -05:00
Tim Sarbin 6606774ece
Refectoring to reduce code warnings (#283) 2020-02-01 21:51:49 -05:00
Alex Yatskov ea4450f207
Move d2config to d2core, remove d2helper (#282) 2020-02-01 21:06:22 -05:00
Alex Yatskov b5c1f5222d
Move rendering stuff out of d2common into d2render (#281)
* Move rendering stuff out of d2common into d2render

* Remove d2interface
2020-02-01 20:39:28 -05:00
Alex Yatskov 8a547ebf0e
Moving files around to make more sense (#279)
* Prevent input fighting between terminal and other input listeners.

* Moving files around, removing exports

* Add missing line
2020-02-01 18:55:56 -05:00
Alex Yatskov e878ebcbcd
Prevent input fighting between terminal and other input listeners. (#278) 2020-02-01 14:35:55 -05:00
Tim Sarbin 2461142fbd
Minor changes to project layout (#276)
* Minor changes to reduce interdependencies on modules.
2020-01-31 23:18:11 -05:00
Tim Sarbin 6832a5a0db
merged d2shared into the core package (#275) 2020-01-26 00:39:13 -05:00
Alex Yatskov 8de0cde818 Event-based input manager with priority system (#274) 2020-01-25 23:28:21 -05:00
nicholas-eden d6769975cd Initial inventory handling (#270)
Add struct to display inventory panel.
Add struct to handle inventory and merchant grids.

Hook up `i` key to toggle inventory panel.
2019-12-28 23:32:53 -05:00
Alex Yatskov c01bedaedf Do not advance state in render (#269)
* Do not advance state in render

* Update advance logic for sprite and region
2019-12-28 23:32:24 -05:00
Alex Yatskov 49b9a190f2 Render to surface, not ebiten texture (#268)
* Render to surface, not ebiten texture

* Fix debug text
2019-12-28 16:46:08 -05:00
Ziemas 0c2b7cfd8d Advance hero animations on char select screen. (#267) 2019-12-26 11:14:26 -05:00
Alex Yatskov b7e50bf098 Add terminal, surface, assetmanager commands (#266)
* Add terminal, surface, assetmanager commands

* echo command

* add verbose logging

* more logging, word wrap

* add timescale command
2019-12-26 11:13:05 -05:00
Alex Yatskov 0ee937f01b Rename Paperdoll to Composite (#265)
Make AnimatedEntity use Composite
2019-12-24 01:48:45 -05:00
Alex Yatskov 1b03e691b9 High level resource caching; resource cleanup (#264)
* Work on resource loading

* Use new material flag name. (#261)

Update ebiten ref while at it

* Hopefully fix CI (#262)

* Don't try to copy config.json on travis (#263)

I doesn't exist anymore

* Update D2Shared references

* Fix character selection rect

Co-authored-by: Ziemas <ziemas@ziemas.se>
2019-12-21 20:53:18 -05:00
Alex Yatskov 4ebe199a8e Move save game location to ~/.config/OpenDiablo2/Save (#258) 2019-12-17 23:20:06 -05:00
Alex Yatskov d5a0038125 Configuration cleanup (#257)
* Cleanup config file loading, move defaults to code

* Default to fullscreen

* Cleanup

* Store configuration in UserConfigDir

* print config path on load and save
2019-12-17 21:32:37 -05:00
Alex Yatskov cead000c3f Fix case sensitivity when loading MPQ files (#256)
* Fix case sensitivity when loading MPQ files

* remove print
2019-12-17 20:06:01 -05:00
Alex Yatskov cc678ba747 Add asset manager (#253)
* Add asset manager

* Fix rebase

* Update asset manager to support mpq hash caching

* Update vendoring
2019-12-16 22:23:01 -05:00
nicholas-eden d033c63e18 Initial in-game ui and keyboard controls (#254)
Move player movement out of `Game`, add arrow key movement.  Render bottom panel.
2019-12-16 11:04:39 -05:00
Alex Yatskov a194913609 Engine and region reorganization in preperation for spatial partitioning (#249)
* Engine and region reorg
* Remove unnecessary file diff
* Remove extra render of debug mesh
2019-12-13 00:33:11 -05:00
Alex Yatskov 1262c80e6b Create viewport and camera types (#246) 2019-12-08 22:18:42 -05:00
nicholas-eden 9a8e16c411 Pause npcs at each target location for a random time (#245)
Loop through neutral animation a random number of repetitions before moving on.  Only run the skill animation once, it is not designed for looping.
2019-12-06 23:58:36 -05:00
nicholas-eden b5db51800c Setup NPCs to follow paths (#243)
Change location to contain canonical location, add field to get rounded location for tile rendering.
If NPC has path, loop through path.
2019-12-06 09:44:51 -05:00
j0y c6235411b7 Add basic movement (#240)
* Add basic movement

* Calculate step length based on tick time between updates, teleport to target if within one step.

* Smooth camera, hero movement

removed float to int conversions in Render and IsoToScreen functions

* Render hero in the center of the screen (assuming 800x600 resolution)

* Revert changing Render() parameters type

* Render hero in the tile loop

hero will naturally render in front of the walls of the current tile but behind the walls of the tile below

* Smoother steps near target coordinates

remove jitter from trying to get one step away from target on both axis
2019-12-02 16:55:48 -05:00
Ziemas 51d78bfcbf Draw object layers in order and generally untangle the direction mess. (#239)
* Implement drawing COF Layers by priority

Hack it up by using always draw order for direction 0 until we get a
better handle on directions in the engine.

* Take directions in "cof directions"

Transform into dcc directions for loading frames.

* Set characters to dir 0 in char select.

Direction 0 is now facing down universally
2019-11-26 21:04:36 -05:00
nicholas-eden 19257abddb Extract sprite from dc6 from D2Shared (#234)
Remove processing of dc6 file type from sprite creation.  Use dc6 loader from D2Shared.
2019-11-24 17:58:23 -05:00
負弌 30c3bb7330 Fix CJK render problem partially (#222)
* Fixed CJK render problem
* Add partial support of loading CJK fonts
2019-11-21 21:40:12 -05:00
Ziemas e70378d627 Increase draw distance up and down (#209)
* Scroll slowly in map test by holding shift
* Increase draw distance up and down
Avoid issues with long tiles popping in and out of view. (As long as
camera is reasonably within bounds)
2019-11-18 18:23:33 -05:00
Ziemas 9117616b0c Fix the tile coordinates shown in the top left (#208) 2019-11-18 17:42:38 -05:00
Tim Sarbin 7f6e14c5d0
More map engine improvements. (#203) 2019-11-17 16:06:02 -05:00
Averrin 5eafa9cc0b Create tiles cache on region loading (#200)
* tile choice algo
* cycle region files
* switcher limited by preset
* create tile caches befor rendering
* remove keyLocked
2019-11-17 08:09:54 -05:00
Tim Sarbin 4254b0f020
Finished orientation values. (#198)
* Finished directions for entity.
2019-11-17 02:54:22 -05:00
Tim Sarbin 297184376f
Phase 1 prep work for gameplay (#196)
* Updates
* More merge adjustments.
* Don't commit local changes...
2019-11-17 01:14:58 -05:00
Averrin c3ba3f71e4 Switcher with presets & better tiles randomizing (#173)
* tile choice algo
* cycle region files
* switcher limited by preset
2019-11-17 00:52:13 -05:00
ndechiara 1c2b4869a1 Migrate out d2common d2helper d2data modules (#195)
* Switch items to dynamic load with a common struct, add misc.txt loading
* Update Ebiten Reference
* Switch references to point to D2Shared
* Migrate part 2
2019-11-17 00:16:33 -05:00
ndechiara f13433f299 Switch items to dynamic load with a common struct, add misc.txt loading (#185) 2019-11-15 22:31:10 -05:00
axx c72c4d5768 Some corrections for credits (#183)
Related to issue #77
2019-11-15 19:47:58 -05:00
Ziemas 0475a11512 Toggle tile display in map test with F7 (#172)
* Toggle tile display in map test with F7
* Sub-tile display
Cycle through tile display modes with F7
2019-11-15 09:04:27 -05:00
Myles b9209541c8 Closes Issue#176 (#178) 2019-11-14 23:55:51 -05:00
Tim Sarbin b97bf6353d
Added inventory objects. (#177) 2019-11-14 22:20:01 -05:00
Averrin 78a70c2d2b add map switcher (#162) 2019-11-13 14:26:42 -05:00
TehGoat 055fcd72ed Idle animation and hover gets out of sync (#161) 2019-11-13 12:56:54 -05:00
TehGoat 358fa1481c Modified hero animation speed (#160) 2019-11-13 12:32:17 -05:00
Averrin f83ab90d96 Add CONTRIBUTORS file content to credits screen (#159) 2019-11-13 11:56:45 -05:00
Tim Sarbin a8171145f9
Started work on gameplay scene. (#153) 2019-11-13 00:31:52 -05:00
Tim Sarbin 4fa66988d4
Added the scrollbar. (#152) 2019-11-12 23:44:04 -05:00
Robin Eklind e1d9f676cf fix permissions on .OpenDiablo2 directory (#144) 2019-11-12 08:15:50 -05:00
Tim Sarbin a6a9434267
Added more functionality to character select screen. (#143) 2019-11-11 23:48:55 -05:00
Tim Sarbin 352ff81b72
Fixed texture atlas. Added GC debugging. (#140) 2019-11-10 20:13:10 -05:00
Tim Sarbin 3f01ad09ae
Renamed files to lowercase. (#137) 2019-11-10 17:36:25 -05:00
Ziemas d4d3fdfad3 Checkboxes! (#136)
And add them to the hero class scene.
2019-11-10 17:17:42 -05:00
Tim Sarbin 5d5009208b
Renamed all files to proper go conventions. (#134) 2019-11-10 14:06:05 -05:00
Tim Sarbin f156475731
Added text entry. Fixed performance issue. Added error checking. (#132) 2019-11-10 12:28:41 -05:00
Tim Sarbin e8292e9c42
More optimizations and cleanup. (#131) 2019-11-10 10:44:13 -05:00
Tim Sarbin f2b1bdfba4
More package cleanup. (#130) 2019-11-10 08:51:02 -05:00
Tim Sarbin b41f7f4dab
Restructured everything. (#128) 2019-11-10 03:36:53 -05:00