mirror of
https://github.com/fallout2-ce/fallout2-ce.git
synced 2026-07-27 16:47:11 -07:00
Compare commits
5
Commits
main
...
sfall-port
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39b369f7df | ||
|
|
76ac71bc08 | ||
|
|
0e31ac4753 | ||
|
|
a949178e30 | ||
|
|
0e806d9be3 |
+33
-7
@@ -269,6 +269,7 @@ static void inventoryWindowOpenContextMenu(int eventCode, int inventoryWindowTyp
|
||||
static InventoryMoveResult _move_inventory(Object* item, int slotIndex, Object* targetObj, bool isPlanting);
|
||||
static int _barter_compute_value(Object* dude, Object* npc);
|
||||
static int _barter_attempt_transaction(Object* dude, Object* offerTable, Object* npc, Object* barterTable);
|
||||
static int _barter_get_quantity_moved_items(Object* item, int maxQuantity, bool fromDude, bool fromInventory);
|
||||
static void _barter_move_inventory(Object* item, int quantity, int slotIndex, int indexOffset, Object* npc, Object* sourceTable, bool fromDude);
|
||||
static void _barter_move_from_table_inventory(Object* item, int quantity, int slotIndex, Object* npc, Object* sourceTable, bool fromDude);
|
||||
static void inventoryWindowRenderInnerInventories(int win, Object* leftTable, Object* rightTable, int draggedSlotIndex);
|
||||
@@ -277,7 +278,7 @@ static void _container_exit(int keyCode, int inventoryWindowType);
|
||||
static int _drop_into_container(Object* container, Object* item, int sourceIndex, Object** itemSlot, int quantity);
|
||||
static int _drop_ammo_into_weapon(Object* weapon, Object* ammo, Object** ammoItemSlot, int quantity, int keyCode);
|
||||
static void _draw_amount(int value, int inventoryWindowType);
|
||||
static int inventoryQuantitySelect(int inventoryWindowType, Object* item, int maximum);
|
||||
static int inventoryQuantitySelect(int inventoryWindowType, Object* item, int max, int defaultValue = 1);
|
||||
static int inventoryQuantityWindowInit(int inventoryWindowType, Object* item);
|
||||
static int inventoryQuantityWindowFree(int inventoryWindowType);
|
||||
|
||||
@@ -4761,6 +4762,31 @@ static int _barter_attempt_transaction(Object* dude, Object* offerTable, Object*
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _barter_get_quantity_moved_items(
|
||||
Object* item,
|
||||
int maxQuantity,
|
||||
bool fromPlayer,
|
||||
bool fromInventory
|
||||
) {
|
||||
if (maxQuantity <= 1) {
|
||||
return maxQuantity;
|
||||
}
|
||||
|
||||
int suggestedValue = 1;
|
||||
if (item->pid == PROTO_ID_MONEY && !gGameDialogSpeakerIsPartyMember) {
|
||||
// Calculate change money automatically
|
||||
int totalCostPlayer = objectGetCost(_ptable);
|
||||
int totalCostNpc = _barter_compute_value(gDude, _target_stack[0]);
|
||||
// Actor's balance: negative - the actor must add money to balance the tables and vice versa
|
||||
int balance = fromPlayer ? totalCostPlayer - totalCostNpc : totalCostNpc - totalCostPlayer;
|
||||
|
||||
if ( (balance < 0 && fromInventory) || (balance > 0 && !fromInventory) ) {
|
||||
suggestedValue = std::min(std::abs(balance), maxQuantity);
|
||||
}
|
||||
}
|
||||
return inventoryQuantitySelect(INVENTORY_WINDOW_TYPE_MOVE_ITEMS, item, maxQuantity, suggestedValue);
|
||||
}
|
||||
|
||||
// 0x474DAC
|
||||
static void _barter_move_inventory(Object* item, int quantity, int slotIndex, int indexOffset, Object* npc, Object* sourceTable, bool fromDude)
|
||||
{
|
||||
@@ -4819,7 +4845,7 @@ static void _barter_move_inventory(Object* item, int quantity, int slotIndex, in
|
||||
|
||||
if (fromDude) {
|
||||
if (mouseHitTestInWindow(gInventoryWindow, INVENTORY_TRADE_INNER_LEFT_SCROLLER_TRACKING_X, INVENTORY_TRADE_INNER_LEFT_SCROLLER_TRACKING_Y, INVENTORY_TRADE_INNER_LEFT_SCROLLER_TRACKING_MAX_X, INVENTORY_SLOT_HEIGHT * gInventorySlotsCount + INVENTORY_TRADE_INNER_LEFT_SCROLLER_TRACKING_Y)) {
|
||||
int quantityToMove = quantity > 1 ? inventoryQuantitySelect(INVENTORY_WINDOW_TYPE_MOVE_ITEMS, item, quantity) : 1;
|
||||
int quantityToMove = _barter_get_quantity_moved_items(item, quantity, true, true);
|
||||
if (quantityToMove != -1) {
|
||||
if (itemMoveForce(_inven_dude, sourceTable, item, quantityToMove) == -1) {
|
||||
// There is no space left for that item.
|
||||
@@ -4832,7 +4858,7 @@ static void _barter_move_inventory(Object* item, int quantity, int slotIndex, in
|
||||
}
|
||||
} else {
|
||||
if (mouseHitTestInWindow(gInventoryWindow, INVENTORY_TRADE_INNER_RIGHT_SCROLLER_TRACKING_X, INVENTORY_TRADE_INNER_RIGHT_SCROLLER_TRACKING_Y, INVENTORY_TRADE_INNER_RIGHT_SCROLLER_TRACKING_MAX_X, INVENTORY_SLOT_HEIGHT * gInventorySlotsCount + INVENTORY_TRADE_INNER_RIGHT_SCROLLER_TRACKING_Y)) {
|
||||
int quantityToMove = quantity > 1 ? inventoryQuantitySelect(INVENTORY_WINDOW_TYPE_MOVE_ITEMS, item, quantity) : 1;
|
||||
int quantityToMove = _barter_get_quantity_moved_items(item, quantity, false, true);
|
||||
if (quantityToMove != -1) {
|
||||
if (itemMoveForce(npc, sourceTable, item, quantityToMove) == -1) {
|
||||
// You cannot pick that up. You are at your maximum weight capacity.
|
||||
@@ -4906,7 +4932,7 @@ static void _barter_move_from_table_inventory(Object* item, int quantity, int sl
|
||||
|
||||
if (fromDude) {
|
||||
if (mouseHitTestInWindow(gInventoryWindow, INVENTORY_TRADE_LEFT_SCROLLER_TRACKING_X, INVENTORY_TRADE_LEFT_SCROLLER_TRACKING_Y, INVENTORY_TRADE_LEFT_SCROLLER_TRACKING_MAX_X, INVENTORY_SLOT_HEIGHT * gInventorySlotsCount + INVENTORY_TRADE_LEFT_SCROLLER_TRACKING_Y)) {
|
||||
int quantityToMove = quantity > 1 ? inventoryQuantitySelect(INVENTORY_WINDOW_TYPE_MOVE_ITEMS, item, quantity) : 1;
|
||||
int quantityToMove = _barter_get_quantity_moved_items(item, quantity, true, false);
|
||||
if (quantityToMove != -1) {
|
||||
if (itemMoveForce(sourceTable, _inven_dude, item, quantityToMove) == -1) {
|
||||
// There is no space left for that item.
|
||||
@@ -4919,7 +4945,7 @@ static void _barter_move_from_table_inventory(Object* item, int quantity, int sl
|
||||
}
|
||||
} else {
|
||||
if (mouseHitTestInWindow(gInventoryWindow, INVENTORY_TRADE_RIGHT_SCROLLER_TRACKING_X, INVENTORY_TRADE_RIGHT_SCROLLER_TRACKING_Y, INVENTORY_TRADE_RIGHT_SCROLLER_TRACKING_MAX_X, INVENTORY_SLOT_HEIGHT * gInventorySlotsCount + INVENTORY_TRADE_RIGHT_SCROLLER_TRACKING_Y)) {
|
||||
int quantityToMove = quantity > 1 ? inventoryQuantitySelect(INVENTORY_WINDOW_TYPE_MOVE_ITEMS, item, quantity) : 1;
|
||||
int quantityToMove = _barter_get_quantity_moved_items(item, quantity, false, false);
|
||||
if (quantityToMove != -1) {
|
||||
if (itemMoveForce(sourceTable, npc, item, quantityToMove) == -1) {
|
||||
// You cannot pick that up. You are at your maximum weight capacity.
|
||||
@@ -5581,7 +5607,7 @@ static void _draw_amount(int value, int inventoryWindowType)
|
||||
}
|
||||
|
||||
// 0x47688C
|
||||
static int inventoryQuantitySelect(int inventoryWindowType, Object* item, int max)
|
||||
static int inventoryQuantitySelect(int inventoryWindowType, Object* item, int max, int defaultValue)
|
||||
{
|
||||
ScopedGameMode gm(GameMode::kCounter);
|
||||
|
||||
@@ -5590,11 +5616,11 @@ static int inventoryQuantitySelect(int inventoryWindowType, Object* item, int ma
|
||||
int value;
|
||||
int min;
|
||||
if (inventoryWindowType == INVENTORY_WINDOW_TYPE_MOVE_ITEMS) {
|
||||
value = 1;
|
||||
if (max > 99999) {
|
||||
max = 99999;
|
||||
}
|
||||
min = 1;
|
||||
value = std::clamp(defaultValue, min, max);
|
||||
} else {
|
||||
value = 60;
|
||||
min = 10;
|
||||
|
||||
Reference in New Issue
Block a user