Commit graph

521 commits

Author SHA1 Message Date
Juliano Leal Goncalves
a983792880 ♻️ Replace 'pair<int, int>' with 'Size' in 'GetItemSizeOnSlot' and 'GetInvItemSize' 2021-06-20 18:27:45 -07:00
Juliano Leal Goncalves
572c3e632e ♻️ Leverage 'Point' in 'InvDrawSlotBack' implementation 2021-06-20 18:27:45 -07:00
Juliano Leal Goncalves
07a049f667 ♻️ Replace 'INV_SLOT_SIZE_PX' macro with Size-based constexpr 2021-06-20 18:27:45 -07:00
Juliano Leal Goncalves
0e2d734bbb ♻️ Leverage 'Size' in 'CheckInvPaste' implementation 2021-06-20 18:27:45 -07:00
Juliano Leal Goncalves
4ab80d25f4 ♻️ Leverage 'Size' in 'AddItemToInvGrid' function 2021-06-20 18:27:45 -07:00
Gleb Mazovetskiy
43bc08bd63 Hardware Cursor: Fall back to software on failure 2021-06-19 12:36:39 +01:00
Gleb Mazovetskiy
523d838bd4 Hardware Cursor: Use item hotpoint
For a hardware item cursor, set the hotpoint to the center
instead of manually setting the cursor position.
2021-06-19 12:36:39 +01:00
Gleb Mazovetskiy
432fdacd81 Clip InvDrawSlotBack draw call 2021-06-16 03:12:54 +02:00
qndel
816b244689 HasItem/RemoveInvItem combo refactor 2021-06-13 05:18:08 +02:00
qndel
0c39656c91 fix reconstructed note 2021-06-13 05:18:08 +02:00
Juliano Leal Goncalves
1328c9ea93 🎨 Make 'Size' fields camelCase 2021-06-12 19:47:52 +02:00
Vladimir Olteanu
512fcdb790 Use WalkingDistance in PutItem 2021-06-02 13:36:17 +02:00
Juliano Leal Goncalves
8622130966 ♻️ Add '==' and '!=' operators to 'Size' struct 2021-05-31 06:13:24 +02:00
Juliano Leal Goncalves
ff3dee8d45 ♻️ Replace poor usages of 'Size' with 'Point's 2021-05-31 06:05:13 +02:00
Juliano Leal Goncalves
abee4fe6fe ♻️ Repurpose the 'InvXY' struct as a new 'Size' struct 2021-05-31 06:05:13 +02:00
Juliano Leal Goncalves
21ecaa225f
♻️ Leverage 'Point' struct on inventory functions (#2094) 2021-05-30 23:44:38 +02:00
Kalebe Alves
118efe8e6d
Use Point/SDL_Rect for control functions coordinate system 2021-05-28 19:57:16 +02:00
Gleb Mazovetskiy
dd3ea66fa2 ♻️ Split getTextColor(bool) into 2 functions
This is a bit more readable than using a bool argument.
2021-05-28 13:38:36 +02:00
qndel
2f3cf65b27 cleanup getTextColor 2021-05-26 15:58:14 +02:00
Anders Jenbo
8a7ec56d3a Player by reference part 2
This mostly change player to be by reference instead of by index.
But additionally it does stript checks for gold in the belt, move some
value types to the initialization and short circute a few functiongs.
2021-05-24 21:00:32 +02:00
Anders Jenbo
6ce8f13751 Apply clang-tidy to more code and do some related cleanups 2021-05-24 05:27:06 +02:00
Juliano Leal Goncalves
21fdb0dcd9 ♻️ Replace manual direction displacement logic with 'Point' add operator 2021-05-24 04:46:08 +02:00
Juliano Leal Goncalves
d55cd99dd5 🚚 Rename 'direction' enum to 'Direction' 2021-05-24 04:46:08 +02:00
Juliano Leal Goncalves
15c46b9eb0 💬 Rename HeroSpeech members to improve discoverability 2021-05-23 22:01:47 +02:00
Juliano Leal Goncalves
5350250a76 🚚 Rename speech functions to 'Say' variations 2021-05-23 05:32:34 +02:00
Juliano Leal Goncalves
8c620ce29e ♻️ Extract 'HeroSpeech' enum class for hero sounds instead of using raw ints 2021-05-23 05:32:34 +02:00
Jmgr
0e7ada15fc Apply new format to ngexttext translations 2021-05-21 01:02:45 +02:00
Anders Jenbo
34744c068f ♻️Consitantly use %i and not %d 2021-05-15 14:17:52 +02:00
Stefan Mielke
30bfe45781 One pixel was not being calculated on the X axis when trying to find for an inventory slot to put the item. 2021-05-15 12:27:48 +02:00
qndel
89c40eaa7b
inventory items rendering cleanup (#1938) 2021-05-14 12:46:16 +02:00
Anders Jenbo
0c2042fa52 ♻️ Player by reference
Update Source/items.cpp
Update Source/lighting.cpp
Update Source/pack.cpp
asd


ads


as
2021-05-13 01:47:46 +02:00
Anders Jenbo
68e73c0dfe 🐛 Fix infopanel text color 2021-05-12 11:40:31 +02:00
Anders Jenbo
ad97ebe980 🔥 Remove redundant code from towners.cpp
This changes one bavious. Previously walking away from the dead guy
would interupt the "Your death shall be reveanged", the interuption
seamed un natural and the code didn't seam to have been specifically
made for this case (TownCtrlMsg).

Fix several edge cases in quests where the incorrect state could be reached
2021-05-10 23:17:43 +02:00
Stefan Mielke
dfece830ad
Controller Inventory Improvements (#1885)
- controller: Move inventory coordinates logic to outside of the method to ease visibility and changes; Fix cursor offset when holding items on the inventory; Move cursor between edges of the inventory to ease movement inside.
- Renamed InvGetCoord to InvGetSlotCoord.
- adding more SLOTXY_xxx options to improve controls code
- changed inventory slots comment to improve legibility
- fixing bugs and centering sprite on the slot
- fix belt item movement
- slots 9 and 10 move to belt 8 when moving down using a controller
- creating function to return correct mousePos slot to remove code duplication
- create BeltGetSlotCoord to get coords for belts and remove duplicates; code cleanup.
- adding INV_ROW_SLOT_SIZE to hold the amount of slots on an inv row
- improve code for moving item to the belt when it's the last 2 slots.
- fix bug that would not update the cursor position when going up on certain conditions.
- equip equipment when pressing [use] on the controller
- moving items in the inventory as a single instance, and blocking them from moving accordingly.
- move item to belt when clicking the spell button (Y)
- resetting the cursor takes into consideration if the current slot has an item that is bigger than 1x1
- change whitespace to tabs on inv.h changes
- fixing plrctrls.cpp formatting
2021-05-09 17:00:48 +02:00
Aneurin
2365b5f440
Improve inventory filling algorithm (#1876)
* Extract loop body into GoldAutoPlaceInInventorySlot()
* Improve placement of gold in inventory

When adding gold to the inventory, this now finds a free slot as
follows:

1) Start at X, and work left until row 3 is full
2) Start at Y, and work up until column 9 is full
3) Move one column left, start at row 2 and work up
4) Repeat step 3 until there is no free space

