Compare commits

...
Author SHA1 Message Date
github-actions[bot] 75a9303579 chore: auto-format with clang-format 2025-05-29 06:28:28 +00:00
Mike Klaas 30a6a8b2d1 Proper scrollwheel support in Perks/Karma/Kills folder 2025-05-28 23:24:26 -07:00
cambragol 016c83bc48 Inventory Item not Disappearing Fix (#161)
Fixes #160 

Conditional was incorrect.
2025-05-28 21:58:23 -07:00
Vasilii Rogin 145cf6bbcc Merge pull request #157 from fallout2-ce/deobfus-window-2
More deobfuscation in `window.cc,h`
2025-05-25 08:59:40 +03:00
Mike Klaas 5b39307f61 More deobfuscation in window.cc,h
As usualy, no logic changes
2025-05-24 22:45:21 -07:00
Vasilii Rogin 547cabc42d Merge pull request #153 from roginvs/auto-fix-formatting-on-main-branch
Auto fix formatting on main branch or PR branch
2025-05-24 17:34:47 +03:00
Vasilii Rogin d2a3d61dcb Trying auto-format 2025-05-24 14:16:53 +03:00
Vasilii Rogin 2d1966f0af Adding manual workflow 2025-05-24 13:56:48 +03:00
Vasilii Rogin a406c5f019 CI fixes 2025-05-24 13:43:31 +03:00
Vasilii Rogin 9ca540f05e Auto-format only PRs from the same repo 2025-05-24 13:32:12 +03:00
Vasilii Rogin 4678e19edd Add formatter for PR too 2025-05-24 13:31:06 +03:00
Vasilii Rogin 485d2253f4 Add auto-formatting workflow 2025-05-24 13:29:16 +03:00
Mike Klaas 72309fc9dc Deobfuscate some parameters in window.h,cc (#152)
Note: no logic changes

Removed a parameter which was never used
2025-05-23 23:45:05 -07:00
cambragol fda6fd0646 Update game_dialog.cc (#139)
* Update game_dialog.cc

* Update game_dialog.cc

* Update game_dialog.cc
2025-05-23 21:24:59 -07:00
Mike Klaas 2126e23161 QoL: Add Ctrl-click to move items in inventory, barter, looting/stealing (#133)
* Add Ctrl-click to move items in inventory, barter, looting/stealing

Barter: move from table (offer) to inventory, on both merchant and pc.
Looting/stealing: move from one side to the other.
Inventory: ctrl-click to unequip armor or item in hand.

Modeled after the SFALL feature.

* skip quantity selection when quick moving

* Add `a` to inventory quantity select screen as a quick way to select ALL

* format

* Add Readme changes, and `a` to `Take All`

* try to format

* fmt
2025-05-24 13:06:41 +09:00
Vasilii Rogin 0fa90a1a00 Merge pull request #140 from fallout2-ce/add_test_script_for_sfall_opcodes
Add test script for sFall opcodes
2025-05-23 22:43:21 +03:00
Vasilii Rogin 9bfc3e83cd Add fix_formatting script 2025-05-23 22:34:41 +03:00
Vasilii Rogin 2f974aefed Fix formatting 2025-05-23 22:29:47 +03:00
Vasilii Rogin b27093b7ac Merge remote-tracking branch 'fallout2-ce/main' into add_test_script_for_sfall_opcodes 2025-05-23 22:29:26 +03:00
Vasilii Rogin 6f240acf0a Fix typo 2025-05-23 21:35:20 +03:00
cambragol 5dbcfd997c Fixes slightly misaligned buttons in the pipboy (#147) 2025-05-22 23:17:07 -07:00
Vasilii Rogin a3d37e11c1 Update README 2025-05-18 22:49:32 +03:00
Vasilii Rogin 0e18e77901 Fix formatting 2025-05-18 18:43:07 +03:00
Vasilii Rogin 9d2db5b36a Remove note 2025-05-18 16:17:25 +03:00
Vasilii Rogin b88230426d Update README 2025-05-18 16:14:40 +03:00
Vasilii Rogin bbf52f6b2d Add testing information 2025-05-18 15:51:25 +03:00
Vasilii Rogin 89a9d1ae12 Add initial version of test scripts 2025-05-18 15:15:28 +03:00
18 changed files with 518 additions and 196 deletions
+42
View File
@@ -0,0 +1,42 @@
name: Auto Format with Clang
on:
pull_request:
types: [opened, synchronize]
push:
branches: [main]
jobs:
format:
runs-on: ubuntu-latest
if: github.actor != 'github-actions[bot]' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.ref_name }}
token: ${{ secrets.PAT_FOR_ACTIONS }}
- name: Run clang-format via Docker
run: |
docker run --rm \
-v ${{ github.workspace }}:/app --workdir /app \
--user $(id -u):$(id -g) silkeh/clang:18 \
bash -c 'find src -type f \( -name "*.cc" -o -name "*.h" \) -print0 | xargs -0 clang-format -i'
# https://github.com/actions/checkout?tab=readme-ov-file#push-a-commit-to-a-pr-using-the-built-in-token
- name: Check and commit changes if needed
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
if ! git diff --quiet; then
git diff
git commit -am "chore: auto-format with clang-format"
git push
else
echo "No formatting changes"
fi
+11
View File
@@ -141,6 +141,17 @@ The third configuration file is `ddraw.ini` (part of Sfall). There are dozens of
For a sample ddraw.ini configuration file, containing all currently working settings use this link: [ddraw.ini](https://raw.githubusercontent.com/fallout2-ce/fallout2-ce/refs/heads/main/files/ddraw.ini)
## Quality of life benefits over vanilla Fallout
* High resolution support
* Increased pathfinding nodes 5x for more accurate pathfinding
* Ctrl-click to quickly move items when bartering, looting, or stealing
* _a_ to select "all" when selecting item quantity
* _a_ to `Take All` when looting
* When bartering, caps default to the right amount to balance the trade (if possible)
* Music continues playing between maps (requires config)
* Auto open doors (requires config)
## Contributing
Integrating Sfall goodies is the top priority. Quality of life updates are OK too. Please no large scale refactorings at this time as we need to reconcile changes from Reference Edition, which will make this process slow and error-prone. In any case open up an issue with your suggestion or to notify other people that something is being worked on.
+7
View File
@@ -0,0 +1,7 @@
#!/bin/bash
docker run --rm \
-v $(pwd):/app --workdir /app \
--user $(id -u):$(id -g) silkeh/clang:18 \
bash -c 'find src -type f -name \*.cc -o -name \*.h | xargs clang-format -i'
+1
View File
@@ -0,0 +1 @@
*.int
+33
View File
@@ -0,0 +1,33 @@
# Testing sFall scripting features
## Basic info
This folder contains scripts which can be used for sFall opcodes.
## Build script using sFall Script Editor
1. Get "Fallout sFall Script Editor v4.1.7.RC1", for example from https://nuclear-grot.ucoz.net/forum/12-20-1
2. Run script editor, add "sfall_headers" into "Location folder of headers files" in the options
3. Open any script here and compile it
4. This shoud create compiled script <file.int>
## Run test script
1. Move compiled .int file into game folder as `mods/tests/SCRIPTS/OBJ_DUDE.INT` (case-sensitive!)
2. Change `mods/mods_order.txt` file: add a line `tests` there
3. Run game, check that game displays message about tests
4. Comment tests line in `mods/mods_order.txt` in order to enable game back
## TODO
- Use custom global script instead of `obj_dude`
- Add note about compile.exe and https://marketplace.visualstudio.com/items?itemName=BGforge.bgforge-mls
+201
View File
@@ -0,0 +1,201 @@
#include "lib.arrays.h"
// #include "define_lite.h"
variable test_suite_errors := 0;
variable test_suite_verbose := true;
#ifndef assertEquals
procedure assertEquals(variable desc, variable a, variable b) begin
if (a != b or typeof(a) != typeof(b)) then begin
display_msg("Assertion failed \""+desc+"\": "+a+" != "+b);
test_suite_errors ++;
end else if (test_suite_verbose) then begin
display_msg("Assert \""+desc+"\" ok");
end
end
procedure assertNotEquals(variable desc, variable a, variable b) begin
if (a == b) then begin
display_msg("Assertion failed \""+desc+"\": "+a+" == "+b);
test_suite_errors ++;
end else if (test_suite_verbose) then begin
display_msg("Assert \""+desc+"\" ok");
end
end
#endif
#define ARRAY_MAX_STRING (255)
#define ARRAY_MAX_SIZE (100000)
procedure array_test_suite begin
variable arr, i, arr2, map, k, v, s;
test_suite_errors := 0;
display_msg("Testing arrays_equal functions...");
call assertEquals("array_equals 1", arrays_equal([9, 7, 2, 1], [9, 7, 2, 1]), true);
call assertEquals("array_equals 2", arrays_equal([9, 7, 0, 1], [9, 7, 2, 1]), false);
call assertEquals("array_equals 3", arrays_equal([1, 1, 1, 1], [1, 1, 1]), false);
call assertEquals("array_equals 4", arrays_equal([], []), true);
call assertEquals("array_equals 5", arrays_equal({}, []), false);
call assertEquals("array_equals 6", arrays_equal({1: 1.0, 2: 2.0}, {1: 1.000, 2: 2.000}), true);
call assertEquals("array_equals 7", arrays_equal({"name": "John", "dept": 15.20}, {"name": "John"}), false);
display_msg("Testing utility functions...");
call assertEquals("strlen", strlen("testing"), 7);
call assertEquals("substr 1", substr("testing", 4, 2), "in");
call assertEquals("substr 2", substr("testing", 1, -1), "estin");
call assertEquals("substr 3", substr("testing", -5, 5), "sting");
call assertEquals("typeof 1", typeof(1), VALTYPE_INT);
call assertEquals("typeof 2", typeof(1.0), VALTYPE_FLOAT);
call assertEquals("typeof 3", typeof("1.0"), VALTYPE_STR);
// Basic array functionality
display_msg("Testing basic arrays functionality...");
arr := create_array(5,0);
call assertEquals("array size", len_array(arr), 5);
arr[0]:=100;
call assertEquals("get array", get_array(arr, 0), 100);
arr[1]:=5.555;
call assertEquals("get array float", get_array(arr, 1), 5.555);
arr[2]:="hello";
call assertEquals("get array str", get_array(arr, 2), "hello");
call assertEquals("get array invalid index", get_array(arr, -1), 0);
call assertEquals("get array invalid index", get_array(arr, 6), 0);
resize_array(arr, 77);
call assertEquals("list resize", len_array(arr), 77);
resize_array(arr, ARRAY_MAX_SIZE + 100);
call assertEquals("resize max", len_array(arr), ARRAY_MAX_SIZE);
free_array(arr);
call assertEquals("not exists check", len_array(arr), -1);
arr := create_array(ARRAY_MAX_SIZE + 100, 0);
call assertEquals("create max", len_array(arr), ARRAY_MAX_SIZE);
free_array(arr);
arr := [6, 1, 10, "one", 10, "two", 5, "three"];
arr[0] := "wtf";
//display_msg(debug_array_str(arr));
call assertEquals("scan list", scan_array(arr, 10), 2);
call assertEquals("scan list 2", scan_array(arr, "two"), 5);
call assertEquals("array_key", array_key(arr, 5), 5);
call assertEquals("array_key out of range", array_key(arr, 9), 0);
call assertEquals("is list", array_key(arr, -1), 0);
call assertEquals("get array as substr", get_array("NiCe", 1), "i");
arr := [78, 12, 99, 1, -5];
sort_array(arr);
call assertEquals("sort ASC", arrays_equal(arr, [-5, 1, 12, 78, 99]), true);
arr := ["Albert", "John", "Mike", "David"];
sort_array_reverse(arr);
call assertEquals("sort DESC", arrays_equal(arr, ["Mike", "John", "David", "Albert"]), true);
reverse_array(arr);
call assertEquals("reverse list", arrays_equal(arr, ["Albert", "David", "John", "Mike"]), true);
shuffle_array(arr);
call assertEquals("shuffle list 1", arrays_equal(arr, ["Albert", "David", "John", "Mike"]), false);
call assertEquals("shuffle list 2", len_array(arr), 4);
if (test_suite_verbose) then display_array(arr);
// some additional stuff
call assertEquals("string_split", get_array(string_split("this+is+good", "+"), 2), "good");
call assertEquals("string_split 2", len_array(string_split("advice", "")), 6);
s := "";
for (i := 0; i < ARRAY_MAX_STRING+30; i+=10) begin
s += "Verbosity.";
end
arr[0] := s;
call assertEquals("array max string", strlen(arr[0]), ARRAY_MAX_STRING-1);
// ASSOC ARRAYS TEST
display_msg("Testing associative arrays...");
arr := create_array(-1,0);
call assertEquals("is map", array_key(arr, -1), 1);
call assertEquals("exists check", len_array(arr), 0);
arr["123"] := 100;
call assertEquals("set/get str=>int", arr["123"], 100);
arr["123"] := 50;
call assertEquals("overwrite 1", arr["123"], 50);
call assertEquals("overwrite 2", len_array(arr), 1);
arr[-1] := "wtf";
call assertEquals("set/get int=>str", arr[-1], "wtf");
arr[3.14] := 0.00001;
call assertEquals("set/get float=>float", arr[3.14], 0.00001);
arr["fourth"] := "elem";
call assertEquals("map size", len_array(arr), 4);
arr[-1] := 0;
call assertEquals("unset key: length", len_array(arr), 3);
call assertEquals("unset key: hashmap", arr[3.14], 0.00001);
call assertEquals("key not exist", arr[777], 0);
free_array(arr);
call assertEquals("not exists check", len_array(arr), -1);
arr := {6:5, 1.001:0.5, 10:"A", 5:0, "wtf":1.1, 10:0.0001, "some":"What"}; // 7 here
// 10:"A" will be overwritten by 10:0.0001
call assertEquals("assoc array expr", len_array(arr), 6); // 6 actual
call assertEquals("scan map 1", scan_array(arr, 1.1), "wtf");
call assertEquals("scan map 2", scan_array(arr, 5), 6);
call assertEquals("scan map 3", scan_array(arr, "What"), "some");
call assertEquals("array_key 1", array_key(arr, 0), 6);
call assertEquals("array_key 2", array_key(arr, 4), "wtf");
call assertEquals("array_key 3", array_key(arr, 1), 1.001);
resize_array(arr, 2);
call assertEquals("map resize 1", len_array(arr), 2);
call assertEquals("map resize 2", arrays_equal(arr, {6:5, 1.001:0.5}), true);
resize_array(arr, 0);
call assertEquals("map clear", len_array(arr), 0);
display_msg("Testing foreach...");
s := "ar";
arr := [6, 10, 0.5, "wtf"];
foreach v in arr begin
s += v;
end
call assertEquals("foreach 1", s, "ar6100.50000wtf");
s := "ar2=";
arr := {"name": "John", "hp": 25, 0: 5.5};
foreach k: v in arr begin
s += k+":"+v+";";
end
call assertEquals("foreach 2", s, "ar2=name:John;hp:25;0:5.50000;");
/*
display_msg("Testing save/load...");
arr := [2,1];
arr2 := {1:2};
save_array("myarray", arr);
call assertEquals("load 1", load_array("myarray"), arr);
save_array("myarray", arr2);
call assertEquals("load 2", load_array("myarray"), arr2);
free_array(arr2);
call assertEquals("not exists check", len_array(arr2), -1);
call assertEquals("load fail", load_array("myarray"), 0);
save_array(0.1, arr);
call assertEquals("save as float", load_array(0.1), arr);
arr2 := list_saved_arrays; // list of array names
//display_msg(debug_array_str(arr2));
call assertNotEquals("saved arrays 1", scan_array(arr2, 0.1), -1);
call assertEquals("saved arrays 2", scan_array(arr2, "myarray"), -1);
save_array(0, arr);
call assertEquals("unsave array 1", load_array(0.1), 0);
call assertEquals("unsave array 2", len_array(arr), 2);
call assertEquals("saved arrays 3", len_array(list_saved_arrays), len_array(arr2) - 1);
*/
display_msg("All tests finished with "+test_suite_errors+" errors.");
end
procedure map_enter_p_proc begin
display_msg("Starting tests");
call array_test_suite();
end
+70 -1
View File
@@ -789,6 +789,62 @@ struct CustomKarmaFolderDescription {
static std::vector<CustomKarmaFolderDescription> gCustomKarmaFolderDescriptions;
static std::vector<TownReputationEntry> gCustomTownReputationEntries;
/* Explaining characterEditorSelectedItem
0-6: Primary Stats (SPECIAL)
- 0-6 = The seven primary stats (Strength, Perception, Endurance, Charisma, Intelligence, Agility, Luck)
- Used for highlighting which SPECIAL stat is selected
7-9: Level/Experience Area
- 7 = Level display
- 8 = Experience points display
- 9 = Experience needed for next level
10-42: Folder Content Area (Perks/Karma/Kills)
- 10-42 = Items within the currently selected folder tab (perks, karma, or kills)
- 10 = First visible item in the folder
- The actual content depends on which folder is active (characterEditorWindowSelectedFolder)
- This is the range where mouse wheel scrolling is active
- When scrolling, items shift but the selection stays within this range
43-50: Status Conditions
- 43 = Hit Points (EDITOR_HIT_POINTS)
- 44 = Poisoned status (EDITOR_POISONED)
- 45 = Radiated status (EDITOR_RADIATED)
- 46 = Eye damage (EDITOR_EYE_DAMAGE)
- 47 = Crippled right arm (EDITOR_CRIPPLED_RIGHT_ARM)
- 48 = Crippled left arm (EDITOR_CRIPPLED_LEFT_ARM)
- 49 = Crippled right leg (EDITOR_CRIPPLED_RIGHT_LEG)
- 50 = Crippled left leg (EDITOR_CRIPPLED_LEFT_LEG)
51-60: Derived Stats
- 51-60 = The 10 derived stats (EDITOR_FIRST_DERIVED_STAT + EDITOR_DERIVED_STAT_*)
- Armor Class, Action Points, Carry Weight, Melee Damage, etc.
61-78: Skills
- 61-78 = The 18 skills (EDITOR_FIRST_SKILL to EDITOR_FIRST_SKILL + SKILL_COUNT)
- Small Guns, Big Guns, Energy Weapons, Unarmed, etc.
- characterEditorSelectedItem - 61 gives the actual skill index
79-81: Skill Controls
- 79 = Tag Skill button (EDITOR_TAG_SKILL)
- 80 = Skills header/button (EDITOR_SKILLS)
- 81 = Optional Traits button (EDITOR_OPTIONAL_TRAITS)
82-97: Optional Traits
- 82-97 = The 16 trait slots (EDITOR_FIRST_TRAIT to EDITOR_FIRST_TRAIT + TRAIT_COUNT)
- Fast Metabolism, Bruiser, Small Frame, etc.
- Can be arranged in 2 columns (left: 82-89, right: 90-97)
*/
// 0x431DF8
int characterEditorShow(bool isCreationMode)
{
@@ -826,7 +882,20 @@ int characterEditorShow(bool isCreationMode)
_frame_time = getTicks();
int keyCode = inputGetInput();
convertMouseWheelToArrowKey(&keyCode);
// check for mouse wheel over the "folder" area (perks/karma/kills)
if (keyCode == -1 && (mouseGetEvent() & MOUSE_EVENT_WHEEL) != 0 && !gCharacterEditorIsCreationMode && mouseHitTestInWindow(gCharacterEditorWindow, 34, 364, 314, 364 + 9 * (fontGetLineHeight() + 1))) {
int wheelX, wheelY;
mouseGetWheel(&wheelX, &wheelY);
if (wheelY > 0) { // Scroll up
characterEditorFolderViewScroll(-1);
} else if (wheelY < 0) { // Scroll down
characterEditorFolderViewScroll(1);
}
characterEditorDrawCard();
windowRefresh(gCharacterEditorWindow);
} else {
convertMouseWheelToArrowKey(&keyCode);
}
bool done = false;
if (keyCode == 500) {
+2 -2
View File
@@ -123,7 +123,7 @@ MessageList gMiscMessageList;
static void** gGameGlobalPointers = nullptr;
// 0x442580
int gameInitWithOptions(const char* windowTitle, bool isMapper, int font, int a4, int argc, char** argv)
int gameInitWithOptions(const char* windowTitle, bool isMapper, int font, int flags, int argc, char** argv)
{
char path[COMPAT_MAX_PATH];
@@ -150,7 +150,7 @@ int gameInitWithOptions(const char* windowTitle, bool isMapper, int font, int a4
messageListRepositoryInit();
programWindowSetTitle(windowTitle);
_initWindow(1, a4);
_initWindow(1, flags);
paletteInit();
const char* language = settings.system.language.c_str();
+1 -1
View File
@@ -23,7 +23,7 @@ extern int _game_user_wants_to_quit;
extern MessageList gMiscMessageList;
int gameInitWithOptions(const char* windowTitle, bool isMapper, int a3, int a4, int argc, char** argv);
int gameInitWithOptions(const char* windowTitle, bool isMapper, int font, int flags, int argc, char** argv);
void gameReset();
void gameExit();
int gameHandleKey(int eventCode, bool isInCombatMode);
+4 -5
View File
@@ -3241,12 +3241,12 @@ int _gdialog_barter_create_win()
backgroundFrmImage.unlock();
// TRADE
_gdialog_buttons[0] = buttonCreate(gGameDialogWindow, 41, 163, 14, 14, -1, -1, -1, KEY_LOWERCASE_M, _redButtonNormalFrmImage.getData(), _redButtonPressedFrmImage.getData(), nullptr, BUTTON_FLAG_TRANSPARENT);
_gdialog_buttons[0] = buttonCreate(gGameDialogWindow, 40, 162, 14, 14, -1, -1, -1, KEY_LOWERCASE_M, _redButtonNormalFrmImage.getData(), _redButtonPressedFrmImage.getData(), nullptr, BUTTON_FLAG_TRANSPARENT);
if (_gdialog_buttons[0] != -1) {
buttonSetCallbacks(_gdialog_buttons[0], _gsound_med_butt_press, _gsound_med_butt_release);
// TALK
_gdialog_buttons[1] = buttonCreate(gGameDialogWindow, 584, 162, 14, 14, -1, -1, -1, KEY_LOWERCASE_T, _redButtonNormalFrmImage.getData(), _redButtonPressedFrmImage.getData(), nullptr, BUTTON_FLAG_TRANSPARENT);
_gdialog_buttons[1] = buttonCreate(gGameDialogWindow, 583, 161, 14, 14, -1, -1, -1, KEY_LOWERCASE_T, _redButtonNormalFrmImage.getData(), _redButtonPressedFrmImage.getData(), nullptr, BUTTON_FLAG_TRANSPARENT);
if (_gdialog_buttons[1] != -1) {
buttonSetCallbacks(_gdialog_buttons[1], _gsound_med_butt_press, _gsound_med_butt_release);
@@ -4143,7 +4143,6 @@ int _gdCustomSelect(int a1)
buttonSetCallbacks(btn2, _gsound_red_butt_press, _gsound_red_butt_release);
}
fontSetCurrent(103);
MessageListItem messageListItem;
@@ -4186,7 +4185,7 @@ int _gdCustomSelect(int a1)
STRUCT_5189E4* ptr = &(_custom_settings[a1][value]);
_custom_current_selected[a1] = value;
_gdCustomUpdateSetting(a1, ptr->value);
if (keyCode != 500){
if (keyCode != 500) {
soundPlayFile("ib1p1xx1");
}
done = true;
@@ -4364,7 +4363,7 @@ int _gdialog_window_create()
// BARTER/TRADE - button moved here to set above background window
_gdialog_buttons[0] = buttonCreate(gGameDialogWindow, 593, 41, 14, 14, -1, -1, -1, -1, _redButtonNormalFrmImage.getData(), _redButtonPressedFrmImage.getData(), nullptr, BUTTON_FLAG_TRANSPARENT);
if (_dialogue_just_started) {
windowRefresh(gGameDialogBackgroundWindow);
_gdialog_scroll_subwin(gGameDialogWindow, true, backgroundFrmData, windowBuf, nullptr, _dialogue_subwin_len, true);
+7 -7
View File
@@ -352,20 +352,20 @@ void takeScreenshot()
return;
}
WINDOWDRAWINGPROC v0 = _scr_blit;
WINDOWDRAWINGPROC old_src = _scr_blit;
_scr_blit = screenshotBlitter;
WINDOWDRAWINGPROC v2 = _mouse_blit;
WINDOWDRAWINGPROC old_mouse = _mouse_blit;
_mouse_blit = screenshotBlitter;
WindowDrawingProc2* v1 = _mouse_blit_trans;
WindowDrawingProc2* old_mouse_trans = _mouse_blit_trans;
_mouse_blit_trans = nullptr;
windowRefreshAll(&_scr_size);
_mouse_blit_trans = v1;
_mouse_blit = v2;
_scr_blit = v0;
_mouse_blit_trans = old_mouse_trans;
_mouse_blit = old_mouse;
_scr_blit = old_src;
unsigned char* palette = _getSystemPalette();
gScreenshotHandler(width, height, gScreenshotBuffer, palette);
@@ -373,7 +373,7 @@ void takeScreenshot()
}
// 0x4C8FF0
static void screenshotBlitter(unsigned char* src, int srcPitch, int a3, int srcX, int srcY, int width, int height, int destX, int destY)
static void screenshotBlitter(unsigned char* src, int srcPitch, int _, int srcX, int srcY, int width, int height, int destX, int destY)
{
int destWidth = _scr_size.right - _scr_size.left + 1;
blitBufferToBuffer(src + srcPitch * srcY + srcX, width, height, srcPitch, gScreenshotBuffer + destWidth * destY + destX, destWidth);
+92 -120
View File
@@ -269,7 +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 fromPlayer, bool fromInventory);
static int _barter_get_quantity_moved_items(Object* item, int maxQuantity, bool fromPlayer, bool fromInventory, bool immediate);
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);
@@ -281,6 +281,8 @@ static void _draw_amount(int value, int inventoryWindowType);
static int inventoryQuantitySelect(int inventoryWindowType, Object* item, int maximum, int defaultValue = 1);
static int inventoryQuantityWindowInit(int inventoryWindowType, Object* item);
static int inventoryQuantityWindowFree(int inventoryWindowType);
static bool _ctrl_pressed();
static void _drag_item_loop(Object* item, bool immediate);
// 0x46E6D0
static const int gSummaryStats[7] = {
@@ -464,7 +466,7 @@ static Object* _ptable;
static InventoryPrintItemDescriptionHandler* gInventoryPrintItemDescriptionHandler;
// 0x59E93C
static int _im_value;
static int _im_value; // "keyCode" corresponding to an inventory item "button", or -1 if nothing
// 0x59E940
static int gInventoryCursor;
@@ -2311,7 +2313,8 @@ static void _inven_pickup(int buttonCode, int indexOffset)
break;
}
if (itemIndex == -1 || _pud->items[indexOffset + itemIndex].quantity <= 1) {
// fix for disappearing/not disappearing inventory items
if (itemIndex == -1 || _pud->items[_pud->length - (itemIndex + indexOffset + 1)].quantity <= 1) { // slots
unsigned char* windowBuffer = windowGetBuffer(gInventoryWindow);
if (gInventoryRightHandItem != gInventoryLeftHandItem || item != gInventoryLeftHandItem) {
int height;
@@ -2359,42 +2362,21 @@ static void _inven_pickup(int buttonCode, int indexOffset)
_display_inventory(indexOffset, itemIndex, INVENTORY_WINDOW_TYPE_NORMAL);
}
FrmImage itemInventoryFrmImage;
int itemInventoryFid = itemGetInventoryFid(item);
if (itemInventoryFrmImage.lock(itemInventoryFid)) {
int width = itemInventoryFrmImage.getWidth();
int height = itemInventoryFrmImage.getHeight();
unsigned char* data = itemInventoryFrmImage.getData();
mouseSetFrame(data, width, height, width, width / 2, height / 2, 0);
soundPlayFile("ipickup1");
}
if (itemInHand != nullptr) {
_inven_update_lighting(nullptr);
}
do {
sharedFpsLimiter.mark();
// SFALL: allow ctrl-click to unequip
bool immediate = itemIndex == -1 && _ctrl_pressed();
_drag_item_loop(item, immediate);
inputGetInput();
_display_body(-1, INVENTORY_WINDOW_TYPE_NORMAL);
renderPresent();
sharedFpsLimiter.throttle();
} while ((mouseGetEvent() & MOUSE_EVENT_LEFT_BUTTON_REPEAT) != 0);
if (itemInventoryFrmImage.isLocked()) {
itemInventoryFrmImage.unlock();
soundPlayFile("iputdown");
}
if (mouseHitTestInWindow(gInventoryWindow, INVENTORY_SCROLLER_X, INVENTORY_SCROLLER_Y, INVENTORY_SCROLLER_MAX_X, INVENTORY_SLOT_HEIGHT * gInventorySlotsCount + INVENTORY_SCROLLER_Y)) {
if (immediate || mouseHitTestInWindow(gInventoryWindow, INVENTORY_SCROLLER_X, INVENTORY_SCROLLER_Y, INVENTORY_SCROLLER_MAX_X, INVENTORY_SLOT_HEIGHT * gInventorySlotsCount + INVENTORY_SCROLLER_Y)) {
int x;
int y;
mouseGetPositionInWindow(gInventoryWindow, &x, &y);
int targetIndex = (y - 39) / INVENTORY_SLOT_HEIGHT + indexOffset;
if (targetIndex < _pud->length) {
if (!immediate && targetIndex < _pud->length) {
Object* targetItem = _pud->items[targetIndex].item;
if (targetItem != item) {
// Dropping item on top of another item.
@@ -2410,7 +2392,7 @@ static void _inven_pickup(int buttonCode, int indexOffset)
}
}
if (itemIndex == -1) {
if (immediate || itemIndex == -1) {
// TODO: Holy shit, needs refactoring.
*itemSlot = nullptr;
if (itemAdd(_inven_dude, item, 1)) {
@@ -4273,7 +4255,7 @@ int inventoryOpenLooting(Object* looter, Object* target)
break;
}
if (keyCode == KEY_UPPERCASE_A) {
if (keyCode == KEY_UPPERCASE_A || keyCode == KEY_LOWERCASE_A) {
if (!_gIsSteal) {
int maxCarryWeight = critterGetStat(looter, STAT_CARRY_WEIGHT);
int currentWeight = objectGetInventoryWeight(looter);
@@ -4527,6 +4509,7 @@ int inventoryOpenStealing(Object* thief, Object* target)
}
// 0x474708
// note: this is looting and stealing, not the inventory screen
static InventoryMoveResult _move_inventory(Object* item, int slotIndex, Object* targetObj, bool isPlanting)
{
bool needRefresh = true;
@@ -4576,40 +4559,17 @@ static InventoryMoveResult _move_inventory(Object* item, int slotIndex, Object*
windowRefreshRect(gInventoryWindow, &rect);
}
FrmImage itemInventoryFrmImage;
int itemInventoryFid = itemGetInventoryFid(item);
if (itemInventoryFrmImage.lock(itemInventoryFid)) {
int width = itemInventoryFrmImage.getWidth();
int height = itemInventoryFrmImage.getHeight();
unsigned char* data = itemInventoryFrmImage.getData();
mouseSetFrame(data, width, height, width, width / 2, height / 2, 0);
soundPlayFile("ipickup1");
}
do {
sharedFpsLimiter.mark();
inputGetInput();
renderPresent();
sharedFpsLimiter.throttle();
} while ((mouseGetEvent() & MOUSE_EVENT_LEFT_BUTTON_REPEAT) != 0);
if (itemInventoryFrmImage.isLocked()) {
itemInventoryFrmImage.unlock();
soundPlayFile("iputdown");
}
bool immediate = _ctrl_pressed();
_drag_item_loop(item, immediate);
InventoryMoveResult result = INVENTORY_MOVE_RESULT_FAILED;
MessageListItem messageListItem;
if (isPlanting) {
if (mouseHitTestInWindow(gInventoryWindow, INVENTORY_LOOT_RIGHT_SCROLLER_X, INVENTORY_LOOT_RIGHT_SCROLLER_Y, INVENTORY_LOOT_RIGHT_SCROLLER_MAX_X, INVENTORY_SLOT_HEIGHT * gInventorySlotsCount + INVENTORY_LOOT_RIGHT_SCROLLER_Y)) {
int quantityToMove;
if (quantity > 1) {
if (immediate || mouseHitTestInWindow(gInventoryWindow, INVENTORY_LOOT_RIGHT_SCROLLER_X, INVENTORY_LOOT_RIGHT_SCROLLER_Y, INVENTORY_LOOT_RIGHT_SCROLLER_MAX_X, INVENTORY_SLOT_HEIGHT * gInventorySlotsCount + INVENTORY_LOOT_RIGHT_SCROLLER_Y)) {
int quantityToMove = quantity;
if (quantity > 1 && !immediate) {
quantityToMove = inventoryQuantitySelect(INVENTORY_WINDOW_TYPE_MOVE_ITEMS, item, quantity);
} else {
quantityToMove = 1;
}
if (quantityToMove != -1) {
@@ -4633,12 +4593,10 @@ static InventoryMoveResult _move_inventory(Object* item, int slotIndex, Object*
}
}
} else {
if (mouseHitTestInWindow(gInventoryWindow, INVENTORY_LOOT_LEFT_SCROLLER_X, INVENTORY_LOOT_LEFT_SCROLLER_Y, INVENTORY_LOOT_LEFT_SCROLLER_MAX_X, INVENTORY_SLOT_HEIGHT * gInventorySlotsCount + INVENTORY_LOOT_LEFT_SCROLLER_Y)) {
int quantityToMove;
if (quantity > 1) {
if (immediate || mouseHitTestInWindow(gInventoryWindow, INVENTORY_LOOT_LEFT_SCROLLER_X, INVENTORY_LOOT_LEFT_SCROLLER_Y, INVENTORY_LOOT_LEFT_SCROLLER_MAX_X, INVENTORY_SLOT_HEIGHT * gInventorySlotsCount + INVENTORY_LOOT_LEFT_SCROLLER_Y)) {
int quantityToMove = quantity;
if (quantity > 1 && !immediate) {
quantityToMove = inventoryQuantitySelect(INVENTORY_WINDOW_TYPE_MOVE_ITEMS, item, quantity);
} else {
quantityToMove = 1;
}
if (quantityToMove != -1) {
@@ -4766,7 +4724,7 @@ 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)
static int _barter_get_quantity_moved_items(Object* item, int maxQuantity, bool fromPlayer, bool fromInventory, bool immediate)
{
if (maxQuantity <= 1) {
return maxQuantity;
@@ -4782,11 +4740,54 @@ static int _barter_get_quantity_moved_items(Object* item, int maxQuantity, bool
if ((balance < 0 && fromInventory) || (balance > 0 && !fromInventory)) {
suggestedValue = std::min(std::abs(balance), maxQuantity);
if (immediate) {
return suggestedValue;
}
}
}
if (immediate) {
return maxQuantity;
}
return inventoryQuantitySelect(INVENTORY_WINDOW_TYPE_MOVE_ITEMS, item, maxQuantity, suggestedValue);
}
// clicked on an inventory in preparation of dragging or immediate transfer
static void _drag_item_loop(Object* item, bool immediate)
{
if (immediate) {
soundPlayFile("iputdown");
// prevent item look from occuring after immediate move
_im_value = -1;
return;
}
FrmImage itemInventoryFrmImage;
int itemInventoryFid = itemGetInventoryFid(item);
if (itemInventoryFrmImage.lock(itemInventoryFid)) {
int width = itemInventoryFrmImage.getWidth();
int height = itemInventoryFrmImage.getHeight();
unsigned char* data = itemInventoryFrmImage.getData();
mouseSetFrame(data, width, height, width, width / 2, height / 2, 0);
soundPlayFile("ipickup1");
}
do {
sharedFpsLimiter.mark();
inputGetInput();
renderPresent();
sharedFpsLimiter.throttle();
} while ((mouseGetEvent() & MOUSE_EVENT_LEFT_BUTTON_REPEAT) != 0);
if (itemInventoryFrmImage.isLocked()) {
itemInventoryFrmImage.unlock();
soundPlayFile("iputdown");
}
}
// 0x474DAC
static void _barter_move_inventory(Object* item, int quantity, int slotIndex, int indexOffset, Object* npc, Object* sourceTable, bool fromDude)
{
@@ -4817,35 +4818,14 @@ static void _barter_move_inventory(Object* item, int quantity, int slotIndex, in
windowRefreshRect(gInventoryWindow, &rect);
}
FrmImage itemInventoryFrmImage;
int itemInventoryFid = itemGetInventoryFid(item);
if (itemInventoryFrmImage.lock(itemInventoryFid)) {
int width = itemInventoryFrmImage.getWidth();
int height = itemInventoryFrmImage.getHeight();
unsigned char* data = itemInventoryFrmImage.getData();
mouseSetFrame(data, width, height, width, width / 2, height / 2, 0);
soundPlayFile("ipickup1");
}
do {
sharedFpsLimiter.mark();
inputGetInput();
renderPresent();
sharedFpsLimiter.throttle();
} while ((mouseGetEvent() & MOUSE_EVENT_LEFT_BUTTON_REPEAT) != 0);
if (itemInventoryFrmImage.isLocked()) {
itemInventoryFrmImage.unlock();
soundPlayFile("iputdown");
}
bool immediate = _ctrl_pressed();
_drag_item_loop(item, immediate);
MessageListItem messageListItem;
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 = _barter_get_quantity_moved_items(item, quantity, true, true);
if (immediate || 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 = _barter_get_quantity_moved_items(item, quantity, true, true, immediate);
if (quantityToMove != -1) {
if (itemMoveForce(_inven_dude, sourceTable, item, quantityToMove) == -1) {
// There is no space left for that item.
@@ -4857,8 +4837,8 @@ 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 = _barter_get_quantity_moved_items(item, quantity, false, true);
if (immediate || 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 = _barter_get_quantity_moved_items(item, quantity, false, true, immediate);
if (quantityToMove != -1) {
if (itemMoveForce(npc, sourceTable, item, quantityToMove) == -1) {
// You cannot pick that up. You are at your maximum weight capacity.
@@ -4904,35 +4884,14 @@ static void _barter_move_from_table_inventory(Object* item, int quantity, int sl
windowRefreshRect(gInventoryWindow, &rect);
}
FrmImage itemInventoryFrmImage;
int itemInventoryFid = itemGetInventoryFid(item);
if (itemInventoryFrmImage.lock(itemInventoryFid)) {
int width = itemInventoryFrmImage.getWidth();
int height = itemInventoryFrmImage.getHeight();
unsigned char* data = itemInventoryFrmImage.getData();
mouseSetFrame(data, width, height, width, width / 2, height / 2, 0);
soundPlayFile("ipickup1");
}
do {
sharedFpsLimiter.mark();
inputGetInput();
renderPresent();
sharedFpsLimiter.throttle();
} while ((mouseGetEvent() & MOUSE_EVENT_LEFT_BUTTON_REPEAT) != 0);
if (itemInventoryFrmImage.isLocked()) {
itemInventoryFrmImage.unlock();
soundPlayFile("iputdown");
}
bool immediate = _ctrl_pressed();
_drag_item_loop(item, immediate);
MessageListItem messageListItem;
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 = _barter_get_quantity_moved_items(item, quantity, true, false);
if (immediate || 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 = _barter_get_quantity_moved_items(item, quantity, true, false, immediate);
if (quantityToMove != -1) {
if (itemMoveForce(sourceTable, _inven_dude, item, quantityToMove) == -1) {
// There is no space left for that item.
@@ -4944,8 +4903,8 @@ 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 = _barter_get_quantity_moved_items(item, quantity, false, false);
if (immediate || 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 = _barter_get_quantity_moved_items(item, quantity, false, false, immediate);
if (quantityToMove != -1) {
if (itemMoveForce(sourceTable, npc, item, quantityToMove) == -1) {
// You cannot pick that up. You are at your maximum weight capacity.
@@ -5053,6 +5012,12 @@ static void inventoryWindowRenderInnerInventories(int win, Object* leftTable, Ob
fontSetCurrent(oldFont);
}
static bool _ctrl_pressed()
{
const Uint8* keyboardState = SDL_GetKeyboardState(nullptr);
return keyboardState[SDL_SCANCODE_LCTRL] || keyboardState[SDL_SCANCODE_RCTRL];
}
// 0x4757F0
void inventoryOpenTrade(int win, Object* barterer, Object* playerTable, Object* bartererTable, int barterMod)
{
@@ -5150,11 +5115,13 @@ void inventoryOpenTrade(int win, Object* barterer, Object* playerTable, Object*
_barter_mod = barterMod + modifier;
if (keyCode == KEY_LOWERCASE_T || modifier <= -30) {
// T == return to talk
itemMoveAll(bartererTable, barterer);
itemMoveAll(playerTable, gDude);
_barter_end_to_talk_to();
break;
} else if (keyCode == KEY_LOWERCASE_M) {
// M == attempt offer
if (playerTable->data.inventory.length != 0 || _btable->data.inventory.length != 0) {
if (_barter_attempt_transaction(_inven_dude, playerTable, barterer, bartererTable) == 0) {
_display_target_inventory(_target_stack_offset[_target_curr_stack], -1, _target_pud, INVENTORY_WINDOW_TYPE_TRADE);
@@ -5228,6 +5195,7 @@ void inventoryOpenTrade(int win, Object* barterer, Object* playerTable, Object*
inventoryWindowOpenContextMenu(keyCode, INVENTORY_WINDOW_TYPE_TRADE);
inventoryWindowRenderInnerInventories(win, playerTable, nullptr, -1);
} else {
// player inventory
int slotIndex = keyCode - 1000;
if (slotIndex + _stack_offset[_curr_stack] < _pud->length) {
int offset = _stack_offset[_curr_stack];
@@ -5241,6 +5209,7 @@ void inventoryOpenTrade(int win, Object* barterer, Object* playerTable, Object*
keyCode = -1;
} else if (keyCode >= 2000 && keyCode <= 2000 + gInventorySlotsCount) {
// merchant inventory
if (gInventoryCursor == INVENTORY_WINDOW_CURSOR_ARROW) {
inventoryWindowOpenContextMenu(keyCode, INVENTORY_WINDOW_TYPE_TRADE);
inventoryWindowRenderInnerInventories(win, nullptr, bartererTable, -1);
@@ -5258,6 +5227,7 @@ void inventoryOpenTrade(int win, Object* barterer, Object* playerTable, Object*
keyCode = -1;
} else if (keyCode >= 2300 && keyCode <= 2300 + gInventorySlotsCount) {
// player table (offer)
if (gInventoryCursor == INVENTORY_WINDOW_CURSOR_ARROW) {
inventoryWindowOpenContextMenu(keyCode, INVENTORY_WINDOW_TYPE_TRADE);
inventoryWindowRenderInnerInventories(win, playerTable, nullptr, -1);
@@ -5274,6 +5244,7 @@ void inventoryOpenTrade(int win, Object* barterer, Object* playerTable, Object*
keyCode = -1;
} else if (keyCode >= 2400 && keyCode <= 2400 + gInventorySlotsCount) {
// merchant table (offer)
if (gInventoryCursor == INVENTORY_WINDOW_CURSOR_ARROW) {
inventoryWindowOpenContextMenu(keyCode, INVENTORY_WINDOW_TYPE_TRADE);
inventoryWindowRenderInnerInventories(win, nullptr, bartererTable, -1);
@@ -5649,7 +5620,8 @@ static int inventoryQuantitySelect(int inventoryWindowType, Object* item, int ma
soundPlayFile("iisxxxx1");
}
break;
} else if (keyCode == 5000) {
} else if (keyCode == 5000 || keyCode == KEY_LOWERCASE_A) {
isTyping = false;
value = max;
_draw_amount(value, inventoryWindowType);
+6 -6
View File
@@ -781,17 +781,17 @@ int _movieRun(int win, char* filePath)
}
// 0x487B1C
int _movieRunRect(int win, char* filePath, int a3, int a4, int a5, int a6)
int _movieRunRect(int win, char* filePath, int x, int y, int w, int h)
{
if (_running) {
return 1;
}
_movieX = a3;
_movieY = a4;
_movieOffset = a3 + a4 * windowGetWidth(win);
_movieW = a5;
_movieH = a6;
_movieX = x;
_movieY = y;
_movieOffset = x + y * windowGetWidth(win);
_movieW = w;
_movieH = h;
_movieSubRectFlag = 1;
return _movieStart(win, filePath);
+2 -2
View File
@@ -28,11 +28,11 @@ typedef int(MovieBlitFunc)(int win, unsigned char* data, int width, int height,
void movieInit();
void movieExit();
void _movieStop();
int movieSetFlags(int a1);
int movieSetFlags(int flags);
void _movieSetPaletteFunc(MovieSetPaletteEntriesProc* proc);
void movieSetPaletteProc(MovieSetPaletteProc* proc);
int _movieRun(int win, char* filePath);
int _movieRunRect(int win, char* filePath, int a3, int a4, int a5, int a6);
int _movieRunRect(int win, char* filePath, int x, int y, int w, int h);
void movieSetBuildSubtitleFilePathProc(MovieBuildSubtitleFilePathProc* proc);
void movieSetVolume(int volume);
void _movieUpdate();
+3 -2
View File
@@ -687,8 +687,9 @@ static int pipboyWindowInit(int intent)
buttonSetCallbacks(alarmButton, _gsound_med_butt_press, _gsound_med_butt_release);
}
int y = 341;
int y = 340;
int eventCode = 500;
int yOffsets[] = { 27, 27, 29, 25, 27 }; // handles slighlty misaligned buttons on background
for (int index = 0; index < 5; index += 1) {
if (index != 1) {
int btn = buttonCreate(gPipboyWindow,
@@ -711,7 +712,7 @@ static int pipboyWindowInit(int intent)
eventCode += 1;
}
y += 27;
y += yOffsets[index];
}
if (intent == PIPBOY_OPEN_INTENT_REST) {
+1 -1
View File
@@ -298,7 +298,7 @@ unsigned char* directDrawGetPalette()
}
// 0x4CB850
void _GNW95_ShowRect(unsigned char* src, int srcPitch, int a3, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY)
void _GNW95_ShowRect(unsigned char* src, int srcPitch, int _, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY)
{
blitBufferToBuffer(src + srcPitch * srcY + srcX, srcWidth, srcHeight, srcPitch, (unsigned char*)gSdlSurface->pixels + gSdlSurface->pitch * destY + destX, gSdlSurface->pitch);
+24 -38
View File
@@ -206,10 +206,10 @@ int windowGetFont()
}
// 0x4B6128
int windowSetFont(int a1)
int windowSetFont(int font)
{
gWidgetFont = a1;
fontSetCurrent(a1);
gWidgetFont = font;
fontSetCurrent(font);
return 1;
}
@@ -232,9 +232,9 @@ int windowGetTextFlags()
}
// 0x4B6168
int windowSetTextFlags(int a1)
int windowSetTextFlags(int flags)
{
gWidgetTextFlags = a1;
gWidgetTextFlags = flags;
return 1;
}
@@ -624,8 +624,9 @@ void _doRightButtonRelease(int btn, int keyCode)
sub_4B704C(btn, MANAGED_BUTTON_RIGHT_MOUSE_EVENT_BUTTON_UP);
}
// Note: this used to have a third buffer parameter, but it was never used
// 0x4B7118
void _setButtonGFX(int width, int height, unsigned char* normal, unsigned char* pressed, unsigned char* a5)
void _setButtonGFX(int width, int height, unsigned char* normal, unsigned char* pressed)
{
if (normal != nullptr) {
bufferFill(normal, width, height, width, _colorTable[0]);
@@ -648,21 +649,6 @@ void _setButtonGFX(int width, int height, unsigned char* normal, unsigned char*
bufferDrawLine(pressed, width, 1, 1, width - 2, 1, _colorTable[32767] + 44);
bufferDrawLine(pressed, width, 1, 1, 1, height - 2, _colorTable[32767] + 44);
}
if (a5 != nullptr) {
bufferFill(a5, width, height, width, _colorTable[0]);
bufferFill(a5 + width + 1, width - 2, height - 2, width, intensityColorTable[_colorTable[32767]][89]);
bufferDrawLine(a5, width, 1, 1, width - 2, 1, _colorTable[32767]);
bufferDrawLine(a5, width, 2, 2, width - 3, 2, _colorTable[32767]);
bufferDrawLine(a5, width, 1, height - 2, width - 2, height - 2, intensityColorTable[_colorTable[32767]][44]);
bufferDrawLine(a5, width, 2, height - 3, width - 3, height - 3, intensityColorTable[_colorTable[32767]][44]);
bufferDrawLine(a5, width, width - 2, 1, width - 3, 2, intensityColorTable[_colorTable[32767]][89]);
bufferDrawLine(a5, width, 1, 2, 1, height - 3, _colorTable[32767]);
bufferDrawLine(a5, width, 2, 3, 2, height - 4, _colorTable[32767]);
bufferDrawLine(a5, width, width - 2, 2, width - 2, height - 3, intensityColorTable[_colorTable[32767]][44]);
bufferDrawLine(a5, width, width - 3, 3, width - 3, height - 4, intensityColorTable[_colorTable[32767]][44]);
bufferDrawLine(a5, width, 1, height - 2, 2, height - 3, intensityColorTable[_colorTable[32767]][89]);
}
}
// 0x4B75F4
@@ -1052,7 +1038,7 @@ void _windowPrintBuf(int win, char* string, int stringLength, int width, int max
}
// 0x4B8638
char** _windowWordWrap(char* string, int maxLength, int a3, int* substringListLengthPtr)
char** _windowWordWrap(char* string, int maxLength, int indent, int* substringListLengthPtr)
{
if (string == nullptr) {
*substringListLengthPtr = 0;
@@ -1064,15 +1050,15 @@ char** _windowWordWrap(char* string, int maxLength, int a3, int* substringListLe
char* start = string;
char* pch = string;
int v1 = a3;
int width = indent;
while (*pch != '\0') {
v1 += fontGetCharacterWidth(*pch & 0xFF);
if (*pch != '\n' && v1 <= maxLength) {
v1 += fontGetLetterSpacing();
width += fontGetCharacterWidth(*pch & 0xFF);
if (*pch != '\n' && width <= maxLength) {
width += fontGetLetterSpacing();
pch++;
} else {
while (v1 > maxLength) {
v1 -= fontGetCharacterWidth(*pch);
while (width > maxLength) {
width -= fontGetCharacterWidth(*pch);
pch--;
}
@@ -1098,7 +1084,7 @@ char** _windowWordWrap(char* string, int maxLength, int a3, int* substringListLe
pch++;
}
v1 = 0;
width = 0;
start = pch;
substringListLength++;
}
@@ -1141,7 +1127,7 @@ void _windowFreeWordList(char** substringList, int substringListLength)
// Renders multiline string in the specified bounding box.
//
// 0x4B8854
void _windowWrapLineWithSpacing(int win, char* string, int width, int height, int x, int y, int flags, int textAlignment, int a9)
void _windowWrapLineWithSpacing(int win, char* string, int width, int height, int x, int y, int flags, int textAlignment, int spacing)
{
if (string == nullptr) {
return;
@@ -1151,7 +1137,7 @@ void _windowWrapLineWithSpacing(int win, char* string, int width, int height, in
char** substringList = _windowWordWrap(string, width, 0, &substringListLength);
for (int index = 0; index < substringListLength; index++) {
int v1 = y + index * (a9 + fontGetLineHeight());
int v1 = y + index * (spacing + fontGetLineHeight());
_windowPrintBuf(win, substringList[index], strlen(substringList[index]), width, height + y, x, v1, flags, textAlignment);
}
@@ -1195,13 +1181,13 @@ bool _windowFormatMessage(char* string, int x, int y, int width, int height, int
}
// 0x4B8A60
bool _windowPrint(char* string, int a2, int x, int y, int a5)
bool _windowPrint(char* string, int width, int x, int y, int color)
{
ManagedWindow* managedWindow = &(gManagedWindows[gCurrentManagedWindowIndex]);
x = (int)(x * managedWindow->field_54);
y = (int)(y * managedWindow->field_58);
windowDrawText(managedWindow->window, string, a2, x, y, a5);
windowDrawText(managedWindow->window, string, width, x, y, color);
return true;
}
@@ -1349,7 +1335,7 @@ void _removeProgramReferences_3(Program* program)
}
// 0x4B9190
void _initWindow(int resolution, int a2)
void _initWindow(int resolution, int flags)
{
char err[COMPAT_MAX_PATH];
int rc;
@@ -1372,7 +1358,7 @@ void _initWindow(int resolution, int a2)
gManagedWindows[i].window = -1;
}
rc = windowManagerInit(_gfx_init[resolution], directDrawFree, a2);
rc = windowManagerInit(_gfx_init[resolution], directDrawFree, flags);
if (rc != WINDOW_MANAGER_OK) {
switch (rc) {
case WINDOW_MANAGER_ERR_INITIALIZING_VIDEO_MODE:
@@ -1669,7 +1655,7 @@ bool _windowAddButton(const char* buttonName, int x, int y, int width, int heigh
memset(normal, 0, width * height);
memset(pressed, 0, width * height);
} else {
_setButtonGFX(width, height, normal, pressed, nullptr);
_setButtonGFX(width, height, normal, pressed);
}
managedButton->btn = buttonCreate(
@@ -2319,9 +2305,9 @@ bool _windowPlayMovie(char* filePath)
}
// 0x4BB280
bool _windowPlayMovieRect(char* filePath, int a2, int a3, int a4, int a5)
bool _windowPlayMovieRect(char* filePath, int x, int y, int w, int h)
{
if (_movieRunRect(gManagedWindows[gCurrentManagedWindowIndex].window, filePath, a2, a3, a4, a5) != 0) {
if (_movieRunRect(gManagedWindows[gCurrentManagedWindowIndex].window, filePath, x, y, w, h) != 0) {
return false;
}
+11 -11
View File
@@ -8,7 +8,7 @@
namespace fallout {
typedef void (*WINDOWDRAWINGPROC)(unsigned char* src, int src_pitch, int a3, int src_x, int src_y, int src_width, int src_height, int dest_x, int dest_y);
typedef void (*WINDOWDRAWINGPROC)(unsigned char* src, int src_pitch, int _, int src_x, int src_y, int src_width, int src_height, int dest_x, int dest_y);
typedef void WindowDrawingProc2(unsigned char* buf, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, unsigned char a10);
typedef bool(WindowInputHandler)(int key);
typedef void(WindowDeleteCallback)(int windowIndex, const char* windowName);
@@ -37,14 +37,14 @@ typedef enum ManagedButtonRightMouseEvent {
} ManagedButtonRightMouseEvent;
int windowGetFont();
int windowSetFont(int a1);
int windowSetFont(int font);
void windowResetTextAttributes();
int windowGetTextFlags();
int windowSetTextFlags(int a1);
int windowSetTextFlags(int flags);
unsigned char windowGetTextColor();
unsigned char windowGetHighlightColor();
int windowSetTextColor(float a1, float a2, float a3);
int windowSetHighlightColor(float a1, float a2, float a3);
int windowSetTextColor(float r, float g, float b);
int windowSetHighlightColor(float r, float g, float b);
bool _checkRegion(int windowIndex, int mouseX, int mouseY, int mouseEvent);
bool _windowCheckRegion(int windowIndex, int mouseX, int mouseY, int mouseEvent);
bool _windowRefreshRegions();
@@ -62,7 +62,7 @@ void _doButtonRelease(int btn, int keyCode);
void _doRightButtonPress(int btn, int keyCode);
void sub_4B704C(int btn, int mouseEvent);
void _doRightButtonRelease(int btn, int keyCode);
void _setButtonGFX(int width, int height, unsigned char* normal, unsigned char* pressed, unsigned char* a5);
void _setButtonGFX(int width, int height, unsigned char* normal);
bool _windowHide();
bool _windowShow();
int _windowWidth();
@@ -80,13 +80,13 @@ unsigned char* _windowGetBuffer();
int _pushWindow(const char* windowName);
int _popWindow();
void _windowPrintBuf(int win, char* string, int stringLength, int width, int maxY, int x, int y, int flags, int textAlignment);
char** _windowWordWrap(char* string, int maxLength, int a3, int* substringListLengthPtr);
char** _windowWordWrap(char* string, int maxLength, int indent, int* substringListLengthPtr);
void _windowFreeWordList(char** substringList, int substringListLength);
void _windowWrapLineWithSpacing(int win, char* string, int width, int height, int x, int y, int flags, int textAlignment, int a9);
void _windowWrapLineWithSpacing(int win, char* string, int width, int height, int x, int y, int flags, int textAlignment, int spacing);
void _windowWrapLine(int win, char* string, int width, int height, int x, int y, int flags, int textAlignment);
bool _windowPrintRect(char* string, int a2, int textAlignment);
bool _windowFormatMessage(char* string, int x, int y, int width, int height, int textAlignment);
bool _windowPrint(char* string, int a2, int x, int y, int a5);
bool _windowPrint(char* string, int width, int x, int y, int color);
void _displayInWindow(unsigned char* data, int width, int height, int pitch);
void _displayFile(char* fileName);
void _displayFileRaw(char* fileName);
@@ -95,7 +95,7 @@ bool _windowDisplayBuf(unsigned char* src, int srcWidth, int srcHeight, int dest
int _windowGetXres();
int _windowGetYres();
void _removeProgramReferences_3(Program* program);
void _initWindow(int resolution, int a2);
void _initWindow(int resolution, int flags);
void _windowClose();
bool _windowDeleteButton(const char* buttonName);
bool _windowSetButtonFlag(const char* buttonName, int value);
@@ -122,7 +122,7 @@ void _updateWindows();
int _windowMoviePlaying();
bool _windowSetMovieFlags(int flags);
bool _windowPlayMovie(char* filePath);
bool _windowPlayMovieRect(char* filePath, int a2, int a3, int a4, int a5);
bool _windowPlayMovieRect(char* filePath, int x, int y, int w, int h);
void _windowStopMovie();
void _drawScaled(unsigned char* dest, int destWidth, int destHeight, int destPitch, unsigned char* src, int srcWidth, int srcHeight, int srcPitch);
void _drawScaledBuf(unsigned char* dest, int destWidth, int destHeight, unsigned char* src, int srcWidth, int srcHeight);