Commit Graph

51 Commits

Author SHA1 Message Date
gravestench 783993470e
Lint error cleanup1 (#779)
* fixed lint error in d2app/app.go

* go fmt entire project

* adding doc.go for d2records

* fixed lint issues in d2core/d2map

* fixed lint error in d2interface/palette.go

* fixed lint error in  d2core/d2hero/hero_state_factory.go

* adding dov.go to d2common/d2geom

* fixing lint errors in d2common/d2loader

* adding doc.go to d2common/d2cache

* adding doc files for d2datautils, d2util, d2path

* adding package doc strings for mapgen, in-geam help screen, and tcp client connection

* removed all cuddling lint errors

* changed stamina equality check to '<=' instead of '<'
2020-10-22 01:12:06 -04:00
presiyan-ivanov 88326b5278
Initial cast overlay implementation. Fix HeroSkill deserialization & map entities processing crashing for remote client. (#766)
* Casting a skill now plays the corresponding overlay(if any).

* Prevent a crash caused by nil pointer in HeroSkill deserialization, happening when
unmarshalling HeroSkill from packets as a remote client.

* Add PlayerAnimationModeNone to handle some of the Skills(e.g.
Paladin auras) having "" as animation mode.

* Joining a game as remote client now waits for map generation to finish
before rendering map or processing map entities. This is temporary hack to prevent the game from
crashing due to concurrent map read & write exception.

* Send CastSkill packet to other clients.

Co-authored-by: Presiyan Ivanov <presiyan-ivanov@users.noreply.github.com>
2020-10-10 18:47:51 -04:00
Josh Jordan b1cdb47302
Help and Escape Menu click through and close behavior (#761)
* Disallow clicking through the help menu to control the game

* Move Navigator and EscapeMenu up in package tree to be accessible by GameControls. Disallow GameControls input when EscapeMenu is open

* Make ESC key behavior more consistent with D2
2020-10-07 21:20:05 -04:00
leahiel 815c0d17ba
help panel: semi-trans background, font reset, string table (#758) 2020-09-26 11:14:34 -04:00
gravestench fc87b2be7a
Removing d2datadict singletons (#738)
* Remove weapons, armor, misc, itemCommon, itemTyps datadict singletons

- removed loader calls from d2app
- removed the HeroObjects singleton from `d2core/d2inventory`
- added an InventoryItemFactory in d2inventory
- package-level functions that use data records are now methods of the InventoryItemFactory
- renamed ItemGenerator in d2item to ItemFactory
- package-level functions that use records are now methods of ItemFactory
- d2map.MapEntityFactory now has an item factory instance for creating items
- fixed a bug in unique item record loader where it loaded an empty record
- added a PlayerStateFactory for creating a player state (uses the asset manager)
- updated the test inventory/equipment code in d2player to handle errors from the ItemFactory
- character select and character creation screens have a player state and inventory item factory
- updated item tests to use the item factory

* minor edit

* Removed d2datadict.Experience singleton

added a HeroStatsFactory, much like the other factories. The factory  gets an
asset manager reference in order to use data records.

* removed d2datadict.AutoMagic singleton

* removed d2datadict.AutoMap singleton

* removed d2datadict.BodyLocations singleton

* removed d2datadict.Books singleton

* Removed singletons for level records

- removed loader calls in d2app
- changed type references from d2datadict to d2records
- added a `MapGenerator` in d2mapgen which uses thew asset manager and map engine
- package-level map generation functions are now MapGenerator methods
- `d2datadict.GetLevelDetails(id int)` is now a method of the RecordManager

* remove SkillCalc and MissileCalc singletons

* Removed CharStats and ItemStatCost singletons

- added an ItemStatFactory which uses the asset manager to create stats
- package-level functions for stats in d2item are now StatFactory methods
- changed type references from d2datadict to d2records
- `d2player.GetAllPlayerStates` is now a method of the `PlayerStateFactory`

* Removed DkillDesc and Skills singletons from d2datadict

- removed loader calls from d2app
- diablo2stats.Stat instances are given a reference to the factory for doing record lookups

* update the stats test to use mock a asset manager and stat factory

* fixed diablo2stats tests and diablo2item tests

* removed CompCodes singleton from d2datadict

* remove cubemain singleton from d2datadict

* removed DifficultyLevels singleton from d2datadict

* removed ElemTypes singleton from d2datadict

* removed events.go loader from d2datadict (was unused)

* removed Gems singleton from d2datadict

* removed Hireling and Inventory singletons from d2datadict

* removed MagicPrefix and MagicSuffix singletons from d2datadict

* removed ItemRatios singleton from d2datadict

* removed Missiles singleton from d2datadict

* removed MonModes singleton

* Removed all monster and npc singletons from d2datadict

- MapStamp instances now get a reference to their factory for doing record lookups

* removed SoundEntry and SoundEnviron singletons from d2datadict
2020-09-20 17:52:01 -04:00
presiyan-ivanov a4e9797431
Initial player Left skill and Right skill handling (#741)
* Initial player Left skill and Right skill handling

* Handle empty skill names in charStats.BaseSkils + add Attack skill for all classes.

Co-authored-by: Presiyan Ivanov <presiyan-ivanov@users.noreply.github.com>
2020-09-20 11:55:44 -04:00
Gürkan Kaymak ef0fbc0581
removed gui manager singleton in d2gui (#735) 2020-09-18 16:10:52 -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
Gürkan Kaymak 32a58fd5d3
Added mini panel (#711)
* resolves #685, added mini panel

* formatting
2020-08-25 09:10:26 -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 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 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 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
Tim Sarbin 7da1843f49
Lint cleanup (#628) 2020-07-26 14:52: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 7a49f3637f
lint fixes (#615) 2020-07-23 12:56:50 -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
lord c92ad67eaa
removed most lint errors in d2gamescreen, except for map_engine_testing.go (#603) 2020-07-18 09:54:10 -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
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
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
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
Gürkan Kaymak 473a0b3b19
Remaining lint fixes for the d2gamescreen package (#550)
* lint fixes for the game.go

* lint fixes for the gui_testing.go

* lint fixes for the blizzard_intro.go, map_engine_testing.go and select_hero_class.go

* added package comment for the d2gamescreen package

* fixes after merge
2020-07-06 20:13:55 -04:00
Tim Sarbin 5bfec3ccb0 Removed render singleton. Updated refs. 2020-07-03 14:00:56 -04:00
Intyre 5b9a0fe5bc
Fixes #523, unbind the escapeMenu when game is unloaded (#524) 2020-07-02 20:03:15 -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
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
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
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
Tim Sarbin 66e6d32680
Added all music definitions (#472) 2020-06-27 03:16:53 -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
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
Brendan Porter 2656339def
Refactor escape (#450)
* refactoring escape menu to allow pop back to menu

* refactors escape menu to allow exiting the game

* fixes bug causing player to not be removed on game exit
2020-06-25 10:16:17 -04:00
Tim Sarbin 6dae0097b9
Added npc labels. More mapgen stuff. (#449) 2020-06-25 00:39:09 -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
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
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
Ziemas 8c50a014ac
Free camera option in single player (#382)
Enable toggling free camera in single player with the freecam console
command.

Handy for looking around while debugging.
2020-06-21 20:46:00 -04:00
Tim Sarbin 912aaf044c
Re-tooled rendering engine (#379) 2020-06-21 18:40:37 -04:00
Maxime Lavigne (malavv) 8bdbef60ed
Added Menu on Escape Key Press (#353) (#371)
- New menu in d2player.
 - Added OnMouseMove and Advance to GameControl.
 - Pause the MapEngine when single player.
2020-06-21 16:06:52 -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