| |0|1|2|3|4|5|6|7|8|9|
|-|-|-|-|-|-|-|-|-|-|-|
|0| | | | | | | | | | |
|1| | | | | | | | | | |
|2| | | | | | | | | |Y|
|3| | | | | | | | | |X|

* Improve inventory placement for single-height items

When adding single-height items (which in practice are all 1x1) to the
inventory, this now finds a free slot as follows:

1) Start at X, and work right until row 3 is full
2) Start at Y, and work up until column 9 is full
3) Move one column left, start at row 2 and work up
4) Repeat step 3 until there is no free space

| |0|1|2|3|4|5|6|7|8|9|
|-|-|-|-|-|-|-|-|-|-|-|
|0| | | | | | | | | | |
|1| | | | | | | | | | |
|2| | | | | | | | | |Y|
|3|X| | | | | | | | | |

* Improve inventory placement for two-height items

When adding 1x2 items to the inventory, this now finds a free slot as
follows:

1) Start at X, and work down until column 9 is full
2) Move one column left, start at row 0 and work down
3) Repeat step 2 until there is no free space

| |0|1|2|3|4|5|6|7|8|9|
|-|-|-|-|-|-|-|-|-|-|-|
|0| | | | | | | |Z|Y|X|
|1| | | | | | | | | | |
|2| | | | | | | | | | |
|3| | | | | | | | | | |

When adding 2x2 items, it first tries to place them in even columns,
then goes to odd columns of no space was found:

1) Start at Y, and work down until columns 8/9 are full
2) Move two columns left, start at row 0 and work down
3) Repeat step 2 until there is no free space in columns 0/1
4) Go to Z, and work down until columns 7/8 are full
5) Move two columns left, start at row 0 and work down
3) Repeat step 5 until there is no free space
2021-05-09 06:34:57 +02:00
Anders Jenbo
8361e70087 ♻️Use DrawString in error.cpp 2021-05-08 18:48:19 +02:00
Anders Jenbo
68923c6c33 Generic game text render function
This should gradually replace all the direct rendering of game texts
throughout the code. The interface is made to closly mirror that of the
art fonts as that is what will eventually be used for rendering Unicode
fonts both in the menus and ingame.

fixup!  Generic game text render function
2021-05-08 18:48:19 +02:00
Anders Jenbo
4b577329f4 ♻️Refactor towner initialization 2021-05-07 00:30:23 +02:00
Anders Jenbo
6321bf04d5 ♻️Pass player to towner by reference instead of index 2021-05-07 00:29:46 +02:00
Gleb Mazovetskiy
0edfa3de66 🚚 Move CEL rendering to engine/render/cel_render.cpp 2021-05-07 00:16:40 +02:00
Gleb Mazovetskiy
34b4ed759a 🐞 Clean up and fix inventory sprite handling 2021-05-02 04:01:03 +02:00
Anders Jenbo
22d7d41615 🌐 Fix remaning plural form of gold related texts 2021-05-02 00:31:02 +02:00
Gleb Mazovetskiy
1b8b62a8c2 ♻️ Store CEL width with the sprite itself
Instead of passing the CEL sprite width when drawing, store the CEL
width at load time in the new `CelSprite` struct.

Implemented for most sprites except towners, missiles, or monsters.
2021-05-01 20:51:55 +02:00
Mathieu Maret
a87f1d8d2e Avoid a strcpy
if _iIdentified is true, the first strcpy was not usefull
2021-05-01 02:48:25 +02:00
Anders Jenbo
f884ba5340 🔥 Remove more miniwin dependencies 2021-04-29 23:04:56 +02:00
Anders Jenbo
d5173f4c9c ♻️Clean up PutItem 2021-04-29 21:36:31 +02:00
Anders Jenbo
5745f099ba ♻️Use Point for positions in msg.cpp functions 2021-04-29 21:36:31 +02:00
Anders Jenbo
bd515ac75d ♻️Apply Point equality operator 2021-04-29 16:04:30 +02:00
thebigMuh
ad8f342db0 Adding constness 2021-04-26 23:30:02 +02:00
John Törnblom
e0dddf508a
Add automatically translated string literals (#1694) 2021-04-25 18:14:58 +02:00