[Scummvm-cvs-logs] scummvm master -> 11e03fbce271d4817225d834349e5f2e276353ef
sev-
sev at scummvm.org
Sun Feb 14 17:32:49 CET 2016
This automated email contains information about 418 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
c532b6c74f WAGE: Initial version. "Another Fine Mess 1.8" is detected.
ae1f601855 WAGE: Resource file is loaded.
ce6aa4dd28 WAGE: Added stubs for most classes. Implemented Obj and Scene classes.
37cb2480fc WAGE: Added Context class and completed Chr class.
65eb49cbd8 WAGE: Removed tons on those accessors.
2caf210222 WAGE: Remove chr.cpp as it is non-needed.
199bea2167 WAGE: Started scene loader implemenation
53029635b1 WAGE: Load scene scripts too.
f488762703 WAGE: Finished world loading.
add5bba03f WAGE: Merged most headers into entities.h
406a05aec1 WAGE: Implement reading of all entities. This completes the world loading.
d9e0667dcc WAGE: Move MacResManager to Common
bee9d5e2d9 WAGE: Added MIT license to mll relevant files.
e8194a6b79 WAGE: Fix compilation under *nix.
879425385e WAGE: Started implementing script execution.
2910ff45d8 WAGE: Add .gitignore file.
aabe774cbe WAGE: Update Engine Code For Common::RandomSource API Changes.
83617a77da WAGE: Update Engine For Changes To Advanced Detector API.
9d448131c5 WAGE: Update Engine For MKID_BE to MKTAG Change.
0ee543b9fb WAGE: StringList Replaced by StringArray...
37e5e205cc WAGE: Updated Engine for MemoryReadStream Header Change.
2442f12bb4 WAGE: Replace Forbidden Printf calls with debug() calls.
5926af06f1 WAGE: Correct Engine For DebugMan API Changes.
ff672c771c WAGE: Add Missing Required Engine Headers.
0593022a73 WAGE: Correction For MacResManager Constructor Changes.
691e9134c4 WAGE: Minor Comment Corrections and Removal.
af656f220a WAGE: Add Missing Headers For World Class.
2fde3eaabb WAGE: Update World Class with MKTAG fourCC.
57b464b2e9 WAGE: More Updates To World Class for MacResManager API Changes.
624c401873 WAGE: Change Script Object to use Common::SeekableReadStream.
6d90f6c089 WAGE: Fixed Remaining Issues Preventing Compilation.
af8fb354c5 WAGE: Add README.
684d5bf7af WAGE: Remove snprintf() instance. Unused anyway.
30793f99eb WAGE: Update AdvancedMetaEngine For Removal of ADParams.
43aaffc80d WAGE: Fix Detection For ADParams Removal From AdvancedMetaEngine.
1b128d26d7 WAGE: Fix compilation with modern ScummVM
5d7c72c6b6 WAGE: Remove SVN keywords from the headers
d1682018eb WAGE: Added debug output, fixed semantics
e42540a234 WAGE: Sync with modern ScummVM
076a667862 WAGE: Sync with mainline
8e82969ead WAGE: Stub for Design::paint()
d3917bf931 WAGE: Added stub for polygon drawing
080d3827f9 WAGE: Implemented debug drawing
327a9ec74a WAGE: Implemented stub for drawRect
4cfc0d0480 WAGE: Get rid of hacky drawing
5ebbe35238 WAGE: Fix pattern loading
539c2ea8e4 WAGE: Implement drawing patterned rectangles
0ddb529636 WAGE: Start of implementation for patterned polygons
e75a96e66c WAGE: Fix screen size
6efb8bec68 WAGE: Fixed polygon rendering
1ffabd4325 WAGE: Implement ellipses. Refactoring
e112ffdf48 WAGE: Added detection for Camp Cantitoe
c00bd70f02 WAGE: Implement drawBitmap
8950bd5248 WAGE: Implemented drawing of think lines
b054e82dbe WAGE: Switched polygon drawing to generic
f483bc0d83 WAGE: Made ellipse drawing generic
9ae6992c7c WAGE: Switched rectangle drawing to general code
cce763ea2e WAGE: Completed drawFilledEllipse
d9c61c1649 WAGE: Cleanup
0c37ed2c56 WAGE: Fix hang up
0d5c219885 WAGE: Cleanup, completed all routines
b92e7f602f WAGE: Added delay to avoid CPU hogging
e4d9f885f1 WAGE: Fixed h/v line
57648a20c5 WAGE: Simplified code
057753a77a WAGE: Fixed screen size
bebf1b4e86 WAGE: Added 'A mess O'Trouble' detection
7e23caa342 WAGE: Cleanup
0d6b726fd8 WAGE: First stub for rounded rectangles
fd37094c82 WAGE: Firhter work on rounded rectangles
0b79d5611e WAGE: Fixed rectangle drawing
08ffaf8055 WAGE: Fixed rounded rect drawing
3adda8284f WAGE: Fix to roundrect rendering
36e4722922 WAGE: Fix polygon rendering
27adb22aba WAGE: Cleanup
cd84abb2f3 WAGE: Fix pattern filling
efab4a1a5b WAGE: Simplify code
3b94913e17 WAGE: Made drawing process visible for debugging purposes
6c214c2c4a WAGE: Special case for 1-pixel wide ellipses, support for transparent pattern
a616e9fb09 WAGE: More support for transparent primitives
c17c2421f4 WAGE: Improved rounded rects. Now rects with radius > side are drawn correctly
900903324d WAGE: Fixed think vertical/horizontal lines
a4ba9313be WAGE: Fixed think transparent rectangles
bb46957def WAGE: Fixed ver/horisontal lines thickness
5b957c4b06 WAGE: Implementing loading service dialog strings
d5c3b45756 WAGE: Added enhanced Skepters pattern loading
6590f2c3f7 WAGE: Added stubs for menu loading
c1d051da65 WAGE: More work on menu reading
5c2f3301f0 WAGE: More robust rectangle drawing
80af9c9c71 WAGE: Stubs for command processing
c40b5a30c0 WAGE: Implement proper design drawing quitting
423d364296 WAGE: Implemented processLet()
878d1dc78b WAGE: Fixed uservar addressing
e71fe81d09 WAGE: stubbed attack handling
0b3e161d85 WAGE: Test script execution
e11aef1a7d WAGE: Fixes to script execution
60ce5fa557 WAGE: Unstub processIf()
a2ac4ea859 WAGE: Handle NULL value Operands
29cb01f71c WAGE: Unstubbed Script::eval()
6d4a9f54e1 WAGE: Implement first round of comparisons
5478cbe9c8 WAGE: Implement non0direct comparisons
870d6748fe WAGE: Fix crash on double free()
88faad5d08 WAGE: Simplified code and avoid extra object allocations
f76eb1831c WAGE: Implemented object taking logic
9dc5a51660 WAGE: Implement script decoding
370c1932f6 WAGE: Fix bug with skipping nested IF's
9902ac2454 WAGE: Implement handleLookCommand()
35cce4123c WAGE: Cleanup
d4afcf99f2 WAGE: Initial code for world initialization
59b2809f37 WAGE: Finished WageEngine::performInitialSetup()
5f2ef620c1 WAGE: Implemented World::move(Obj *obj, Chr *chr)
113a274027 WAGE: Implemented World::move(Obj *obj, Scene *scene)
81dc7cd98f WAGE: Implement World::move(Chr *chr, Scene *scene)
6d3fe95689 WAGE: Implemented WageEngine::onMove()
ab34bafc31 WAGE: Implement scene drawing
91d5b8b17e WAGE: Started border drawing implementation
069735d0b7 WAGE: Fix border drawing
cd063ec0e8 WAGE: Further work on border drawing
357d956a83 WAGE: More improvements to the border drawing
9ecb9f5bab WAGE: Implement font mapping
88e864a553 WAGE: Implemented script for downloading fonts
c020cd7e96 WAGE: More debug output
2802566f43 WAGE: Fix font downloading script
0d6b87b785 WAGE: Added more documentation to the script
13a62ce1a1 WAGE: Cleanup
3fe3ad7ee3 WAGE: Moved scene drawing calls to Gui class
438eb45704 WAGE: Increased startup speed
0c682799a1 WAGE: Draw checkered background to simulate desktop
0dde7a94a9 WAGE: Implement design caching
97c17ed199 WAGE; Fix border drawing
1c3560cd65 WAGE: Draw console window border.
a712a1d80b WAGE: Implement appendText()
141bddbf57 WAGE: Stub for console rendering
f25663605b WAGE: Implement console drawing
849220b6b6 WAGE: Simplified border drawing API
a3cc6cdddc WAGE: Draw scene title
dad200e50e WAGE: Load fonts from wage.dat
18990b49ae WAGE: Use Mac fonts for rendering
3835f9f626 WAGE: Matched game screen size to Macintosh, fixed line spacing
b0990b7100 WAGE: Hide noisy debug messages deeper
1b6663a7bb WAGE: Fix random crash on start
6852fc9e2a WAGE: Initialize class variables
130a671e8f WAGE: Remove obsolete README
c001c30547 WAGE: Finished world reset
ac87bc9671 WAGE: Implement cursor drawing and handling
03e3f80bff WAGE: Mac has roundrect on desktop. Render it
1332958c9a WAGE: Stub for menu drawing
584dcae75c WAGE: Pad windows to match the original
02a8291c5b WAGE: Fix console padding
c65f15e7e4 WAGE: Fix console output for empty lines
559e486034 WAGE: Stub for rendering menu items
1ef7beb8e8 WAGE: Stub for object clicking
2e6732171d WAGE: More work on object interaction
e825eadb80 WAGE: Made Gui autosense scene change
31e4f810c6 WAGE: Fixed game loop
8d6e811842 WAGE: Redraw Gui parts on demand
0870ac88b8 WAGE: Implement evalClickCondition
c6a83d1e06 WAGE: Proper game start
a210ff65a3 WAGE; Fix stringOp reading
8ce82bd8b8 WAGE: Fix ifClick conditional
b1a558f53c WAGE: Fix number parsing
c3f20695ee WAGE: Less intrusive stub
330f4417e5 WAGE: More debug output
077048032b WAGE: Refactored coordinate manipulation
2aef67c0ac WAGE: Refactored font querying
e684c1148e WAGE: Remove redundant headers
a4251c58b5 WAGE: Implement processMove()
4e14c952d8 WAGE: Fixed processMove operands
74cbf5477d WAGE: Implement console scrolling
b25b2ec8ad WAGE: Implement immediate text rendering to match original
6233e429f3 WAGE: Leave room for input text in console
07d11b4af6 WAGE: Complete Script::compare()
d66c3a21f1 WAGE: Implement getGroundItemsList()
562355e62d WAGE: Graceful engine quitting
0b361b94dc WAGE: Initial cursor drawing code
aec3bc19ec WAGE: Fixed cursor position
e95122be6c WAGE: Optimized screen blitting
f97c915c7b WAGE: Display text input
c8b20bc8ab WAGE: Fix cursor position
44582b503a WAGE: Support full range of ASCII in input
1b0d6a4304 WAGE: Implement command execution
2c8922ed30 WAGE: Fix cursor position at the scroll end
cc14b5f96f WAGE: Implement handleMoveCommand()
b386467903 WAGE: Fix crash when wage.dat is not present
21dae458ea WAGE: Properly print out input text on game events
5cffbed146 WAGE: Fix cursor position for built-in fonts
e7eb7ffc81 WAGE: Further fixes to cursor position
3b48d90f13 WAGE: Mark scene as dirty of some object was moved to/from it
5843a18053 WAGE: Fix Script::processMove(), so it works with double conversion too
b5ffcac009 WAGE: Switched most primitives to proper thick brush drawing.
2db59e9c45 WAGE: Switched round rectangles to think brush drawing
79dfc2bda5 WAGE: Fixes to think round rectangle drawing
e2fa8c1de7 WAGE: Fix menu height
5c129d65da WAGE: Fixed ellipse rendering
4cbabd89a2 WAGE: Simplified code
3eeb240f95 WAGE: Fixed round rect drawing
e4002d3fee WAGE: Fixed bitmap rendering
9d09466f50 WAGE: Simplified bitmap code
0aaab27025 WAGE: Remove redundant code
41bad49b4a WAGE: Do not copy scene under border. Removes gfx glitch
ba34243d5b WAGE: Make console window active when text is entered. Matches original
2ec86f1381 WAGE: Fix command processing
bc8b63cfb4 WAGE: Full redraw on scene change
ca7470b697 WAGE: Fix bitmap drawing by implementing flood fill algorithm
05ffd45360 WAGE: Remove debug output
8763ca4841 WAGE: Fix scene transitions
57372c7375 WAGE: Fix console clearing
5d715e178a WAGE: Added detection for "Escape from School!"
1f9e724a53 WAGE: Added detection for "Queen Quest"
550d393341 WAGE: Fix crash
af691d9959 WAGE: Fix crash with empty input
b28dc762df WAGE: Fix warnings
fdfb4eedcd WAGE: More warning fixes
ac0be3401c WAGE: Clean up world on exit
4ba3da8b9b WAGE: Plug memory leak
4a9bb72cd8 WAGE: Plug memory leak
f67b43eec8 WAGE: Fix unsigned/signed comparison
71f41f9ff8 WAGE: Plug another leak
ac6e5cc48a WAGE: Fix warning
f9ea23f6a5 WAGE: More leak plugging
b9c256587b WAGE: Warning fixws
777536d203 WAGE: Add last line from scene description
28a02b8200 WAGE: Fixed couple of memory leaks
6b428f211c WAGE: Fix numerpous memory leaks
07642d291e WAGE: Fix scene randomization
4d3707d795 WAGE: Plugged even more memory leaks
46076a0e6c WAGE: Plugged great deal of leaks
f2584488aa WAGE: Fixed font mapping
9bd51254c6 WAGE: Process scenes without scripts
83dcdf9c63 WAGE: Fix race condition which led to random crashes
7bdb942cac WAGE: Implement WageEngine::regen()
87766f6753 WAGE: Implement monster following
51af66371d WAGE: Implement WageEngine::encounter()
82d0026298 WAGE: Started implementation of performCombatAction()
db6fafd58a WAGE: Implemented performCombatAction
42ebff811a WAGE: SPlit out combat-related methods into separate file
9b8e5020bf WAGE: Reduced header dependency
3906c36898 WAGE: Put lists into typedefs
4665f23c4a WAGE: Implement RandomHat
91d70b6df6 WAGE: Fix _monster/getMonster() mess
047a660dac WAGE: Implement performTake()
165066107f WAGE: Implement performOffer()
5b374c6f55 WAGE: Moved menu rendering into separate file
faa2588ba4 WAGE: Made rendering of 1st menu level generic
856a4e1eb3 WAGE: Fix crash at startup
c368504646 WAGE: Added safeguards to avoid future mistakes
061a00bf09 WAGE: Started submenu implementation
db503e967d WAGE: Stop leaking menu on exit
2d2c8ab340 WAGE: Highlight first level menus
d485f7d7bb WAGE: Show menu only with mouse button on hold
644f1ef215 WAGE: Optimize menu redraws
a65fdcf756 WAGE: Fixed menu highlight size
db9a9665a4 WAGE: Precalculate menu dimensions
80bea99436 WAGE: Simplify code
a2053eb405 WAGE: Calculate submenu bounds
5a9acaa162 WAGE: Render submenu rectangle
91ef3e6dcd WAGE: Blit submenu to screen
506748c82f WAGE: Do not crash on empty submenus
b911c63750 WAGE: Render submenu item texts
a1e9c82579 WAGE: Fix menu dropdown dimensions
d0b60fe4b7 WAGE: Fix crash with empty submenus
02e0498e36 WAGE: Copy screen to backbuffer when entering menu
a45c66b5a7 WAGE: Retore background with menu hovering
a6cf968533 WAGE: Draw drop-down menu shadow
f9412921f4 WAGE: Show accelerator keys for submenus
0476f0ea36 WAGE: Highlight submenu items
5c2ed06dc6 WAGE: Do not highlight separators
1c3a4e3dbb WAGE: Adjustments to precise menu rendering
ab1fdb518f WAGE: Menu fixes for fallback fonts
00fce85c74 WAGE: Show Ctrl synbol for built-in fonts
b0387a4a76 WAGE: Render submenu delimeter
b34308a03c WAGE: Fix vertical submenu size
d7bbe3a6c5 WAGE: Fix submenu delimiter rendering
c196d5fa7e WAGE: Use named constants for patterns
0299f5c580 WAGE: Support for disabled submenu items
3646555a66 WAGE: Implement rendering disabled submenu items
4c8b9bb52c WAGE: Moved global patterns to Gui class
7c04b4ddf7 WAGE: Proper rendering of accelerators
3dc9223399 WAGE: Deactivate submenu on hovering away
0c6b063f1e WAGE: Generate Commands menu
d918724568 WAGE: Fix compilation on some platforms
72b95e639e WAGE: Create weapons menu
61c4f2091b WAGE: Make menu commands working
5a887808ab WAGE: Regenerate weapons menu on demand
402a9cf8ef WAGE: Implemented getAboutMenuItemName()
540a2e78e5 WAGE: Fix compilation on some platforms
84b382db00 WAGE: Fix about menu
c3824f40ba WAGE: Hide debug output
43df45d610 WAGE: Implement handleRestCommand
87698593db WAGE: Implement printPlayerCondition()
8e30167e85 WAGE: Implement handleAcceptCommand()
2a16cef20e WAGE: Simplified message output formation
76639b5d3a WAGE: Add Enchanced Scepters detection
61dec8fd96 WAGE: Fix scene and text position as it is provided by the game data
f428f59788 WAGE: Remove now useess warning
40eb91da3c WAGE: More menu finetuning
ee8999241e WAGE: Fix submenu rendering
d9c3cd18d6 WAGE: Simplified default pattern setting
028e3c14d5 WAGE: Fix border title drawing
5f5280d8cf WAGE: Stub for dialogs
8760362302 WAGE: Draw dialog
750e44219f WAGE: Dialog loop
efdf51d3dd WAGE: Draw gameover dialog
c7eed7f0ad WAGE: Implement getWeapons(). Got rid of class Weapon
936609fb11 WAGE: Implemented saveDialog()
ad02d2eb95 WAGE: Implement dialog interaction
632825d71b WAGE: Fix crash on menu exiting
f11721d036 WAGE: Proper background restoriation on dialog closing
6c205ad46d WAGE: Made save dialog functional
c76b7ec63c WAGE: Implement performAttack()
b70ae62d4b WAGE: Implement performMagic()
b90e9361fe WAGE: Implement handleDropCommand()
3cdc17be94 WAGE: Implement handleTakeCommand()
b066a592ee WAGE: Implement handleStatusCommand()
2dc5841fcc WAGE: Implement handleInventoryCommand()
02374868f7 WAGE: Implement handleAimCommand()
42c7440376 WAGE: Implement handleWearCommand()
605a32d9bf WAGE: Implement wearObj()
f43a36edb5 WAGE: Rename Script::_callbacks to _engine
47b3f404b8 WAGE: Moved all interaction-related methods from script.cpp to combat.cpp
9713e260a2 WAGE: Added missing messages
851c2d6f70 WAGE: Implement getValidMoveDirections()
2fba6e3a17 WAGE: Unstub redrawScene()
df609fb468 WAGE: Implement performMove()
adc5b87cb6 WAGE: Implement performHealingMagic()
b5d55fdf2b WAGE: Implement decrementUses()
a9b7b04630 WAGE: Implement tryAttack()
45afdbbd5c WAGE: Implement handleOfferCommand()
34f9a1375d WAGE: Get rid of Common::String import
f813c0e556 WAGE: Some renames
e226265294 WAGE: Implement attackHit()
da0611ec30 WAGE: Implement handleAttack()
0e34bff8ab WAGE: Implement getMagicalObjects()
c2341f3948 WAGE: Refactor commands menu creation
345effab98 WAGE: Implement WageEngine::setMenu()
07d176cace WAGE: Put less significant games to generic target
b44ba1b901 WAGE: Use extra as game name for generic games
3911c5c031 WAGE: Added detection for Zoony
6e91ae4b9f WAGE: Added ZikTuria detection
4aa7440ffd WAGE: Added Deep Angst detection
cedee5b3d9 WAGE: Drop language and platform for WAGE games
e41c3c50de WAGE: Fix crash in Deep Angst, when border is beyond the screen
efc7bf6451 WAGE: FIx crash in amot
12f02969be WAGE: Fix crashes during direction change
6e3cd0bcb2 WAGE: Better processing of direction abbreviations
0a57ac4fc9 WAGE: Remove redundant operation
9d67bd022a WAGE: Fix regression with commands menu
95a3a31ee1 WAGE: Initial code for shortcuts
52c317b842 WAGE: Make shortcuts functional
63ef49ec8a WAGE: Rename mouse event processor to add clarity
d812706328 WAGE: Started text selection implementation
53e68cf92c WAGE: Calculate click position in text
0ab0daa1dc WAGE: Further work on console selection
42793dac25 WAGE: Show warning for missing functionality
ed21eaef99 WAGE: Fixed typo in game name
ed3372d8bf WAGE: Fix formatting
81fb44960f WAGE: Rename function to CamelCase
1d0eed9cdd WAGE: Remove leftover debug message
db7d5aa218 WAGE: Removed another leftover warning
6cbd4d4749 WAGE: Hid debug message deeper
b0941e247c WAGE: Hid more debug messages
9d9e769b5e WAGE: Mark full lines of selected text
d585719c2d WAGE: First attempt to draw partial highlights
b24be406d2 WAGE: Fixes to selection highlighting
d56590784f WAGE: Fix text end marking
61dc7d5d04 WAGE: Fix regression leading to a crash
40cdf028b3 WAGE: Fix end of selection calculation
5ac2581645 WAGE: Fix text coordinate calculation
30713e4262 WAGE: Implement highlighting one line selection
8ee5d6e9d1 WAGE: Fix crash and remove debug output
06ba17395d WAGE: Fix cursors during dialogs
c02c36ce88 WAGE: Implemented a way to remove selection
7e8c1028d3 WAGE: Implement API to enable/disable menu items
a2e3d33a2d WAGE: Get rid of magic constants in menu code for referring menu items
fe40bb284c WAGE: Started copy command implementation
08b3f89b09 WAGE: Made copy command working
e56d934836 WAGE: Make keyboard shortcuts work for the Edit menu
3570e417c9 WAGE: Implement Paste action
1d5220ef3f WAGE: Implement Undo action
5e002c4fe2 GRAPHICS: Move generic primitives from WAGE engine
ab20b96f60 WAGE: Improve text entry
6f2c769aae WAGE: REmove redundant .gitignore
c72c92a3ef WAGE: More const'ness
82fff0ab86 WAGE: Made code cleaner
ab9bda22b2 WAGE: Remove redundant type casts
c1d548764a WAGE: Event more const
7dd3874a43 WAGE: Indentation fixes
a31cfff9d6 WAGE: Let compiler optimize %8's
c0be640d5e WAGE: More const'ness
47e3fec8ea WAGE: Firther work on input improvements
c80bc8cbe0 WAGE: Move all console-related stuff to gui-console.cpp
1e2d292eb4 WAGE: Finally fix input text behavior
fcebf28fd2 WAGE: Fix behavior of the multiline paste
1158987a1e WAGE: Disable Undo action after command exectution
1b27abafdc WAGE: Skip disabled command on shortcuts
5cea5a4d3a WAGE: Implement Cut and Clear actions
96cb9a620a WAGE: More const
5e21a82c1e WAGE: Simplify code
d91b52052d WAGE: Rename to match our naming conventions
9c8d0352ad WAGE: Avoid potential race condition in cursor drawing code
c5a01f3f38 WAGE: Marked some methods as static, const'ness
c0697f7f2b WAGE: const goodness
13da5d5376 WAGE: Renames to follow our conventions
bbcd455004 GRAPHICS: Use our own sort instead of bubble
362557935b WAGE: Use String::clear() for emptying stings
e105ec8df3 WAGE: Proper name for include guard
e56fa50889 WAGE: Better names for constants
eacbe42e3a WAGE: Simplify operand stringification
e83a0ce32e WAGE: Moved non-trivial method implementation to .cpp file
13c979ae8f WAGE: Indentation fixes
b09e70d1ca WAGE: Consistently use .empty() instead of .size() == 0
8e8145ef25 WAGE: Fix name in accordance with our naming conventions
33b8a265c5 WAGE: Remove redundant check
9d9fefb17a WAGE: Simplify polygon reading code
acdddf8ade WAGE: Simplify bitmap reading code
d2303ac6dd GRAPHICS: Fix regression in polygon drawing
eef56e167e WAGE: Simplify savename generation code
499519fec3 WAGE: Fix int/uint comparison
11e03fbce2 Merge pull request #658 from sev-/wage
Commit: c532b6c74fc60ed10a26cdc8670dfbb98622d399
https://github.com/scummvm/scummvm/commit/c532b6c74fc60ed10a26cdc8670dfbb98622d399
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Initial version. "Another Fine Mess 1.8" is detected.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
A engines/wage/detection.cpp
A engines/wage/module.mk
A engines/wage/wage.cpp
A engines/wage/wage.h
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
new file mode 100644
index 0000000..991732d
--- /dev/null
+++ b/engines/wage/detection.cpp
@@ -0,0 +1,176 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/engines/agi/detection.cpp $
+ * $Id: detection.cpp 46472 2009-12-21 22:40:52Z sev $
+ *
+ */
+
+
+#include "base/plugins.h"
+
+#include "engines/advancedDetector.h"
+#include "common/system.h"
+#include "common/savefile.h"
+
+#include "wage/wage.h"
+
+static const PlainGameDescriptor cineGames[] = {
+ {"wage", "World Adventure Game Engine game"},
+ {0, 0}
+};
+
+namespace Wage {
+
+using Common::GUIO_NONE;
+
+static const ADGameDescription gameDescriptions[] = {
+ {
+ "wage",
+ "Another Fine Mess (v1.8)",
+ AD_ENTRY1s("Another Fine Mess 1.8", "8e5aa915f3253efb2aab52435647b25e", 1456000),
+ Common::EN_ANY,
+ Common::kPlatformPC,
+ ADGF_USEEXTRAASTITLE,
+ GUIO_NONE
+ },
+
+ AD_TABLE_END_MARKER
+};
+
+} // End of namespace Wage
+
+static const ADParams detectionParams = {
+ // Pointer to ADGameDescription or its superset structure
+ (const byte *)Wage::gameDescriptions,
+ // Size of that superset structure
+ sizeof(ADGameDescription),
+ // Number of bytes to compute MD5 sum for
+ 5000,
+ // List of all engine targets
+ cineGames,
+ // Structure for autoupgrading obsolete targets
+ 0,
+ // Name of single gameid (optional)
+ "wage",
+ // List of files for file-based fallback detection (optional)
+ 0,
+ // Flags
+ 0,
+ // Additional GUI options (for every game}
+ Common::GUIO_NOSPEECH | Common::GUIO_NOMIDI
+};
+
+class WageMetaEngine : public AdvancedMetaEngine {
+public:
+ WageMetaEngine() : AdvancedMetaEngine(detectionParams) {}
+
+ virtual const char *getName() const {
+ return "World Adventure Game Engine";
+ }
+
+ virtual const char *getOriginalCopyright() const {
+ return "World Builder (C) Silicon Beach Software";
+ }
+
+ virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
+ virtual bool hasFeature(MetaEngineFeature f) const;
+ virtual SaveStateList listSaves(const char *target) const;
+ virtual int getMaximumSaveSlot() const;
+ virtual void removeSaveState(const char *target, int slot) const;
+};
+
+bool WageMetaEngine::hasFeature(MetaEngineFeature f) const {
+ return
+ (f == kSupportsListSaves) ||
+ (f == kSupportsLoadingDuringStartup) ||
+ (f == kSupportsDeleteSave);
+}
+
+bool Wage::WageEngine::hasFeature(EngineFeature f) const {
+ return
+ (f == kSupportsRTL) ||
+ (f == kSupportsLoadingDuringRuntime) ||
+ (f == kSupportsSavingDuringRuntime);
+}
+
+bool WageMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
+ if (desc) {
+ *engine = new Wage::WageEngine(syst, desc);
+ }
+ return desc != 0;
+}
+
+SaveStateList WageMetaEngine::listSaves(const char *target) const {
+ const uint32 WAGEflag = MKID_BE('WAGE');
+ Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+ Common::StringList filenames;
+ char saveDesc[31];
+ Common::String pattern = target;
+ pattern += ".???";
+
+ filenames = saveFileMan->listSavefiles(pattern);
+ sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
+
+ SaveStateList saveList;
+ for (Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+ // Obtain the last 3 digits of the filename, since they correspond to the save slot
+ int slotNum = atoi(file->c_str() + file->size() - 3);
+
+ if (slotNum >= 0 && slotNum <= 999) {
+ Common::InSaveFile *in = saveFileMan->openForLoading(*file);
+ if (in) {
+ uint32 type = in->readUint32BE();
+ if (type == WAGEflag)
+ in->read(saveDesc, 31);
+ saveList.push_back(SaveStateDescriptor(slotNum, saveDesc));
+ delete in;
+ }
+ }
+ }
+
+ return saveList;
+}
+
+int WageMetaEngine::getMaximumSaveSlot() const { return 999; }
+
+void WageMetaEngine::removeSaveState(const char *target, int slot) const {
+ char fileName[MAXPATHLEN];
+ sprintf(fileName, "%s.%03d", target, slot);
+ g_system->getSavefileManager()->removeSavefile(fileName);
+}
+
+#if PLUGIN_ENABLED_DYNAMIC(WAGE)
+ REGISTER_PLUGIN_DYNAMIC(WAGE, PLUGIN_TYPE_ENGINE, WageMetaEngine);
+#else
+ REGISTER_PLUGIN_STATIC(WAGE, PLUGIN_TYPE_ENGINE, WageMetaEngine);
+#endif
+
+namespace Wage {
+
+bool WageEngine::canLoadGameStateCurrently() {
+ return false;
+}
+
+bool WageEngine::canSaveGameStateCurrently() {
+ return false;
+}
+
+} // End of namespace Wage
diff --git a/engines/wage/module.mk b/engines/wage/module.mk
new file mode 100644
index 0000000..a5e0b29
--- /dev/null
+++ b/engines/wage/module.mk
@@ -0,0 +1,16 @@
+MODULE := engines/wage
+
+MODULE_OBJS := \
+ detection.o \
+ wage.o
+
+MODULE_DIRS += \
+ engines/wage
+
+# This module can be built as a plugin
+ifeq ($(ENABLE_WAGE), DYNAMIC_PLUGIN)
+PLUGIN := 1
+endif
+
+# Include common rules
+include $(srcdir)/rules.mk
\ No newline at end of file
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
new file mode 100644
index 0000000..1468d24
--- /dev/null
+++ b/engines/wage/wage.cpp
@@ -0,0 +1,75 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "common/config-manager.h"
+#include "common/debug.h"
+#include "common/EventRecorder.h"
+#include "common/file.h"
+#include "common/fs.h"
+
+#include "wage/wage.h"
+
+namespace Wage {
+
+WageEngine::WageEngine(OSystem *syst, const ADGameDescription *desc) : Engine(syst), _gameDescription(desc) {
+ // Don't forget to register your random source
+ g_eventRec.registerRandomSource(_rnd, "wage");
+
+ printf("WageEngine::WageEngine\n");
+}
+
+WageEngine::~WageEngine() {
+ // Dispose your resources here
+ printf("WageEngine::~WageEngine\n");
+
+ // Remove all of our debug levels here
+ Common::clearAllDebugChannels();
+}
+
+Common::Error WageEngine::run() {
+ // Initialize graphics using following:
+ initGraphics(320, 200, false);
+
+ // Create debugger console. It requires GFX to be initialized
+ _console = new Console(this);
+
+ // Additional setup.
+ printf("WageEngine::init\n");
+
+ // Your main even loop should be (invoked from) here.
+ printf("WageEngine::go: Hello, World!\n");
+
+ // This test will show up if -d1 and --debugflags=example are specified on the commandline
+ debugC(1, kWageDebugExample, "Example debug call");
+
+ // This test will show up if --debugflags=example or --debugflags=example2 or both of them and -d3 are specified on the commandline
+ debugC(3, kWageDebugExample | kWageDebugExample2, "Example debug call two");
+
+ return Common::kNoError;
+}
+
+} // End of namespace Wage
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
new file mode 100644
index 0000000..ff51c7f
--- /dev/null
+++ b/engines/wage/wage.h
@@ -0,0 +1,77 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef WAGE_H
+#define WAGE_H
+
+#include "engines/engine.h"
+#include "gui/debugger.h"
+#include "common/endian.h"
+
+struct ADGameDescription;
+
+namespace Wage {
+
+class Console;
+
+// our engine debug levels
+enum {
+ kWageDebugExample = 1 << 0,
+ kWageDebugExample2 = 1 << 1
+ // next new level must be 1 << 2 (4)
+ // the current limitation is 32 debug levels (1 << 31 is the last one)
+};
+
+class WageEngine : public Engine {
+public:
+ WageEngine(OSystem *syst, const ADGameDescription *gameDesc);
+ ~WageEngine();
+
+ virtual bool hasFeature(EngineFeature f) const;
+
+ virtual Common::Error run();
+
+ bool canLoadGameStateCurrently();
+ bool canSaveGameStateCurrently();
+
+private:
+ Console *_console;
+
+ // We need random numbers
+ Common::RandomSource _rnd;
+
+ const ADGameDescription *_gameDescription;
+};
+
+// Example console class
+class Console : public GUI::Debugger {
+public:
+ Console(WageEngine *vm) {}
+ virtual ~Console(void) {}
+};
+
+} // End of namespace Wage
+
+#endif
Commit: ae1f601855dfef89f01100ea4947639f66d032d0
https://github.com/scummvm/scummvm/commit/ae1f601855dfef89f01100ea4947639f66d032d0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Resource file is loaded.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
A engines/wage/macresman.cpp
A engines/wage/macresman.h
A engines/wage/util.cpp
A engines/wage/world.cpp
diff --git a/engines/wage/macresman.cpp b/engines/wage/macresman.cpp
new file mode 100755
index 0000000..0dce789
--- /dev/null
+++ b/engines/wage/macresman.cpp
@@ -0,0 +1,376 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/scummsys.h"
+#include "common/debug.h"
+#include "common/file.h"
+#include "common/util.h"
+
+#include "wage/macresman.h"
+
+namespace Wage {
+
+MacResManager::MacResManager(Common::String fileName) : _fileName(fileName), _resOffset(-1) {
+ _resFile.open(_fileName);
+
+ if (!_resFile.isOpen()) {
+ error("Cannot open file %s", _fileName.c_str());
+ }
+
+ if (!init())
+ error("Resource fork is missing in file '%s'", _fileName.c_str());
+}
+
+MacResManager::~MacResManager() {
+ for (int i = 0; i < _resMap.numTypes; i++) {
+ for (int j = 0; j < _resTypes[i].items; j++) {
+ if (_resLists[i][j].nameOffset != -1) {
+ delete _resLists[i][j].name;
+ }
+ }
+ delete _resLists[i];
+ }
+
+ delete _resLists;
+ delete _resTypes;
+
+ _resFile.close();
+}
+
+#define MBI_INFOHDR 128
+#define MBI_ZERO1 0
+#define MBI_NAMELEN 1
+#define MBI_ZERO2 74
+#define MBI_ZERO3 82
+#define MBI_DFLEN 83
+#define MBI_RFLEN 87
+#define MAXNAMELEN 63
+
+bool MacResManager::init() {
+ byte infoHeader[MBI_INFOHDR];
+ int32 data_size, rsrc_size;
+ int32 data_size_pad, rsrc_size_pad;
+ int filelen;
+
+ filelen = _resFile.size();
+ _resFile.read(infoHeader, MBI_INFOHDR);
+
+ // Maybe we have MacBinary?
+ if (infoHeader[MBI_ZERO1] == 0 && infoHeader[MBI_ZERO2] == 0 &&
+ infoHeader[MBI_ZERO3] == 0 && infoHeader[MBI_NAMELEN] <= MAXNAMELEN) {
+
+ // Pull out fork lengths
+ data_size = READ_BE_UINT32(infoHeader + MBI_DFLEN);
+ rsrc_size = READ_BE_UINT32(infoHeader + MBI_RFLEN);
+
+ data_size_pad = (((data_size + 127) >> 7) << 7);
+ rsrc_size_pad = (((rsrc_size + 127) >> 7) << 7);
+
+ // Length check
+ int sumlen = MBI_INFOHDR + data_size_pad + rsrc_size_pad;
+
+ if (sumlen == filelen)
+ _resOffset = MBI_INFOHDR + data_size_pad;
+ }
+
+ if (_resOffset == -1) // MacBinary check is failed
+ _resOffset = 0; // Maybe we have dumped fork?
+
+ _resFile.seek(_resOffset);
+
+ _dataOffset = _resFile.readUint32BE() + _resOffset;
+ _mapOffset = _resFile.readUint32BE() + _resOffset;
+ _dataLength = _resFile.readUint32BE();
+ _mapLength = _resFile.readUint32BE();
+
+ // do sanity check
+ if (_dataOffset >= filelen || _mapOffset >= filelen ||
+ _dataLength + _mapLength > filelen) {
+ _resOffset = -1;
+ return false;
+ }
+
+ debug(7, "got header: data %d [%d] map %d [%d]",
+ _dataOffset, _dataLength, _mapOffset, _mapLength);
+
+ readMap();
+
+ return true;
+}
+
+MacResIDArray MacResManager::getResIDArray(const char *typeID) {
+ int typeNum = -1;
+ MacResIDArray res;
+
+ for (int i = 0; i < _resMap.numTypes; i++)
+ if (strcmp(_resTypes[i].id, typeID) == 0) {
+ typeNum = i;
+ break;
+ }
+
+ if (typeNum == -1)
+ return res;
+
+ res.resize(_resTypes[typeNum].items);
+
+ for (int i = 0; i < _resTypes[typeNum].items; i++)
+ res[i] = _resLists[typeNum][i].id;
+
+ return res;
+}
+
+byte *MacResManager::getResource(const char *typeID, int16 resID, int *size) {
+ int i;
+ int typeNum = -1;
+ int resNum = -1;
+ byte *buf;
+ int len;
+
+ for (i = 0; i < _resMap.numTypes; i++)
+ if (strcmp(_resTypes[i].id, typeID) == 0) {
+ typeNum = i;
+ break;
+ }
+
+ if (typeNum == -1)
+ return NULL;
+
+ for (i = 0; i < _resTypes[typeNum].items; i++)
+ if (_resLists[typeNum][i].id == resID) {
+ resNum = i;
+ break;
+ }
+
+ if (resNum == -1)
+ return NULL;
+
+ _resFile.seek(_dataOffset + _resLists[typeNum][resNum].dataOffset);
+
+ len = _resFile.readUint32BE();
+ buf = (byte *)malloc(len);
+
+ _resFile.read(buf, len);
+
+ *size = len;
+
+ return buf;
+}
+
+void MacResManager::readMap() {
+ int i, j, len;
+
+ _resFile.seek(_mapOffset + 22);
+
+ _resMap.resAttr = _resFile.readUint16BE();
+ _resMap.typeOffset = _resFile.readUint16BE();
+ _resMap.nameOffset = _resFile.readUint16BE();
+ _resMap.numTypes = _resFile.readUint16BE();
+ _resMap.numTypes++;
+
+ _resFile.seek(_mapOffset + _resMap.typeOffset + 2);
+ _resTypes = new ResType[_resMap.numTypes];
+
+ for (i = 0; i < _resMap.numTypes; i++) {
+ _resFile.read(_resTypes[i].id, 4);
+ _resTypes[i].id[4] = 0;
+ _resTypes[i].items = _resFile.readUint16BE();
+ _resTypes[i].offset = _resFile.readUint16BE();
+ _resTypes[i].items++;
+
+ debug(8, "resType: <%s> items: %d offset: %d (0x%x)", _resTypes[i].id, _resTypes[i].items, _resTypes[i].offset, _resTypes[i].offset);
+ }
+
+ _resLists = new ResPtr[_resMap.numTypes];
+
+ for (i = 0; i < _resMap.numTypes; i++) {
+ _resLists[i] = new Resource[_resTypes[i].items];
+ _resFile.seek(_resTypes[i].offset + _mapOffset + _resMap.typeOffset);
+
+ for (j = 0; j < _resTypes[i].items; j++) {
+ ResPtr resPtr = _resLists[i] + j;
+
+ resPtr->id = _resFile.readUint16BE();
+ resPtr->nameOffset = _resFile.readUint16BE();
+ resPtr->dataOffset = _resFile.readUint32BE();
+ _resFile.readUint32BE();
+ resPtr->name = 0;
+
+ resPtr->attr = resPtr->dataOffset >> 24;
+ resPtr->dataOffset &= 0xFFFFFF;
+ }
+
+ for (j = 0; j < _resTypes[i].items; j++) {
+ if (_resLists[i][j].nameOffset != -1) {
+ _resFile.seek(_resLists[i][j].nameOffset + _mapOffset + _resMap.nameOffset);
+
+ len = _resFile.readByte();
+ _resLists[i][j].name = new byte[len + 1];
+ _resLists[i][j].name[len] = 0;
+ _resFile.read(_resLists[i][j].name, len);
+ }
+ }
+ }
+}
+
+void MacResManager::convertCursor(byte *data, int datasize, byte **cursor, int *w, int *h,
+ int *hotspot_x, int *hotspot_y, int *keycolor, bool colored, byte **palette, int *palSize) {
+ Common::MemoryReadStream dis(data, datasize);
+ int i, b;
+ byte imageByte;
+ byte *iconData;
+ int numBytes;
+ int pixelsPerByte, bpp;
+ int ctSize;
+ byte bitmask;
+ int iconRowBytes, iconBounds[4];
+ int ignored;
+ int iconDataSize;
+
+ dis.readUint16BE(); // type
+ dis.readUint32BE(); // offset to pixel map
+ dis.readUint32BE(); // offset to pixel data
+ dis.readUint32BE(); // expanded cursor data
+ dis.readUint16BE(); // expanded data depth
+ dis.readUint32BE(); // reserved
+
+ // Grab B/W icon data
+ *cursor = (byte *)malloc(16 * 16);
+ for (i = 0; i < 32; i++) {
+ imageByte = dis.readByte();
+ for (b = 0; b < 8; b++)
+ cursor[0][i*8+b] = (byte)((imageByte &
+ (0x80 >> b)) > 0? 0x0F: 0x00);
+ }
+
+ // Apply mask data
+ for (i = 0; i < 32; i++) {
+ imageByte = dis.readByte();
+ for (b = 0; b < 8; b++)
+ if ((imageByte & (0x80 >> b)) == 0)
+ cursor[0][i*8+b] = 0xff;
+ }
+
+ *hotspot_y = dis.readUint16BE();
+ *hotspot_x = dis.readUint16BE();
+ *w = *h = 16;
+
+ // Use b/w cursor on backends which don't support cursor palettes
+ if (!colored)
+ return;
+
+ dis.readUint32BE(); // reserved
+ dis.readUint32BE(); // cursorID
+
+ // Color version of cursor
+ dis.readUint32BE(); // baseAddr
+
+ // Keep only lowbyte for now
+ dis.readByte();
+ iconRowBytes = dis.readByte();
+
+ if (!iconRowBytes)
+ return;
+
+ iconBounds[0] = dis.readUint16BE();
+ iconBounds[1] = dis.readUint16BE();
+ iconBounds[2] = dis.readUint16BE();
+ iconBounds[3] = dis.readUint16BE();
+
+ dis.readUint16BE(); // pmVersion
+ dis.readUint16BE(); // packType
+ dis.readUint32BE(); // packSize
+
+ dis.readUint32BE(); // hRes
+ dis.readUint32BE(); // vRes
+
+ dis.readUint16BE(); // pixelType
+ dis.readUint16BE(); // pixelSize
+ dis.readUint16BE(); // cmpCount
+ dis.readUint16BE(); // cmpSize
+
+ dis.readUint32BE(); // planeByte
+ dis.readUint32BE(); // pmTable
+ dis.readUint32BE(); // reserved
+
+ // Pixel data for cursor
+ iconDataSize = iconRowBytes * (iconBounds[3] - iconBounds[1]);
+ iconData = (byte *)malloc(iconDataSize);
+ dis.read(iconData, iconDataSize);
+
+ // Color table
+ dis.readUint32BE(); // ctSeed
+ dis.readUint16BE(); // ctFlag
+ ctSize = dis.readUint16BE() + 1;
+
+ *palette = (byte *)malloc(ctSize * 4);
+
+ // Read just high byte of 16-bit color
+ for (int c = 0; c < ctSize; c++) {
+ // We just use indices 0..ctSize, so ignore color ID
+ dis.readUint16BE(); // colorID[c]
+
+ palette[0][c * 4 + 0] = dis.readByte();
+ ignored = dis.readByte();
+
+ palette[0][c * 4 + 1] = dis.readByte();
+ ignored = dis.readByte();
+
+ palette[0][c * 4 + 2] = dis.readByte();
+ ignored = dis.readByte();
+
+ palette[0][c * 4 + 3] = 0;
+ }
+
+ *palSize = ctSize;
+
+ numBytes =
+ (iconBounds[2] - iconBounds[0]) *
+ (iconBounds[3] - iconBounds[1]);
+
+ pixelsPerByte = (iconBounds[2] - iconBounds[0]) / iconRowBytes;
+ bpp = 8 / pixelsPerByte;
+
+ // build a mask to make sure the pixels are properly shifted out
+ bitmask = 0;
+ for (int m = 0; m < bpp; m++) {
+ bitmask <<= 1;
+ bitmask |= 1;
+ }
+
+ // Extract pixels from bytes
+ for (int j = 0; j < iconDataSize; j++)
+ for (b = 0; b < pixelsPerByte; b++) {
+ int idx = j * pixelsPerByte + (pixelsPerByte - 1 - b);
+
+ if (cursor[0][idx] != 0xff) // if mask is not there
+ cursor[0][idx] = (byte)((iconData[j] >> (b * bpp)) & bitmask);
+ }
+
+ free(iconData);
+
+ assert(datasize - dis.pos() == 0);
+}
+
+} // End of namespace Wage
diff --git a/engines/wage/macresman.h b/engines/wage/macresman.h
new file mode 100755
index 0000000..c60d294
--- /dev/null
+++ b/engines/wage/macresman.h
@@ -0,0 +1,91 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/array.h"
+#include "common/file.h"
+
+#ifndef WAGE_MACRESMAN_H
+#define WAGE_MACRESMAN_H
+
+namespace Wage {
+
+typedef Common::Array<int16> MacResIDArray;
+
+class MacResManager {
+
+public:
+ MacResManager(Common::String fileName);
+ ~MacResManager();
+ byte *getResource(const char *typeID, int16 resID, int *size);
+ void convertCursor(byte *data, int datasize, byte **cursor, int *w, int *h,
+ int *hotspot_x, int *hotspot_y, int *keycolor, bool colored, byte **palette, int *palSize);
+
+ MacResIDArray getResIDArray(const char *typeID);
+
+private:
+ int extractResource(int id, byte **buf);
+ bool init();
+ void readMap();
+
+ struct ResMap {
+ int16 resAttr;
+ int16 typeOffset;
+ int16 nameOffset;
+ int16 numTypes;
+ };
+
+ struct ResType {
+ char id[5];
+ int16 items;
+ int16 offset;
+ };
+
+ struct Resource {
+ int16 id;
+ int16 nameOffset;
+ byte attr;
+ int32 dataOffset;
+ byte *name;
+ };
+
+ typedef Resource *ResPtr;
+
+private:
+ int _resOffset;
+ int32 _dataOffset;
+ int32 _dataLength;
+ int32 _mapOffset;
+ int32 _mapLength;
+ ResMap _resMap;
+ ResType *_resTypes;
+ ResPtr *_resLists;
+
+ Common::String _fileName;
+ Common::File _resFile;
+};
+
+} // End of namespace Wage
+
+#endif
diff --git a/engines/wage/util.cpp b/engines/wage/util.cpp
new file mode 100644
index 0000000..9420150
--- /dev/null
+++ b/engines/wage/util.cpp
@@ -0,0 +1,56 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "wage/wage.h"
+
+#include "common/stream.h"
+
+namespace Wage {
+Common::String WageEngine::readPascalString(Common::SeekableReadStream &in) {
+ Common::String s;
+ char *buf;
+ int len;
+ int i;
+
+ len = in.readSByte();
+ if (len < 0)
+ len += 256;
+
+ buf = (char *)malloc(len + 1);
+ for (i = 0; i < len; i++) {
+ buf[i] = in.readByte();
+ if (buf[i] == 0x0d)
+ buf[i] = '\n';
+ }
+
+ buf[i] = 0;
+
+ s = buf;
+ free(buf);
+
+ return s;
+}
+
+} // End of namespace Wage
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
new file mode 100644
index 0000000..67987a5
--- /dev/null
+++ b/engines/wage/world.cpp
@@ -0,0 +1,68 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "wage/wage.h"
+#include "wage/macresman.h"
+
+#include "common/stream.h"
+
+namespace Wage {
+
+bool WageEngine::loadWorld(MacResManager *resMan) {
+ int resSize;
+ MacResIDArray resArray;
+ byte *res;
+ MacResIDArray::const_iterator iter;
+
+ if ((resArray = resMan->getResIDArray("VERS")).size() == 0)
+ return false;
+
+ if (resArray.size() > 1)
+ warning("Too many VERS resources");
+
+ res = resMan->getResource("VERS", resArray[0], &resSize);
+
+ Common::MemoryReadStream readS(res, resSize);
+ readS.skip(10);
+ byte b = readS.readByte();
+ _weaponMenuDisabled = (b != 0);
+ if (b != 0 && b != 1)
+ error("Unexpected value for weapons menu");
+
+ readS.skip(3);
+ _aboutMessage = readPascalString(readS);
+
+ if (!stricmp(getGameFile(), "Scepters"))
+ readS.skip(1); // ????
+
+ _soundLibrary1 = readPascalString(readS);
+ _soundLibrary2 = readPascalString(readS);
+
+ debug(0, "%s\n%s", _soundLibrary1.c_str(), _soundLibrary2.c_str());
+
+ return true;
+}
+
+} // End of namespace Wage
Commit: ce6aa4dd28c2c8054e6c6287c11c717376771d90
https://github.com/scummvm/scummvm/commit/ce6aa4dd28c2c8054e6c6287c11c717376771d90
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Added stubs for most classes. Implemented Obj and Scene classes.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
A engines/wage/chr.cpp
A engines/wage/chr.h
A engines/wage/design.cpp
A engines/wage/design.h
A engines/wage/designed.cpp
A engines/wage/designed.h
A engines/wage/obj.h
A engines/wage/scene.h
A engines/wage/script.cpp
A engines/wage/script.h
A engines/wage/sound.cpp
A engines/wage/sound.h
A engines/wage/world.h
engines/wage/detection.cpp
engines/wage/macresman.cpp
engines/wage/macresman.h
engines/wage/util.cpp
engines/wage/wage.cpp
engines/wage/wage.h
engines/wage/world.cpp
diff --git a/engines/wage/chr.cpp b/engines/wage/chr.cpp
new file mode 100644
index 0000000..2c02a2d
--- /dev/null
+++ b/engines/wage/chr.cpp
@@ -0,0 +1,37 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "wage/wage.h"
+#include "wage/chr.h"
+
+namespace Wage {
+
+Chr::Chr() {
+}
+
+Chr::~Chr() {
+}
+
+} // End of namespace Wage
diff --git a/engines/wage/chr.h b/engines/wage/chr.h
new file mode 100644
index 0000000..51fdce0
--- /dev/null
+++ b/engines/wage/chr.h
@@ -0,0 +1,39 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef WAGE_CHR_H
+#define WAGE_CHR_H
+
+namespace Wage {
+
+class Chr {
+public:
+ Chr();
+ ~Chr();
+};
+
+} // End of namespace Wage
+
+#endif
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
new file mode 100644
index 0000000..ce9063c
--- /dev/null
+++ b/engines/wage/design.cpp
@@ -0,0 +1,42 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "wage/wage.h"
+#include "wage/design.h"
+
+namespace Wage {
+
+Design::Design(byte *data) {
+ int len = READ_UINT16(data);
+
+ _data = (byte *)malloc(len);
+ memcpy(_data, data, len);
+}
+
+Design::~Design() {
+ free(_data);
+}
+
+} // End of namespace Wage
diff --git a/engines/wage/design.h b/engines/wage/design.h
new file mode 100644
index 0000000..2956f84
--- /dev/null
+++ b/engines/wage/design.h
@@ -0,0 +1,53 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef WAGE_DESIGN_H
+#define WAGE_DESIGN_H
+
+#include "common/rect.h"
+
+namespace Wage {
+
+class Design {
+public:
+ Design(byte *data);
+ ~Design();
+
+ void setBounds(Common::Rect bounds) {
+ _bounds = new Common::Rect(bounds);
+ }
+
+ Common::Rect *getBounds() {
+ return new Common::Rect(*_bounds);
+ }
+
+private:
+ byte *_data;
+ Common::Rect *_bounds;
+};
+
+} // End of namespace Wage
+
+#endif
diff --git a/engines/wage/designed.cpp b/engines/wage/designed.cpp
new file mode 100644
index 0000000..040d821
--- /dev/null
+++ b/engines/wage/designed.cpp
@@ -0,0 +1,37 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "wage/wage.h"
+#include "wage/designed.h"
+#include "wage/design.h"
+
+namespace Wage {
+
+void Designed::setDesignBounds(Common::Rect bounds) {
+ _designBounds = new Common::Rect(bounds);
+ _design->setBounds(bounds);
+}
+
+} // End of namespace Wage
diff --git a/engines/wage/designed.h b/engines/wage/designed.h
new file mode 100644
index 0000000..8ef1fa2
--- /dev/null
+++ b/engines/wage/designed.h
@@ -0,0 +1,62 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef WAGE_DESIGNED_H
+#define WAGE_DESIGNED_H
+
+#include "common/str.h"
+#include "common/rect.h"
+
+using Common::String;
+
+namespace Wage {
+
+class Design;
+
+class Designed {
+public:
+ Designed() : _design(NULL), _designBounds(NULL) {}
+
+ String _name;
+ Design *_design;
+ Common::Rect *_designBounds;
+
+ String getName() { return _name; }
+ void setName(String name) { _name = name; }
+ String toString() { return _name; }
+
+ Design *getDesign() { return _design; }
+ void setDesign(Design *design) { _design = design; }
+
+ Common::Rect *getDesignBounds() {
+ return _designBounds == NULL ? NULL : new Common::Rect(*_designBounds);
+ }
+
+ void setDesignBounds(Common::Rect bounds);
+};
+
+} // End of namespace Wage
+
+#endif
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
index 991732d..3c5ac73 100644
--- a/engines/wage/detection.cpp
+++ b/engines/wage/detection.cpp
@@ -32,7 +32,16 @@
#include "wage/wage.h"
+namespace Wage {
+
+const char *WageEngine::getGameFile() const {
+ return _gameDescription->filesDescriptions[0].fileName;
+}
+
+}
+
static const PlainGameDescriptor cineGames[] = {
+ {"afm", "Another Fine Mess"},
{"wage", "World Adventure Game Engine game"},
{0, 0}
};
@@ -43,12 +52,12 @@ using Common::GUIO_NONE;
static const ADGameDescription gameDescriptions[] = {
{
- "wage",
- "Another Fine Mess (v1.8)",
+ "afm",
+ "v1.8",
AD_ENTRY1s("Another Fine Mess 1.8", "8e5aa915f3253efb2aab52435647b25e", 1456000),
Common::EN_ANY,
Common::kPlatformPC,
- ADGF_USEEXTRAASTITLE,
+ ADGF_NO_FLAGS,
GUIO_NONE
},
diff --git a/engines/wage/macresman.cpp b/engines/wage/macresman.cpp
old mode 100755
new mode 100644
diff --git a/engines/wage/macresman.h b/engines/wage/macresman.h
old mode 100755
new mode 100644
index c60d294..58635ae
--- a/engines/wage/macresman.h
+++ b/engines/wage/macresman.h
@@ -44,6 +44,8 @@ public:
MacResIDArray getResIDArray(const char *typeID);
+ Common::String getFileName() { return _fileName; }
+
private:
int extractResource(int id, byte **buf);
bool init();
diff --git a/engines/wage/obj.h b/engines/wage/obj.h
new file mode 100644
index 0000000..65049ed
--- /dev/null
+++ b/engines/wage/obj.h
@@ -0,0 +1,166 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef WAGE_OBJ_H
+#define WAGE_OBJ_H
+
+#include "common/rect.h"
+
+#include "wage/designed.h"
+
+namespace Wage {
+
+class Weapon {
+public:
+ virtual ~Weapon() {}
+ virtual String getOperativeVerb() = 0;
+ virtual int getType() = 0;
+ virtual int getAccuracy() = 0;
+ virtual int getDamage() = 0;
+ virtual String getSound() = 0;
+ virtual void decrementNumberOfUses() = 0;
+};
+
+class Design;
+class Scene;
+class Chr;
+
+class Obj : public Weapon, public Designed {
+public:
+ Obj() : _currentOwner(NULL), _currentScene(NULL) {}
+
+ enum ObjectTypes {
+ REGULAR_WEAPON = 1,
+ THROW_WEAPON = 2,
+ MAGICAL_OBJECT = 3,
+ HELMET = 4,
+ SHIELD = 5,
+ CHEST_ARMOR = 6,
+ SPIRITUAL_ARMOR = 7,
+ MOBILE_OBJECT = 8,
+ IMMOBILE_OBJECT = 9
+ };
+
+ enum AttackTypes {
+ CAUSES_PHYSICAL_DAMAGE = 0,
+ CAUSES_SPIRITUAL_DAMAGE = 1,
+ CAUSES_PHYSICAL_AND_SPIRITUAL_DAMAGE = 2,
+ HEALS_PHYSICAL_DAMAGE = 3,
+ HEALS_SPIRITUAL_DAMAGE = 4,
+ HEALS_PHYSICAL_AND_SPIRITUAL_DAMAGE = 5,
+ FREEZES_OPPONENT = 6
+ };
+
+private:
+ int _index;
+ bool _namePlural;
+ int _type;
+ int _value;
+ int _damage;
+ int _accuracy;
+ int _attackType;
+ int _numberOfUses;
+ bool _returnToRandomScene;
+ String _sceneOrOwner;
+ String _clickMessage;
+ String _operativeVerb;
+ String _failureMessage;
+ String _useMessage;
+ String _sound;
+
+ Scene *_currentScene;
+ Chr *_currentOwner;
+
+public:
+ Chr *getCurrentOwner() { return _currentOwner; }
+
+ void setCurrentOwner(Chr *currentOwner) {
+ _currentOwner = currentOwner;
+ if (currentOwner != NULL)
+ _currentScene = NULL;
+ }
+
+ Scene *getCurrentScene() { return _currentScene; }
+
+ void setCurrentScene(Scene *currentScene) {
+ _currentScene = currentScene;
+ if (currentScene != NULL)
+ _currentOwner = NULL;
+ }
+
+ int getAccuracy() { return _accuracy; }
+ void setAccuracy(int accuracy) { _accuracy = accuracy; }
+
+ int getAttackType() { return _attackType; }
+ void setAttackType(int attackType) { _attackType = attackType; }
+
+ String getClickMessage() { return _clickMessage; }
+ void setClickMessage(String clickMessage) { _clickMessage = clickMessage; }
+
+ int getDamage() { return _damage; }
+ void setDamage(int damage) { _damage = damage; }
+
+ String getFailureMessage() { return _failureMessage; }
+ void setFailureMessage(String failureMessage) { _failureMessage = failureMessage; }
+
+ int getNumberOfUses() { return _numberOfUses; }
+ void setNumberOfUses(int numberOfUses) { _numberOfUses = numberOfUses; }
+ void decrementNumberOfUses() {
+ if (_numberOfUses != -1) {
+ _numberOfUses--;
+ }
+ }
+
+ int getType() { return _type; }
+ void setType(int type) { _type = type; }
+
+ String getOperativeVerb() { return _operativeVerb; }
+ void setOperativeVerb(String operativeVerb) { _operativeVerb = operativeVerb; }
+
+ bool isReturnToRandomScene() { return _returnToRandomScene; }
+ void setReturnToRandomScene(bool returnToRandomScene) { _returnToRandomScene = returnToRandomScene; }
+
+ String getSceneOrOwner() { return _sceneOrOwner; }
+ void setSceneOrOwner(String sceneOrOwner) { _sceneOrOwner = sceneOrOwner; }
+
+ String getSound() { return _sound; }
+ void setSound(String sound) { _sound = sound; }
+
+ String getUseMessage() { return _useMessage; }
+ void setUseMessage(String useMessage) { _useMessage = useMessage; }
+
+ int getValue() { return _value; }
+ void setValue(int value) { _value = value; }
+
+ bool isNamePlural() { return _namePlural; }
+ void setNamePlural(bool namePlural) { _namePlural = namePlural; }
+
+ int getIndex() { return _index; }
+ void setIndex(int index) { _index = index; }
+};
+
+} // End of namespace Wage
+
+#endif
diff --git a/engines/wage/scene.h b/engines/wage/scene.h
new file mode 100644
index 0000000..a1873fc
--- /dev/null
+++ b/engines/wage/scene.h
@@ -0,0 +1,171 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef WAGE_SCENE_H
+#define WAGE_SCENE_H
+
+#include "common/list.h"
+#include "common/rect.h"
+
+#include "wage/designed.h"
+
+namespace Wage {
+
+class Script;
+class Chr;
+class Obj;
+
+class Scene : public Designed {
+public:
+ enum Directions {
+ NORTH = 0,
+ SOUTH = 1,
+ EAST = 2,
+ WEST = 3
+ };
+
+ enum SceneTypes {
+ PERIODIC = 0,
+ RANDOM = 1
+ };
+
+private:
+ Script *_script;
+ String _text;
+ Common::Rect *_textBounds;
+ int _fontSize;
+ int _fontType; // 3 => Geneva, 22 => Courier, param to TextFont() function
+ bool _blocked[4];
+ String _messages[4];
+ int _soundFrequency; // times a minute, max 3600
+ int _soundType;
+ String _soundName;
+ int _worldX;
+ int _worldY;
+
+ Common::List<Obj> _objs;
+ Common::List<Chr> _chrs;
+
+public:
+ int getSoundFrequency() { return _soundFrequency; }
+ void setSoundFrequency(int soundFrequency) { _soundFrequency = soundFrequency; }
+
+ Common::Rect *getTextBounds() {
+ return _textBounds == NULL ? NULL : new Common::Rect(*_textBounds);
+ }
+
+ void setTextBounds(Common::Rect bounds) { _textBounds = new Common::Rect(bounds); }
+
+ void setDirMessage(int dir, String message) { _messages[dir] = message; }
+ String getDirMessage(int dir) { return _messages[dir]; }
+
+ void setDirBlocked(int dir, bool blocked) { _blocked[dir] = blocked; }
+ bool isDirBlocked(int dir) { return _blocked[dir]; }
+
+ String getText() { return _text; }
+ void setText(String text) { _text = text; }
+
+ Script *getScript() { return _script; }
+ void setScript(Script *script) { _script = script; }
+
+ int getSoundType() { return _soundType; }
+ void setSoundType(int soundType) { _soundType = soundType; }
+
+ int getWorldX() { return _worldX; }
+ void setWorldX(int worldX) { _worldX = worldX; }
+
+ int getWorldY() { return _worldY; }
+ void setWorldY(int worldY) { _worldY = worldY; }
+
+ String getSoundName() { return _soundName; }
+ void setSoundName(String soundName) { _soundName = soundName; }
+
+ int getFontSize() { return _fontSize; }
+ void setFontSize(int fontSize) { _fontSize = fontSize; }
+
+ int getFontType() { return _fontType; }
+
+#if 0
+ String getFontName() {
+ String[] fonts = {
+ "Chicago", // system font
+ "Geneva", // application font
+ "New York",
+ "Geneva",
+
+ "Monaco",
+ "Venice",
+ "London",
+ "Athens",
+
+ "San Francisco",
+ "Toronto",
+ "Cairo",
+ "Los Angeles", // 12
+
+ null, null, null, null, null, null, null, // not in Inside Macintosh
+
+ "Times", // 20
+ "Helvetica",
+ "Courier",
+ "Symbol",
+ "Taliesin" // mobile?
+ };
+ /*
+mappings found on some forums:
+systemFont(0):System(Swiss)
+times(20):Times New Roman(Roman)
+helvetica(21):Arial(Modern)
+courier(22):Courier New(Modern)
+symbol(23):Symbol(Decorative)
+applFont(1):Arial(Swiss)
+newYork(2):Times New Roman(Roman)
+geneva(3):Arial(Swiss)
+monaco(4):Courier New(Modern)
+venice(5):Times New Roman(Roman)
+london(6):Times New Roman(Roman)
+athens(7):Times New Roman(Roman)
+sanFran(8):Times New Roman(Roman)
+toronto(9):Times New Roman(Roman)
+cairo(11):Wingdings(Decorative)
+losAngeles(12):Times New Roman(Roman)
+taliesin(24):Wingdings(Decorative)
+ */
+ if (fontType >= 0 && fontType < fonts.length && fonts[fontType] != null) {
+ return _fonts[fontType];
+ }
+ return _"Unknown";
+ }
+#endif
+
+ void setFontType(int fontType) { _fontType = fontType; }
+
+ Common::List<Chr> getChrs() { return _chrs; }
+ Common::List<Obj> getObjs() { return _objs; }
+};
+
+} // End of namespace Wage
+
+#endif
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
new file mode 100644
index 0000000..03870bf
--- /dev/null
+++ b/engines/wage/script.cpp
@@ -0,0 +1,32 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "wage/wage.h"
+#include "wage/script.h"
+
+namespace Wage {
+
+
+} // End of namespace Wage
diff --git a/engines/wage/script.h b/engines/wage/script.h
new file mode 100644
index 0000000..f216952
--- /dev/null
+++ b/engines/wage/script.h
@@ -0,0 +1,42 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef WAGE_SCRIPT_H
+#define WAGE_SCRIPT_H
+
+namespace Wage {
+
+class Script {
+public:
+ Script(byte *data) : _data(data) {}
+ ~Script();
+
+private:
+ byte *_data;
+};
+
+} // End of namespace Wage
+
+#endif
diff --git a/engines/wage/sound.cpp b/engines/wage/sound.cpp
new file mode 100644
index 0000000..e9d6777
--- /dev/null
+++ b/engines/wage/sound.cpp
@@ -0,0 +1,37 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "wage/wage.h"
+#include "wage/sound.h"
+
+namespace Wage {
+
+Sound::Sound() {
+}
+
+Sound::~Sound() {
+}
+
+} // End of namespace Wage
diff --git a/engines/wage/sound.h b/engines/wage/sound.h
new file mode 100644
index 0000000..30c36f7
--- /dev/null
+++ b/engines/wage/sound.h
@@ -0,0 +1,39 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef WAGE_SOUND_H
+#define WAGE_SOUND_H
+
+namespace Wage {
+
+class Sound {
+public:
+ Sound();
+ ~Sound();
+};
+
+} // End of namespace Wage
+
+#endif
diff --git a/engines/wage/util.cpp b/engines/wage/util.cpp
index 9420150..2598a01 100644
--- a/engines/wage/util.cpp
+++ b/engines/wage/util.cpp
@@ -28,7 +28,8 @@
#include "common/stream.h"
namespace Wage {
-Common::String WageEngine::readPascalString(Common::SeekableReadStream &in) {
+
+Common::String readPascalString(Common::SeekableReadStream &in) {
Common::String s;
char *buf;
int len;
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 1468d24..cbb11bb 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -26,12 +26,13 @@
#include "common/scummsys.h"
#include "common/config-manager.h"
-#include "common/debug.h"
#include "common/EventRecorder.h"
#include "common/file.h"
#include "common/fs.h"
#include "wage/wage.h"
+#include "wage/macresman.h"
+#include "wage/world.h"
namespace Wage {
@@ -61,15 +62,14 @@ Common::Error WageEngine::run() {
printf("WageEngine::init\n");
// Your main even loop should be (invoked from) here.
- printf("WageEngine::go: Hello, World!\n");
-
- // This test will show up if -d1 and --debugflags=example are specified on the commandline
- debugC(1, kWageDebugExample, "Example debug call");
-
- // This test will show up if --debugflags=example or --debugflags=example2 or both of them and -d3 are specified on the commandline
- debugC(3, kWageDebugExample | kWageDebugExample2, "Example debug call two");
+ _resManager = new MacResManager(getGameFile());
+
+ _world = new World();
+
+ if (!_world->loadWorld(_resManager))
+ return Common::kNoGameDataFoundError;
return Common::kNoError;
}
-
+
} // End of namespace Wage
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index ff51c7f..8e5a7bb 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -27,6 +27,7 @@
#define WAGE_H
#include "engines/engine.h"
+#include "common/debug.h"
#include "gui/debugger.h"
#include "common/endian.h"
@@ -35,6 +36,10 @@ struct ADGameDescription;
namespace Wage {
class Console;
+class MacResManager;
+class World;
+
+using Common::String;
// our engine debug levels
enum {
@@ -44,6 +49,8 @@ enum {
// the current limitation is 32 debug levels (1 << 31 is the last one)
};
+Common::String readPascalString(Common::SeekableReadStream &in);
+
class WageEngine : public Engine {
public:
WageEngine(OSystem *syst, const ADGameDescription *gameDesc);
@@ -56,6 +63,11 @@ public:
bool canLoadGameStateCurrently();
bool canSaveGameStateCurrently();
+ const char *getGameFile() const;
+
+private:
+ bool loadWorld(MacResManager *resMan);
+
private:
Console *_console;
@@ -63,6 +75,10 @@ private:
Common::RandomSource _rnd;
const ADGameDescription *_gameDescription;
+
+ MacResManager *_resManager;
+
+ World *_world;
};
// Example console class
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 67987a5..f326f58 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -25,17 +25,32 @@
#include "wage/wage.h"
#include "wage/macresman.h"
+#include "wage/script.h"
+#include "wage/obj.h"
+#include "wage/world.h"
#include "common/stream.h"
namespace Wage {
-bool WageEngine::loadWorld(MacResManager *resMan) {
+World::World() {
+ _storageScene.setName(STORAGESCENE);
+ _orderedScenes.push_back(_storageScene);
+ _scenes[STORAGESCENE] = _storageScene;
+}
+
+bool World::loadWorld(MacResManager *resMan) {
int resSize;
MacResIDArray resArray;
byte *res;
MacResIDArray::const_iterator iter;
+ if ((resArray = resMan->getResIDArray("GCOD")).size() == 0)
+ return false;
+
+ res = resMan->getResource("GCOD", resArray[0], &resSize);
+ _globalScript = new Script(res);
+
if ((resArray = resMan->getResIDArray("VERS")).size() == 0)
return false;
@@ -54,7 +69,7 @@ bool WageEngine::loadWorld(MacResManager *resMan) {
readS.skip(3);
_aboutMessage = readPascalString(readS);
- if (!stricmp(getGameFile(), "Scepters"))
+ if (!stricmp(resMan->getFileName().c_str(), "Scepters"))
readS.skip(1); // ????
_soundLibrary1 = readPascalString(readS);
diff --git a/engines/wage/world.h b/engines/wage/world.h
new file mode 100644
index 0000000..18c3288
--- /dev/null
+++ b/engines/wage/world.h
@@ -0,0 +1,69 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef WAGE_WORLD_H
+#define WAGE_WORLD_H
+
+#include "wage/scene.h"
+#include "wage/script.h"
+#include "wage/obj.h"
+#include "wage/chr.h"
+#include "wage/sound.h"
+
+namespace Wage {
+
+#define STORAGESCENE "STORAGE@"
+
+class World {
+public:
+ World();
+ ~World();
+
+ bool loadWorld(MacResManager *resMan);
+
+ String _name;
+ String _aboutMessage;
+ String _soundLibrary1;
+ String _soundLibrary2;
+
+ bool _weaponMenuDisabled;
+ Script *_globalScript;
+ Common::HashMap<String, Scene> _scenes;
+ Common::HashMap<String, Obj> _objs;
+ Common::HashMap<String, Chr> _chrs;
+ Common::HashMap<String, Sound> _sounds;
+ Common::List<Scene> _orderedScenes;
+ Common::List<Obj> _orderedObjs;
+ Common::List<Chr> _orderedChrs;
+ Common::List<Sound> _orderedSounds;
+ Common::List<byte *> _patterns;
+ Scene _storageScene;
+ Chr _player;
+ //List<MoveListener> moveListeners;
+};
+
+} // End of namespace Wage
+
+#endif
Commit: 37cb2480fcf823f86d353f0ed6fb2b022dd82805
https://github.com/scummvm/scummvm/commit/37cb2480fcf823f86d353f0ed6fb2b022dd82805
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Added Context class and completed Chr class.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
A engines/wage/context.h
diff --git a/engines/wage/context.h b/engines/wage/context.h
new file mode 100644
index 0000000..1cb9af6
--- /dev/null
+++ b/engines/wage/context.h
@@ -0,0 +1,97 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef WAGE_CONTEXT_H
+#define WAGE_CONTEXT_H
+
+namespace Wage {
+
+class Context {
+ enum StatVariables {
+ /** The base physical accuracy of the player. */
+ PHYS_ACC_BAS = 0,
+ /** The current physical accuracy of the player. */
+ PHYS_ACC_CUR = 1,
+ /** The base physical armor of the player. */
+ PHYS_ARM_BAS = 2,
+ /** The current physical armor of the player. */
+ PHYS_ARM_CUR = 3,
+ /** The base physical hit points of the player. */
+ PHYS_HIT_BAS = 4,
+ /** The current physical hit points of the player. */
+ PHYS_HIT_CUR = 5,
+ /** The base physical speed of the player. */
+ PHYS_SPE_BAS = 6,
+ /** The current physical speed of the player. */
+ PHYS_SPE_CUR = 7,
+ /** The base physical strength of the player. */
+ PHYS_STR_BAS = 8,
+ /** The current physical strength of the player. */
+ PHYS_STR_CUR = 9,
+ /** The base spiritual accuracy of the player. */
+ SPIR_ACC_BAS = 10,
+ /** The current spiritual accuracy of the player. */
+ SPIR_ACC_CUR = 11,
+ /** The base spiritual armor of the player. */
+ SPIR_ARM_BAS = 12,
+ /** The current spiritual armor of the player. */
+ SPIR_ARM_CUR = 13,
+ /** The base spiritual hit points of the player. */
+ SPIR_HIT_BAS = 14,
+ /** The current spiritual hit points of the player. */
+ SPIR_HIT_CUR = 15,
+ /** The base spiritual strength of the player. */
+ SPIR_STR_BAS = 16,
+ /** The current spiritual strength of the player. */
+ SPIR_STR_CUR = 17
+ };
+
+private:
+ int16 _visits; // Number of scenes visited, including repeated visits
+ int16 _kills; // Number of characters killed
+ int16 _experience;
+ int16 _userVariables[26 * 9];
+ int16 _statVariables[18];
+
+public:
+ int16 getUserVariable(int index) { return _userVariables[index]; }
+ void setUserVariable(int index, int16 value) { _userVariables[index] = value; }
+
+ int16 getVisits() { return _visits; }
+ void setVisits(int16 visits) { _visits = visits; }
+
+ int16 getKills() { return _kills; }
+ void setKills(int16 kills) { _kills = kills; }
+
+ int16 getExperience() { return _experience; }
+ void setExperience(int16 experience) { _experience = experience; }
+
+ int16 getStatVariable(int index) { return _statVariables[index]; }
+ void setStatVariable(int index, int16 value) { _statVariables[index] = value; }
+};
+
+} // End of namespace Wage
+
+#endif
Commit: 65eb49cbd8a36bff06bc6ce9bda38cd91288feeb
https://github.com/scummvm/scummvm/commit/65eb49cbd8a36bff06bc6ce9bda38cd91288feeb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Removed tons on those accessors.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/chr.h
engines/wage/context.h
engines/wage/designed.h
engines/wage/module.mk
engines/wage/obj.h
engines/wage/scene.h
engines/wage/world.cpp
diff --git a/engines/wage/chr.h b/engines/wage/chr.h
index 51fdce0..edc02c6 100644
--- a/engines/wage/chr.h
+++ b/engines/wage/chr.h
@@ -25,13 +25,159 @@
#ifndef WAGE_CHR_H
#define WAGE_CHR_H
+
+#include "wage/context.h"
namespace Wage {
-class Chr {
+class Chr : public Designed {
+public:
+ enum ChrDestination {
+ RETURN_TO_STORAGE = 0,
+ RETURN_TO_RANDOM_SCENE = 1,
+ RETURN_TO_INITIAL_SCENE = 2
+ };
+
+ enum ChrPart {
+ HEAD = 0,
+ CHEST = 1,
+ SIDE = 2
+ };
+
+ enum ChrArmorType {
+ HEAD_ARMOR = 0,
+ BODY_ARMOR = 1,
+ SHIELD_ARMOR = 2
+ };
+
+ int _index;
+ String _initialScene;
+ int _gender;
+ bool _nameProperNoun;
+ bool _playerCharacter;
+ int _maximumCarriedObjects;
+ int _returnTo;
+
+ int _physicalStrength;
+ int _physicalHp;
+ int _naturalArmor;
+ int _physicalAccuracy;
+ int _spiritualStength;
+ int _spiritialHp;
+ int _resistanceToMagic;
+ int _spiritualAccuracy;
+ int _runningSpeed;
+ int _rejectsOffers;
+ int _followsOpponent;
+
+ String _initialSound;
+ String _scoresHitSound;
+ String _receivesHitSound;
+ String _dyingSound;
+
+ String _nativeWeapon1;
+ String _operativeVerb1;
+ int _weaponDamage1;
+ String _weaponSound1;
+
+ String _nativeWeapon2;
+ String _operativeVerb2;
+ int _weaponDamage2;
+ String _weaponSound2;
+
+ int _winningWeapons;
+ int _winningMagic;
+ int _winningRun;
+ int _winningOffer;
+ int _losingWeapons;
+ int _losingMagic;
+ int _losingRun;
+ int _losingOffer;
+
+ String _initialComment;
+ String _scoresHitComment;
+ String _receivesHitComment;
+ String _makesOfferComment;
+ String _rejectsOfferComment;
+ String _acceptsOfferComment;
+ String _dyingWords;
+
+ Scene _currentScene;
+ Common::List<Obj> _inventory;
+
+ Obj _armor[3];
+
+ Context _context;
+
public:
- Chr();
- ~Chr();
+#if 0
+ Weapon[] getWeapons() {
+ ArrayList<Weapon> weapons = new ArrayList<Weapon>();
+ if (hasNativeWeapon1()) {
+ weapons.add(new Weapon() {
+ String getName() {
+ return _getNativeWeapon1();
+ }
+ String getOperativeVerb() {
+ return _getOperativeVerb1();
+ }
+ int getType() {
+ return _Obj.REGULAR_WEAPON;
+ }
+ int getAccuracy() {
+ return _0;
+ }
+ int getDamage() {
+ return _getWeaponDamage1();
+ }
+ String getSound() {
+ return _getWeaponSound1();
+ }
+ void decrementNumberOfUses() {}
+ });
+ }
+ if (hasNativeWeapon2()) {
+ weapons.add(new Weapon() {
+ String getName() {
+ return _getNativeWeapon2();
+ }
+ String getOperativeVerb() {
+ return _getOperativeVerb2();
+ }
+ int getType() {
+ return _Obj.REGULAR_WEAPON;
+ }
+ int getAccuracy() {
+ return _0;
+ }
+ int getDamage() {
+ return _getWeaponDamage2();
+ }
+ String getSound() {
+ return _getWeaponSound2();
+ }
+ void decrementNumberOfUses() {}
+ });
+ }
+ for (Obj o : getInventory()) {
+ switch (o.getType()) {
+ case Obj.REGULAR_WEAPON:
+ case Obj.THROW_WEAPON:
+ case Obj.MAGICAL_OBJECT:
+ weapons.add(o);
+ }
+ }
+ return _(Weapon[]) weapons.toArray(new Weapon[0]);
+ }
+#endif
+
+ bool hasNativeWeapon1() {
+ return (_nativeWeapon1.size() > 0 && _operativeVerb1.size() > 0);
+ }
+
+ bool hasNativeWeapon2() {
+ return (_nativeWeapon2.size() > 0 && _operativeVerb2.size() > 0);
+ }
};
} // End of namespace Wage
diff --git a/engines/wage/context.h b/engines/wage/context.h
index 1cb9af6..432bdc7 100644
--- a/engines/wage/context.h
+++ b/engines/wage/context.h
@@ -68,28 +68,11 @@ class Context {
SPIR_STR_CUR = 17
};
-private:
int16 _visits; // Number of scenes visited, including repeated visits
int16 _kills; // Number of characters killed
int16 _experience;
int16 _userVariables[26 * 9];
int16 _statVariables[18];
-
-public:
- int16 getUserVariable(int index) { return _userVariables[index]; }
- void setUserVariable(int index, int16 value) { _userVariables[index] = value; }
-
- int16 getVisits() { return _visits; }
- void setVisits(int16 visits) { _visits = visits; }
-
- int16 getKills() { return _kills; }
- void setKills(int16 kills) { _kills = kills; }
-
- int16 getExperience() { return _experience; }
- void setExperience(int16 experience) { _experience = experience; }
-
- int16 getStatVariable(int index) { return _statVariables[index]; }
- void setStatVariable(int index, int16 value) { _statVariables[index] = value; }
};
} // End of namespace Wage
diff --git a/engines/wage/designed.h b/engines/wage/designed.h
index 8ef1fa2..8f6d884 100644
--- a/engines/wage/designed.h
+++ b/engines/wage/designed.h
@@ -43,13 +43,6 @@ public:
Design *_design;
Common::Rect *_designBounds;
- String getName() { return _name; }
- void setName(String name) { _name = name; }
- String toString() { return _name; }
-
- Design *getDesign() { return _design; }
- void setDesign(Design *design) { _design = design; }
-
Common::Rect *getDesignBounds() {
return _designBounds == NULL ? NULL : new Common::Rect(*_designBounds);
}
diff --git a/engines/wage/module.mk b/engines/wage/module.mk
index a5e0b29..6f875f8 100644
--- a/engines/wage/module.mk
+++ b/engines/wage/module.mk
@@ -1,8 +1,15 @@
MODULE := engines/wage
MODULE_OBJS := \
+ design.o \
+ designed.o \
detection.o \
- wage.o
+ macresman.o \
+ script.o \
+ sound.o \
+ util.o \
+ wage.o \
+ world.o
MODULE_DIRS += \
engines/wage
@@ -13,4 +20,4 @@ PLUGIN := 1
endif
# Include common rules
-include $(srcdir)/rules.mk
\ No newline at end of file
+include $(srcdir)/rules.mk
diff --git a/engines/wage/obj.h b/engines/wage/obj.h
index 65049ed..12db147 100644
--- a/engines/wage/obj.h
+++ b/engines/wage/obj.h
@@ -34,13 +34,20 @@ namespace Wage {
class Weapon {
public:
- virtual ~Weapon() {}
- virtual String getOperativeVerb() = 0;
- virtual int getType() = 0;
- virtual int getAccuracy() = 0;
- virtual int getDamage() = 0;
- virtual String getSound() = 0;
- virtual void decrementNumberOfUses() = 0;
+ int _accuracy;
+ String _operativeVerb;
+ int _type;
+ int _damage;
+ String _sound;
+ int _numberOfUses;
+
+ Weapon() : _numberOfUses(0) {}
+
+ void decrementNumberOfUses() {
+ if (_numberOfUses != -1) {
+ _numberOfUses--;
+ }
+ }
};
class Design;
@@ -73,92 +80,34 @@ public:
FREEZES_OPPONENT = 6
};
-private:
+public:
int _index;
bool _namePlural;
- int _type;
int _value;
- int _damage;
- int _accuracy;
int _attackType;
int _numberOfUses;
bool _returnToRandomScene;
String _sceneOrOwner;
String _clickMessage;
- String _operativeVerb;
String _failureMessage;
String _useMessage;
- String _sound;
Scene *_currentScene;
Chr *_currentOwner;
public:
- Chr *getCurrentOwner() { return _currentOwner; }
-
void setCurrentOwner(Chr *currentOwner) {
_currentOwner = currentOwner;
if (currentOwner != NULL)
_currentScene = NULL;
}
- Scene *getCurrentScene() { return _currentScene; }
-
void setCurrentScene(Scene *currentScene) {
_currentScene = currentScene;
if (currentScene != NULL)
_currentOwner = NULL;
}
- int getAccuracy() { return _accuracy; }
- void setAccuracy(int accuracy) { _accuracy = accuracy; }
-
- int getAttackType() { return _attackType; }
- void setAttackType(int attackType) { _attackType = attackType; }
-
- String getClickMessage() { return _clickMessage; }
- void setClickMessage(String clickMessage) { _clickMessage = clickMessage; }
-
- int getDamage() { return _damage; }
- void setDamage(int damage) { _damage = damage; }
-
- String getFailureMessage() { return _failureMessage; }
- void setFailureMessage(String failureMessage) { _failureMessage = failureMessage; }
-
- int getNumberOfUses() { return _numberOfUses; }
- void setNumberOfUses(int numberOfUses) { _numberOfUses = numberOfUses; }
- void decrementNumberOfUses() {
- if (_numberOfUses != -1) {
- _numberOfUses--;
- }
- }
-
- int getType() { return _type; }
- void setType(int type) { _type = type; }
-
- String getOperativeVerb() { return _operativeVerb; }
- void setOperativeVerb(String operativeVerb) { _operativeVerb = operativeVerb; }
-
- bool isReturnToRandomScene() { return _returnToRandomScene; }
- void setReturnToRandomScene(bool returnToRandomScene) { _returnToRandomScene = returnToRandomScene; }
-
- String getSceneOrOwner() { return _sceneOrOwner; }
- void setSceneOrOwner(String sceneOrOwner) { _sceneOrOwner = sceneOrOwner; }
-
- String getSound() { return _sound; }
- void setSound(String sound) { _sound = sound; }
-
- String getUseMessage() { return _useMessage; }
- void setUseMessage(String useMessage) { _useMessage = useMessage; }
-
- int getValue() { return _value; }
- void setValue(int value) { _value = value; }
-
- bool isNamePlural() { return _namePlural; }
- void setNamePlural(bool namePlural) { _namePlural = namePlural; }
-
- int getIndex() { return _index; }
- void setIndex(int index) { _index = index; }
};
} // End of namespace Wage
diff --git a/engines/wage/scene.h b/engines/wage/scene.h
index a1873fc..c239faa 100644
--- a/engines/wage/scene.h
+++ b/engines/wage/scene.h
@@ -69,44 +69,10 @@ private:
Common::List<Chr> _chrs;
public:
- int getSoundFrequency() { return _soundFrequency; }
- void setSoundFrequency(int soundFrequency) { _soundFrequency = soundFrequency; }
-
Common::Rect *getTextBounds() {
return _textBounds == NULL ? NULL : new Common::Rect(*_textBounds);
}
- void setTextBounds(Common::Rect bounds) { _textBounds = new Common::Rect(bounds); }
-
- void setDirMessage(int dir, String message) { _messages[dir] = message; }
- String getDirMessage(int dir) { return _messages[dir]; }
-
- void setDirBlocked(int dir, bool blocked) { _blocked[dir] = blocked; }
- bool isDirBlocked(int dir) { return _blocked[dir]; }
-
- String getText() { return _text; }
- void setText(String text) { _text = text; }
-
- Script *getScript() { return _script; }
- void setScript(Script *script) { _script = script; }
-
- int getSoundType() { return _soundType; }
- void setSoundType(int soundType) { _soundType = soundType; }
-
- int getWorldX() { return _worldX; }
- void setWorldX(int worldX) { _worldX = worldX; }
-
- int getWorldY() { return _worldY; }
- void setWorldY(int worldY) { _worldY = worldY; }
-
- String getSoundName() { return _soundName; }
- void setSoundName(String soundName) { _soundName = soundName; }
-
- int getFontSize() { return _fontSize; }
- void setFontSize(int fontSize) { _fontSize = fontSize; }
-
- int getFontType() { return _fontType; }
-
#if 0
String getFontName() {
String[] fonts = {
@@ -159,11 +125,6 @@ taliesin(24):Wingdings(Decorative)
return _"Unknown";
}
#endif
-
- void setFontType(int fontType) { _fontType = fontType; }
-
- Common::List<Chr> getChrs() { return _chrs; }
- Common::List<Obj> getObjs() { return _objs; }
};
} // End of namespace Wage
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index f326f58..6b56e78 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -34,7 +34,7 @@
namespace Wage {
World::World() {
- _storageScene.setName(STORAGESCENE);
+ _storageScene._name = STORAGESCENE;
_orderedScenes.push_back(_storageScene);
_scenes[STORAGESCENE] = _storageScene;
}
Commit: 2caf2102220a0cdae65a42c794835d859a674596
https://github.com/scummvm/scummvm/commit/2caf2102220a0cdae65a42c794835d859a674596
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Remove chr.cpp as it is non-needed.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
R engines/wage/chr.cpp
diff --git a/engines/wage/chr.cpp b/engines/wage/chr.cpp
deleted file mode 100644
index 2c02a2d..0000000
--- a/engines/wage/chr.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "wage/wage.h"
-#include "wage/chr.h"
-
-namespace Wage {
-
-Chr::Chr() {
-}
-
-Chr::~Chr() {
-}
-
-} // End of namespace Wage
Commit: 199bea21674003ddaffca28125e05d1351bc3712
https://github.com/scummvm/scummvm/commit/199bea21674003ddaffca28125e05d1351bc3712
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Started scene loader implemenation
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/sound.cpp
engines/wage/sound.h
engines/wage/world.cpp
engines/wage/world.h
diff --git a/engines/wage/sound.cpp b/engines/wage/sound.cpp
index e9d6777..272aafc 100644
--- a/engines/wage/sound.cpp
+++ b/engines/wage/sound.cpp
@@ -28,10 +28,5 @@
namespace Wage {
-Sound::Sound() {
-}
-
-Sound::~Sound() {
-}
} // End of namespace Wage
diff --git a/engines/wage/sound.h b/engines/wage/sound.h
index 30c36f7..a0be0c7 100644
--- a/engines/wage/sound.h
+++ b/engines/wage/sound.h
@@ -30,8 +30,11 @@ namespace Wage {
class Sound {
public:
- Sound();
- ~Sound();
+ Sound(byte *data) : _data(data) {}
+ ~Sound() { free(_data); }
+
+ String _name;
+ byte *_data;
};
} // End of namespace Wage
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 6b56e78..d897d9e 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -35,8 +35,8 @@ namespace Wage {
World::World() {
_storageScene._name = STORAGESCENE;
- _orderedScenes.push_back(_storageScene);
- _scenes[STORAGESCENE] = _storageScene;
+ _orderedScenes.push_back(&_storageScene);
+ _scenes[STORAGESCENE] = &_storageScene;
}
bool World::loadWorld(MacResManager *resMan) {
@@ -48,9 +48,11 @@ bool World::loadWorld(MacResManager *resMan) {
if ((resArray = resMan->getResIDArray("GCOD")).size() == 0)
return false;
+ // Load global script
res = resMan->getResource("GCOD", resArray[0], &resSize);
_globalScript = new Script(res);
+ // Load main configuration
if ((resArray = resMan->getResIDArray("VERS")).size() == 0)
return false;
@@ -75,7 +77,13 @@ bool World::loadWorld(MacResManager *resMan) {
_soundLibrary1 = readPascalString(readS);
_soundLibrary2 = readPascalString(readS);
- debug(0, "%s\n%s", _soundLibrary1.c_str(), _soundLibrary2.c_str());
+ // Load scenes
+ resArray = resMan->getResIDArray("ASCN");
+
+ for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
+
+ }
+
return true;
}
diff --git a/engines/wage/world.h b/engines/wage/world.h
index 18c3288..3a8d7ed 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -50,18 +50,50 @@ public:
bool _weaponMenuDisabled;
Script *_globalScript;
- Common::HashMap<String, Scene> _scenes;
- Common::HashMap<String, Obj> _objs;
- Common::HashMap<String, Chr> _chrs;
- Common::HashMap<String, Sound> _sounds;
- Common::List<Scene> _orderedScenes;
- Common::List<Obj> _orderedObjs;
- Common::List<Chr> _orderedChrs;
- Common::List<Sound> _orderedSounds;
+ Common::HashMap<String, Scene *> _scenes;
+ Common::HashMap<String, Obj *> _objs;
+ Common::HashMap<String, Chr *> _chrs;
+ Common::HashMap<String, Sound *> _sounds;
+ Common::List<Scene *> _orderedScenes;
+ Common::List<Obj *> _orderedObjs;
+ Common::List<Chr *> _orderedChrs;
+ Common::List<Sound *> _orderedSounds;
Common::List<byte *> _patterns;
Scene _storageScene;
Chr _player;
//List<MoveListener> moveListeners;
+
+ void addScene(Scene *room) {
+ if (room->_name.size() != 0) {
+ String s = room->_name;
+ s.toLowercase();
+ _scenes[s] = room;
+ }
+ _orderedScenes.push_back(room);
+ }
+
+ void addObj(Obj *obj) {
+ String s = obj->_name;
+ s.toLowercase();
+ _objs[s] = obj;
+ obj->_index = _orderedObjs.size();
+ _orderedObjs.push_back(obj);
+ }
+
+ void addChr(Chr *chr) {
+ String s = chr->_name;
+ s.toLowercase();
+ _chrs[s] = chr;
+ chr->_index = _orderedChrs.size();
+ _orderedChrs.push_back(chr);
+ }
+
+ void addSound(Sound *sound) {
+ String s = sound->_name;
+ s.toLowercase();
+ _sounds[s] = sound;
+ _orderedSounds.push_back(sound);
+ }
};
} // End of namespace Wage
Commit: 53029635b13c6581031ecae0ed9af841bfbeb3ab
https://github.com/scummvm/scummvm/commit/53029635b13c6581031ecae0ed9af841bfbeb3ab
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Load scene scripts too.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/macresman.cpp
engines/wage/macresman.h
engines/wage/module.mk
engines/wage/scene.h
engines/wage/world.cpp
diff --git a/engines/wage/macresman.cpp b/engines/wage/macresman.cpp
index 0dce789..02ea6c9 100644
--- a/engines/wage/macresman.cpp
+++ b/engines/wage/macresman.cpp
@@ -141,6 +141,26 @@ MacResIDArray MacResManager::getResIDArray(const char *typeID) {
return res;
}
+char *MacResManager::getResName(const char *typeID, int16 resID) {
+ int i;
+ int typeNum = -1;
+
+ for (i = 0; i < _resMap.numTypes; i++)
+ if (strcmp(_resTypes[i].id, typeID) == 0) {
+ typeNum = i;
+ break;
+ }
+
+ if (typeNum == -1)
+ return NULL;
+
+ for (i = 0; i < _resTypes[typeNum].items; i++)
+ if (_resLists[typeNum][i].id == resID)
+ return _resLists[typeNum][i].name;
+
+ return NULL;
+}
+
byte *MacResManager::getResource(const char *typeID, int16 resID, int *size) {
int i;
int typeNum = -1;
@@ -226,7 +246,7 @@ void MacResManager::readMap() {
_resFile.seek(_resLists[i][j].nameOffset + _mapOffset + _resMap.nameOffset);
len = _resFile.readByte();
- _resLists[i][j].name = new byte[len + 1];
+ _resLists[i][j].name = new char[len + 1];
_resLists[i][j].name[len] = 0;
_resFile.read(_resLists[i][j].name, len);
}
diff --git a/engines/wage/macresman.h b/engines/wage/macresman.h
index 58635ae..c09f4f7 100644
--- a/engines/wage/macresman.h
+++ b/engines/wage/macresman.h
@@ -39,6 +39,7 @@ public:
MacResManager(Common::String fileName);
~MacResManager();
byte *getResource(const char *typeID, int16 resID, int *size);
+ char *getResName(const char *typeID, int16 resID);
void convertCursor(byte *data, int datasize, byte **cursor, int *w, int *h,
int *hotspot_x, int *hotspot_y, int *keycolor, bool colored, byte **palette, int *palSize);
@@ -69,7 +70,7 @@ private:
int16 nameOffset;
byte attr;
int32 dataOffset;
- byte *name;
+ char *name;
};
typedef Resource *ResPtr;
diff --git a/engines/wage/module.mk b/engines/wage/module.mk
index 6f875f8..f43886c 100644
--- a/engines/wage/module.mk
+++ b/engines/wage/module.mk
@@ -5,6 +5,7 @@ MODULE_OBJS := \
designed.o \
detection.o \
macresman.o \
+ scene.o \
script.o \
sound.o \
util.o \
diff --git a/engines/wage/scene.h b/engines/wage/scene.h
index c239faa..509833a 100644
--- a/engines/wage/scene.h
+++ b/engines/wage/scene.h
@@ -51,7 +51,6 @@ public:
RANDOM = 1
};
-private:
Script *_script;
String _text;
Common::Rect *_textBounds;
@@ -68,7 +67,9 @@ private:
Common::List<Obj> _objs;
Common::List<Chr> _chrs;
-public:
+ Scene() {}
+ Scene(String name, byte *data);
+
Common::Rect *getTextBounds() {
return _textBounds == NULL ? NULL : new Common::Rect(*_textBounds);
}
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index d897d9e..5fd4635 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -81,7 +81,12 @@ bool World::loadWorld(MacResManager *resMan) {
resArray = resMan->getResIDArray("ASCN");
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
-
+ res = resMan->getResource("ASCND", *iter, &resSize);
+ Scene *scene = new Scene(resMan->getResName("ASCN", *iter), res);
+
+ res = resMan->getResource("ACOD", *iter, &resSize);
+ if (res != NULL)
+ scene->_script = new Script(res);
}
Commit: f48876270378849d93dda18553bc15974e297e58
https://github.com/scummvm/scummvm/commit/f48876270378849d93dda18553bc15974e297e58
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Finished world loading.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/chr.h
engines/wage/obj.h
engines/wage/sound.cpp
engines/wage/util.cpp
engines/wage/wage.h
engines/wage/world.cpp
engines/wage/world.h
diff --git a/engines/wage/chr.h b/engines/wage/chr.h
index edc02c6..10b8286 100644
--- a/engines/wage/chr.h
+++ b/engines/wage/chr.h
@@ -50,6 +50,8 @@ public:
SHIELD_ARMOR = 2
};
+ Chr(String name, byte *data) {}
+
int _index;
String _initialScene;
int _gender;
diff --git a/engines/wage/obj.h b/engines/wage/obj.h
index 12db147..41480c7 100644
--- a/engines/wage/obj.h
+++ b/engines/wage/obj.h
@@ -57,6 +57,7 @@ class Chr;
class Obj : public Weapon, public Designed {
public:
Obj() : _currentOwner(NULL), _currentScene(NULL) {}
+ Obj(String name, byte *data) : _currentOwner(NULL), _currentScene(NULL) {}
enum ObjectTypes {
REGULAR_WEAPON = 1,
diff --git a/engines/wage/sound.cpp b/engines/wage/sound.cpp
index 272aafc..cbd4bb1 100644
--- a/engines/wage/sound.cpp
+++ b/engines/wage/sound.cpp
@@ -25,8 +25,12 @@
#include "wage/wage.h"
#include "wage/sound.h"
+#include "wage/world.h"
namespace Wage {
+void World::loadExternalSounds(String fname) {
+}
+
} // End of namespace Wage
diff --git a/engines/wage/util.cpp b/engines/wage/util.cpp
index 2598a01..ab36582 100644
--- a/engines/wage/util.cpp
+++ b/engines/wage/util.cpp
@@ -54,4 +54,15 @@ Common::String readPascalString(Common::SeekableReadStream &in) {
return s;
}
+Common::Rect *readRect(Common::SeekableReadStream &in) {
+ int x1, y1, x2, y2;
+
+ y1 = in.readUint16LE();
+ x1 = in.readUint16LE();
+ y2 = in.readUint16LE() + 4;
+ x2 = in.readUint16LE() + 4;
+
+ return new Common::Rect(x1, y1, x2, y2);
+}
+
} // End of namespace Wage
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 8e5a7bb..75a76e1 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -30,6 +30,7 @@
#include "common/debug.h"
#include "gui/debugger.h"
#include "common/endian.h"
+#include "common/rect.h"
struct ADGameDescription;
@@ -50,6 +51,7 @@ enum {
};
Common::String readPascalString(Common::SeekableReadStream &in);
+Common::Rect *readRect(Common::SeekableReadStream &in);
class WageEngine : public Engine {
public:
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 5fd4635..0c1ddb0 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -77,18 +77,86 @@ bool World::loadWorld(MacResManager *resMan) {
_soundLibrary1 = readPascalString(readS);
_soundLibrary2 = readPascalString(readS);
+ free(res);
+
// Load scenes
resArray = resMan->getResIDArray("ASCN");
-
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
- res = resMan->getResource("ASCND", *iter, &resSize);
+ res = resMan->getResource("ASCN", *iter, &resSize);
Scene *scene = new Scene(resMan->getResName("ASCN", *iter), res);
res = resMan->getResource("ACOD", *iter, &resSize);
if (res != NULL)
scene->_script = new Script(res);
+
+ res = resMan->getResource("ATXT", *iter, &resSize);
+ if (res != NULL) {
+ Common::MemoryReadStream readT(res, resSize);
+ scene->_textBounds = readRect(readT);
+ scene->_fontType = readT.readUint16LE();
+ scene->_fontSize = readT.readUint16LE();
+
+ for (int i = 12; i < resSize; i++)
+ if (res[i] == 0x0d)
+ res[i] = '\n';
+ String text(&((char*)res)[12], resSize - 12);
+ scene->_text = text;
+
+ free(res);
+ }
+ addScene(scene);
}
+ // Load Objects
+ resArray = resMan->getResIDArray("AOBJ");
+ for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
+ res = resMan->getResource("AOBJ", *iter, &resSize);
+ addObj(new Obj(resMan->getResName("AOBJ", *iter), res));
+ }
+
+ // Load Characters
+ resArray = resMan->getResIDArray("ACHR");
+ for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
+ res = resMan->getResource("ACHR", *iter, &resSize);
+ Chr *chr = new Chr(resMan->getResName("ACHR", *iter), res);
+
+ addChr(chr);
+ // TODO: What if there's more than one player character?
+ if (chr->_playerCharacter)
+ _player = chr;
+ }
+
+ // Load Sounds
+ resArray = resMan->getResIDArray("ASND");
+ for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
+ res = resMan->getResource("ASND", *iter, &resSize);
+ Sound *sound = new Sound(res);
+ sound->_name = resMan->getResName("ASND", *iter);
+ addSound(sound);
+ }
+
+ if (_soundLibrary1.size() > 0) {
+ loadExternalSounds(_soundLibrary1);
+ }
+ if (_soundLibrary2.size() > 0) {
+ loadExternalSounds(_soundLibrary2);
+ }
+
+ // Load Patterns
+ res = resMan->getResource("PAT#", 900, &resSize);
+ if (res != NULL) {
+ Common::MemoryReadStream readP(res, resSize);
+ int count = readP.readUint16LE();
+ for (int i = 0; i < count; i++) {
+ byte *pattern = (byte *)malloc(8);
+ for (int j = 0; j < 8; j++) {
+ pattern[j] = readP.readByte();
+ _patterns.push_back(pattern);
+ }
+ }
+
+ free(res);
+ }
return true;
}
diff --git a/engines/wage/world.h b/engines/wage/world.h
index 3a8d7ed..d8c3dae 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -42,6 +42,7 @@ public:
~World();
bool loadWorld(MacResManager *resMan);
+ void loadExternalSounds(String fname);
String _name;
String _aboutMessage;
@@ -60,7 +61,7 @@ public:
Common::List<Sound *> _orderedSounds;
Common::List<byte *> _patterns;
Scene _storageScene;
- Chr _player;
+ Chr *_player;
//List<MoveListener> moveListeners;
void addScene(Scene *room) {
Commit: add5bba03fe8a6274c590f18aa931d1b2a586dc5
https://github.com/scummvm/scummvm/commit/add5bba03fe8a6274c590f18aa931d1b2a586dc5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Merged most headers into entities.h
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
A engines/wage/entities.cpp
A engines/wage/entities.h
R engines/wage/chr.h
R engines/wage/context.h
R engines/wage/designed.cpp
R engines/wage/designed.h
R engines/wage/obj.h
R engines/wage/scene.h
R engines/wage/sound.cpp
R engines/wage/sound.h
engines/wage/module.mk
engines/wage/wage.cpp
engines/wage/world.cpp
engines/wage/world.h
diff --git a/engines/wage/chr.h b/engines/wage/chr.h
deleted file mode 100644
index 10b8286..0000000
--- a/engines/wage/chr.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef WAGE_CHR_H
-#define WAGE_CHR_H
-
-#include "wage/context.h"
-
-namespace Wage {
-
-class Chr : public Designed {
-public:
- enum ChrDestination {
- RETURN_TO_STORAGE = 0,
- RETURN_TO_RANDOM_SCENE = 1,
- RETURN_TO_INITIAL_SCENE = 2
- };
-
- enum ChrPart {
- HEAD = 0,
- CHEST = 1,
- SIDE = 2
- };
-
- enum ChrArmorType {
- HEAD_ARMOR = 0,
- BODY_ARMOR = 1,
- SHIELD_ARMOR = 2
- };
-
- Chr(String name, byte *data) {}
-
- int _index;
- String _initialScene;
- int _gender;
- bool _nameProperNoun;
- bool _playerCharacter;
- int _maximumCarriedObjects;
- int _returnTo;
-
- int _physicalStrength;
- int _physicalHp;
- int _naturalArmor;
- int _physicalAccuracy;
- int _spiritualStength;
- int _spiritialHp;
- int _resistanceToMagic;
- int _spiritualAccuracy;
- int _runningSpeed;
- int _rejectsOffers;
- int _followsOpponent;
-
- String _initialSound;
- String _scoresHitSound;
- String _receivesHitSound;
- String _dyingSound;
-
- String _nativeWeapon1;
- String _operativeVerb1;
- int _weaponDamage1;
- String _weaponSound1;
-
- String _nativeWeapon2;
- String _operativeVerb2;
- int _weaponDamage2;
- String _weaponSound2;
-
- int _winningWeapons;
- int _winningMagic;
- int _winningRun;
- int _winningOffer;
- int _losingWeapons;
- int _losingMagic;
- int _losingRun;
- int _losingOffer;
-
- String _initialComment;
- String _scoresHitComment;
- String _receivesHitComment;
- String _makesOfferComment;
- String _rejectsOfferComment;
- String _acceptsOfferComment;
- String _dyingWords;
-
- Scene _currentScene;
- Common::List<Obj> _inventory;
-
- Obj _armor[3];
-
- Context _context;
-
-public:
-#if 0
- Weapon[] getWeapons() {
- ArrayList<Weapon> weapons = new ArrayList<Weapon>();
- if (hasNativeWeapon1()) {
- weapons.add(new Weapon() {
- String getName() {
- return _getNativeWeapon1();
- }
- String getOperativeVerb() {
- return _getOperativeVerb1();
- }
- int getType() {
- return _Obj.REGULAR_WEAPON;
- }
- int getAccuracy() {
- return _0;
- }
- int getDamage() {
- return _getWeaponDamage1();
- }
- String getSound() {
- return _getWeaponSound1();
- }
- void decrementNumberOfUses() {}
- });
- }
- if (hasNativeWeapon2()) {
- weapons.add(new Weapon() {
- String getName() {
- return _getNativeWeapon2();
- }
- String getOperativeVerb() {
- return _getOperativeVerb2();
- }
- int getType() {
- return _Obj.REGULAR_WEAPON;
- }
- int getAccuracy() {
- return _0;
- }
- int getDamage() {
- return _getWeaponDamage2();
- }
- String getSound() {
- return _getWeaponSound2();
- }
- void decrementNumberOfUses() {}
- });
- }
- for (Obj o : getInventory()) {
- switch (o.getType()) {
- case Obj.REGULAR_WEAPON:
- case Obj.THROW_WEAPON:
- case Obj.MAGICAL_OBJECT:
- weapons.add(o);
- }
- }
- return _(Weapon[]) weapons.toArray(new Weapon[0]);
- }
-#endif
-
- bool hasNativeWeapon1() {
- return (_nativeWeapon1.size() > 0 && _operativeVerb1.size() > 0);
- }
-
- bool hasNativeWeapon2() {
- return (_nativeWeapon2.size() > 0 && _operativeVerb2.size() > 0);
- }
-};
-
-} // End of namespace Wage
-
-#endif
diff --git a/engines/wage/context.h b/engines/wage/context.h
deleted file mode 100644
index 432bdc7..0000000
--- a/engines/wage/context.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef WAGE_CONTEXT_H
-#define WAGE_CONTEXT_H
-
-namespace Wage {
-
-class Context {
- enum StatVariables {
- /** The base physical accuracy of the player. */
- PHYS_ACC_BAS = 0,
- /** The current physical accuracy of the player. */
- PHYS_ACC_CUR = 1,
- /** The base physical armor of the player. */
- PHYS_ARM_BAS = 2,
- /** The current physical armor of the player. */
- PHYS_ARM_CUR = 3,
- /** The base physical hit points of the player. */
- PHYS_HIT_BAS = 4,
- /** The current physical hit points of the player. */
- PHYS_HIT_CUR = 5,
- /** The base physical speed of the player. */
- PHYS_SPE_BAS = 6,
- /** The current physical speed of the player. */
- PHYS_SPE_CUR = 7,
- /** The base physical strength of the player. */
- PHYS_STR_BAS = 8,
- /** The current physical strength of the player. */
- PHYS_STR_CUR = 9,
- /** The base spiritual accuracy of the player. */
- SPIR_ACC_BAS = 10,
- /** The current spiritual accuracy of the player. */
- SPIR_ACC_CUR = 11,
- /** The base spiritual armor of the player. */
- SPIR_ARM_BAS = 12,
- /** The current spiritual armor of the player. */
- SPIR_ARM_CUR = 13,
- /** The base spiritual hit points of the player. */
- SPIR_HIT_BAS = 14,
- /** The current spiritual hit points of the player. */
- SPIR_HIT_CUR = 15,
- /** The base spiritual strength of the player. */
- SPIR_STR_BAS = 16,
- /** The current spiritual strength of the player. */
- SPIR_STR_CUR = 17
- };
-
- int16 _visits; // Number of scenes visited, including repeated visits
- int16 _kills; // Number of characters killed
- int16 _experience;
- int16 _userVariables[26 * 9];
- int16 _statVariables[18];
-};
-
-} // End of namespace Wage
-
-#endif
diff --git a/engines/wage/designed.cpp b/engines/wage/designed.cpp
deleted file mode 100644
index 040d821..0000000
--- a/engines/wage/designed.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "wage/wage.h"
-#include "wage/designed.h"
-#include "wage/design.h"
-
-namespace Wage {
-
-void Designed::setDesignBounds(Common::Rect bounds) {
- _designBounds = new Common::Rect(bounds);
- _design->setBounds(bounds);
-}
-
-} // End of namespace Wage
diff --git a/engines/wage/designed.h b/engines/wage/designed.h
deleted file mode 100644
index 8f6d884..0000000
--- a/engines/wage/designed.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef WAGE_DESIGNED_H
-#define WAGE_DESIGNED_H
-
-#include "common/str.h"
-#include "common/rect.h"
-
-using Common::String;
-
-namespace Wage {
-
-class Design;
-
-class Designed {
-public:
- Designed() : _design(NULL), _designBounds(NULL) {}
-
- String _name;
- Design *_design;
- Common::Rect *_designBounds;
-
- Common::Rect *getDesignBounds() {
- return _designBounds == NULL ? NULL : new Common::Rect(*_designBounds);
- }
-
- void setDesignBounds(Common::Rect bounds);
-};
-
-} // End of namespace Wage
-
-#endif
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
new file mode 100644
index 0000000..ef446a9
--- /dev/null
+++ b/engines/wage/entities.cpp
@@ -0,0 +1,41 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "wage/wage.h"
+#include "wage/entities.h"
+#include "wage/design.h"
+
+namespace Wage {
+
+void Designed::setDesignBounds(Common::Rect bounds) {
+ _designBounds = new Common::Rect(bounds);
+ _design->setBounds(bounds);
+}
+
+Scene::Scene(String name, byte *data) {
+}
+
+
+} // End of namespace Wage
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
new file mode 100644
index 0000000..834ee82
--- /dev/null
+++ b/engines/wage/entities.h
@@ -0,0 +1,427 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef WAGE_ENTITIES_H
+#define WAGE_ENTITIES_H
+
+namespace Wage {
+
+class Design;
+class Obj;
+class Scene;
+class Script;
+
+class Context {
+ enum StatVariables {
+ /** The base physical accuracy of the player. */
+ PHYS_ACC_BAS = 0,
+ /** The current physical accuracy of the player. */
+ PHYS_ACC_CUR = 1,
+ /** The base physical armor of the player. */
+ PHYS_ARM_BAS = 2,
+ /** The current physical armor of the player. */
+ PHYS_ARM_CUR = 3,
+ /** The base physical hit points of the player. */
+ PHYS_HIT_BAS = 4,
+ /** The current physical hit points of the player. */
+ PHYS_HIT_CUR = 5,
+ /** The base physical speed of the player. */
+ PHYS_SPE_BAS = 6,
+ /** The current physical speed of the player. */
+ PHYS_SPE_CUR = 7,
+ /** The base physical strength of the player. */
+ PHYS_STR_BAS = 8,
+ /** The current physical strength of the player. */
+ PHYS_STR_CUR = 9,
+ /** The base spiritual accuracy of the player. */
+ SPIR_ACC_BAS = 10,
+ /** The current spiritual accuracy of the player. */
+ SPIR_ACC_CUR = 11,
+ /** The base spiritual armor of the player. */
+ SPIR_ARM_BAS = 12,
+ /** The current spiritual armor of the player. */
+ SPIR_ARM_CUR = 13,
+ /** The base spiritual hit points of the player. */
+ SPIR_HIT_BAS = 14,
+ /** The current spiritual hit points of the player. */
+ SPIR_HIT_CUR = 15,
+ /** The base spiritual strength of the player. */
+ SPIR_STR_BAS = 16,
+ /** The current spiritual strength of the player. */
+ SPIR_STR_CUR = 17
+ };
+
+ int16 _visits; // Number of scenes visited, including repeated visits
+ int16 _kills; // Number of characters killed
+ int16 _experience;
+ int16 _userVariables[26 * 9];
+ int16 _statVariables[18];
+};
+
+class Designed {
+public:
+ Designed() : _design(NULL), _designBounds(NULL) {}
+
+ String _name;
+ Design *_design;
+ Common::Rect *_designBounds;
+
+ Common::Rect *getDesignBounds() {
+ return _designBounds == NULL ? NULL : new Common::Rect(*_designBounds);
+ }
+
+ void setDesignBounds(Common::Rect bounds);
+};
+
+class Chr : public Designed {
+public:
+ enum ChrDestination {
+ RETURN_TO_STORAGE = 0,
+ RETURN_TO_RANDOM_SCENE = 1,
+ RETURN_TO_INITIAL_SCENE = 2
+ };
+
+ enum ChrPart {
+ HEAD = 0,
+ CHEST = 1,
+ SIDE = 2
+ };
+
+ enum ChrArmorType {
+ HEAD_ARMOR = 0,
+ BODY_ARMOR = 1,
+ SHIELD_ARMOR = 2
+ };
+
+ Chr(String name, byte *data) {}
+
+ int _index;
+ String _initialScene;
+ int _gender;
+ bool _nameProperNoun;
+ bool _playerCharacter;
+ int _maximumCarriedObjects;
+ int _returnTo;
+
+ int _physicalStrength;
+ int _physicalHp;
+ int _naturalArmor;
+ int _physicalAccuracy;
+ int _spiritualStength;
+ int _spiritialHp;
+ int _resistanceToMagic;
+ int _spiritualAccuracy;
+ int _runningSpeed;
+ int _rejectsOffers;
+ int _followsOpponent;
+
+ String _initialSound;
+ String _scoresHitSound;
+ String _receivesHitSound;
+ String _dyingSound;
+
+ String _nativeWeapon1;
+ String _operativeVerb1;
+ int _weaponDamage1;
+ String _weaponSound1;
+
+ String _nativeWeapon2;
+ String _operativeVerb2;
+ int _weaponDamage2;
+ String _weaponSound2;
+
+ int _winningWeapons;
+ int _winningMagic;
+ int _winningRun;
+ int _winningOffer;
+ int _losingWeapons;
+ int _losingMagic;
+ int _losingRun;
+ int _losingOffer;
+
+ String _initialComment;
+ String _scoresHitComment;
+ String _receivesHitComment;
+ String _makesOfferComment;
+ String _rejectsOfferComment;
+ String _acceptsOfferComment;
+ String _dyingWords;
+
+ Scene *_currentScene;
+ Common::List<Obj> _inventory;
+
+ Obj *_armor[3];
+
+ Context _context;
+
+public:
+#if 0
+ Weapon[] getWeapons() {
+ ArrayList<Weapon> weapons = new ArrayList<Weapon>();
+ if (hasNativeWeapon1()) {
+ weapons.add(new Weapon() {
+ String getName() {
+ return _getNativeWeapon1();
+ }
+ String getOperativeVerb() {
+ return _getOperativeVerb1();
+ }
+ int getType() {
+ return _Obj.REGULAR_WEAPON;
+ }
+ int getAccuracy() {
+ return _0;
+ }
+ int getDamage() {
+ return _getWeaponDamage1();
+ }
+ String getSound() {
+ return _getWeaponSound1();
+ }
+ void decrementNumberOfUses() {}
+ });
+ }
+ if (hasNativeWeapon2()) {
+ weapons.add(new Weapon() {
+ String getName() {
+ return _getNativeWeapon2();
+ }
+ String getOperativeVerb() {
+ return _getOperativeVerb2();
+ }
+ int getType() {
+ return _Obj.REGULAR_WEAPON;
+ }
+ int getAccuracy() {
+ return _0;
+ }
+ int getDamage() {
+ return _getWeaponDamage2();
+ }
+ String getSound() {
+ return _getWeaponSound2();
+ }
+ void decrementNumberOfUses() {}
+ });
+ }
+ for (Obj o : getInventory()) {
+ switch (o.getType()) {
+ case Obj.REGULAR_WEAPON:
+ case Obj.THROW_WEAPON:
+ case Obj.MAGICAL_OBJECT:
+ weapons.add(o);
+ }
+ }
+ return _(Weapon[]) weapons.toArray(new Weapon[0]);
+ }
+#endif
+
+ bool hasNativeWeapon1() {
+ return (_nativeWeapon1.size() > 0 && _operativeVerb1.size() > 0);
+ }
+
+ bool hasNativeWeapon2() {
+ return (_nativeWeapon2.size() > 0 && _operativeVerb2.size() > 0);
+ }
+};
+
+class Weapon {
+public:
+ int _accuracy;
+ String _operativeVerb;
+ int _type;
+ int _damage;
+ String _sound;
+ int _numberOfUses;
+
+ Weapon() : _numberOfUses(0) {}
+
+ void decrementNumberOfUses() {
+ if (_numberOfUses != -1) {
+ _numberOfUses--;
+ }
+ }
+};
+
+class Obj : public Weapon, public Designed {
+public:
+ Obj() : _currentOwner(NULL), _currentScene(NULL) {}
+ Obj(String name, byte *data) : _currentOwner(NULL), _currentScene(NULL) {}
+
+ enum ObjectTypes {
+ REGULAR_WEAPON = 1,
+ THROW_WEAPON = 2,
+ MAGICAL_OBJECT = 3,
+ HELMET = 4,
+ SHIELD = 5,
+ CHEST_ARMOR = 6,
+ SPIRITUAL_ARMOR = 7,
+ MOBILE_OBJECT = 8,
+ IMMOBILE_OBJECT = 9
+ };
+
+ enum AttackTypes {
+ CAUSES_PHYSICAL_DAMAGE = 0,
+ CAUSES_SPIRITUAL_DAMAGE = 1,
+ CAUSES_PHYSICAL_AND_SPIRITUAL_DAMAGE = 2,
+ HEALS_PHYSICAL_DAMAGE = 3,
+ HEALS_SPIRITUAL_DAMAGE = 4,
+ HEALS_PHYSICAL_AND_SPIRITUAL_DAMAGE = 5,
+ FREEZES_OPPONENT = 6
+ };
+
+public:
+ int _index;
+ bool _namePlural;
+ int _value;
+ int _attackType;
+ int _numberOfUses;
+ bool _returnToRandomScene;
+ String _sceneOrOwner;
+ String _clickMessage;
+ String _failureMessage;
+ String _useMessage;
+
+ Scene *_currentScene;
+ Chr *_currentOwner;
+
+public:
+ void setCurrentOwner(Chr *currentOwner) {
+ _currentOwner = currentOwner;
+ if (currentOwner != NULL)
+ _currentScene = NULL;
+ }
+
+ void setCurrentScene(Scene *currentScene) {
+ _currentScene = currentScene;
+ if (currentScene != NULL)
+ _currentOwner = NULL;
+ }
+
+};
+
+class Scene : public Designed {
+public:
+ enum Directions {
+ NORTH = 0,
+ SOUTH = 1,
+ EAST = 2,
+ WEST = 3
+ };
+
+ enum SceneTypes {
+ PERIODIC = 0,
+ RANDOM = 1
+ };
+
+ Script *_script;
+ String _text;
+ Common::Rect *_textBounds;
+ int _fontSize;
+ int _fontType; // 3 => Geneva, 22 => Courier, param to TextFont() function
+ bool _blocked[4];
+ String _messages[4];
+ int _soundFrequency; // times a minute, max 3600
+ int _soundType;
+ String _soundName;
+ int _worldX;
+ int _worldY;
+
+ Common::List<Obj> _objs;
+ Common::List<Chr> _chrs;
+
+ Scene() {}
+ Scene(String name, byte *data);
+
+ Common::Rect *getTextBounds() {
+ return _textBounds == NULL ? NULL : new Common::Rect(*_textBounds);
+ }
+
+#if 0
+ String getFontName() {
+ String[] fonts = {
+ "Chicago", // system font
+ "Geneva", // application font
+ "New York",
+ "Geneva",
+
+ "Monaco",
+ "Venice",
+ "London",
+ "Athens",
+
+ "San Francisco",
+ "Toronto",
+ "Cairo",
+ "Los Angeles", // 12
+
+ null, null, null, null, null, null, null, // not in Inside Macintosh
+
+ "Times", // 20
+ "Helvetica",
+ "Courier",
+ "Symbol",
+ "Taliesin" // mobile?
+ };
+ /*
+mappings found on some forums:
+systemFont(0):System(Swiss)
+times(20):Times New Roman(Roman)
+helvetica(21):Arial(Modern)
+courier(22):Courier New(Modern)
+symbol(23):Symbol(Decorative)
+applFont(1):Arial(Swiss)
+newYork(2):Times New Roman(Roman)
+geneva(3):Arial(Swiss)
+monaco(4):Courier New(Modern)
+venice(5):Times New Roman(Roman)
+london(6):Times New Roman(Roman)
+athens(7):Times New Roman(Roman)
+sanFran(8):Times New Roman(Roman)
+toronto(9):Times New Roman(Roman)
+cairo(11):Wingdings(Decorative)
+losAngeles(12):Times New Roman(Roman)
+taliesin(24):Wingdings(Decorative)
+ */
+ if (fontType >= 0 && fontType < fonts.length && fonts[fontType] != null) {
+ return _fonts[fontType];
+ }
+ return _"Unknown";
+ }
+#endif
+};
+
+class Sound {
+public:
+ Sound(byte *data) : _data(data) {}
+ ~Sound() { free(_data); }
+
+ String _name;
+ byte *_data;
+};
+
+} // End of namespace Wage
+
+#endif
diff --git a/engines/wage/module.mk b/engines/wage/module.mk
index f43886c..e314b1a 100644
--- a/engines/wage/module.mk
+++ b/engines/wage/module.mk
@@ -2,12 +2,10 @@ MODULE := engines/wage
MODULE_OBJS := \
design.o \
- designed.o \
detection.o \
+ entities.o \
macresman.o \
- scene.o \
script.o \
- sound.o \
util.o \
wage.o \
world.o
diff --git a/engines/wage/obj.h b/engines/wage/obj.h
deleted file mode 100644
index 41480c7..0000000
--- a/engines/wage/obj.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef WAGE_OBJ_H
-#define WAGE_OBJ_H
-
-#include "common/rect.h"
-
-#include "wage/designed.h"
-
-namespace Wage {
-
-class Weapon {
-public:
- int _accuracy;
- String _operativeVerb;
- int _type;
- int _damage;
- String _sound;
- int _numberOfUses;
-
- Weapon() : _numberOfUses(0) {}
-
- void decrementNumberOfUses() {
- if (_numberOfUses != -1) {
- _numberOfUses--;
- }
- }
-};
-
-class Design;
-class Scene;
-class Chr;
-
-class Obj : public Weapon, public Designed {
-public:
- Obj() : _currentOwner(NULL), _currentScene(NULL) {}
- Obj(String name, byte *data) : _currentOwner(NULL), _currentScene(NULL) {}
-
- enum ObjectTypes {
- REGULAR_WEAPON = 1,
- THROW_WEAPON = 2,
- MAGICAL_OBJECT = 3,
- HELMET = 4,
- SHIELD = 5,
- CHEST_ARMOR = 6,
- SPIRITUAL_ARMOR = 7,
- MOBILE_OBJECT = 8,
- IMMOBILE_OBJECT = 9
- };
-
- enum AttackTypes {
- CAUSES_PHYSICAL_DAMAGE = 0,
- CAUSES_SPIRITUAL_DAMAGE = 1,
- CAUSES_PHYSICAL_AND_SPIRITUAL_DAMAGE = 2,
- HEALS_PHYSICAL_DAMAGE = 3,
- HEALS_SPIRITUAL_DAMAGE = 4,
- HEALS_PHYSICAL_AND_SPIRITUAL_DAMAGE = 5,
- FREEZES_OPPONENT = 6
- };
-
-public:
- int _index;
- bool _namePlural;
- int _value;
- int _attackType;
- int _numberOfUses;
- bool _returnToRandomScene;
- String _sceneOrOwner;
- String _clickMessage;
- String _failureMessage;
- String _useMessage;
-
- Scene *_currentScene;
- Chr *_currentOwner;
-
-public:
- void setCurrentOwner(Chr *currentOwner) {
- _currentOwner = currentOwner;
- if (currentOwner != NULL)
- _currentScene = NULL;
- }
-
- void setCurrentScene(Scene *currentScene) {
- _currentScene = currentScene;
- if (currentScene != NULL)
- _currentOwner = NULL;
- }
-
-};
-
-} // End of namespace Wage
-
-#endif
diff --git a/engines/wage/scene.h b/engines/wage/scene.h
deleted file mode 100644
index 509833a..0000000
--- a/engines/wage/scene.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef WAGE_SCENE_H
-#define WAGE_SCENE_H
-
-#include "common/list.h"
-#include "common/rect.h"
-
-#include "wage/designed.h"
-
-namespace Wage {
-
-class Script;
-class Chr;
-class Obj;
-
-class Scene : public Designed {
-public:
- enum Directions {
- NORTH = 0,
- SOUTH = 1,
- EAST = 2,
- WEST = 3
- };
-
- enum SceneTypes {
- PERIODIC = 0,
- RANDOM = 1
- };
-
- Script *_script;
- String _text;
- Common::Rect *_textBounds;
- int _fontSize;
- int _fontType; // 3 => Geneva, 22 => Courier, param to TextFont() function
- bool _blocked[4];
- String _messages[4];
- int _soundFrequency; // times a minute, max 3600
- int _soundType;
- String _soundName;
- int _worldX;
- int _worldY;
-
- Common::List<Obj> _objs;
- Common::List<Chr> _chrs;
-
- Scene() {}
- Scene(String name, byte *data);
-
- Common::Rect *getTextBounds() {
- return _textBounds == NULL ? NULL : new Common::Rect(*_textBounds);
- }
-
-#if 0
- String getFontName() {
- String[] fonts = {
- "Chicago", // system font
- "Geneva", // application font
- "New York",
- "Geneva",
-
- "Monaco",
- "Venice",
- "London",
- "Athens",
-
- "San Francisco",
- "Toronto",
- "Cairo",
- "Los Angeles", // 12
-
- null, null, null, null, null, null, null, // not in Inside Macintosh
-
- "Times", // 20
- "Helvetica",
- "Courier",
- "Symbol",
- "Taliesin" // mobile?
- };
- /*
-mappings found on some forums:
-systemFont(0):System(Swiss)
-times(20):Times New Roman(Roman)
-helvetica(21):Arial(Modern)
-courier(22):Courier New(Modern)
-symbol(23):Symbol(Decorative)
-applFont(1):Arial(Swiss)
-newYork(2):Times New Roman(Roman)
-geneva(3):Arial(Swiss)
-monaco(4):Courier New(Modern)
-venice(5):Times New Roman(Roman)
-london(6):Times New Roman(Roman)
-athens(7):Times New Roman(Roman)
-sanFran(8):Times New Roman(Roman)
-toronto(9):Times New Roman(Roman)
-cairo(11):Wingdings(Decorative)
-losAngeles(12):Times New Roman(Roman)
-taliesin(24):Wingdings(Decorative)
- */
- if (fontType >= 0 && fontType < fonts.length && fonts[fontType] != null) {
- return _fonts[fontType];
- }
- return _"Unknown";
- }
-#endif
-};
-
-} // End of namespace Wage
-
-#endif
diff --git a/engines/wage/sound.cpp b/engines/wage/sound.cpp
deleted file mode 100644
index cbd4bb1..0000000
--- a/engines/wage/sound.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "wage/wage.h"
-#include "wage/sound.h"
-#include "wage/world.h"
-
-namespace Wage {
-
-void World::loadExternalSounds(String fname) {
-}
-
-
-} // End of namespace Wage
diff --git a/engines/wage/sound.h b/engines/wage/sound.h
deleted file mode 100644
index a0be0c7..0000000
--- a/engines/wage/sound.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef WAGE_SOUND_H
-#define WAGE_SOUND_H
-
-namespace Wage {
-
-class Sound {
-public:
- Sound(byte *data) : _data(data) {}
- ~Sound() { free(_data); }
-
- String _name;
- byte *_data;
-};
-
-} // End of namespace Wage
-
-#endif
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index cbb11bb..1efd3f0 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -32,6 +32,7 @@
#include "wage/wage.h"
#include "wage/macresman.h"
+#include "wage/entities.h"
#include "wage/world.h"
namespace Wage {
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 0c1ddb0..23684e4 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -25,8 +25,8 @@
#include "wage/wage.h"
#include "wage/macresman.h"
+#include "wage/entities.h"
#include "wage/script.h"
-#include "wage/obj.h"
#include "wage/world.h"
#include "common/stream.h"
@@ -161,4 +161,7 @@ bool World::loadWorld(MacResManager *resMan) {
return true;
}
+void World::loadExternalSounds(String fname) {
+}
+
} // End of namespace Wage
diff --git a/engines/wage/world.h b/engines/wage/world.h
index d8c3dae..0086db2 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -26,12 +26,6 @@
#ifndef WAGE_WORLD_H
#define WAGE_WORLD_H
-#include "wage/scene.h"
-#include "wage/script.h"
-#include "wage/obj.h"
-#include "wage/chr.h"
-#include "wage/sound.h"
-
namespace Wage {
#define STORAGESCENE "STORAGE@"
Commit: 406a05aec194729a711e13f9be5163069c931ede
https://github.com/scummvm/scummvm/commit/406a05aec194729a711e13f9be5163069c931ede
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Implement reading of all entities. This completes the world loading.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/util.cpp
engines/wage/world.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index ce9063c..df78247 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -28,8 +28,8 @@
namespace Wage {
-Design::Design(byte *data) {
- int len = READ_UINT16(data);
+Design::Design(byte *data, int dataSize) {
+ int len = READ_BE_UINT16(data);
_data = (byte *)malloc(len);
memcpy(_data, data, len);
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 2956f84..49f8487 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -32,11 +32,11 @@ namespace Wage {
class Design {
public:
- Design(byte *data);
+ Design(byte *data, int size);
~Design();
- void setBounds(Common::Rect bounds) {
- _bounds = new Common::Rect(bounds);
+ void setBounds(Common::Rect *bounds) {
+ _bounds = new Common::Rect(*bounds);
}
Common::Rect *getBounds() {
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index ef446a9..c7336b7 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -27,15 +27,155 @@
#include "wage/entities.h"
#include "wage/design.h"
+#include "common/stream.h"
+
namespace Wage {
-void Designed::setDesignBounds(Common::Rect bounds) {
- _designBounds = new Common::Rect(bounds);
+void Designed::setDesignBounds(Common::Rect *bounds) {
+ _designBounds = new Common::Rect(*bounds);
_design->setBounds(bounds);
}
-Scene::Scene(String name, byte *data) {
+Scene::Scene(String name, byte *data, int dataSize) {
+ _name = name;
+ _design = new Design(data, dataSize);
+
+ Common::MemoryReadStream in(data, dataSize);
+
+ in.skip(in.readUint16BE() - 2); // Skip design.
+ setDesignBounds(readRect(in));
+ _worldY = in.readSint16BE();
+ _worldX = in.readSint16BE();
+ _blocked[Scene::NORTH] = (in.readByte() != 0);
+ _blocked[Scene::SOUTH] = (in.readByte() != 0);
+ _blocked[Scene::EAST] = (in.readByte() != 0);
+ _blocked[Scene::WEST] = (in.readByte() != 0);
+ _soundFrequency = in.readSint16BE();
+ _soundType = in.readByte();
+ in.readByte(); // unknown
+ _messages[Scene::NORTH] = readPascalString(in);
+ _messages[Scene::SOUTH] = readPascalString(in);
+ _messages[Scene::EAST] = readPascalString(in);
+ _messages[Scene::WEST] = readPascalString(in);
+ _soundName = readPascalString(in);
}
+Obj::Obj(String name, byte *data, int dataSize) : _currentOwner(NULL), _currentScene(NULL) {
+ _name = name;
+ _design = new Design(data, dataSize);
+
+ Common::MemoryReadStream in(data, dataSize);
+
+ in.skip(in.readSint16BE() - 2); // Skip design.
+ setDesignBounds(readRect(in));
+
+ int16 namePlural = in.readSint16BE();
+
+ if (namePlural == 256)
+ _namePlural = true; // TODO: other flags?
+ else if (namePlural == 0)
+ _namePlural = false;
+ else
+ error("Obj <%s> had weird namePlural set", name.c_str());
+
+ if (in.readSint16BE() != 0)
+ error("Obj <%s> had short set", name.c_str());
+
+ if (in.readByte() != 0)
+ error("Obj <%s> had byte set", name.c_str());
+
+ _accuracy = in.readByte();
+ _value = in.readByte();
+ _type = in.readSByte();
+ _damage = in.readByte();
+ _attackType = in.readSByte();
+ _numberOfUses = in.readSint16BE();
+ int16 returnTo = in.readSint16BE();
+ if (returnTo == 256) // TODO any other possibilities?
+ _returnToRandomScene = true;
+ else if (returnTo == 0)
+ _returnToRandomScene = false;
+ else
+ error("Obj <%s> had weird returnTo set", name.c_str());
+
+ _sceneOrOwner = readPascalString(in);
+ _clickMessage = readPascalString(in);
+ _operativeVerb = readPascalString(in);
+ _failureMessage = readPascalString(in);
+ _useMessage = readPascalString(in);
+ _sound = readPascalString(in);
+}
+
+Chr::Chr(String name, byte *data, int dataSize) {
+ _name = name;
+ _design = new Design(data, dataSize);
+
+ Common::MemoryReadStream in(data, dataSize);
+
+ in.skip(in.readSint16BE() - 2); // Skip design.
+ setDesignBounds(readRect(in));
+
+ _physicalStrength = in.readByte();
+ _physicalHp = in.readByte();
+ _naturalArmor = in.readByte();
+ _physicalAccuracy = in.readByte();
+
+ _spiritualStength = in.readByte();
+ _spiritialHp = in.readByte();
+ _resistanceToMagic = in.readByte();
+ _spiritualAccuracy = in.readByte();
+
+ _runningSpeed = in.readByte();
+ _rejectsOffers = in.readByte();
+ _followsOpponent = in.readByte();
+
+ in.readSByte(); // TODO: ???
+ in.readSint32BE(); // TODO: ???
+
+ _weaponDamage1 = in.readByte();
+ _weaponDamage2 = in.readByte();
+
+ in.readSByte(); // TODO: ???
+
+ if (in.readSByte() == 1)
+ _playerCharacter = true;
+ _maximumCarriedObjects = in.readByte();
+ _returnTo = in.readSByte();
+
+ _winningWeapons = in.readByte();
+ _winningMagic = in.readByte();
+ _winningRun = in.readByte();
+ _winningOffer = in.readByte();
+ _losingWeapons = in.readByte();
+ _losingMagic = in.readByte();
+ _losingRun = in.readByte();
+ _losingOffer = in.readByte();
+
+ _gender = in.readSByte();
+ if (in.readSByte() == 1)
+ _nameProperNoun = true;
+
+ _initialScene = readPascalString(in);
+ _nativeWeapon1 = readPascalString(in);
+ _operativeVerb1 = readPascalString(in);
+ _nativeWeapon2 = readPascalString(in);
+ _operativeVerb2 = readPascalString(in);
+
+ _initialComment = readPascalString(in);
+ _scoresHitComment = readPascalString(in);
+ _receivesHitComment = readPascalString(in);
+ _makesOfferComment = readPascalString(in);
+ _rejectsOfferComment = readPascalString(in);
+ _acceptsOfferComment = readPascalString(in);
+ _dyingWords = readPascalString(in);
+
+ _initialSound = readPascalString(in);
+ _scoresHitSound = readPascalString(in);
+ _receivesHitSound = readPascalString(in);
+ _dyingSound = readPascalString(in);
+
+ _weaponSound1 = readPascalString(in);
+ _weaponSound2 = readPascalString(in);
+}
} // End of namespace Wage
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 834ee82..07ecbd8 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -92,7 +92,7 @@ public:
return _designBounds == NULL ? NULL : new Common::Rect(*_designBounds);
}
- void setDesignBounds(Common::Rect bounds);
+ void setDesignBounds(Common::Rect *bounds);
};
class Chr : public Designed {
@@ -115,7 +115,7 @@ public:
SHIELD_ARMOR = 2
};
- Chr(String name, byte *data) {}
+ Chr(String name, byte *data, int dataSize);
int _index;
String _initialScene;
@@ -249,7 +249,7 @@ public:
class Weapon {
public:
- int _accuracy;
+ uint _accuracy;
String _operativeVerb;
int _type;
int _damage;
@@ -268,7 +268,7 @@ public:
class Obj : public Weapon, public Designed {
public:
Obj() : _currentOwner(NULL), _currentScene(NULL) {}
- Obj(String name, byte *data) : _currentOwner(NULL), _currentScene(NULL) {}
+ Obj(String name, byte *data, int dataSize);
enum ObjectTypes {
REGULAR_WEAPON = 1,
@@ -295,7 +295,7 @@ public:
public:
int _index;
bool _namePlural;
- int _value;
+ uint _value;
int _attackType;
int _numberOfUses;
bool _returnToRandomScene;
@@ -353,7 +353,7 @@ public:
Common::List<Chr> _chrs;
Scene() {}
- Scene(String name, byte *data);
+ Scene(String name, byte *data, int dataSize);
Common::Rect *getTextBounds() {
return _textBounds == NULL ? NULL : new Common::Rect(*_textBounds);
@@ -415,7 +415,7 @@ taliesin(24):Wingdings(Decorative)
class Sound {
public:
- Sound(byte *data) : _data(data) {}
+ Sound(String name, byte *data, int dataSize) : _name(name), _data(data) {}
~Sound() { free(_data); }
String _name;
diff --git a/engines/wage/util.cpp b/engines/wage/util.cpp
index ab36582..d382561 100644
--- a/engines/wage/util.cpp
+++ b/engines/wage/util.cpp
@@ -57,10 +57,10 @@ Common::String readPascalString(Common::SeekableReadStream &in) {
Common::Rect *readRect(Common::SeekableReadStream &in) {
int x1, y1, x2, y2;
- y1 = in.readUint16LE();
- x1 = in.readUint16LE();
- y2 = in.readUint16LE() + 4;
- x2 = in.readUint16LE() + 4;
+ y1 = in.readUint16BE();
+ x1 = in.readUint16BE();
+ y2 = in.readUint16BE() + 4;
+ x2 = in.readUint16BE() + 4;
return new Common::Rect(x1, y1, x2, y2);
}
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 23684e4..0e3850c 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -83,7 +83,7 @@ bool World::loadWorld(MacResManager *resMan) {
resArray = resMan->getResIDArray("ASCN");
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
res = resMan->getResource("ASCN", *iter, &resSize);
- Scene *scene = new Scene(resMan->getResName("ASCN", *iter), res);
+ Scene *scene = new Scene(resMan->getResName("ASCN", *iter), res, resSize);
res = resMan->getResource("ACOD", *iter, &resSize);
if (res != NULL)
@@ -93,8 +93,8 @@ bool World::loadWorld(MacResManager *resMan) {
if (res != NULL) {
Common::MemoryReadStream readT(res, resSize);
scene->_textBounds = readRect(readT);
- scene->_fontType = readT.readUint16LE();
- scene->_fontSize = readT.readUint16LE();
+ scene->_fontType = readT.readUint16BE();
+ scene->_fontSize = readT.readUint16BE();
for (int i = 12; i < resSize; i++)
if (res[i] == 0x0d)
@@ -111,14 +111,14 @@ bool World::loadWorld(MacResManager *resMan) {
resArray = resMan->getResIDArray("AOBJ");
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
res = resMan->getResource("AOBJ", *iter, &resSize);
- addObj(new Obj(resMan->getResName("AOBJ", *iter), res));
+ addObj(new Obj(resMan->getResName("AOBJ", *iter), res, resSize));
}
// Load Characters
resArray = resMan->getResIDArray("ACHR");
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
res = resMan->getResource("ACHR", *iter, &resSize);
- Chr *chr = new Chr(resMan->getResName("ACHR", *iter), res);
+ Chr *chr = new Chr(resMan->getResName("ACHR", *iter), res, resSize);
addChr(chr);
// TODO: What if there's more than one player character?
@@ -130,9 +130,7 @@ bool World::loadWorld(MacResManager *resMan) {
resArray = resMan->getResIDArray("ASND");
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
res = resMan->getResource("ASND", *iter, &resSize);
- Sound *sound = new Sound(res);
- sound->_name = resMan->getResName("ASND", *iter);
- addSound(sound);
+ addSound(new Sound(resMan->getResName("ASND", *iter), res, resSize));
}
if (_soundLibrary1.size() > 0) {
@@ -146,7 +144,7 @@ bool World::loadWorld(MacResManager *resMan) {
res = resMan->getResource("PAT#", 900, &resSize);
if (res != NULL) {
Common::MemoryReadStream readP(res, resSize);
- int count = readP.readUint16LE();
+ int count = readP.readUint16BE();
for (int i = 0; i < count; i++) {
byte *pattern = (byte *)malloc(8);
for (int j = 0; j < 8; j++) {
@@ -162,6 +160,28 @@ bool World::loadWorld(MacResManager *resMan) {
}
void World::loadExternalSounds(String fname) {
+ Common::File in;
+
+ in.open(fname);
+ if (!in.isOpen()) {
+ warning("Cannot load sound file <%s>", fname.c_str());
+ return;
+ }
+ in.close();
+
+ MacResManager *resMan;
+ resMan = new MacResManager(fname);
+
+ int resSize;
+ MacResIDArray resArray;
+ byte *res;
+ MacResIDArray::const_iterator iter;
+
+ resArray = resMan->getResIDArray("ASND");
+ for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
+ res = resMan->getResource("ASND", *iter, &resSize);
+ addSound(new Sound(resMan->getResName("ASND", *iter), res, resSize));
+ }
}
} // End of namespace Wage
Commit: d9e0667dcc8abb21cbad2d1afd542d3a4bb51873
https://github.com/scummvm/scummvm/commit/d9e0667dcc8abb21cbad2d1afd542d3a4bb51873
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Move MacResManager to Common
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
R engines/wage/macresman.cpp
R engines/wage/macresman.h
engines/wage/module.mk
engines/wage/wage.cpp
engines/wage/wage.h
engines/wage/world.cpp
engines/wage/world.h
diff --git a/engines/wage/macresman.cpp b/engines/wage/macresman.cpp
deleted file mode 100644
index 02ea6c9..0000000
--- a/engines/wage/macresman.cpp
+++ /dev/null
@@ -1,396 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "common/scummsys.h"
-#include "common/debug.h"
-#include "common/file.h"
-#include "common/util.h"
-
-#include "wage/macresman.h"
-
-namespace Wage {
-
-MacResManager::MacResManager(Common::String fileName) : _fileName(fileName), _resOffset(-1) {
- _resFile.open(_fileName);
-
- if (!_resFile.isOpen()) {
- error("Cannot open file %s", _fileName.c_str());
- }
-
- if (!init())
- error("Resource fork is missing in file '%s'", _fileName.c_str());
-}
-
-MacResManager::~MacResManager() {
- for (int i = 0; i < _resMap.numTypes; i++) {
- for (int j = 0; j < _resTypes[i].items; j++) {
- if (_resLists[i][j].nameOffset != -1) {
- delete _resLists[i][j].name;
- }
- }
- delete _resLists[i];
- }
-
- delete _resLists;
- delete _resTypes;
-
- _resFile.close();
-}
-
-#define MBI_INFOHDR 128
-#define MBI_ZERO1 0
-#define MBI_NAMELEN 1
-#define MBI_ZERO2 74
-#define MBI_ZERO3 82
-#define MBI_DFLEN 83
-#define MBI_RFLEN 87
-#define MAXNAMELEN 63
-
-bool MacResManager::init() {
- byte infoHeader[MBI_INFOHDR];
- int32 data_size, rsrc_size;
- int32 data_size_pad, rsrc_size_pad;
- int filelen;
-
- filelen = _resFile.size();
- _resFile.read(infoHeader, MBI_INFOHDR);
-
- // Maybe we have MacBinary?
- if (infoHeader[MBI_ZERO1] == 0 && infoHeader[MBI_ZERO2] == 0 &&
- infoHeader[MBI_ZERO3] == 0 && infoHeader[MBI_NAMELEN] <= MAXNAMELEN) {
-
- // Pull out fork lengths
- data_size = READ_BE_UINT32(infoHeader + MBI_DFLEN);
- rsrc_size = READ_BE_UINT32(infoHeader + MBI_RFLEN);
-
- data_size_pad = (((data_size + 127) >> 7) << 7);
- rsrc_size_pad = (((rsrc_size + 127) >> 7) << 7);
-
- // Length check
- int sumlen = MBI_INFOHDR + data_size_pad + rsrc_size_pad;
-
- if (sumlen == filelen)
- _resOffset = MBI_INFOHDR + data_size_pad;
- }
-
- if (_resOffset == -1) // MacBinary check is failed
- _resOffset = 0; // Maybe we have dumped fork?
-
- _resFile.seek(_resOffset);
-
- _dataOffset = _resFile.readUint32BE() + _resOffset;
- _mapOffset = _resFile.readUint32BE() + _resOffset;
- _dataLength = _resFile.readUint32BE();
- _mapLength = _resFile.readUint32BE();
-
- // do sanity check
- if (_dataOffset >= filelen || _mapOffset >= filelen ||
- _dataLength + _mapLength > filelen) {
- _resOffset = -1;
- return false;
- }
-
- debug(7, "got header: data %d [%d] map %d [%d]",
- _dataOffset, _dataLength, _mapOffset, _mapLength);
-
- readMap();
-
- return true;
-}
-
-MacResIDArray MacResManager::getResIDArray(const char *typeID) {
- int typeNum = -1;
- MacResIDArray res;
-
- for (int i = 0; i < _resMap.numTypes; i++)
- if (strcmp(_resTypes[i].id, typeID) == 0) {
- typeNum = i;
- break;
- }
-
- if (typeNum == -1)
- return res;
-
- res.resize(_resTypes[typeNum].items);
-
- for (int i = 0; i < _resTypes[typeNum].items; i++)
- res[i] = _resLists[typeNum][i].id;
-
- return res;
-}
-
-char *MacResManager::getResName(const char *typeID, int16 resID) {
- int i;
- int typeNum = -1;
-
- for (i = 0; i < _resMap.numTypes; i++)
- if (strcmp(_resTypes[i].id, typeID) == 0) {
- typeNum = i;
- break;
- }
-
- if (typeNum == -1)
- return NULL;
-
- for (i = 0; i < _resTypes[typeNum].items; i++)
- if (_resLists[typeNum][i].id == resID)
- return _resLists[typeNum][i].name;
-
- return NULL;
-}
-
-byte *MacResManager::getResource(const char *typeID, int16 resID, int *size) {
- int i;
- int typeNum = -1;
- int resNum = -1;
- byte *buf;
- int len;
-
- for (i = 0; i < _resMap.numTypes; i++)
- if (strcmp(_resTypes[i].id, typeID) == 0) {
- typeNum = i;
- break;
- }
-
- if (typeNum == -1)
- return NULL;
-
- for (i = 0; i < _resTypes[typeNum].items; i++)
- if (_resLists[typeNum][i].id == resID) {
- resNum = i;
- break;
- }
-
- if (resNum == -1)
- return NULL;
-
- _resFile.seek(_dataOffset + _resLists[typeNum][resNum].dataOffset);
-
- len = _resFile.readUint32BE();
- buf = (byte *)malloc(len);
-
- _resFile.read(buf, len);
-
- *size = len;
-
- return buf;
-}
-
-void MacResManager::readMap() {
- int i, j, len;
-
- _resFile.seek(_mapOffset + 22);
-
- _resMap.resAttr = _resFile.readUint16BE();
- _resMap.typeOffset = _resFile.readUint16BE();
- _resMap.nameOffset = _resFile.readUint16BE();
- _resMap.numTypes = _resFile.readUint16BE();
- _resMap.numTypes++;
-
- _resFile.seek(_mapOffset + _resMap.typeOffset + 2);
- _resTypes = new ResType[_resMap.numTypes];
-
- for (i = 0; i < _resMap.numTypes; i++) {
- _resFile.read(_resTypes[i].id, 4);
- _resTypes[i].id[4] = 0;
- _resTypes[i].items = _resFile.readUint16BE();
- _resTypes[i].offset = _resFile.readUint16BE();
- _resTypes[i].items++;
-
- debug(8, "resType: <%s> items: %d offset: %d (0x%x)", _resTypes[i].id, _resTypes[i].items, _resTypes[i].offset, _resTypes[i].offset);
- }
-
- _resLists = new ResPtr[_resMap.numTypes];
-
- for (i = 0; i < _resMap.numTypes; i++) {
- _resLists[i] = new Resource[_resTypes[i].items];
- _resFile.seek(_resTypes[i].offset + _mapOffset + _resMap.typeOffset);
-
- for (j = 0; j < _resTypes[i].items; j++) {
- ResPtr resPtr = _resLists[i] + j;
-
- resPtr->id = _resFile.readUint16BE();
- resPtr->nameOffset = _resFile.readUint16BE();
- resPtr->dataOffset = _resFile.readUint32BE();
- _resFile.readUint32BE();
- resPtr->name = 0;
-
- resPtr->attr = resPtr->dataOffset >> 24;
- resPtr->dataOffset &= 0xFFFFFF;
- }
-
- for (j = 0; j < _resTypes[i].items; j++) {
- if (_resLists[i][j].nameOffset != -1) {
- _resFile.seek(_resLists[i][j].nameOffset + _mapOffset + _resMap.nameOffset);
-
- len = _resFile.readByte();
- _resLists[i][j].name = new char[len + 1];
- _resLists[i][j].name[len] = 0;
- _resFile.read(_resLists[i][j].name, len);
- }
- }
- }
-}
-
-void MacResManager::convertCursor(byte *data, int datasize, byte **cursor, int *w, int *h,
- int *hotspot_x, int *hotspot_y, int *keycolor, bool colored, byte **palette, int *palSize) {
- Common::MemoryReadStream dis(data, datasize);
- int i, b;
- byte imageByte;
- byte *iconData;
- int numBytes;
- int pixelsPerByte, bpp;
- int ctSize;
- byte bitmask;
- int iconRowBytes, iconBounds[4];
- int ignored;
- int iconDataSize;
-
- dis.readUint16BE(); // type
- dis.readUint32BE(); // offset to pixel map
- dis.readUint32BE(); // offset to pixel data
- dis.readUint32BE(); // expanded cursor data
- dis.readUint16BE(); // expanded data depth
- dis.readUint32BE(); // reserved
-
- // Grab B/W icon data
- *cursor = (byte *)malloc(16 * 16);
- for (i = 0; i < 32; i++) {
- imageByte = dis.readByte();
- for (b = 0; b < 8; b++)
- cursor[0][i*8+b] = (byte)((imageByte &
- (0x80 >> b)) > 0? 0x0F: 0x00);
- }
-
- // Apply mask data
- for (i = 0; i < 32; i++) {
- imageByte = dis.readByte();
- for (b = 0; b < 8; b++)
- if ((imageByte & (0x80 >> b)) == 0)
- cursor[0][i*8+b] = 0xff;
- }
-
- *hotspot_y = dis.readUint16BE();
- *hotspot_x = dis.readUint16BE();
- *w = *h = 16;
-
- // Use b/w cursor on backends which don't support cursor palettes
- if (!colored)
- return;
-
- dis.readUint32BE(); // reserved
- dis.readUint32BE(); // cursorID
-
- // Color version of cursor
- dis.readUint32BE(); // baseAddr
-
- // Keep only lowbyte for now
- dis.readByte();
- iconRowBytes = dis.readByte();
-
- if (!iconRowBytes)
- return;
-
- iconBounds[0] = dis.readUint16BE();
- iconBounds[1] = dis.readUint16BE();
- iconBounds[2] = dis.readUint16BE();
- iconBounds[3] = dis.readUint16BE();
-
- dis.readUint16BE(); // pmVersion
- dis.readUint16BE(); // packType
- dis.readUint32BE(); // packSize
-
- dis.readUint32BE(); // hRes
- dis.readUint32BE(); // vRes
-
- dis.readUint16BE(); // pixelType
- dis.readUint16BE(); // pixelSize
- dis.readUint16BE(); // cmpCount
- dis.readUint16BE(); // cmpSize
-
- dis.readUint32BE(); // planeByte
- dis.readUint32BE(); // pmTable
- dis.readUint32BE(); // reserved
-
- // Pixel data for cursor
- iconDataSize = iconRowBytes * (iconBounds[3] - iconBounds[1]);
- iconData = (byte *)malloc(iconDataSize);
- dis.read(iconData, iconDataSize);
-
- // Color table
- dis.readUint32BE(); // ctSeed
- dis.readUint16BE(); // ctFlag
- ctSize = dis.readUint16BE() + 1;
-
- *palette = (byte *)malloc(ctSize * 4);
-
- // Read just high byte of 16-bit color
- for (int c = 0; c < ctSize; c++) {
- // We just use indices 0..ctSize, so ignore color ID
- dis.readUint16BE(); // colorID[c]
-
- palette[0][c * 4 + 0] = dis.readByte();
- ignored = dis.readByte();
-
- palette[0][c * 4 + 1] = dis.readByte();
- ignored = dis.readByte();
-
- palette[0][c * 4 + 2] = dis.readByte();
- ignored = dis.readByte();
-
- palette[0][c * 4 + 3] = 0;
- }
-
- *palSize = ctSize;
-
- numBytes =
- (iconBounds[2] - iconBounds[0]) *
- (iconBounds[3] - iconBounds[1]);
-
- pixelsPerByte = (iconBounds[2] - iconBounds[0]) / iconRowBytes;
- bpp = 8 / pixelsPerByte;
-
- // build a mask to make sure the pixels are properly shifted out
- bitmask = 0;
- for (int m = 0; m < bpp; m++) {
- bitmask <<= 1;
- bitmask |= 1;
- }
-
- // Extract pixels from bytes
- for (int j = 0; j < iconDataSize; j++)
- for (b = 0; b < pixelsPerByte; b++) {
- int idx = j * pixelsPerByte + (pixelsPerByte - 1 - b);
-
- if (cursor[0][idx] != 0xff) // if mask is not there
- cursor[0][idx] = (byte)((iconData[j] >> (b * bpp)) & bitmask);
- }
-
- free(iconData);
-
- assert(datasize - dis.pos() == 0);
-}
-
-} // End of namespace Wage
diff --git a/engines/wage/macresman.h b/engines/wage/macresman.h
deleted file mode 100644
index c09f4f7..0000000
--- a/engines/wage/macresman.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "common/array.h"
-#include "common/file.h"
-
-#ifndef WAGE_MACRESMAN_H
-#define WAGE_MACRESMAN_H
-
-namespace Wage {
-
-typedef Common::Array<int16> MacResIDArray;
-
-class MacResManager {
-
-public:
- MacResManager(Common::String fileName);
- ~MacResManager();
- byte *getResource(const char *typeID, int16 resID, int *size);
- char *getResName(const char *typeID, int16 resID);
- void convertCursor(byte *data, int datasize, byte **cursor, int *w, int *h,
- int *hotspot_x, int *hotspot_y, int *keycolor, bool colored, byte **palette, int *palSize);
-
- MacResIDArray getResIDArray(const char *typeID);
-
- Common::String getFileName() { return _fileName; }
-
-private:
- int extractResource(int id, byte **buf);
- bool init();
- void readMap();
-
- struct ResMap {
- int16 resAttr;
- int16 typeOffset;
- int16 nameOffset;
- int16 numTypes;
- };
-
- struct ResType {
- char id[5];
- int16 items;
- int16 offset;
- };
-
- struct Resource {
- int16 id;
- int16 nameOffset;
- byte attr;
- int32 dataOffset;
- char *name;
- };
-
- typedef Resource *ResPtr;
-
-private:
- int _resOffset;
- int32 _dataOffset;
- int32 _dataLength;
- int32 _mapOffset;
- int32 _mapLength;
- ResMap _resMap;
- ResType *_resTypes;
- ResPtr *_resLists;
-
- Common::String _fileName;
- Common::File _resFile;
-};
-
-} // End of namespace Wage
-
-#endif
diff --git a/engines/wage/module.mk b/engines/wage/module.mk
index e314b1a..19d56cf 100644
--- a/engines/wage/module.mk
+++ b/engines/wage/module.mk
@@ -4,7 +4,6 @@ MODULE_OBJS := \
design.o \
detection.o \
entities.o \
- macresman.o \
script.o \
util.o \
wage.o \
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 1efd3f0..79c48e8 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -31,7 +31,6 @@
#include "common/fs.h"
#include "wage/wage.h"
-#include "wage/macresman.h"
#include "wage/entities.h"
#include "wage/world.h"
@@ -63,7 +62,7 @@ Common::Error WageEngine::run() {
printf("WageEngine::init\n");
// Your main even loop should be (invoked from) here.
- _resManager = new MacResManager(getGameFile());
+ _resManager = new Common::MacResManager(getGameFile());
_world = new World();
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 75a76e1..36ca44b 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -31,13 +31,13 @@
#include "gui/debugger.h"
#include "common/endian.h"
#include "common/rect.h"
+#include "common/macresman.h"
struct ADGameDescription;
namespace Wage {
class Console;
-class MacResManager;
class World;
using Common::String;
@@ -68,7 +68,7 @@ public:
const char *getGameFile() const;
private:
- bool loadWorld(MacResManager *resMan);
+ bool loadWorld(Common::MacResManager *resMan);
private:
Console *_console;
@@ -78,7 +78,7 @@ private:
const ADGameDescription *_gameDescription;
- MacResManager *_resManager;
+ Common::MacResManager *_resManager;
World *_world;
};
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 0e3850c..db71b7e 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -24,7 +24,7 @@
*/
#include "wage/wage.h"
-#include "wage/macresman.h"
+#include "common/macresman.h"
#include "wage/entities.h"
#include "wage/script.h"
#include "wage/world.h"
@@ -39,11 +39,11 @@ World::World() {
_scenes[STORAGESCENE] = &_storageScene;
}
-bool World::loadWorld(MacResManager *resMan) {
+bool World::loadWorld(Common::MacResManager *resMan) {
int resSize;
- MacResIDArray resArray;
+ Common::MacResIDArray resArray;
byte *res;
- MacResIDArray::const_iterator iter;
+ Common::MacResIDArray::const_iterator iter;
if ((resArray = resMan->getResIDArray("GCOD")).size() == 0)
return false;
@@ -169,13 +169,13 @@ void World::loadExternalSounds(String fname) {
}
in.close();
- MacResManager *resMan;
- resMan = new MacResManager(fname);
+ Common::MacResManager *resMan;
+ resMan = new Common::MacResManager(fname);
int resSize;
- MacResIDArray resArray;
+ Common::MacResIDArray resArray;
byte *res;
- MacResIDArray::const_iterator iter;
+ Common::MacResIDArray::const_iterator iter;
resArray = resMan->getResIDArray("ASND");
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
diff --git a/engines/wage/world.h b/engines/wage/world.h
index 0086db2..74bd82a 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -35,7 +35,7 @@ public:
World();
~World();
- bool loadWorld(MacResManager *resMan);
+ bool loadWorld(Common::MacResManager *resMan);
void loadExternalSounds(String fname);
String _name;
Commit: bee9d5e2d9a9bd15e8602440011510289cf7ffb0
https://github.com/scummvm/scummvm/commit/bee9d5e2d9a9bd15e8602440011510289cf7ffb0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Added MIT license to mll relevant files.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/script.cpp
engines/wage/script.h
engines/wage/util.cpp
engines/wage/wage.cpp
engines/wage/wage.h
engines/wage/world.cpp
engines/wage/world.h
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index df78247..a3f5d95 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -18,6 +18,31 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
* $URL$
* $Id$
*
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 49f8487..1f16907 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -18,6 +18,31 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
* $URL$
* $Id$
*
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index c7336b7..50dfa29 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -18,6 +18,31 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
* $URL$
* $Id$
*
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 07ecbd8..4ac63c5 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -18,6 +18,31 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
* $URL$
* $Id$
*
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 03870bf..47e00c1 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -18,6 +18,31 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
* $URL$
* $Id$
*
diff --git a/engines/wage/script.h b/engines/wage/script.h
index f216952..dcbf408 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -18,6 +18,31 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
* $URL$
* $Id$
*
diff --git a/engines/wage/util.cpp b/engines/wage/util.cpp
index d382561..4a9ca67 100644
--- a/engines/wage/util.cpp
+++ b/engines/wage/util.cpp
@@ -18,6 +18,31 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
* $URL$
* $Id$
*
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 79c48e8..a681fc6 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -18,6 +18,31 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
* $URL$
* $Id$
*
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 36ca44b..04a505c 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -18,6 +18,31 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
* $URL$
* $Id$
*
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index db71b7e..8a3d9d5 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -18,6 +18,31 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
* $URL$
* $Id$
*
diff --git a/engines/wage/world.h b/engines/wage/world.h
index 74bd82a..3ffd607 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -18,6 +18,31 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
* $URL$
* $Id$
*
Commit: e8194a6b79e21eed0647a6358802e8349518872d
https://github.com/scummvm/scummvm/commit/e8194a6b79e21eed0647a6358802e8349518872d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Fix compilation under *nix.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/world.cpp
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 8a3d9d5..a2cca7c 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -96,7 +96,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
readS.skip(3);
_aboutMessage = readPascalString(readS);
- if (!stricmp(resMan->getFileName().c_str(), "Scepters"))
+ if (!scumm_stricmp(resMan->getFileName().c_str(), "Scepters"))
readS.skip(1); // ????
_soundLibrary1 = readPascalString(readS);
Commit: 879425385e07e9c8712908066102c0c102e3e40c
https://github.com/scummvm/scummvm/commit/879425385e07e9c8712908066102c0c102e3e40c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Started implementing script execution.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/entities.h
engines/wage/script.cpp
engines/wage/script.h
engines/wage/wage.cpp
engines/wage/wage.h
engines/wage/world.cpp
engines/wage/world.h
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 4ac63c5..f99d6d1 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -59,6 +59,7 @@ class Scene;
class Script;
class Context {
+public:
enum StatVariables {
/** The base physical accuracy of the player. */
PHYS_ACC_BAS = 0,
@@ -118,6 +119,8 @@ public:
}
void setDesignBounds(Common::Rect *bounds);
+
+ String toString() { return _name; }
};
class Chr : public Designed {
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 47e00c1..a478b8b 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -49,9 +49,278 @@
*/
#include "wage/wage.h"
+#include "wage/entities.h"
#include "wage/script.h"
+#include "wage/world.h"
namespace Wage {
+bool Script::execute(World *world, int loopCount, String *inputText, Designed *inputClick, WageEngine *callbacks) {
+ _world = world;
+ _loopCount = loopCount;
+ _inputText = inputText;
+ _inputClick = inputClick;
+ _callbacks = callbacks;
+ _handled = false;
+
+ _index = 12;
+ while (_index < _dataSize) {
+ switch(_data[_index]) {
+ case 0x80: // IF
+ _index++;
+ processIf();
+ break;
+ case 0x87: // EXIT
+ debug(0, "exit at offset %d", _index - 1);
+
+ return true;
+ case 0x89: // MOVE
+ {
+ _index++;
+ Scene *currentScene = _world->_player->_currentScene;
+ processMove();
+ if (_world->_player->_currentScene != currentScene)
+ return true;
+ break;
+ }
+ case 0x8B: // PRINT
+ {
+ _index++;
+ Operand *op = readOperand();
+ // TODO check op type is string or number, or something good...
+ appendText(op->_str);
+ // TODO check data[_index] == 0xFD
+ _index++;
+ break;
+ }
+ case 0x8C: // SOUND
+ {
+ _index++;
+ Operand *op = readOperand();
+ // TODO check op type is string.
+ _handled = true;
+ callbacks->playSound(op->_str);
+ // TODO check data[_index] == 0xFD
+ _index++;
+ break;
+ }
+ case 0x8E: // LET
+ _index++;
+ processLet();
+ break;
+ case 0x95: // MENU
+ {
+ _index++;
+ Operand *op = readStringOperand(); // allows empty menu
+ // TODO check op type is string.
+ _callbacks->setMenu(op->_str);
+ // TODO check data[_index] == 0xFD
+ _index++;
+ }
+ case 0x88: // END
+ _index++;
+ break;
+ default:
+ debug(0, "Unknown opcode: %d", _index);
+ }
+ }
+
+
+ if (_world->_globalScript != this) {
+ debug(0, "Executing global script...");
+ bool globalHandled = _world->_globalScript->execute(_world, _loopCount, _inputText, _inputClick, _callbacks);
+ if (globalHandled)
+ _handled = true;
+ }
+
+#if 0
+ else if (inputText != null) {
+ String input = inputText.toLowerCase();
+ if (input.equals("n") || input.contains("north")) {
+ handleMoveCommand(Scene.NORTH, "north");
+ } else if (input.equals("e") || input.contains("east")) {
+ handleMoveCommand(Scene.EAST, "east");
+ } else if (input.equals("s") || input.contains("south")) {
+ handleMoveCommand(Scene.SOUTH, "south");
+ } else if (input.equals("w") || input.contains("west")) {
+ handleMoveCommand(Scene.WEST, "west");
+ } else if (input.startsWith("take ")) {
+ handleTakeCommand(input.substring(5));
+ } else if (input.startsWith("get ")) {
+ handleTakeCommand(input.substring(4));
+ } else if (input.startsWith("pick up ")) {
+ handleTakeCommand(input.substring(8));
+ } else if (input.startsWith("drop ")) {
+ handleDropCommand(input.substring(5));
+ } else if (input.startsWith("aim ")) {
+ handleAimCommand(input.substring(4));
+ } else if (input.startsWith("wear ")) {
+ handleWearCommand(input.substring(5));
+ } else if (input.startsWith("put on ")) {
+ handleWearCommand(input.substring(7));
+ } else if (input.startsWith("offer ")) {
+ handleOfferCommand(input.substring(6));
+ } else if (input.contains("look")) {
+ handleLookCommand();
+ } else if (input.contains("inventory")) {
+ handleInventoryCommand();
+ } else if (input.contains("status")) {
+ handleStatusCommand();
+ } else if (input.contains("rest") || input.equals("wait")) {
+ handleRestCommand();
+ } else if (callbacks.getOffer() != null && input.contains("accept")) {
+ handleAcceptCommand();
+ } else {
+ Chr player = world.getPlayer();
+ for (Weapon weapon : player.getWeapons()) {
+ if (tryAttack(weapon, input)) {
+ handleAttack(weapon);
+ break;
+ }
+ }
+ }
+ // TODO: weapons, offer, etc...
+ } else if (inputClick instanceof Obj) {
+ Obj obj = (Obj) inputClick;
+ if (obj.getType() != Obj.IMMOBILE_OBJECT) {
+ takeObj(obj);
+ } else {
+ appendText(obj.getClickMessage());
+ }
+ }
+#endif
+
+ return _handled;
+}
+
+Script::Operand *Script::readOperand() {
+ switch (_data[_index++]) {
+ case 0xA0: // TEXT$
+ return new Operand(_inputText, Operand::TEXT_INPUT);
+ case 0xA1:
+ return new Operand(_inputClick, Operand::CLICK_INPUT);
+ case 0xC0: // STORAGE@
+ return new Operand(&_world->_storageScene, Operand::SCENE);
+ case 0xC1: // SCENE@
+ return new Operand(_world->_player->_currentScene, Operand::SCENE);
+ case 0xC2: // PLAYER@
+ return new Operand(_world->_player, Operand::CHR);
+ case 0xC3: // MONSTER@
+ return new Operand(_callbacks->_monster, Operand::CHR);
+ case 0xC4: // RANDOMSCN@
+ return new Operand(_world->_orderedScenes[_callbacks->_rnd.getRandomNumber(_world->_orderedScenes.size())], Operand::SCENE);
+ case 0xC5: // RANDOMCHR@
+ return new Operand(_world->_orderedChrs[_callbacks->_rnd.getRandomNumber(_world->_orderedChrs.size())], Operand::CHR);
+ case 0xC6: // RANDOMOBJ@
+ return new Operand(_world->_orderedObjs[_callbacks->_rnd.getRandomNumber(_world->_orderedObjs.size())], Operand::OBJ);
+ case 0xB0: // VISITS#
+ return new Operand(_world->_player->_context._visits, Operand::NUMBER);
+ case 0xB1: // RANDOM# for Star Trek, but VISITS# for some other games?
+ return new Operand(1 + _callbacks->_rnd.getRandomNumber(100), Operand::NUMBER);
+ case 0xB5: // RANDOM# // A random number between 1 and 100.
+ return new Operand(1 + _callbacks->_rnd.getRandomNumber(100), Operand::NUMBER);
+ case 0xB2: // LOOP#
+ return new Operand(_loopCount, Operand::NUMBER);
+ case 0xB3: // VICTORY#
+ return new Operand(_world->_player->_context._kills, Operand::NUMBER);
+ case 0xB4: // BADCOPY#
+ return new Operand(0, Operand::NUMBER); // ????
+ case 0xFF:
+ {
+ // user variable
+ int value = _data[_index++];
+ if (value < 0)
+ value += 256;
+
+ // TODO: Verify that we're using the right index.
+ return new Operand(_world->_player->_context._userVariables[value], Operand::NUMBER);
+ }
+ case 0xD0:
+ return new Operand(_world->_player->_context._statVariables[Context::PHYS_STR_BAS], Operand::NUMBER);
+ case 0xD1:
+ return new Operand(_world->_player->_context._statVariables[Context::PHYS_HIT_BAS], Operand::NUMBER);
+ case 0xD2:
+ return new Operand(_world->_player->_context._statVariables[Context::PHYS_ARM_BAS], Operand::NUMBER);
+ case 0xD3:
+ return new Operand(_world->_player->_context._statVariables[Context::PHYS_ACC_BAS], Operand::NUMBER);
+ case 0xD4:
+ return new Operand(_world->_player->_context._statVariables[Context::SPIR_STR_BAS], Operand::NUMBER);
+ case 0xD5:
+ return new Operand(_world->_player->_context._statVariables[Context::SPIR_HIT_BAS], Operand::NUMBER);
+ case 0xD6:
+ return new Operand(_world->_player->_context._statVariables[Context::SPIR_ARM_BAS], Operand::NUMBER);
+ case 0xD7:
+ return new Operand(_world->_player->_context._statVariables[Context::SPIR_ACC_BAS], Operand::NUMBER);
+ case 0xD8:
+ return new Operand(_world->_player->_context._statVariables[Context::PHYS_SPE_BAS], Operand::NUMBER);
+ case 0xE0:
+ return new Operand(_world->_player->_context._statVariables[Context::PHYS_STR_CUR], Operand::NUMBER);
+ case 0xE1:
+ return new Operand(_world->_player->_context._statVariables[Context::PHYS_HIT_CUR], Operand::NUMBER);
+ case 0xE2:
+ return new Operand(_world->_player->_context._statVariables[Context::PHYS_ARM_CUR], Operand::NUMBER);
+ case 0xE3:
+ return new Operand(_world->_player->_context._statVariables[Context::PHYS_ACC_CUR], Operand::NUMBER);
+ case 0xE4:
+ return new Operand(_world->_player->_context._statVariables[Context::SPIR_STR_CUR], Operand::NUMBER);
+ case 0xE5:
+ return new Operand(_world->_player->_context._statVariables[Context::SPIR_HIT_CUR], Operand::NUMBER);
+ case 0xE6:
+ return new Operand(_world->_player->_context._statVariables[Context::SPIR_ARM_CUR], Operand::NUMBER);
+ case 0xE7:
+ return new Operand(_world->_player->_context._statVariables[Context::SPIR_ACC_CUR], Operand::NUMBER);
+ case 0xE8:
+ return new Operand(_world->_player->_context._statVariables[Context::PHYS_SPE_CUR], Operand::NUMBER);
+ default:
+ _index--;
+ if (_data[_index] >= 0x20 && _data[_index] < 0x80) {
+ return readStringOperand();
+ } else {
+ debug("Dunno what %x is (index=%d)!\n", _data[_index], _index);
+ }
+ _index++;
+ return NULL;
+ }
+}
+
+Script::Operand *Script::readStringOperand() {
+ String *sb;
+ bool allDigits = true;
+
+ sb = new String();
+
+ while (_data[_index] >= 0x20 && _data[_index] < 0x80) {
+ char c = _data[_index++];
+ if (c < '0' || c > '9')
+ allDigits = false;
+ *sb += c;
+ }
+
+ if (allDigits && sb->size() > 0) {
+ debug(0, "Read number %s", sb->c_str());
+ int r = atol(sb->c_str());
+ delete sb;
+
+ return new Operand(r, Operand::NUMBER);
+ } else {
+ // TODO: This string could be a room name or something like that.
+ debug(0, "Read string %s", sb->c_str());
+ return new Operand(sb, Operand::STRING);
+ }
+}
+
+void Script::processIf() {
+}
+
+void Script::processMove() {
+}
+
+void Script::processLet() {
+}
+
+void Script::appendText(String str) {
+ _handled = true;
+ _callbacks->appendText(str);
+}
} // End of namespace Wage
diff --git a/engines/wage/script.h b/engines/wage/script.h
index dcbf408..a5288d6 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -55,11 +55,94 @@ namespace Wage {
class Script {
public:
- Script(byte *data) : _data(data) {}
+ Script(byte *data, int dataSize) : _data(data), _dataSize(dataSize) {}
~Script();
private:
byte *_data;
+ int _dataSize;
+
+ WageEngine *_callbacks;
+ World *_world;
+ int _loopCount;
+ String *_inputText;
+ Designed *_inputClick;
+ int _index;
+ bool _evalResult;
+ bool _handled;
+
+ class Operand {
+ public:
+ enum OperandTypes {
+ OBJ = 0,
+ CHR = 1,
+ SCENE = 2,
+ NUMBER = 3,
+ STRING = 4,
+ CLICK_INPUT = 5,
+ TEXT_INPUT = 6
+ };
+
+ union {
+ Obj *obj;
+ Chr *chr;
+ Scene *scene;
+ int16 number;
+ String *string;
+ Designed *inputClick;
+ } _value;
+ OperandTypes _type;
+ String _str;
+
+ Operand(Obj *value, OperandTypes type) {
+ _value.obj = value;
+ _str = value->toString();
+ _type = type;
+ }
+
+ Operand(Chr *value, OperandTypes type) {
+ _value.chr = value;
+ _str = value->toString();
+ _type = type;
+ }
+
+ Operand(Scene *value, OperandTypes type) {
+ _value.scene = value;
+ _str = value->toString();
+ _type = type;
+ }
+
+ Operand(int value, OperandTypes type) {
+ char buf[30];
+ _value.number = value;
+ snprintf(buf, 30, "%d", value);
+ _str = value;
+ _type = type;
+ }
+
+ Operand(String *value, OperandTypes type) {
+ _value.string = value;
+ _str = *value;
+ _type = type;
+ }
+
+ Operand(Designed *value, OperandTypes type) {
+ _value.inputClick = value;
+ _str = value->toString();
+ _type = type;
+ }
+ };
+
+
+ bool execute(World *world, int loopCount, String *inputText, Designed *inputClick, WageEngine *callbacks);
+ Operand *readOperand();
+ Operand *readStringOperand();
+ void processIf();
+ void processMove();
+ void processLet();
+
+ void appendText(String str);
+
};
} // End of namespace Wage
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index a681fc6..2be43e7 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -64,6 +64,8 @@ namespace Wage {
WageEngine::WageEngine(OSystem *syst, const ADGameDescription *desc) : Engine(syst), _gameDescription(desc) {
// Don't forget to register your random source
g_eventRec.registerRandomSource(_rnd, "wage");
+
+ _aim = -1;
printf("WageEngine::WageEngine\n");
}
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 04a505c..5c56d74 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -64,6 +64,9 @@ namespace Wage {
class Console;
class World;
+class Scene;
+class Obj;
+class Chr;
using Common::String;
@@ -95,17 +98,35 @@ public:
private:
bool loadWorld(Common::MacResManager *resMan);
-private:
- Console *_console;
-
+public:
// We need random numbers
Common::RandomSource _rnd;
+ World *_world;
+
+ Scene *_lastScene;
+ //PrintStream out;
+ int _loopCount;
+ int _turn;
+ //Callbacks callbacks;
+ Chr *_monster;
+ Obj *_offer;
+ bool _commandWasQuick;
+ int _aim;
+ bool _temporarilyHidden;
+
+ void playSound(String soundName) {}
+ void setMenu(String soundName) {}
+ void appendText(String str) {}
+
+
+private:
+ Console *_console;
+
const ADGameDescription *_gameDescription;
Common::MacResManager *_resManager;
- World *_world;
};
// Example console class
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index a2cca7c..c8ed238 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -75,7 +75,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
// Load global script
res = resMan->getResource("GCOD", resArray[0], &resSize);
- _globalScript = new Script(res);
+ _globalScript = new Script(res, resSize);
// Load main configuration
if ((resArray = resMan->getResIDArray("VERS")).size() == 0)
@@ -112,7 +112,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
res = resMan->getResource("ACOD", *iter, &resSize);
if (res != NULL)
- scene->_script = new Script(res);
+ scene->_script = new Script(res, resSize);
res = resMan->getResource("ATXT", *iter, &resSize);
if (res != NULL) {
diff --git a/engines/wage/world.h b/engines/wage/world.h
index 3ffd607..30832a6 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -74,11 +74,11 @@ public:
Common::HashMap<String, Obj *> _objs;
Common::HashMap<String, Chr *> _chrs;
Common::HashMap<String, Sound *> _sounds;
- Common::List<Scene *> _orderedScenes;
- Common::List<Obj *> _orderedObjs;
- Common::List<Chr *> _orderedChrs;
- Common::List<Sound *> _orderedSounds;
- Common::List<byte *> _patterns;
+ Common::Array<Scene *> _orderedScenes;
+ Common::Array<Obj *> _orderedObjs;
+ Common::Array<Chr *> _orderedChrs;
+ Common::Array<Sound *> _orderedSounds;
+ Common::Array<byte *> _patterns;
Scene _storageScene;
Chr *_player;
//List<MoveListener> moveListeners;
Commit: 2910ff45d800f543475608de04108ff0bae9b59c
https://github.com/scummvm/scummvm/commit/2910ff45d800f543475608de04108ff0bae9b59c
Author: D G Turner (digitall at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Add .gitignore file.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
A engines/wage/.gitignore
diff --git a/engines/wage/.gitignore b/engines/wage/.gitignore
new file mode 100644
index 0000000..81a48b8
--- /dev/null
+++ b/engines/wage/.gitignore
@@ -0,0 +1,3 @@
+.deps
+*.o
+lib*.a
Commit: aabe774cbe962491457ec17df9545642716d8315
https://github.com/scummvm/scummvm/commit/aabe774cbe962491457ec17df9545642716d8315
Author: D G Turner (digitall at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Update Engine Code For Common::RandomSource API Changes.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/script.cpp
engines/wage/wage.cpp
engines/wage/wage.h
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index a478b8b..685ba66 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -208,17 +208,17 @@ Script::Operand *Script::readOperand() {
case 0xC3: // MONSTER@
return new Operand(_callbacks->_monster, Operand::CHR);
case 0xC4: // RANDOMSCN@
- return new Operand(_world->_orderedScenes[_callbacks->_rnd.getRandomNumber(_world->_orderedScenes.size())], Operand::SCENE);
+ return new Operand(_world->_orderedScenes[_callbacks->_rnd->getRandomNumber(_world->_orderedScenes.size())], Operand::SCENE);
case 0xC5: // RANDOMCHR@
- return new Operand(_world->_orderedChrs[_callbacks->_rnd.getRandomNumber(_world->_orderedChrs.size())], Operand::CHR);
+ return new Operand(_world->_orderedChrs[_callbacks->_rnd->getRandomNumber(_world->_orderedChrs.size())], Operand::CHR);
case 0xC6: // RANDOMOBJ@
- return new Operand(_world->_orderedObjs[_callbacks->_rnd.getRandomNumber(_world->_orderedObjs.size())], Operand::OBJ);
+ return new Operand(_world->_orderedObjs[_callbacks->_rnd->getRandomNumber(_world->_orderedObjs.size())], Operand::OBJ);
case 0xB0: // VISITS#
return new Operand(_world->_player->_context._visits, Operand::NUMBER);
case 0xB1: // RANDOM# for Star Trek, but VISITS# for some other games?
- return new Operand(1 + _callbacks->_rnd.getRandomNumber(100), Operand::NUMBER);
+ return new Operand(1 + _callbacks->_rnd->getRandomNumber(100), Operand::NUMBER);
case 0xB5: // RANDOM# // A random number between 1 and 100.
- return new Operand(1 + _callbacks->_rnd.getRandomNumber(100), Operand::NUMBER);
+ return new Operand(1 + _callbacks->_rnd->getRandomNumber(100), Operand::NUMBER);
case 0xB2: // LOOP#
return new Operand(_loopCount, Operand::NUMBER);
case 0xB3: // VICTORY#
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 2be43e7..35dc36e 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -62,8 +62,7 @@
namespace Wage {
WageEngine::WageEngine(OSystem *syst, const ADGameDescription *desc) : Engine(syst), _gameDescription(desc) {
- // Don't forget to register your random source
- g_eventRec.registerRandomSource(_rnd, "wage");
+ _rnd = new Common::RandomSource("wage");
_aim = -1;
@@ -76,6 +75,7 @@ WageEngine::~WageEngine() {
// Remove all of our debug levels here
Common::clearAllDebugChannels();
+ delete _rnd;
}
Common::Error WageEngine::run() {
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 5c56d74..0c70b5c 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -57,6 +57,7 @@
#include "common/endian.h"
#include "common/rect.h"
#include "common/macresman.h"
+#include "common/random.h"
struct ADGameDescription;
@@ -99,8 +100,7 @@ private:
bool loadWorld(Common::MacResManager *resMan);
public:
- // We need random numbers
- Common::RandomSource _rnd;
+ Common::RandomSource *_rnd;
World *_world;
Commit: 83617a77da8dc486c042b19a6c496ea343a7f9af
https://github.com/scummvm/scummvm/commit/83617a77da8dc486c042b19a6c496ea343a7f9af
Author: D G Turner (digitall at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Update Engine For Changes To Advanced Detector API.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/detection.cpp
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
index 3c5ac73..fcdc5df 100644
--- a/engines/wage/detection.cpp
+++ b/engines/wage/detection.cpp
@@ -66,6 +66,10 @@ static const ADGameDescription gameDescriptions[] = {
} // End of namespace Wage
+static const char *directoryGlobs[] = {
+ 0
+};
+
static const ADParams detectionParams = {
// Pointer to ADGameDescription or its superset structure
(const byte *)Wage::gameDescriptions,
@@ -84,7 +88,11 @@ static const ADParams detectionParams = {
// Flags
0,
// Additional GUI options (for every game}
- Common::GUIO_NOSPEECH | Common::GUIO_NOMIDI
+ Common::GUIO_NOSPEECH | Common::GUIO_NOMIDI,
+ // Maximum directory depth
+ 0,
+ // List of directory globs
+ directoryGlobs
};
class WageMetaEngine : public AdvancedMetaEngine {
Commit: 9d448131c5ca4718cf2aa6a23c1515156db8cc8d
https://github.com/scummvm/scummvm/commit/9d448131c5ca4718cf2aa6a23c1515156db8cc8d
Author: D G Turner (digitall at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Update Engine For MKID_BE to MKTAG Change.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/detection.cpp
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
index fcdc5df..8f1b623 100644
--- a/engines/wage/detection.cpp
+++ b/engines/wage/detection.cpp
@@ -136,7 +136,7 @@ bool WageMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGame
}
SaveStateList WageMetaEngine::listSaves(const char *target) const {
- const uint32 WAGEflag = MKID_BE('WAGE');
+ const uint32 WAGEflag = MKTAG('W','A','G','E');
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::StringList filenames;
char saveDesc[31];
Commit: 0ee543b9fb6525aa1401599fb451f62636d3425c
https://github.com/scummvm/scummvm/commit/0ee543b9fb6525aa1401599fb451f62636d3425c
Author: D G Turner (digitall at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: StringList Replaced by StringArray...
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/detection.cpp
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
index 8f1b623..976ec0f 100644
--- a/engines/wage/detection.cpp
+++ b/engines/wage/detection.cpp
@@ -138,7 +138,7 @@ bool WageMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGame
SaveStateList WageMetaEngine::listSaves(const char *target) const {
const uint32 WAGEflag = MKTAG('W','A','G','E');
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
- Common::StringList filenames;
+ Common::StringArray filenames;
char saveDesc[31];
Common::String pattern = target;
pattern += ".???";
@@ -147,7 +147,7 @@ SaveStateList WageMetaEngine::listSaves(const char *target) const {
sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
SaveStateList saveList;
- for (Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+ for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
int slotNum = atoi(file->c_str() + file->size() - 3);
Commit: 37e5e205ccc00e52342b4d6ebdbcf3112613b09f
https://github.com/scummvm/scummvm/commit/37e5e205ccc00e52342b4d6ebdbcf3112613b09f
Author: D G Turner (digitall at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Updated Engine for MemoryReadStream Header Change.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/entities.cpp
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 50dfa29..10f1139 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -52,7 +52,7 @@
#include "wage/entities.h"
#include "wage/design.h"
-#include "common/stream.h"
+#include "common/memstream.h"
namespace Wage {
Commit: 2442f12bb471792228fb0399644049ab67a20371
https://github.com/scummvm/scummvm/commit/2442f12bb471792228fb0399644049ab67a20371
Author: D G Turner (digitall at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Replace Forbidden Printf calls with debug() calls.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/wage.cpp
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 35dc36e..79400e9 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -66,12 +66,12 @@ WageEngine::WageEngine(OSystem *syst, const ADGameDescription *desc) : Engine(sy
_aim = -1;
- printf("WageEngine::WageEngine\n");
+ debug("WageEngine::WageEngine()");
}
WageEngine::~WageEngine() {
// Dispose your resources here
- printf("WageEngine::~WageEngine\n");
+ debug("WageEngine::~WageEngine()");
// Remove all of our debug levels here
Common::clearAllDebugChannels();
@@ -86,7 +86,7 @@ Common::Error WageEngine::run() {
_console = new Console(this);
// Additional setup.
- printf("WageEngine::init\n");
+ debug("WageEngine::init");
// Your main even loop should be (invoked from) here.
_resManager = new Common::MacResManager(getGameFile());
Commit: 5926af06f15be989dac61b6134a29a21d2d44e1d
https://github.com/scummvm/scummvm/commit/5926af06f15be989dac61b6134a29a21d2d44e1d
Author: D G Turner (digitall at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Correct Engine For DebugMan API Changes.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/wage.cpp
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 79400e9..efdd3f0 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -51,6 +51,7 @@
#include "common/scummsys.h"
#include "common/config-manager.h"
+#include "common/debug-channels.h"
#include "common/EventRecorder.h"
#include "common/file.h"
#include "common/fs.h"
@@ -73,8 +74,7 @@ WageEngine::~WageEngine() {
// Dispose your resources here
debug("WageEngine::~WageEngine()");
- // Remove all of our debug levels here
- Common::clearAllDebugChannels();
+ DebugMan.clearAllDebugChannels();
delete _rnd;
}
Commit: ff672c771c52e01ee5eb56f2aed1fcabef601305
https://github.com/scummvm/scummvm/commit/ff672c771c52e01ee5eb56f2aed1fcabef601305
Author: D G Turner (digitall at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Add Missing Required Engine Headers.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/wage.cpp
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index efdd3f0..14287d0 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -52,9 +52,12 @@
#include "common/config-manager.h"
#include "common/debug-channels.h"
+#include "common/error.h"
#include "common/EventRecorder.h"
#include "common/file.h"
#include "common/fs.h"
+
+#include "engines/util.h"
#include "wage/wage.h"
#include "wage/entities.h"
Commit: 0593022a73da4419a09d0b73f47e7df7627f1f66
https://github.com/scummvm/scummvm/commit/0593022a73da4419a09d0b73f47e7df7627f1f66
Author: D G Turner (digitall at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Correction For MacResManager Constructor Changes.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/wage.cpp
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 14287d0..fe6cf90 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -92,7 +92,8 @@ Common::Error WageEngine::run() {
debug("WageEngine::init");
// Your main even loop should be (invoked from) here.
- _resManager = new Common::MacResManager(getGameFile());
+ _resManager = new Common::MacResManager();
+ _resManager->open(getGameFile());
_world = new World();
Commit: 691e9134c4a42368415147f689313076ed8ea255
https://github.com/scummvm/scummvm/commit/691e9134c4a42368415147f689313076ed8ea255
Author: D G Turner (digitall at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Minor Comment Corrections and Removal.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/wage.cpp
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index fe6cf90..eeae2fa 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -74,7 +74,6 @@ WageEngine::WageEngine(OSystem *syst, const ADGameDescription *desc) : Engine(sy
}
WageEngine::~WageEngine() {
- // Dispose your resources here
debug("WageEngine::~WageEngine()");
DebugMan.clearAllDebugChannels();
@@ -82,16 +81,14 @@ WageEngine::~WageEngine() {
}
Common::Error WageEngine::run() {
- // Initialize graphics using following:
initGraphics(320, 200, false);
// Create debugger console. It requires GFX to be initialized
_console = new Console(this);
- // Additional setup.
debug("WageEngine::init");
- // Your main even loop should be (invoked from) here.
+ // Your main event loop should be (invoked from) here.
_resManager = new Common::MacResManager();
_resManager->open(getGameFile());
Commit: af656f220a9fb9a2e294342732b0de54a73449e3
https://github.com/scummvm/scummvm/commit/af656f220a9fb9a2e294342732b0de54a73449e3
Author: D G Turner (digitall at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Add Missing Headers For World Class.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/world.cpp
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index c8ed238..c78a58d 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -49,12 +49,13 @@
*/
#include "wage/wage.h"
-#include "common/macresman.h"
#include "wage/entities.h"
#include "wage/script.h"
#include "wage/world.h"
-#include "common/stream.h"
+#include "common/file.h"
+#include "common/macresman.h"
+#include "common/memstream.h"
namespace Wage {
Commit: 2fde3eaabbef1fd809bd3268dfd22f4fbab77efd
https://github.com/scummvm/scummvm/commit/2fde3eaabbef1fd809bd3268dfd22f4fbab77efd
Author: D G Turner (digitall at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Update World Class with MKTAG fourCC.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/world.cpp
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index c78a58d..a2f01ce 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -71,21 +71,21 @@ bool World::loadWorld(Common::MacResManager *resMan) {
byte *res;
Common::MacResIDArray::const_iterator iter;
- if ((resArray = resMan->getResIDArray("GCOD")).size() == 0)
+ if ((resArray = resMan->getResIDArray(MKTAG('G','C','O','D'))).size() == 0)
return false;
// Load global script
- res = resMan->getResource("GCOD", resArray[0], &resSize);
+ res = resMan->getResource(MKTAG('G','C','O','D'), resArray[0], &resSize);
_globalScript = new Script(res, resSize);
// Load main configuration
- if ((resArray = resMan->getResIDArray("VERS")).size() == 0)
+ if ((resArray = resMan->getResIDArray(MKTAG('V','E','R','S'))).size() == 0)
return false;
if (resArray.size() > 1)
warning("Too many VERS resources");
- res = resMan->getResource("VERS", resArray[0], &resSize);
+ res = resMan->getResource(MKTAG('V','E','R','S'), resArray[0], &resSize);
Common::MemoryReadStream readS(res, resSize);
readS.skip(10);
@@ -106,16 +106,16 @@ bool World::loadWorld(Common::MacResManager *resMan) {
free(res);
// Load scenes
- resArray = resMan->getResIDArray("ASCN");
+ resArray = resMan->getResIDArray(MKTAG('A','S','C','N'));
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
- res = resMan->getResource("ASCN", *iter, &resSize);
- Scene *scene = new Scene(resMan->getResName("ASCN", *iter), res, resSize);
+ res = resMan->getResource(MKTAG('A','S','C','N'), *iter, &resSize);
+ Scene *scene = new Scene(resMan->getResName(MKTAG('A','S','C','N'), *iter), res, resSize);
- res = resMan->getResource("ACOD", *iter, &resSize);
+ res = resMan->getResource(MKTAG('A','C','O','D'), *iter, &resSize);
if (res != NULL)
scene->_script = new Script(res, resSize);
- res = resMan->getResource("ATXT", *iter, &resSize);
+ res = resMan->getResource(MKTAG('A','T','X','T'), *iter, &resSize);
if (res != NULL) {
Common::MemoryReadStream readT(res, resSize);
scene->_textBounds = readRect(readT);
@@ -134,17 +134,17 @@ bool World::loadWorld(Common::MacResManager *resMan) {
}
// Load Objects
- resArray = resMan->getResIDArray("AOBJ");
+ resArray = resMan->getResIDArray(MKTAG('A','O','B','J'));
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
- res = resMan->getResource("AOBJ", *iter, &resSize);
- addObj(new Obj(resMan->getResName("AOBJ", *iter), res, resSize));
+ res = resMan->getResource(MKTAG('A','O','B','J'), *iter, &resSize);
+ addObj(new Obj(resMan->getResName(MKTAG('A','O','B','J'), *iter), res, resSize));
}
// Load Characters
- resArray = resMan->getResIDArray("ACHR");
+ resArray = resMan->getResIDArray(MKTAG('A','C','H','R'));
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
- res = resMan->getResource("ACHR", *iter, &resSize);
- Chr *chr = new Chr(resMan->getResName("ACHR", *iter), res, resSize);
+ res = resMan->getResource(MKTAG('A','C','H','R'), *iter, &resSize);
+ Chr *chr = new Chr(resMan->getResName(MKTAG('A','C','H','R'), *iter), res, resSize);
addChr(chr);
// TODO: What if there's more than one player character?
@@ -153,10 +153,10 @@ bool World::loadWorld(Common::MacResManager *resMan) {
}
// Load Sounds
- resArray = resMan->getResIDArray("ASND");
+ resArray = resMan->getResIDArray(MKTAG('A','S','N','D'));
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
- res = resMan->getResource("ASND", *iter, &resSize);
- addSound(new Sound(resMan->getResName("ASND", *iter), res, resSize));
+ res = resMan->getResource(MKTAG('A','S','N','D'), *iter, &resSize);
+ addSound(new Sound(resMan->getResName(MKTAG('A','S','N','D')), *iter), res, resSize));
}
if (_soundLibrary1.size() > 0) {
@@ -167,7 +167,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
}
// Load Patterns
- res = resMan->getResource("PAT#", 900, &resSize);
+ res = resMan->getResource(MKTAG('P','A','T','#'), 900, &resSize);
if (res != NULL) {
Common::MemoryReadStream readP(res, resSize);
int count = readP.readUint16BE();
@@ -203,10 +203,10 @@ void World::loadExternalSounds(String fname) {
byte *res;
Common::MacResIDArray::const_iterator iter;
- resArray = resMan->getResIDArray("ASND");
+ resArray = resMan->getResIDArray(MKTAG('A','S','N','D'));
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
- res = resMan->getResource("ASND", *iter, &resSize);
- addSound(new Sound(resMan->getResName("ASND", *iter), res, resSize));
+ res = resMan->getResource(MKTAG('A','S','N','D'), *iter, &resSize);
+ addSound(new Sound(resMan->getResName(MKTAG('A','S','N','D'), *iter), res, resSize));
}
}
Commit: 57b464b2e9c8d5e8aff0d5c35e1f8fcb1ef2ae90
https://github.com/scummvm/scummvm/commit/57b464b2e9c8d5e8aff0d5c35e1f8fcb1ef2ae90
Author: D G Turner (digitall at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: More Updates To World Class for MacResManager API Changes.
Still will not compile as need to deal with propagating
SeekableReadStream instead of (byte* res, int resSize) parameters.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/world.cpp
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index a2f01ce..d33ca69 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -66,17 +66,16 @@ World::World() {
}
bool World::loadWorld(Common::MacResManager *resMan) {
- int resSize;
Common::MacResIDArray resArray;
- byte *res;
+ Common::SeekableReadStream *res;
Common::MacResIDArray::const_iterator iter;
if ((resArray = resMan->getResIDArray(MKTAG('G','C','O','D'))).size() == 0)
return false;
// Load global script
- res = resMan->getResource(MKTAG('G','C','O','D'), resArray[0], &resSize);
- _globalScript = new Script(res, resSize);
+ res = resMan->getResource(MKTAG('G','C','O','D'), resArray[0]);
+ _globalScript = new Script(res, res->size());
// Load main configuration
if ((resArray = resMan->getResIDArray(MKTAG('V','E','R','S'))).size() == 0)
@@ -85,9 +84,9 @@ bool World::loadWorld(Common::MacResManager *resMan) {
if (resArray.size() > 1)
warning("Too many VERS resources");
- res = resMan->getResource(MKTAG('V','E','R','S'), resArray[0], &resSize);
+ res = resMan->getResource(MKTAG('V','E','R','S'), resArray[0]);
- Common::MemoryReadStream readS(res, resSize);
+ Common::MemoryReadStream readS(res, res->size());
readS.skip(10);
byte b = readS.readByte();
_weaponMenuDisabled = (b != 0);
@@ -108,27 +107,27 @@ bool World::loadWorld(Common::MacResManager *resMan) {
// Load scenes
resArray = resMan->getResIDArray(MKTAG('A','S','C','N'));
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
- res = resMan->getResource(MKTAG('A','S','C','N'), *iter, &resSize);
- Scene *scene = new Scene(resMan->getResName(MKTAG('A','S','C','N'), *iter), res, resSize);
+ res = resMan->getResource(MKTAG('A','S','C','N'), *iter);
+ Scene *scene = new Scene(resMan->getResName(MKTAG('A','S','C','N'), *iter), res, res->size());
- res = resMan->getResource(MKTAG('A','C','O','D'), *iter, &resSize);
+ res = resMan->getResource(MKTAG('A','C','O','D'), *iter);
if (res != NULL)
- scene->_script = new Script(res, resSize);
+ scene->_script = new Script(res, res->size());
- res = resMan->getResource(MKTAG('A','T','X','T'), *iter, &resSize);
+ res = resMan->getResource(MKTAG('A','T','X','T'), *iter);
if (res != NULL) {
- Common::MemoryReadStream readT(res, resSize);
+ Common::MemoryReadStream readT(res, res->size());
scene->_textBounds = readRect(readT);
scene->_fontType = readT.readUint16BE();
scene->_fontSize = readT.readUint16BE();
- for (int i = 12; i < resSize; i++)
+ for (int i = 12; i < res->size(); i++)
if (res[i] == 0x0d)
res[i] = '\n';
- String text(&((char*)res)[12], resSize - 12);
+ String text(&((char*)res)[12], res->size() - 12);
scene->_text = text;
- free(res);
+ delete res;
}
addScene(scene);
}
@@ -136,15 +135,15 @@ bool World::loadWorld(Common::MacResManager *resMan) {
// Load Objects
resArray = resMan->getResIDArray(MKTAG('A','O','B','J'));
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
- res = resMan->getResource(MKTAG('A','O','B','J'), *iter, &resSize);
- addObj(new Obj(resMan->getResName(MKTAG('A','O','B','J'), *iter), res, resSize));
+ res = resMan->getResource(MKTAG('A','O','B','J'), *iter);
+ addObj(new Obj(resMan->getResName(MKTAG('A','O','B','J'), *iter), res, res->size()));
}
// Load Characters
resArray = resMan->getResIDArray(MKTAG('A','C','H','R'));
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
- res = resMan->getResource(MKTAG('A','C','H','R'), *iter, &resSize);
- Chr *chr = new Chr(resMan->getResName(MKTAG('A','C','H','R'), *iter), res, resSize);
+ res = resMan->getResource(MKTAG('A','C','H','R'), *iter);
+ Chr *chr = new Chr(resMan->getResName(MKTAG('A','C','H','R'), *iter), res, res->size());
addChr(chr);
// TODO: What if there's more than one player character?
@@ -155,8 +154,8 @@ bool World::loadWorld(Common::MacResManager *resMan) {
// Load Sounds
resArray = resMan->getResIDArray(MKTAG('A','S','N','D'));
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
- res = resMan->getResource(MKTAG('A','S','N','D'), *iter, &resSize);
- addSound(new Sound(resMan->getResName(MKTAG('A','S','N','D')), *iter), res, resSize));
+ res = resMan->getResource(MKTAG('A','S','N','D'), *iter);
+ addSound(new Sound(resMan->getResName(MKTAG('A','S','N','D')), *iter), res, res->size()));
}
if (_soundLibrary1.size() > 0) {
@@ -167,9 +166,9 @@ bool World::loadWorld(Common::MacResManager *resMan) {
}
// Load Patterns
- res = resMan->getResource(MKTAG('P','A','T','#'), 900, &resSize);
+ res = resMan->getResource(MKTAG('P','A','T','#'), 900);
if (res != NULL) {
- Common::MemoryReadStream readP(res, resSize);
+ Common::MemoryReadStream readP(res, res->size());
int count = readP.readUint16BE();
for (int i = 0; i < count; i++) {
byte *pattern = (byte *)malloc(8);
@@ -179,7 +178,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
}
}
- free(res);
+ delete res;
}
return true;
@@ -198,15 +197,14 @@ void World::loadExternalSounds(String fname) {
Common::MacResManager *resMan;
resMan = new Common::MacResManager(fname);
- int resSize;
Common::MacResIDArray resArray;
- byte *res;
+ Common::SeekableReadStream *res;
Common::MacResIDArray::const_iterator iter;
resArray = resMan->getResIDArray(MKTAG('A','S','N','D'));
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
- res = resMan->getResource(MKTAG('A','S','N','D'), *iter, &resSize);
- addSound(new Sound(resMan->getResName(MKTAG('A','S','N','D'), *iter), res, resSize));
+ res = resMan->getResource(MKTAG('A','S','N','D'), *iter);
+ addSound(new Sound(resMan->getResName(MKTAG('A','S','N','D'), *iter), res, res->size()));
}
}
Commit: 624c4018736f93b499597f78b6dabed7e08d1016
https://github.com/scummvm/scummvm/commit/624c4018736f93b499597f78b6dabed7e08d1016
Author: D G Turner (digitall at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Change Script Object to use Common::SeekableReadStream.
This replaces the use of (byte* data, int dataSize) type buffer.
Also, some replacements of code in world object to incorporate.
Still not compilable.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/script.cpp
engines/wage/script.h
engines/wage/world.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 685ba66..dd40497 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -53,6 +53,8 @@
#include "wage/script.h"
#include "wage/world.h"
+#include "common/stream.h"
+
namespace Wage {
bool Script::execute(World *world, int loopCount, String *inputText, Designed *inputClick, WageEngine *callbacks) {
@@ -63,20 +65,18 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
_callbacks = callbacks;
_handled = false;
- _index = 12;
- while (_index < _dataSize) {
- switch(_data[_index]) {
+ _data->skip(12);
+ while (_data->pos() < _data->size()) {
+ switch(_data->readByte()) {
case 0x80: // IF
- _index++;
processIf();
break;
case 0x87: // EXIT
- debug(0, "exit at offset %d", _index - 1);
+ debug(0, "exit at offset %d", _data->pos() - 1);
return true;
case 0x89: // MOVE
{
- _index++;
Scene *currentScene = _world->_player->_currentScene;
processMove();
if (_world->_player->_currentScene != currentScene)
@@ -85,43 +85,41 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
}
case 0x8B: // PRINT
{
- _index++;
Operand *op = readOperand();
// TODO check op type is string or number, or something good...
appendText(op->_str);
- // TODO check data[_index] == 0xFD
- _index++;
+ byte d = _data->readByte();
+ if (d != 0xFD)
+ warning("Operand 0x8B (PRINT) End Byte != 0xFD");
break;
}
case 0x8C: // SOUND
{
- _index++;
Operand *op = readOperand();
// TODO check op type is string.
_handled = true;
callbacks->playSound(op->_str);
- // TODO check data[_index] == 0xFD
- _index++;
+ byte d = _data->readByte();
+ if (d != 0xFD)
+ warning("Operand 0x8B (PRINT) End Byte != 0xFD");
break;
}
case 0x8E: // LET
- _index++;
processLet();
break;
case 0x95: // MENU
{
- _index++;
Operand *op = readStringOperand(); // allows empty menu
// TODO check op type is string.
_callbacks->setMenu(op->_str);
- // TODO check data[_index] == 0xFD
- _index++;
+ byte d = _data->readByte();
+ if (d != 0xFD)
+ warning("Operand 0x8B (PRINT) End Byte != 0xFD");
}
case 0x88: // END
- _index++;
break;
default:
- debug(0, "Unknown opcode: %d", _index);
+ debug(0, "Unknown opcode: %d", _data->pos());
}
}
@@ -194,7 +192,8 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
}
Script::Operand *Script::readOperand() {
- switch (_data[_index++]) {
+ byte operandType = _data->readByte();
+ switch (operandType) {
case 0xA0: // TEXT$
return new Operand(_inputText, Operand::TEXT_INPUT);
case 0xA1:
@@ -228,7 +227,7 @@ Script::Operand *Script::readOperand() {
case 0xFF:
{
// user variable
- int value = _data[_index++];
+ int value = _data->readByte();
if (value < 0)
value += 256;
@@ -272,13 +271,11 @@ Script::Operand *Script::readOperand() {
case 0xE8:
return new Operand(_world->_player->_context._statVariables[Context::PHYS_SPE_CUR], Operand::NUMBER);
default:
- _index--;
- if (_data[_index] >= 0x20 && _data[_index] < 0x80) {
+ if (operandType >= 0x20 && operandType < 0x80) {
return readStringOperand();
} else {
- debug("Dunno what %x is (index=%d)!\n", _data[_index], _index);
+ debug("Dunno what %x is (index=%d)!\n", operandType, _data->pos()-1);
}
- _index++;
return NULL;
}
}
@@ -289,8 +286,9 @@ Script::Operand *Script::readStringOperand() {
sb = new String();
- while (_data[_index] >= 0x20 && _data[_index] < 0x80) {
- char c = _data[_index++];
+ byte c = 0x20;
+ while (c >= 0x20 && c < 0x80) {
+ c = _data->readByte();
if (c < '0' || c > '9')
allDigits = false;
*sb += c;
diff --git a/engines/wage/script.h b/engines/wage/script.h
index a5288d6..7f7ea0d 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -55,19 +55,17 @@ namespace Wage {
class Script {
public:
- Script(byte *data, int dataSize) : _data(data), _dataSize(dataSize) {}
+ Script(Common::SeekableReadStream *data) : _data(data) {}
~Script();
private:
- byte *_data;
- int _dataSize;
+ Common::SeekableReadStream *_data;
WageEngine *_callbacks;
World *_world;
int _loopCount;
String *_inputText;
Designed *_inputClick;
- int _index;
bool _evalResult;
bool _handled;
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index d33ca69..a8bba1b 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -75,7 +75,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
// Load global script
res = resMan->getResource(MKTAG('G','C','O','D'), resArray[0]);
- _globalScript = new Script(res, res->size());
+ _globalScript = new Script(res);
// Load main configuration
if ((resArray = resMan->getResIDArray(MKTAG('V','E','R','S'))).size() == 0)
@@ -86,23 +86,22 @@ bool World::loadWorld(Common::MacResManager *resMan) {
res = resMan->getResource(MKTAG('V','E','R','S'), resArray[0]);
- Common::MemoryReadStream readS(res, res->size());
- readS.skip(10);
- byte b = readS.readByte();
+ res->skip(10);
+ byte b = res->readByte();
_weaponMenuDisabled = (b != 0);
if (b != 0 && b != 1)
error("Unexpected value for weapons menu");
- readS.skip(3);
- _aboutMessage = readPascalString(readS);
+ res->skip(3);
+ _aboutMessage = readPascalString(res);
if (!scumm_stricmp(resMan->getFileName().c_str(), "Scepters"))
- readS.skip(1); // ????
+ res->skip(1); // ????
- _soundLibrary1 = readPascalString(readS);
- _soundLibrary2 = readPascalString(readS);
+ _soundLibrary1 = readPascalString(res);
+ _soundLibrary2 = readPascalString(res);
- free(res);
+ delete res;
// Load scenes
resArray = resMan->getResIDArray(MKTAG('A','S','C','N'));
@@ -116,10 +115,9 @@ bool World::loadWorld(Common::MacResManager *resMan) {
res = resMan->getResource(MKTAG('A','T','X','T'), *iter);
if (res != NULL) {
- Common::MemoryReadStream readT(res, res->size());
- scene->_textBounds = readRect(readT);
- scene->_fontType = readT.readUint16BE();
- scene->_fontSize = readT.readUint16BE();
+ scene->_textBounds = readRect(res);
+ scene->_fontType = res->readUint16BE();
+ scene->_fontSize = res->readUint16BE();
for (int i = 12; i < res->size(); i++)
if (res[i] == 0x0d)
@@ -168,12 +166,11 @@ bool World::loadWorld(Common::MacResManager *resMan) {
// Load Patterns
res = resMan->getResource(MKTAG('P','A','T','#'), 900);
if (res != NULL) {
- Common::MemoryReadStream readP(res, res->size());
- int count = readP.readUint16BE();
+ int count = res->readUint16BE();
for (int i = 0; i < count; i++) {
byte *pattern = (byte *)malloc(8);
for (int j = 0; j < 8; j++) {
- pattern[j] = readP.readByte();
+ pattern[j] = res->readByte();
_patterns.push_back(pattern);
}
}
Commit: 6d90f6c0896cc270efa98d2714c523b09b308c55
https://github.com/scummvm/scummvm/commit/6d90f6c0896cc270efa98d2714c523b09b308c55
Author: D G Turner (digitall at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Fixed Remaining Issues Preventing Compilation.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/world.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index a3f5d95..1442fa3 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -51,13 +51,16 @@
#include "wage/wage.h"
#include "wage/design.h"
+#include "common/stream.h"
+
namespace Wage {
-Design::Design(byte *data, int dataSize) {
+Design::Design(Common::SeekableReadStream *data) {
int len = READ_BE_UINT16(data);
_data = (byte *)malloc(len);
- memcpy(_data, data, len);
+ for (int i = 0; i < len; i++)
+ _data[i] = data->readByte();
}
Design::~Design() {
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 1f16907..e89b91d 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -57,7 +57,7 @@ namespace Wage {
class Design {
public:
- Design(byte *data, int size);
+ Design(Common::SeekableReadStream *data);
~Design();
void setBounds(Common::Rect *bounds) {
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 10f1139..688c11a 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -61,40 +61,34 @@ void Designed::setDesignBounds(Common::Rect *bounds) {
_design->setBounds(bounds);
}
-Scene::Scene(String name, byte *data, int dataSize) {
+Scene::Scene(String name, Common::SeekableReadStream *data) {
_name = name;
- _design = new Design(data, dataSize);
-
- Common::MemoryReadStream in(data, dataSize);
-
- in.skip(in.readUint16BE() - 2); // Skip design.
- setDesignBounds(readRect(in));
- _worldY = in.readSint16BE();
- _worldX = in.readSint16BE();
- _blocked[Scene::NORTH] = (in.readByte() != 0);
- _blocked[Scene::SOUTH] = (in.readByte() != 0);
- _blocked[Scene::EAST] = (in.readByte() != 0);
- _blocked[Scene::WEST] = (in.readByte() != 0);
- _soundFrequency = in.readSint16BE();
- _soundType = in.readByte();
- in.readByte(); // unknown
- _messages[Scene::NORTH] = readPascalString(in);
- _messages[Scene::SOUTH] = readPascalString(in);
- _messages[Scene::EAST] = readPascalString(in);
- _messages[Scene::WEST] = readPascalString(in);
- _soundName = readPascalString(in);
+ _design = new Design(data);
+
+ setDesignBounds(readRect(*data));
+ _worldY = data->readSint16BE();
+ _worldX = data->readSint16BE();
+ _blocked[Scene::NORTH] = (data->readByte() != 0);
+ _blocked[Scene::SOUTH] = (data->readByte() != 0);
+ _blocked[Scene::EAST] = (data->readByte() != 0);
+ _blocked[Scene::WEST] = (data->readByte() != 0);
+ _soundFrequency = data->readSint16BE();
+ _soundType = data->readByte();
+ data->readByte(); // unknown
+ _messages[Scene::NORTH] = readPascalString(*data);
+ _messages[Scene::SOUTH] = readPascalString(*data);
+ _messages[Scene::EAST] = readPascalString(*data);
+ _messages[Scene::WEST] = readPascalString(*data);
+ _soundName = readPascalString(*data);
}
-Obj::Obj(String name, byte *data, int dataSize) : _currentOwner(NULL), _currentScene(NULL) {
+Obj::Obj(String name, Common::SeekableReadStream *data) : _currentOwner(NULL), _currentScene(NULL) {
_name = name;
- _design = new Design(data, dataSize);
+ _design = new Design(data);
- Common::MemoryReadStream in(data, dataSize);
+ setDesignBounds(readRect(*data));
- in.skip(in.readSint16BE() - 2); // Skip design.
- setDesignBounds(readRect(in));
-
- int16 namePlural = in.readSint16BE();
+ int16 namePlural = data->readSint16BE();
if (namePlural == 256)
_namePlural = true; // TODO: other flags?
@@ -103,19 +97,19 @@ Obj::Obj(String name, byte *data, int dataSize) : _currentOwner(NULL), _currentS
else
error("Obj <%s> had weird namePlural set", name.c_str());
- if (in.readSint16BE() != 0)
+ if (data->readSint16BE() != 0)
error("Obj <%s> had short set", name.c_str());
- if (in.readByte() != 0)
+ if (data->readByte() != 0)
error("Obj <%s> had byte set", name.c_str());
- _accuracy = in.readByte();
- _value = in.readByte();
- _type = in.readSByte();
- _damage = in.readByte();
- _attackType = in.readSByte();
- _numberOfUses = in.readSint16BE();
- int16 returnTo = in.readSint16BE();
+ _accuracy = data->readByte();
+ _value = data->readByte();
+ _type = data->readSByte();
+ _damage = data->readByte();
+ _attackType = data->readSByte();
+ _numberOfUses = data->readSint16BE();
+ int16 returnTo = data->readSint16BE();
if (returnTo == 256) // TODO any other possibilities?
_returnToRandomScene = true;
else if (returnTo == 0)
@@ -123,84 +117,81 @@ Obj::Obj(String name, byte *data, int dataSize) : _currentOwner(NULL), _currentS
else
error("Obj <%s> had weird returnTo set", name.c_str());
- _sceneOrOwner = readPascalString(in);
- _clickMessage = readPascalString(in);
- _operativeVerb = readPascalString(in);
- _failureMessage = readPascalString(in);
- _useMessage = readPascalString(in);
- _sound = readPascalString(in);
+ _sceneOrOwner = readPascalString(*data);
+ _clickMessage = readPascalString(*data);
+ _operativeVerb = readPascalString(*data);
+ _failureMessage = readPascalString(*data);
+ _useMessage = readPascalString(*data);
+ _sound = readPascalString(*data);
}
-Chr::Chr(String name, byte *data, int dataSize) {
+Chr::Chr(String name, Common::SeekableReadStream *data) {
_name = name;
- _design = new Design(data, dataSize);
-
- Common::MemoryReadStream in(data, dataSize);
+ _design = new Design(data);
- in.skip(in.readSint16BE() - 2); // Skip design.
- setDesignBounds(readRect(in));
+ setDesignBounds(readRect(*data));
- _physicalStrength = in.readByte();
- _physicalHp = in.readByte();
- _naturalArmor = in.readByte();
- _physicalAccuracy = in.readByte();
+ _physicalStrength = data->readByte();
+ _physicalHp = data->readByte();
+ _naturalArmor = data->readByte();
+ _physicalAccuracy = data->readByte();
- _spiritualStength = in.readByte();
- _spiritialHp = in.readByte();
- _resistanceToMagic = in.readByte();
- _spiritualAccuracy = in.readByte();
+ _spiritualStength = data->readByte();
+ _spiritialHp = data->readByte();
+ _resistanceToMagic = data->readByte();
+ _spiritualAccuracy = data->readByte();
- _runningSpeed = in.readByte();
- _rejectsOffers = in.readByte();
- _followsOpponent = in.readByte();
+ _runningSpeed = data->readByte();
+ _rejectsOffers = data->readByte();
+ _followsOpponent = data->readByte();
- in.readSByte(); // TODO: ???
- in.readSint32BE(); // TODO: ???
+ data->readSByte(); // TODO: ???
+ data->readSint32BE(); // TODO: ???
- _weaponDamage1 = in.readByte();
- _weaponDamage2 = in.readByte();
+ _weaponDamage1 = data->readByte();
+ _weaponDamage2 = data->readByte();
- in.readSByte(); // TODO: ???
+ data->readSByte(); // TODO: ???
- if (in.readSByte() == 1)
+ if (data->readSByte() == 1)
_playerCharacter = true;
- _maximumCarriedObjects = in.readByte();
- _returnTo = in.readSByte();
-
- _winningWeapons = in.readByte();
- _winningMagic = in.readByte();
- _winningRun = in.readByte();
- _winningOffer = in.readByte();
- _losingWeapons = in.readByte();
- _losingMagic = in.readByte();
- _losingRun = in.readByte();
- _losingOffer = in.readByte();
-
- _gender = in.readSByte();
- if (in.readSByte() == 1)
+ _maximumCarriedObjects = data->readByte();
+ _returnTo = data->readSByte();
+
+ _winningWeapons = data->readByte();
+ _winningMagic = data->readByte();
+ _winningRun = data->readByte();
+ _winningOffer = data->readByte();
+ _losingWeapons = data->readByte();
+ _losingMagic = data->readByte();
+ _losingRun = data->readByte();
+ _losingOffer = data->readByte();
+
+ _gender = data->readSByte();
+ if (data->readSByte() == 1)
_nameProperNoun = true;
- _initialScene = readPascalString(in);
- _nativeWeapon1 = readPascalString(in);
- _operativeVerb1 = readPascalString(in);
- _nativeWeapon2 = readPascalString(in);
- _operativeVerb2 = readPascalString(in);
-
- _initialComment = readPascalString(in);
- _scoresHitComment = readPascalString(in);
- _receivesHitComment = readPascalString(in);
- _makesOfferComment = readPascalString(in);
- _rejectsOfferComment = readPascalString(in);
- _acceptsOfferComment = readPascalString(in);
- _dyingWords = readPascalString(in);
-
- _initialSound = readPascalString(in);
- _scoresHitSound = readPascalString(in);
- _receivesHitSound = readPascalString(in);
- _dyingSound = readPascalString(in);
-
- _weaponSound1 = readPascalString(in);
- _weaponSound2 = readPascalString(in);
+ _initialScene = readPascalString(*data);
+ _nativeWeapon1 = readPascalString(*data);
+ _operativeVerb1 = readPascalString(*data);
+ _nativeWeapon2 = readPascalString(*data);
+ _operativeVerb2 = readPascalString(*data);
+
+ _initialComment = readPascalString(*data);
+ _scoresHitComment = readPascalString(*data);
+ _receivesHitComment = readPascalString(*data);
+ _makesOfferComment = readPascalString(*data);
+ _rejectsOfferComment = readPascalString(*data);
+ _acceptsOfferComment = readPascalString(*data);
+ _dyingWords = readPascalString(*data);
+
+ _initialSound = readPascalString(*data);
+ _scoresHitSound = readPascalString(*data);
+ _receivesHitSound = readPascalString(*data);
+ _dyingSound = readPascalString(*data);
+
+ _weaponSound1 = readPascalString(*data);
+ _weaponSound2 = readPascalString(*data);
}
} // End of namespace Wage
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index f99d6d1..3acde80 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -143,7 +143,7 @@ public:
SHIELD_ARMOR = 2
};
- Chr(String name, byte *data, int dataSize);
+ Chr(String name, Common::SeekableReadStream *data);
int _index;
String _initialScene;
@@ -296,7 +296,7 @@ public:
class Obj : public Weapon, public Designed {
public:
Obj() : _currentOwner(NULL), _currentScene(NULL) {}
- Obj(String name, byte *data, int dataSize);
+ Obj(String name, Common::SeekableReadStream *data);
enum ObjectTypes {
REGULAR_WEAPON = 1,
@@ -381,7 +381,7 @@ public:
Common::List<Chr> _chrs;
Scene() {}
- Scene(String name, byte *data, int dataSize);
+ Scene(String name, Common::SeekableReadStream *data);
Common::Rect *getTextBounds() {
return _textBounds == NULL ? NULL : new Common::Rect(*_textBounds);
@@ -443,11 +443,11 @@ taliesin(24):Wingdings(Decorative)
class Sound {
public:
- Sound(String name, byte *data, int dataSize) : _name(name), _data(data) {}
- ~Sound() { free(_data); }
+ Sound(String name, Common::SeekableReadStream *data) : _name(name), _data(data) {}
+ ~Sound() { }
String _name;
- byte *_data;
+ Common::SeekableReadStream *_data;
};
} // End of namespace Wage
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index a8bba1b..bd1f8bc 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -93,13 +93,13 @@ bool World::loadWorld(Common::MacResManager *resMan) {
error("Unexpected value for weapons menu");
res->skip(3);
- _aboutMessage = readPascalString(res);
+ _aboutMessage = readPascalString(*res);
- if (!scumm_stricmp(resMan->getFileName().c_str(), "Scepters"))
+ if (!scumm_stricmp(resMan->getBaseFileName().c_str(), "Scepters"))
res->skip(1); // ????
- _soundLibrary1 = readPascalString(res);
- _soundLibrary2 = readPascalString(res);
+ _soundLibrary1 = readPascalString(*res);
+ _soundLibrary2 = readPascalString(*res);
delete res;
@@ -107,22 +107,25 @@ bool World::loadWorld(Common::MacResManager *resMan) {
resArray = resMan->getResIDArray(MKTAG('A','S','C','N'));
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
res = resMan->getResource(MKTAG('A','S','C','N'), *iter);
- Scene *scene = new Scene(resMan->getResName(MKTAG('A','S','C','N'), *iter), res, res->size());
+ Scene *scene = new Scene(resMan->getResName(MKTAG('A','S','C','N'), *iter), res);
res = resMan->getResource(MKTAG('A','C','O','D'), *iter);
if (res != NULL)
- scene->_script = new Script(res, res->size());
+ scene->_script = new Script(res);
res = resMan->getResource(MKTAG('A','T','X','T'), *iter);
if (res != NULL) {
- scene->_textBounds = readRect(res);
+ scene->_textBounds = readRect(*res);
scene->_fontType = res->readUint16BE();
scene->_fontSize = res->readUint16BE();
- for (int i = 12; i < res->size(); i++)
- if (res[i] == 0x0d)
- res[i] = '\n';
- String text(&((char*)res)[12], res->size() - 12);
+ String text;
+ while (res->pos() < res->size()) {
+ char c = res->readByte();
+ if (c == 0x0d)
+ c = '\n';
+ text += c;
+ }
scene->_text = text;
delete res;
@@ -134,14 +137,14 @@ bool World::loadWorld(Common::MacResManager *resMan) {
resArray = resMan->getResIDArray(MKTAG('A','O','B','J'));
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
res = resMan->getResource(MKTAG('A','O','B','J'), *iter);
- addObj(new Obj(resMan->getResName(MKTAG('A','O','B','J'), *iter), res, res->size()));
+ addObj(new Obj(resMan->getResName(MKTAG('A','O','B','J'), *iter), res));
}
// Load Characters
resArray = resMan->getResIDArray(MKTAG('A','C','H','R'));
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
res = resMan->getResource(MKTAG('A','C','H','R'), *iter);
- Chr *chr = new Chr(resMan->getResName(MKTAG('A','C','H','R'), *iter), res, res->size());
+ Chr *chr = new Chr(resMan->getResName(MKTAG('A','C','H','R'), *iter), res);
addChr(chr);
// TODO: What if there's more than one player character?
@@ -153,7 +156,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
resArray = resMan->getResIDArray(MKTAG('A','S','N','D'));
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
res = resMan->getResource(MKTAG('A','S','N','D'), *iter);
- addSound(new Sound(resMan->getResName(MKTAG('A','S','N','D')), *iter), res, res->size()));
+ addSound(new Sound(resMan->getResName(MKTAG('A','S','N','D'), *iter), res));
}
if (_soundLibrary1.size() > 0) {
@@ -192,7 +195,8 @@ void World::loadExternalSounds(String fname) {
in.close();
Common::MacResManager *resMan;
- resMan = new Common::MacResManager(fname);
+ resMan = new Common::MacResManager();
+ resMan->open(fname);
Common::MacResIDArray resArray;
Common::SeekableReadStream *res;
@@ -201,7 +205,7 @@ void World::loadExternalSounds(String fname) {
resArray = resMan->getResIDArray(MKTAG('A','S','N','D'));
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
res = resMan->getResource(MKTAG('A','S','N','D'), *iter);
- addSound(new Sound(resMan->getResName(MKTAG('A','S','N','D'), *iter), res, res->size()));
+ addSound(new Sound(resMan->getResName(MKTAG('A','S','N','D'), *iter), res));
}
}
Commit: af8fb354c5db6e76e104235fee4a39bfa8a66929
https://github.com/scummvm/scummvm/commit/af8fb354c5db6e76e104235fee4a39bfa8a66929
Author: D G Turner (digitall at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Add README.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
A engines/wage/README
diff --git a/engines/wage/README b/engines/wage/README
new file mode 100644
index 0000000..1a0d0ab
--- /dev/null
+++ b/engines/wage/README
@@ -0,0 +1,5 @@
+WAGE Engine For ScummVM
+
+Engine to play games built with http://en.wikipedia.org/wiki/World_Builder
+
+Currently WIP, incomplete and not usable.
Commit: 684d5bf7af434c5c104e41fc6a2f107b774171c9
https://github.com/scummvm/scummvm/commit/684d5bf7af434c5c104e41fc6a2f107b774171c9
Author: D G Turner (digitall at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Remove snprintf() instance. Unused anyway.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/script.h
diff --git a/engines/wage/script.h b/engines/wage/script.h
index 7f7ea0d..29f2d53 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -111,9 +111,7 @@ private:
}
Operand(int value, OperandTypes type) {
- char buf[30];
_value.number = value;
- snprintf(buf, 30, "%d", value);
_str = value;
_type = type;
}
Commit: 30793f99ebf81d64d58248e88877f8f2b04b7b5f
https://github.com/scummvm/scummvm/commit/30793f99ebf81d64d58248e88877f8f2b04b7b5f
Author: D G Turner (digitall at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Update AdvancedMetaEngine For Removal of ADParams.
Also, fixed incorrect structure naming which likely conflicted
i.e. cineGames -> wageGames
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/detection.cpp
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
index 976ec0f..e0d40ff 100644
--- a/engines/wage/detection.cpp
+++ b/engines/wage/detection.cpp
@@ -40,7 +40,7 @@ const char *WageEngine::getGameFile() const {
}
-static const PlainGameDescriptor cineGames[] = {
+static const PlainGameDescriptor wageGames[] = {
{"afm", "Another Fine Mess"},
{"wage", "World Adventure Game Engine game"},
{0, 0}
@@ -66,38 +66,12 @@ static const ADGameDescription gameDescriptions[] = {
} // End of namespace Wage
-static const char *directoryGlobs[] = {
- 0
-};
-
-static const ADParams detectionParams = {
- // Pointer to ADGameDescription or its superset structure
- (const byte *)Wage::gameDescriptions,
- // Size of that superset structure
- sizeof(ADGameDescription),
- // Number of bytes to compute MD5 sum for
- 5000,
- // List of all engine targets
- cineGames,
- // Structure for autoupgrading obsolete targets
- 0,
- // Name of single gameid (optional)
- "wage",
- // List of files for file-based fallback detection (optional)
- 0,
- // Flags
- 0,
- // Additional GUI options (for every game}
- Common::GUIO_NOSPEECH | Common::GUIO_NOMIDI,
- // Maximum directory depth
- 0,
- // List of directory globs
- directoryGlobs
-};
-
class WageMetaEngine : public AdvancedMetaEngine {
public:
- WageMetaEngine() : AdvancedMetaEngine(detectionParams) {}
+ WageMetaEngine() : AdvancedMetaEngine(Wage::gameDescriptions, sizeof(ADGameDescription), wageGames) {
+ params.singleid = "wage";
+ params.guioptions = Common::GUIO_NOSPEECH | Common::GUIO_NOMIDI;
+ }
virtual const char *getName() const {
return "World Adventure Game Engine";
Commit: 43aaffc80d1bf34da9edc47dcf00bd2b399fb5a3
https://github.com/scummvm/scummvm/commit/43aaffc80d1bf34da9edc47dcf00bd2b399fb5a3
Author: D G Turner (digitall at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Fix Detection For ADParams Removal From AdvancedMetaEngine.
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/detection.cpp
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
index e0d40ff..fa6a1e8 100644
--- a/engines/wage/detection.cpp
+++ b/engines/wage/detection.cpp
@@ -69,8 +69,8 @@ static const ADGameDescription gameDescriptions[] = {
class WageMetaEngine : public AdvancedMetaEngine {
public:
WageMetaEngine() : AdvancedMetaEngine(Wage::gameDescriptions, sizeof(ADGameDescription), wageGames) {
- params.singleid = "wage";
- params.guioptions = Common::GUIO_NOSPEECH | Common::GUIO_NOMIDI;
+ _singleid = "wage";
+ _guioptions = Common::GUIO_NOSPEECH | Common::GUIO_NOMIDI;
}
virtual const char *getName() const {
Commit: 1b128d26d7a40877514040a517b7f0527141504e
https://github.com/scummvm/scummvm/commit/1b128d26d7a40877514040a517b7f0527141504e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Fix compilation with modern ScummVM
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/detection.cpp
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
index fa6a1e8..9b05f8b 100644
--- a/engines/wage/detection.cpp
+++ b/engines/wage/detection.cpp
@@ -48,8 +48,6 @@ static const PlainGameDescriptor wageGames[] = {
namespace Wage {
-using Common::GUIO_NONE;
-
static const ADGameDescription gameDescriptions[] = {
{
"afm",
@@ -58,7 +56,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO_NONE
+ GUIO0()
},
AD_TABLE_END_MARKER
@@ -70,7 +68,7 @@ class WageMetaEngine : public AdvancedMetaEngine {
public:
WageMetaEngine() : AdvancedMetaEngine(Wage::gameDescriptions, sizeof(ADGameDescription), wageGames) {
_singleid = "wage";
- _guioptions = Common::GUIO_NOSPEECH | Common::GUIO_NOMIDI;
+ _guioptions = GUIO2(GUIO_NOSPEECH, GUIO_NOMIDI);
}
virtual const char *getName() const {
Commit: 5d7c72c6b67ce67577b581ac4876b6903e432eab
https://github.com/scummvm/scummvm/commit/5d7c72c6b67ce67577b581ac4876b6903e432eab
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Remove SVN keywords from the headers
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
engines/wage/detection.cpp
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/script.cpp
engines/wage/script.h
engines/wage/util.cpp
engines/wage/wage.cpp
engines/wage/wage.h
engines/wage/world.cpp
engines/wage/world.h
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 1442fa3..f361636 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -43,9 +43,6 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
- * $URL$
- * $Id$
- *
*/
#include "wage/wage.h"
diff --git a/engines/wage/design.h b/engines/wage/design.h
index e89b91d..9cd8b90 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -43,9 +43,6 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
- * $URL$
- * $Id$
- *
*/
#ifndef WAGE_DESIGN_H
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
index 9b05f8b..e54bd2d 100644
--- a/engines/wage/detection.cpp
+++ b/engines/wage/detection.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/engines/agi/detection.cpp $
- * $Id: detection.cpp 46472 2009-12-21 22:40:52Z sev $
- *
*/
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 688c11a..57435f8 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -43,9 +43,6 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
- * $URL$
- * $Id$
- *
*/
#include "wage/wage.h"
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 3acde80..43bc55f 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -43,9 +43,6 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
- * $URL$
- * $Id$
- *
*/
#ifndef WAGE_ENTITIES_H
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index dd40497..65d4fbb 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -43,9 +43,6 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
- * $URL$
- * $Id$
- *
*/
#include "wage/wage.h"
diff --git a/engines/wage/script.h b/engines/wage/script.h
index 29f2d53..e898d51 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -43,9 +43,6 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
- * $URL$
- * $Id$
- *
*/
#ifndef WAGE_SCRIPT_H
diff --git a/engines/wage/util.cpp b/engines/wage/util.cpp
index 4a9ca67..1a6c010 100644
--- a/engines/wage/util.cpp
+++ b/engines/wage/util.cpp
@@ -43,9 +43,6 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
- * $URL$
- * $Id$
- *
*/
#include "wage/wage.h"
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index eeae2fa..98b437e 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -43,9 +43,6 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
- * $URL$
- * $Id$
- *
*/
#include "common/scummsys.h"
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 0c70b5c..5958ea2 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -43,9 +43,6 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
- * $URL$
- * $Id$
- *
*/
#ifndef WAGE_H
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index bd1f8bc..513bba9 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -43,9 +43,6 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
- * $URL$
- * $Id$
- *
*/
#include "wage/wage.h"
diff --git a/engines/wage/world.h b/engines/wage/world.h
index 30832a6..8d7c70f 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -43,9 +43,6 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
- * $URL$
- * $Id$
- *
*/
#ifndef WAGE_WORLD_H
Commit: d1682018eb1c83462349ae9e62a88849fefcb121
https://github.com/scummvm/scummvm/commit/d1682018eb1c83462349ae9e62a88849fefcb121
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Added debug output, fixed semantics
Signed-off-by: Eugene Sandulenko <sev at scummvm.org>
Changed paths:
engines/wage/design.cpp
engines/wage/entities.cpp
engines/wage/util.cpp
engines/wage/wage.h
engines/wage/world.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index f361636..5017992 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -53,7 +53,7 @@
namespace Wage {
Design::Design(Common::SeekableReadStream *data) {
- int len = READ_BE_UINT16(data);
+ int len = data->readUint16BE() - 2;
_data = (byte *)malloc(len);
for (int i = 0; i < len; i++)
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 57435f8..c499283 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -62,7 +62,7 @@ Scene::Scene(String name, Common::SeekableReadStream *data) {
_name = name;
_design = new Design(data);
- setDesignBounds(readRect(*data));
+ setDesignBounds(readRect(data));
_worldY = data->readSint16BE();
_worldX = data->readSint16BE();
_blocked[Scene::NORTH] = (data->readByte() != 0);
@@ -72,18 +72,19 @@ Scene::Scene(String name, Common::SeekableReadStream *data) {
_soundFrequency = data->readSint16BE();
_soundType = data->readByte();
data->readByte(); // unknown
- _messages[Scene::NORTH] = readPascalString(*data);
- _messages[Scene::SOUTH] = readPascalString(*data);
- _messages[Scene::EAST] = readPascalString(*data);
- _messages[Scene::WEST] = readPascalString(*data);
- _soundName = readPascalString(*data);
+ _messages[Scene::NORTH] = readPascalString(data);
+ _messages[Scene::SOUTH] = readPascalString(data);
+ _messages[Scene::EAST] = readPascalString(data);
+ _messages[Scene::WEST] = readPascalString(data);
+ _soundName = readPascalString(data);
}
Obj::Obj(String name, Common::SeekableReadStream *data) : _currentOwner(NULL), _currentScene(NULL) {
_name = name;
+
_design = new Design(data);
- setDesignBounds(readRect(*data));
+ setDesignBounds(readRect(data));
int16 namePlural = data->readSint16BE();
@@ -92,7 +93,7 @@ Obj::Obj(String name, Common::SeekableReadStream *data) : _currentOwner(NULL), _
else if (namePlural == 0)
_namePlural = false;
else
- error("Obj <%s> had weird namePlural set", name.c_str());
+ error("Obj <%s> had weird namePlural set (%d)", name.c_str(), namePlural);
if (data->readSint16BE() != 0)
error("Obj <%s> had short set", name.c_str());
@@ -114,19 +115,19 @@ Obj::Obj(String name, Common::SeekableReadStream *data) : _currentOwner(NULL), _
else
error("Obj <%s> had weird returnTo set", name.c_str());
- _sceneOrOwner = readPascalString(*data);
- _clickMessage = readPascalString(*data);
- _operativeVerb = readPascalString(*data);
- _failureMessage = readPascalString(*data);
- _useMessage = readPascalString(*data);
- _sound = readPascalString(*data);
+ _sceneOrOwner = readPascalString(data);
+ _clickMessage = readPascalString(data);
+ _operativeVerb = readPascalString(data);
+ _failureMessage = readPascalString(data);
+ _useMessage = readPascalString(data);
+ _sound = readPascalString(data);
}
Chr::Chr(String name, Common::SeekableReadStream *data) {
_name = name;
_design = new Design(data);
- setDesignBounds(readRect(*data));
+ setDesignBounds(readRect(data));
_physicalStrength = data->readByte();
_physicalHp = data->readByte();
@@ -168,27 +169,27 @@ Chr::Chr(String name, Common::SeekableReadStream *data) {
if (data->readSByte() == 1)
_nameProperNoun = true;
- _initialScene = readPascalString(*data);
- _nativeWeapon1 = readPascalString(*data);
- _operativeVerb1 = readPascalString(*data);
- _nativeWeapon2 = readPascalString(*data);
- _operativeVerb2 = readPascalString(*data);
-
- _initialComment = readPascalString(*data);
- _scoresHitComment = readPascalString(*data);
- _receivesHitComment = readPascalString(*data);
- _makesOfferComment = readPascalString(*data);
- _rejectsOfferComment = readPascalString(*data);
- _acceptsOfferComment = readPascalString(*data);
- _dyingWords = readPascalString(*data);
-
- _initialSound = readPascalString(*data);
- _scoresHitSound = readPascalString(*data);
- _receivesHitSound = readPascalString(*data);
- _dyingSound = readPascalString(*data);
-
- _weaponSound1 = readPascalString(*data);
- _weaponSound2 = readPascalString(*data);
+ _initialScene = readPascalString(data);
+ _nativeWeapon1 = readPascalString(data);
+ _operativeVerb1 = readPascalString(data);
+ _nativeWeapon2 = readPascalString(data);
+ _operativeVerb2 = readPascalString(data);
+
+ _initialComment = readPascalString(data);
+ _scoresHitComment = readPascalString(data);
+ _receivesHitComment = readPascalString(data);
+ _makesOfferComment = readPascalString(data);
+ _rejectsOfferComment = readPascalString(data);
+ _acceptsOfferComment = readPascalString(data);
+ _dyingWords = readPascalString(data);
+
+ _initialSound = readPascalString(data);
+ _scoresHitSound = readPascalString(data);
+ _receivesHitSound = readPascalString(data);
+ _dyingSound = readPascalString(data);
+
+ _weaponSound1 = readPascalString(data);
+ _weaponSound2 = readPascalString(data);
}
} // End of namespace Wage
diff --git a/engines/wage/util.cpp b/engines/wage/util.cpp
index 1a6c010..0bed88e 100644
--- a/engines/wage/util.cpp
+++ b/engines/wage/util.cpp
@@ -51,19 +51,19 @@
namespace Wage {
-Common::String readPascalString(Common::SeekableReadStream &in) {
+Common::String readPascalString(Common::SeekableReadStream *in) {
Common::String s;
char *buf;
int len;
int i;
- len = in.readSByte();
+ len = in->readSByte();
if (len < 0)
len += 256;
buf = (char *)malloc(len + 1);
for (i = 0; i < len; i++) {
- buf[i] = in.readByte();
+ buf[i] = in->readByte();
if (buf[i] == 0x0d)
buf[i] = '\n';
}
@@ -76,13 +76,13 @@ Common::String readPascalString(Common::SeekableReadStream &in) {
return s;
}
-Common::Rect *readRect(Common::SeekableReadStream &in) {
+Common::Rect *readRect(Common::SeekableReadStream *in) {
int x1, y1, x2, y2;
- y1 = in.readUint16BE();
- x1 = in.readUint16BE();
- y2 = in.readUint16BE() + 4;
- x2 = in.readUint16BE() + 4;
+ y1 = in->readUint16BE();
+ x1 = in->readUint16BE();
+ y2 = in->readUint16BE() + 4;
+ x2 = in->readUint16BE() + 4;
return new Common::Rect(x1, y1, x2, y2);
}
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 5958ea2..516550f 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -76,8 +76,8 @@ enum {
// the current limitation is 32 debug levels (1 << 31 is the last one)
};
-Common::String readPascalString(Common::SeekableReadStream &in);
-Common::Rect *readRect(Common::SeekableReadStream &in);
+Common::String readPascalString(Common::SeekableReadStream *in);
+Common::Rect *readRect(Common::SeekableReadStream *in);
class WageEngine : public Engine {
public:
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 513bba9..5fe551f 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -74,6 +74,8 @@ bool World::loadWorld(Common::MacResManager *resMan) {
res = resMan->getResource(MKTAG('G','C','O','D'), resArray[0]);
_globalScript = new Script(res);
+ // TODO: read creator
+
// Load main configuration
if ((resArray = resMan->getResIDArray(MKTAG('V','E','R','S'))).size() == 0)
return false;
@@ -81,27 +83,33 @@ bool World::loadWorld(Common::MacResManager *resMan) {
if (resArray.size() > 1)
warning("Too many VERS resources");
- res = resMan->getResource(MKTAG('V','E','R','S'), resArray[0]);
+ if (resArray.size()) {
+ debug(3, "Loading version info");
- res->skip(10);
- byte b = res->readByte();
- _weaponMenuDisabled = (b != 0);
- if (b != 0 && b != 1)
- error("Unexpected value for weapons menu");
+ res = resMan->getResource(MKTAG('V','E','R','S'), resArray[0]);
- res->skip(3);
- _aboutMessage = readPascalString(*res);
+ res->skip(10);
+ byte b = res->readByte();
+ _weaponMenuDisabled = (b != 0);
+ if (b != 0 && b != 1)
+ error("Unexpected value for weapons menu");
- if (!scumm_stricmp(resMan->getBaseFileName().c_str(), "Scepters"))
- res->skip(1); // ????
+ res->skip(3);
+ _aboutMessage = readPascalString(res);
- _soundLibrary1 = readPascalString(*res);
- _soundLibrary2 = readPascalString(*res);
+ if (!scumm_stricmp(resMan->getBaseFileName().c_str(), "Scepters"))
+ res->skip(1); // ????
- delete res;
+ _soundLibrary1 = readPascalString(res);
+ _soundLibrary2 = readPascalString(res);
+
+ delete res;
+ }
// Load scenes
resArray = resMan->getResIDArray(MKTAG('A','S','C','N'));
+ debug(3, "Loading %d scenes", resArray.size());
+
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
res = resMan->getResource(MKTAG('A','S','C','N'), *iter);
Scene *scene = new Scene(resMan->getResName(MKTAG('A','S','C','N'), *iter), res);
@@ -112,7 +120,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
res = resMan->getResource(MKTAG('A','T','X','T'), *iter);
if (res != NULL) {
- scene->_textBounds = readRect(*res);
+ scene->_textBounds = readRect(res);
scene->_fontType = res->readUint16BE();
scene->_fontSize = res->readUint16BE();
@@ -132,6 +140,8 @@ bool World::loadWorld(Common::MacResManager *resMan) {
// Load Objects
resArray = resMan->getResIDArray(MKTAG('A','O','B','J'));
+ debug(3, "Loading %d objects", resArray.size());
+
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
res = resMan->getResource(MKTAG('A','O','B','J'), *iter);
addObj(new Obj(resMan->getResName(MKTAG('A','O','B','J'), *iter), res));
@@ -139,6 +149,8 @@ bool World::loadWorld(Common::MacResManager *resMan) {
// Load Characters
resArray = resMan->getResIDArray(MKTAG('A','C','H','R'));
+ debug(3, "Loading %d characters", resArray.size());
+
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
res = resMan->getResource(MKTAG('A','C','H','R'), *iter);
Chr *chr = new Chr(resMan->getResName(MKTAG('A','C','H','R'), *iter), res);
@@ -151,6 +163,8 @@ bool World::loadWorld(Common::MacResManager *resMan) {
// Load Sounds
resArray = resMan->getResIDArray(MKTAG('A','S','N','D'));
+ debug(3, "Loading %d sounds", resArray.size());
+
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
res = resMan->getResource(MKTAG('A','S','N','D'), *iter);
addSound(new Sound(resMan->getResName(MKTAG('A','S','N','D'), *iter), res));
@@ -167,6 +181,8 @@ bool World::loadWorld(Common::MacResManager *resMan) {
res = resMan->getResource(MKTAG('P','A','T','#'), 900);
if (res != NULL) {
int count = res->readUint16BE();
+ debug(3, "Loading %d patterns", count);
+
for (int i = 0; i < count; i++) {
byte *pattern = (byte *)malloc(8);
for (int j = 0; j < 8; j++) {
Commit: e42540a23458887bb61e71be4abc4a0ba435248a
https://github.com/scummvm/scummvm/commit/e42540a23458887bb61e71be4abc4a0ba435248a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Sync with modern ScummVM
Changed paths:
A engines/wage/configure.engine
diff --git a/engines/wage/configure.engine b/engines/wage/configure.engine
new file mode 100644
index 0000000..6205211
--- /dev/null
+++ b/engines/wage/configure.engine
@@ -0,0 +1,3 @@
+# This file is included from the main "configure" script
+# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps]
+add_engine wage "WAGE" no
Commit: 076a66786299180ff31b2da48d56544757a19ac1
https://github.com/scummvm/scummvm/commit/076a66786299180ff31b2da48d56544757a19ac1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Sync with mainline
Changed paths:
engines/wage/detection.cpp
engines/wage/wage.cpp
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
index e54bd2d..f8297c2 100644
--- a/engines/wage/detection.cpp
+++ b/engines/wage/detection.cpp
@@ -51,7 +51,7 @@ static const ADGameDescription gameDescriptions[] = {
"v1.8",
AD_ENTRY1s("Another Fine Mess 1.8", "8e5aa915f3253efb2aab52435647b25e", 1456000),
Common::EN_ANY,
- Common::kPlatformPC,
+ Common::kPlatformMacintosh,
ADGF_NO_FLAGS,
GUIO0()
},
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 98b437e..d47d284 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -46,45 +46,45 @@
*/
#include "common/scummsys.h"
-
+
#include "common/config-manager.h"
#include "common/debug-channels.h"
#include "common/error.h"
-#include "common/EventRecorder.h"
#include "common/file.h"
#include "common/fs.h"
#include "engines/util.h"
+#include "gui/EventRecorder.h"
#include "wage/wage.h"
#include "wage/entities.h"
#include "wage/world.h"
-
+
namespace Wage {
-
+
WageEngine::WageEngine(OSystem *syst, const ADGameDescription *desc) : Engine(syst), _gameDescription(desc) {
_rnd = new Common::RandomSource("wage");
_aim = -1;
-
+
debug("WageEngine::WageEngine()");
}
-
+
WageEngine::~WageEngine() {
debug("WageEngine::~WageEngine()");
-
+
DebugMan.clearAllDebugChannels();
delete _rnd;
}
-
+
Common::Error WageEngine::run() {
initGraphics(320, 200, false);
-
+
// Create debugger console. It requires GFX to be initialized
_console = new Console(this);
-
+
debug("WageEngine::init");
-
+
// Your main event loop should be (invoked from) here.
_resManager = new Common::MacResManager();
_resManager->open(getGameFile());
@@ -93,7 +93,7 @@ Common::Error WageEngine::run() {
if (!_world->loadWorld(_resManager))
return Common::kNoGameDataFoundError;
-
+
return Common::kNoError;
}
Commit: 8e82969ead37be6dea0d1ca83e3d7fe5af942754
https://github.com/scummvm/scummvm/commit/8e82969ead37be6dea0d1ca83e3d7fe5af942754
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Stub for Design::paint()
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 5017992..4fbd2e3 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -49,19 +49,59 @@
#include "wage/design.h"
#include "common/stream.h"
+#include "common/memstream.h"
namespace Wage {
Design::Design(Common::SeekableReadStream *data) {
- int len = data->readUint16BE() - 2;
-
- _data = (byte *)malloc(len);
- for (int i = 0; i < len; i++)
- _data[i] = data->readByte();
+ _len = data->readUint16BE() - 2;
+ _data = (byte *)malloc(_len);
+ data->read(_data, _len);
}
Design::~Design() {
free(_data);
}
+void Design::paint(Graphics::Surface *canvas, TexturePaint *patterns, bool mask) {
+ Common::MemoryReadStream in(_data, _len);
+
+ if (mask) {
+ //canvas.setColor(Color.WHITE);
+ canvas->fillRect(Common::Rect(0, 0, _bounds->width(), _bounds->height()), 0xff);
+ //canvas.setColor(Color.BLACK);
+ }
+
+ while (!in.eos()) {
+ byte fillType = in.readByte();
+ byte borderThickness = in.readByte();
+ byte borderFillType = in.readByte();
+ int type = in.readByte();
+ switch (type) {
+/*
+ case 4:
+ drawRect(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
+ break;
+ case 8:
+ drawRoundRect(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
+ break;
+ case 12:
+ drawOval(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
+ break;
+ case 16:
+ case 20:
+ drawPolygon(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
+ break;
+ case 24:
+ drawBitmap(canvas, in, mask);
+ break;
+*/
+ default:
+ error("Unknown type => %d", type);
+ return;
+ }
+ }
+}
+
+
} // End of namespace Wage
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 9cd8b90..a0315b5 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -48,10 +48,13 @@
#ifndef WAGE_DESIGN_H
#define WAGE_DESIGN_H
+#include "graphics/surface.h"
#include "common/rect.h"
-
+
namespace Wage {
+struct TexturePaint;
+
class Design {
public:
Design(Common::SeekableReadStream *data);
@@ -60,16 +63,19 @@ public:
void setBounds(Common::Rect *bounds) {
_bounds = new Common::Rect(*bounds);
}
-
+
Common::Rect *getBounds() {
return new Common::Rect(*_bounds);
}
-
+
+ void paint(Graphics::Surface *canvas, TexturePaint *patterns, bool mask);
+
private:
byte *_data;
+ int _len;
Common::Rect *_bounds;
};
} // End of namespace Wage
-
+
#endif
Commit: d3917bf9314f22adfb72b0ce9cb6b9634467c662
https://github.com/scummvm/scummvm/commit/d3917bf9314f22adfb72b0ce9cb6b9634467c662
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Added stub for polygon drawing
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 4fbd2e3..59cf80f 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -48,15 +48,14 @@
#include "wage/wage.h"
#include "wage/design.h"
-#include "common/stream.h"
-#include "common/memstream.h"
-
namespace Wage {
Design::Design(Common::SeekableReadStream *data) {
_len = data->readUint16BE() - 2;
_data = (byte *)malloc(_len);
data->read(_data, _len);
+
+ paint(0, 0, false);
}
Design::~Design() {
@@ -68,7 +67,7 @@ void Design::paint(Graphics::Surface *canvas, TexturePaint *patterns, bool mask)
if (mask) {
//canvas.setColor(Color.WHITE);
- canvas->fillRect(Common::Rect(0, 0, _bounds->width(), _bounds->height()), 0xff);
+ canvas->fillRect(Common::Rect(0, 0, _bounds->width(), _bounds->height()), kColorWhite);
//canvas.setColor(Color.BLACK);
}
@@ -88,10 +87,12 @@ void Design::paint(Graphics::Surface *canvas, TexturePaint *patterns, bool mask)
case 12:
drawOval(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
+*/
case 16:
case 20:
drawPolygon(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
+/*
case 24:
drawBitmap(canvas, in, mask);
break;
@@ -103,5 +104,104 @@ void Design::paint(Graphics::Surface *canvas, TexturePaint *patterns, bool mask)
}
}
+void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
+ TexturePaint *patterns, byte fillType, byte borderThickness, byte borderFillType) {
+ //surface->setColor(Color.BLACK);
+ //in.readUint16BE();
+ warning("ignored => %d", in.readSint16BE());
+ int numBytes = in.readSint16BE(); // #bytes used by polygon data, including the numBytes
+ warning("Num bytes is %d", numBytes);
+ // Ignoring these values works!!!
+ //in.readUint16BE(); in.readUint16BE(); in.readUint16BE(); in.readUint16BE();
+ warning("Ignoring: %d", in.readSint16BE());
+ warning("Ignoring: %d", in.readSint16BE());
+ warning("Ignoring: %d", in.readSint16BE());
+ warning("Ignoring: %d", in.readSint16BE());
+
+ numBytes -= 8;
+
+ int y1 = in.readSint16BE();
+ int x1 = in.readSint16BE();
+
+ Common::Array<int> xcoords;
+ Common::Array<int> ycoords;
+
+ warning("Start point is (%d,%d)", x1, y1);
+ numBytes -= 6;
+
+ while (numBytes > 0) {
+ int y2 = y1;
+ int x2 = x1;
+ int b = in.readSByte();
+ warning("YB = %x", b);
+ if (b == (byte)0x80) {
+ y2 = in.readSint16BE();
+ numBytes -= 3;
+ } else {
+ warning("Y");
+ y2 += b;
+ numBytes -= 1;
+ }
+ b = in.readSByte();
+ warning("XB = %x", b);
+ if (b == (byte) 0x80) {
+ x2 = in.readSint16BE();
+ numBytes -= 3;
+ } else {
+ warning("X");
+ x2 += b;
+ numBytes -= 1;
+ }
+ //surface->setColor(colors[c++]);
+ //surface->setColor(Color.black);
+ xcoords.push_back(x1);
+ ycoords.push_back(y1);
+ warning("%d %d %d %d", x1, y1, x2, y2);
+ //surface->drawLine(x1, y1, x2, y2);
+ x1 = x2;
+ y1 = y2;
+ }
+ xcoords.push_back(x1);
+ ycoords.push_back(y1);
+
+ int npoints = xcoords.size();
+ int *xpoints = (int *)calloc(npoints, sizeof(int));
+ int *ypoints = (int *)calloc(npoints, sizeof(int));
+ for (int i = 0; i < npoints; i++) {
+ xpoints[i] = xcoords[i];
+ ypoints[i] = ycoords[i];
+ }
+ // warning(fillType);
+/*
+ if (mask) {
+ surface->fillPolygon(xpoints, ypoints, npoints);
+ if (borderThickness > 0) {
+ Stroke oldStroke = surface->getStroke();
+ surface->setStroke(new BasicStroke(borderThickness - 0.5f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL));
+ for (int i = 1; i < npoints; i++)
+ surface->drawLine(xpoints[i-1], ypoints[i-1], xpoints[i], ypoints[i]);
+ surface->setStroke(oldStroke);
+ }
+ return;
+ }
+ if (setPattern(g2d, patterns, fillType - 1)) {
+ surface->fillPolygon(xpoints, ypoints, npoints);
+ }
+ // warning(borderFillType);
+ //surface->setColor(Color.black);
+ //if (1==0)
+ if (borderThickness > 0 && setPattern(g2d, patterns, borderFillType - 1)) {
+ Stroke oldStroke = surface->getStroke();
+ //if (borderThickness != 1)
+ surface->setStroke(new BasicStroke(borderThickness - 0.5f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL));
+ for (int i = 1; i < npoints; i++)
+ surface->drawLine(xpoints[i-1], ypoints[i-1], xpoints[i], ypoints[i]);
+ surface->setStroke(oldStroke);
+ }
+*/
+ free(xpoints);
+ free(ypoints);
+}
+
} // End of namespace Wage
diff --git a/engines/wage/design.h b/engines/wage/design.h
index a0315b5..beb5c89 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -49,12 +49,18 @@
#define WAGE_DESIGN_H
#include "graphics/surface.h"
+#include "common/memstream.h"
#include "common/rect.h"
namespace Wage {
struct TexturePaint;
+enum {
+ kColorWhite = 0xff,
+ kColorBlack = 0x0
+};
+
class Design {
public:
Design(Common::SeekableReadStream *data);
@@ -74,6 +80,11 @@ private:
byte *_data;
int _len;
Common::Rect *_bounds;
+
+private:
+ void drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
+ TexturePaint *patterns, byte fillType, byte borderThickness, byte borderFillType);
+
};
} // End of namespace Wage
Commit: 080d3827f98f47e9e712ce6790fbc567ae249e64
https://github.com/scummvm/scummvm/commit/080d3827f98f47e9e712ce6790fbc567ae249e64
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Implemented debug drawing
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
engines/wage/wage.cpp
engines/wage/wage.h
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 59cf80f..399c2ad 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -45,6 +45,7 @@
*
*/
+#include "common/system.h"
#include "wage/wage.h"
#include "wage/design.h"
@@ -55,7 +56,9 @@ Design::Design(Common::SeekableReadStream *data) {
_data = (byte *)malloc(_len);
data->read(_data, _len);
- paint(0, 0, false);
+ Graphics::Surface screen;
+ screen.create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
+ paint(&screen, 0, false);
}
Design::~Design() {
@@ -98,9 +101,17 @@ void Design::paint(Graphics::Surface *canvas, TexturePaint *patterns, bool mask)
break;
*/
default:
- error("Unknown type => %d", type);
+ warning("Unknown type => %d", type);
+ while (true) {
+ ((WageEngine *)g_engine)->processEvents();
+ g_system->updateScreen();
+ }
return;
}
+
+ g_system->copyRectToScreen(canvas->getPixels(), canvas->pitch, 0, 0, canvas->w, canvas->h);
+ g_system->updateScreen();
+
}
}
@@ -133,22 +144,22 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
int y2 = y1;
int x2 = x1;
int b = in.readSByte();
- warning("YB = %x", b);
+ //warning("YB = %x", b);
if (b == (byte)0x80) {
y2 = in.readSint16BE();
numBytes -= 3;
} else {
- warning("Y");
+ //warning("Y");
y2 += b;
numBytes -= 1;
}
b = in.readSByte();
- warning("XB = %x", b);
+ //warning("XB = %x", b);
if (b == (byte) 0x80) {
x2 = in.readSint16BE();
numBytes -= 3;
} else {
- warning("X");
+ //warning("X");
x2 += b;
numBytes -= 1;
}
@@ -194,11 +205,12 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
Stroke oldStroke = surface->getStroke();
//if (borderThickness != 1)
surface->setStroke(new BasicStroke(borderThickness - 0.5f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL));
- for (int i = 1; i < npoints; i++)
- surface->drawLine(xpoints[i-1], ypoints[i-1], xpoints[i], ypoints[i]);
- surface->setStroke(oldStroke);
- }
*/
+ for (int i = 1; i < npoints; i++)
+ surface->drawLine(xpoints[i-1], ypoints[i-1], xpoints[i], ypoints[i], kColorWhite);
+// surface->setStroke(oldStroke);
+// }
+
free(xpoints);
free(ypoints);
}
diff --git a/engines/wage/design.h b/engines/wage/design.h
index beb5c89..294ffb1 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -57,8 +57,9 @@ namespace Wage {
struct TexturePaint;
enum {
- kColorWhite = 0xff,
- kColorBlack = 0x0
+ kColorBlack = 0,
+ kColorGray = 1,
+ kColorWhite = 2
};
class Design {
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index d47d284..ec9396f 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -53,9 +53,11 @@
#include "common/file.h"
#include "common/fs.h"
+#include "engines/engine.h"
#include "engines/util.h"
#include "gui/EventRecorder.h"
-
+#include "graphics/palette.h"
+
#include "wage/wage.h"
#include "wage/entities.h"
#include "wage/world.h"
@@ -77,9 +79,17 @@ WageEngine::~WageEngine() {
delete _rnd;
}
+static byte palette[] = {
+ 0, 0, 0,
+ 0x80, 0x80, 0x80,
+ 0xff, 0xff, 0xff
+};
+
Common::Error WageEngine::run() {
initGraphics(320, 200, false);
+ g_system->getPaletteManager()->setPalette(palette, 0, 3);
+
// Create debugger console. It requires GFX to be initialized
_console = new Console(this);
@@ -97,4 +107,18 @@ Common::Error WageEngine::run() {
return Common::kNoError;
}
+void WageEngine::processEvents() {
+ Common::Event event;
+
+ while (_eventMan->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_QUIT:
+ error("Exiting");
+ break;
+ default:
+ break;
+ }
+ }
+}
+
} // End of namespace Wage
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 516550f..d58be8f 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -47,7 +47,7 @@
#ifndef WAGE_H
#define WAGE_H
-
+
#include "engines/engine.h"
#include "common/debug.h"
#include "gui/debugger.h"
@@ -59,7 +59,7 @@
struct ADGameDescription;
namespace Wage {
-
+
class Console;
class World;
class Scene;
@@ -67,7 +67,7 @@ class Obj;
class Chr;
using Common::String;
-
+
// our engine debug levels
enum {
kWageDebugExample = 1 << 0,
@@ -83,11 +83,11 @@ class WageEngine : public Engine {
public:
WageEngine(OSystem *syst, const ADGameDescription *gameDesc);
~WageEngine();
-
+
virtual bool hasFeature(EngineFeature f) const;
virtual Common::Error run();
-
+
bool canLoadGameStateCurrently();
bool canSaveGameStateCurrently();
@@ -115,7 +115,7 @@ public:
void playSound(String soundName) {}
void setMenu(String soundName) {}
void appendText(String str) {}
-
+ void processEvents();
private:
Console *_console;
@@ -125,14 +125,14 @@ private:
Common::MacResManager *_resManager;
};
-
+
// Example console class
class Console : public GUI::Debugger {
public:
Console(WageEngine *vm) {}
virtual ~Console(void) {}
};
-
+
} // End of namespace Wage
-
+
#endif
Commit: 327a9ec74ae7ce0e9ae100449b31df5320700d75
https://github.com/scummvm/scummvm/commit/327a9ec74ae7ce0e9ae100449b31df5320700d75
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Implemented stub for drawRect
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 399c2ad..42e1c0a 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -58,7 +58,9 @@ Design::Design(Common::SeekableReadStream *data) {
Graphics::Surface screen;
screen.create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
- paint(&screen, 0, false);
+ Common::Rect r(0, 0, 320, 200);
+ setBounds(&r);
+ paint(&screen, 0, true);
}
Design::~Design() {
@@ -80,10 +82,10 @@ void Design::paint(Graphics::Surface *canvas, TexturePaint *patterns, bool mask)
byte borderFillType = in.readByte();
int type = in.readByte();
switch (type) {
-/*
case 4:
drawRect(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
+ /*
case 8:
drawRoundRect(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
@@ -115,6 +117,23 @@ void Design::paint(Graphics::Surface *canvas, TexturePaint *patterns, bool mask)
}
}
+void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
+ TexturePaint *patterns, byte fillType, byte borderThickness, byte borderFillType) {
+ int16 y = in.readSint16BE();
+ int16 x = in.readSint16BE();
+ int16 height = in.readSint16BE();
+ int16 width = in.readSint16BE();
+ Common::Rect outer(x, y, width, height);
+
+ if (mask) {
+ surface->fillRect(outer, kColorBlack);
+ return;
+ }
+ //Shape inner = new Rectangle(x+borderThickness, y+borderThickness, width-2*borderThickness, height-2*borderThickness);
+ //paintShape(g2d, patterns, outer, inner, borderFillType, fillType);
+ surface->frameRect(outer, kColorBlack);
+}
+
void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
TexturePaint *patterns, byte fillType, byte borderThickness, byte borderFillType) {
//surface->setColor(Color.BLACK);
@@ -207,7 +226,7 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
surface->setStroke(new BasicStroke(borderThickness - 0.5f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL));
*/
for (int i = 1; i < npoints; i++)
- surface->drawLine(xpoints[i-1], ypoints[i-1], xpoints[i], ypoints[i], kColorWhite);
+ surface->drawLine(xpoints[i-1], ypoints[i-1], xpoints[i], ypoints[i], kColorBlack);
// surface->setStroke(oldStroke);
// }
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 294ffb1..1c08cd9 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -83,7 +83,9 @@ private:
Common::Rect *_bounds;
private:
- void drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
+ void drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
+ TexturePaint *patterns, byte fillType, byte borderThickness, byte borderFillType);
+ void drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
TexturePaint *patterns, byte fillType, byte borderThickness, byte borderFillType);
};
Commit: 4cfc0d0480088476fabfe2fd99f1ec6a5e63a833
https://github.com/scummvm/scummvm/commit/4cfc0d0480088476fabfe2fd99f1ec6a5e63a833
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Get rid of hacky drawing
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
engines/wage/entities.cpp
engines/wage/wage.cpp
engines/wage/wage.h
engines/wage/world.h
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 42e1c0a..66205f5 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -55,19 +55,13 @@ Design::Design(Common::SeekableReadStream *data) {
_len = data->readUint16BE() - 2;
_data = (byte *)malloc(_len);
data->read(_data, _len);
-
- Graphics::Surface screen;
- screen.create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
- Common::Rect r(0, 0, 320, 200);
- setBounds(&r);
- paint(&screen, 0, true);
}
Design::~Design() {
free(_data);
}
-void Design::paint(Graphics::Surface *canvas, TexturePaint *patterns, bool mask) {
+void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
Common::MemoryReadStream in(_data, _len);
if (mask) {
@@ -80,6 +74,7 @@ void Design::paint(Graphics::Surface *canvas, TexturePaint *patterns, bool mask)
byte fillType = in.readByte();
byte borderThickness = in.readByte();
byte borderFillType = in.readByte();
+ warning("fill: %d border: %d borderFill: %d", fillType, borderThickness, borderFillType);
int type = in.readByte();
switch (type) {
case 4:
@@ -118,7 +113,7 @@ void Design::paint(Graphics::Surface *canvas, TexturePaint *patterns, bool mask)
}
void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
- TexturePaint *patterns, byte fillType, byte borderThickness, byte borderFillType) {
+ Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
int16 y = in.readSint16BE();
int16 x = in.readSint16BE();
int16 height = in.readSint16BE();
@@ -135,7 +130,7 @@ void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool m
}
void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
- TexturePaint *patterns, byte fillType, byte borderThickness, byte borderFillType) {
+ Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
//surface->setColor(Color.BLACK);
//in.readUint16BE();
warning("ignored => %d", in.readSint16BE());
@@ -143,10 +138,11 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
warning("Num bytes is %d", numBytes);
// Ignoring these values works!!!
//in.readUint16BE(); in.readUint16BE(); in.readUint16BE(); in.readUint16BE();
- warning("Ignoring: %d", in.readSint16BE());
- warning("Ignoring: %d", in.readSint16BE());
- warning("Ignoring: %d", in.readSint16BE());
- warning("Ignoring: %d", in.readSint16BE());
+ int16 by1 = in.readSint16BE();
+ int16 bx1 = in.readSint16BE();
+ int16 by2 = in.readSint16BE();
+ int16 bx2 = in.readSint16BE();
+ warning("Bbox: %d, %d, %d, %d", bx1, by1, bx2, by2);
numBytes -= 8;
@@ -186,7 +182,7 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
//surface->setColor(Color.black);
xcoords.push_back(x1);
ycoords.push_back(y1);
- warning("%d %d %d %d", x1, y1, x2, y2);
+ debug(8, "%d %d %d %d", x1, y1, x2, y2);
//surface->drawLine(x1, y1, x2, y2);
x1 = x2;
y1 = y2;
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 1c08cd9..59b3226 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -54,8 +54,6 @@
namespace Wage {
-struct TexturePaint;
-
enum {
kColorBlack = 0,
kColorGray = 1,
@@ -75,7 +73,7 @@ public:
return new Common::Rect(*_bounds);
}
- void paint(Graphics::Surface *canvas, TexturePaint *patterns, bool mask);
+ void paint(Graphics::Surface *canvas, Patterns &patterns, bool mask);
private:
byte *_data;
@@ -84,9 +82,9 @@ private:
private:
void drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
- TexturePaint *patterns, byte fillType, byte borderThickness, byte borderFillType);
+ Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
void drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
- TexturePaint *patterns, byte fillType, byte borderThickness, byte borderFillType);
+ Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
};
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index c499283..d75a348 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -62,6 +62,8 @@ Scene::Scene(String name, Common::SeekableReadStream *data) {
_name = name;
_design = new Design(data);
+ warning("Scene %s", _name.c_str());
+
setDesignBounds(readRect(data));
_worldY = data->readSint16BE();
_worldX = data->readSint16BE();
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index ec9396f..fdeb5d3 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -61,6 +61,7 @@
#include "wage/wage.h"
#include "wage/entities.h"
#include "wage/world.h"
+#include "wage/design.h"
namespace Wage {
@@ -104,6 +105,12 @@ Common::Error WageEngine::run() {
if (!_world->loadWorld(_resManager))
return Common::kNoGameDataFoundError;
+ Graphics::Surface screen;
+ screen.create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
+ Common::Rect r(0, 0, 320, 200);
+ _world->_scenes["entry"]->_design->setBounds(&r);
+ _world->_scenes["entry"]->_design->paint(&screen, _world->_patterns, true);
+
return Common::kNoError;
}
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index d58be8f..d7c3386 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -79,6 +79,8 @@ enum {
Common::String readPascalString(Common::SeekableReadStream *in);
Common::Rect *readRect(Common::SeekableReadStream *in);
+typedef Common::Array<byte *> Patterns;
+
class WageEngine : public Engine {
public:
WageEngine(OSystem *syst, const ADGameDescription *gameDesc);
diff --git a/engines/wage/world.h b/engines/wage/world.h
index 8d7c70f..1b1bc73 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -56,7 +56,7 @@ class World {
public:
World();
~World();
-
+
bool loadWorld(Common::MacResManager *resMan);
void loadExternalSounds(String fname);
@@ -75,7 +75,7 @@ public:
Common::Array<Obj *> _orderedObjs;
Common::Array<Chr *> _orderedChrs;
Common::Array<Sound *> _orderedSounds;
- Common::Array<byte *> _patterns;
+ Patterns _patterns;
Scene _storageScene;
Chr *_player;
//List<MoveListener> moveListeners;
@@ -112,7 +112,7 @@ public:
_orderedSounds.push_back(sound);
}
};
-
+
} // End of namespace Wage
-
+
#endif
Commit: 5ebbe3523856732f544df0ac1ad2991f995bbd8f
https://github.com/scummvm/scummvm/commit/5ebbe3523856732f544df0ac1ad2991f995bbd8f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Fix pattern loading
Changed paths:
engines/wage/world.cpp
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 5fe551f..1b69559 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -123,7 +123,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
scene->_textBounds = readRect(res);
scene->_fontType = res->readUint16BE();
scene->_fontSize = res->readUint16BE();
-
+
String text;
while (res->pos() < res->size()) {
char c = res->readByte();
@@ -137,7 +137,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
}
addScene(scene);
}
-
+
// Load Objects
resArray = resMan->getResIDArray(MKTAG('A','O','B','J'));
debug(3, "Loading %d objects", resArray.size());
@@ -169,7 +169,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
res = resMan->getResource(MKTAG('A','S','N','D'), *iter);
addSound(new Sound(resMan->getResName(MKTAG('A','S','N','D'), *iter), res));
}
-
+
if (_soundLibrary1.size() > 0) {
loadExternalSounds(_soundLibrary1);
}
@@ -187,10 +187,10 @@ bool World::loadWorld(Common::MacResManager *resMan) {
byte *pattern = (byte *)malloc(8);
for (int j = 0; j < 8; j++) {
pattern[j] = res->readByte();
- _patterns.push_back(pattern);
}
+ _patterns.push_back(pattern);
}
-
+
delete res;
}
Commit: 539c2ea8e4bf52828392870f5bbd1d3236259380
https://github.com/scummvm/scummvm/commit/539c2ea8e4bf52828392870f5bbd1d3236259380
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Implement drawing patterned rectangles
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
engines/wage/wage.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 66205f5..e569c85 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -64,7 +64,7 @@ Design::~Design() {
void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
Common::MemoryReadStream in(_data, _len);
- if (mask) {
+ if (mask || 1) {
//canvas.setColor(Color.WHITE);
canvas->fillRect(Common::Rect(0, 0, _bounds->width(), _bounds->height()), kColorWhite);
//canvas.setColor(Color.BLACK);
@@ -114,19 +114,19 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
- int16 y = in.readSint16BE();
- int16 x = in.readSint16BE();
- int16 height = in.readSint16BE();
- int16 width = in.readSint16BE();
- Common::Rect outer(x, y, width, height);
+ int16 y1 = in.readSint16BE();
+ int16 x1 = in.readSint16BE();
+ int16 y2 = in.readSint16BE();
+ int16 x2 = in.readSint16BE();
+ Common::Rect outer(x1, y1, x2, y2);
if (mask) {
surface->fillRect(outer, kColorBlack);
return;
}
- //Shape inner = new Rectangle(x+borderThickness, y+borderThickness, width-2*borderThickness, height-2*borderThickness);
- //paintShape(g2d, patterns, outer, inner, borderFillType, fillType);
- surface->frameRect(outer, kColorBlack);
+ fillType = 7;
+ Common::Rect inner(x1 + borderThickness, y1 + borderThickness, x2 - borderThickness, y2 - borderThickness);
+ patternThickRect(surface, patterns, outer, inner, borderFillType, fillType);
}
void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
@@ -230,5 +230,17 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
free(ypoints);
}
+void Design::patternThickRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &outer,
+ Common::Rect &inner, byte borderFillType, byte fillType) {
+ patternRect(surface, patterns, outer, borderFillType);
+ patternRect(surface, patterns, inner, fillType);
+}
+
+void Design::patternRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &rect, byte fillType) {
+ for (int y = rect.top; y < rect.bottom; y++)
+ for (int x = rect.left; x < rect.right; x++)
+ if (patterns[fillType][(y - rect.top) % 8] & (1 << (7 - (x - rect.left) % 8)))
+ *((byte *)surface->getBasePtr(x, y)) = kColorBlack;
+}
} // End of namespace Wage
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 59b3226..b1c0172 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -86,6 +86,11 @@ private:
void drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
+ void patternThickRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &outer,
+ Common::Rect &inner, byte borderFillType, byte fillType);
+
+ void patternRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &rect, byte fillType);
+
};
} // End of namespace Wage
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index fdeb5d3..1c0e3cf 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -109,7 +109,7 @@ Common::Error WageEngine::run() {
screen.create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
Common::Rect r(0, 0, 320, 200);
_world->_scenes["entry"]->_design->setBounds(&r);
- _world->_scenes["entry"]->_design->paint(&screen, _world->_patterns, true);
+ _world->_scenes["entry"]->_design->paint(&screen, _world->_patterns, false);
return Common::kNoError;
}
Commit: 0ddb529636664135a1039e380f6b34468540e828
https://github.com/scummvm/scummvm/commit/0ddb529636664135a1039e380f6b34468540e828
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Start of implementation for patterned polygons
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index e569c85..a1f7941 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -142,6 +142,7 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
int16 bx1 = in.readSint16BE();
int16 by2 = in.readSint16BE();
int16 bx2 = in.readSint16BE();
+ Common::Rect bbox(bx1, by1, bx2, by2);
warning("Bbox: %d, %d, %d, %d", bx1, by1, bx2, by2);
numBytes -= 8;
@@ -221,9 +222,8 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
//if (borderThickness != 1)
surface->setStroke(new BasicStroke(borderThickness - 0.5f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL));
*/
- for (int i = 1; i < npoints; i++)
- surface->drawLine(xpoints[i-1], ypoints[i-1], xpoints[i], ypoints[i], kColorBlack);
-// surface->setStroke(oldStroke);
+ patternThickPolygon(surface, patterns, xpoints, ypoints, npoints, bbox, borderFillType, fillType);
+ // surface->setStroke(oldStroke);
// }
free(xpoints);
@@ -239,8 +239,63 @@ void Design::patternThickRect(Graphics::Surface *surface, Patterns &patterns, Co
void Design::patternRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &rect, byte fillType) {
for (int y = rect.top; y < rect.bottom; y++)
for (int x = rect.left; x < rect.right; x++)
- if (patterns[fillType][(y - rect.top) % 8] & (1 << (7 - (x - rect.left) % 8)))
+ if (patterns[fillType-1][(y - rect.top) % 8] & (1 << (7 - (x - rect.left) % 8)))
*((byte *)surface->getBasePtr(x, y)) = kColorBlack;
}
+
+// Based on public-domain code by Darel Rex Finley, 2007
+// http://alienryderflex.com/polygon_fill/
+void Design::patternThickPolygon(Graphics::Surface *surface, Patterns &patterns, int *polyX,
+ int *polyY, int npoints, Common::Rect &bbox, byte borderFillType, byte fillType) {
+ int *nodeX = (int *)calloc(npoints, sizeof(int));
+ int i, j;
+
+ // Loop through the rows of the image.
+ for (int pixelY = bbox.top; pixelY < bbox.bottom; pixelY++) {
+ // Build a list of nodes.
+ int nodes = 0;
+ j = npoints - 1;
+
+ for (i = 0; i < npoints; i++) {
+ if ((polyY[i] < pixelY && polyY[j] >= pixelY) || (polyY[j] < pixelY && polyY[i] >= pixelY)) {
+ nodeX[nodes++] = (int)(polyX[i] + (pixelY - polyY[i]) / (polyY[j]-polyY[i]) * (polyX[j] - polyX[i]));
+ }
+ j = i;
+ }
+
+ // Sort the nodes, via a simple “Bubble” sort.
+ i = 0;
+ while (i < nodes - 1) {
+ if (nodeX[i] > nodeX[i + 1]) {
+ SWAP(nodeX[i], nodeX[i + 1]);
+ if (i)
+ i--;
+ } else {
+ i++;
+ }
+ }
+
+ // Fill the pixels between node pairs.
+ for (i = 0; i < nodes; i += 2) {
+ if (nodeX[i ] >= bbox.right)
+ break;
+ if (nodeX[i + 1] > bbox.left) {
+ nodeX[i] = MAX<int16>(nodeX[i], bbox.left);
+ nodeX[i + 1] = MIN<int16>(nodeX[i + 1], bbox.right);
+
+ for (int pixelX = nodeX[i]; pixelX < nodeX[i + 1]; pixelX++)
+ if (pixelX >= 0 && pixelX < surface->w && pixelY >= 0 && pixelY < surface->h)
+ if (patterns[fillType - 1][(pixelY - bbox.top) % 8] & (1 << (7 - (pixelX - bbox.left) % 8)))
+ *((byte *)surface->getBasePtr(pixelX, pixelY)) = kColorBlack;
+ }
+ }
+ }
+
+ free(nodeX);
+
+ for (i = 1; i < npoints; i++)
+ surface->drawLine(polyX[i-1], polyY[i-1], polyX[i], polyY[i], kColorBlack);
+}
+
} // End of namespace Wage
diff --git a/engines/wage/design.h b/engines/wage/design.h
index b1c0172..76c66df 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -90,6 +90,9 @@ private:
Common::Rect &inner, byte borderFillType, byte fillType);
void patternRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &rect, byte fillType);
+ void patternThickPolygon(Graphics::Surface *surface, Patterns &patterns, int *xpoints,
+ int *ypoints, int npoints, Common::Rect &bbox, byte borderFillType, byte fillType);
+
};
Commit: e75a96e66cc5b5ae8c77e755c618ba2302999552
https://github.com/scummvm/scummvm/commit/e75a96e66cc5b5ae8c77e755c618ba2302999552
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Fix screen size
Changed paths:
engines/wage/wage.cpp
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 1c0e3cf..1ee89d4 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -87,7 +87,7 @@ static byte palette[] = {
};
Common::Error WageEngine::run() {
- initGraphics(320, 200, false);
+ initGraphics(640, 400, true);
g_system->getPaletteManager()->setPalette(palette, 0, 3);
@@ -106,8 +106,8 @@ Common::Error WageEngine::run() {
return Common::kNoGameDataFoundError;
Graphics::Surface screen;
- screen.create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
- Common::Rect r(0, 0, 320, 200);
+ screen.create(640, 400, Graphics::PixelFormat::createFormatCLUT8());
+ Common::Rect r(0, 0, screen.w, screen.h);
_world->_scenes["entry"]->_design->setBounds(&r);
_world->_scenes["entry"]->_design->paint(&screen, _world->_patterns, false);
Commit: 6efb8bec681bd0c41ee7753681510961746ed60e
https://github.com/scummvm/scummvm/commit/6efb8bec681bd0c41ee7753681510961746ed60e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Fixed polygon rendering
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index a1f7941..301c6c7 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -239,8 +239,9 @@ void Design::patternThickRect(Graphics::Surface *surface, Patterns &patterns, Co
void Design::patternRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &rect, byte fillType) {
for (int y = rect.top; y < rect.bottom; y++)
for (int x = rect.left; x < rect.right; x++)
- if (patterns[fillType-1][(y - rect.top) % 8] & (1 << (7 - (x - rect.left) % 8)))
- *((byte *)surface->getBasePtr(x, y)) = kColorBlack;
+ *((byte *)surface->getBasePtr(x, y)) =
+ (patterns[fillType-1][(y - rect.top) % 8] & (1 << (7 - (x - rect.left) % 8))) ?
+ kColorBlack : kColorWhite;
}
@@ -259,7 +260,8 @@ void Design::patternThickPolygon(Graphics::Surface *surface, Patterns &patterns,
for (i = 0; i < npoints; i++) {
if ((polyY[i] < pixelY && polyY[j] >= pixelY) || (polyY[j] < pixelY && polyY[i] >= pixelY)) {
- nodeX[nodes++] = (int)(polyX[i] + (pixelY - polyY[i]) / (polyY[j]-polyY[i]) * (polyX[j] - polyX[i]));
+ nodeX[nodes++] = (int)(polyX[i] + (double)(pixelY - polyY[i]) / (double)(polyY[j]-polyY[i]) *
+ (double)(polyX[j] - polyX[i]) + 0.5);
}
j = i;
}
@@ -286,8 +288,9 @@ void Design::patternThickPolygon(Graphics::Surface *surface, Patterns &patterns,
for (int pixelX = nodeX[i]; pixelX < nodeX[i + 1]; pixelX++)
if (pixelX >= 0 && pixelX < surface->w && pixelY >= 0 && pixelY < surface->h)
- if (patterns[fillType - 1][(pixelY - bbox.top) % 8] & (1 << (7 - (pixelX - bbox.left) % 8)))
- *((byte *)surface->getBasePtr(pixelX, pixelY)) = kColorBlack;
+ *((byte *)surface->getBasePtr(pixelX, pixelY)) =
+ (patterns[fillType - 1][(pixelY - bbox.top) % 8] & (1 << (7 - (pixelX - bbox.left) % 8))) ?
+ kColorBlack : kColorWhite;
}
}
}
Commit: 1ffabd432522151169fe8e0be4dbcd382154355a
https://github.com/scummvm/scummvm/commit/1ffabd432522151169fe8e0be4dbcd382154355a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:39:52+01:00
Commit Message:
WAGE: Implement ellipses. Refactoring
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 301c6c7..40a64ca 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -84,10 +84,10 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
case 8:
drawRoundRect(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
+ */
case 12:
drawOval(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
-*/
case 16:
case 20:
drawPolygon(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
@@ -238,10 +238,7 @@ void Design::patternThickRect(Graphics::Surface *surface, Patterns &patterns, Co
void Design::patternRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &rect, byte fillType) {
for (int y = rect.top; y < rect.bottom; y++)
- for (int x = rect.left; x < rect.right; x++)
- *((byte *)surface->getBasePtr(x, y)) =
- (patterns[fillType-1][(y - rect.top) % 8] & (1 << (7 - (x - rect.left) % 8))) ?
- kColorBlack : kColorWhite;
+ patternHLine(surface, patterns, fillType, rect.left, rect.right, y, rect.left, rect.top);
}
@@ -286,11 +283,7 @@ void Design::patternThickPolygon(Graphics::Surface *surface, Patterns &patterns,
nodeX[i] = MAX<int16>(nodeX[i], bbox.left);
nodeX[i + 1] = MIN<int16>(nodeX[i + 1], bbox.right);
- for (int pixelX = nodeX[i]; pixelX < nodeX[i + 1]; pixelX++)
- if (pixelX >= 0 && pixelX < surface->w && pixelY >= 0 && pixelY < surface->h)
- *((byte *)surface->getBasePtr(pixelX, pixelY)) =
- (patterns[fillType - 1][(pixelY - bbox.top) % 8] & (1 << (7 - (pixelX - bbox.left) % 8))) ?
- kColorBlack : kColorWhite;
+ patternHLine(surface, patterns, fillType, nodeX[i], nodeX[i + 1], pixelY, bbox.left, bbox.top);
}
}
}
@@ -301,4 +294,61 @@ void Design::patternThickPolygon(Graphics::Surface *surface, Patterns &patterns,
surface->drawLine(polyX[i-1], polyY[i-1], polyX[i], polyY[i], kColorBlack);
}
+void Design::drawOval(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
+ Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
+ int16 y1 = in.readSint16BE();
+ int16 x1 = in.readSint16BE();
+ int16 y2 = in.readSint16BE();
+ int16 x2 = in.readSint16BE();
+
+ plotEllipseRect(surface, patterns, x1, y1, x2, y2, borderFillType);
+ plotEllipseRect(surface, patterns, x1+borderThickness, y1+borderThickness, x2-2*borderThickness, y2-2*borderThickness, fillType);
+}
+
+
+void Design::plotEllipseRect(Graphics::Surface *surface, Patterns &patterns,
+ int x0, int y0, int x1, int y1, byte fillType) {
+ int xO = x0, yO = y0;
+ int a = abs(x1-x0), b = abs(y1-y0), b1 = b&1; /* values of diameter */
+ long dx = 4*(1-a)*b*b, dy = 4*(b1+1)*a*a; /* error increment */
+ long err = dx+dy+b1*a*a, e2; /* error of 1.step */
+
+ if (x0 > x1) { x0 = x1; x1 += a; } /* if called with swapped points */
+ if (y0 > y1) y0 = y1; /* .. exchange them */
+ y0 += (b+1)/2; y1 = y0-b1; /* starting pixel */
+ a *= 8*a; b1 = 8*b*b;
+
+ do {
+ patternHLine(surface, patterns, fillType, x0, x1 + 1, y0, xO, yO);
+ patternHLine(surface, patterns, fillType, x0, x1 + 1, y1, xO, yO);
+ e2 = 2*err;
+ if (e2 <= dy) { y0++; y1--; err += dy += a; } /* y step */
+ if (e2 >= dx || 2*err > dy) { x0++; x1--; err += dx += b1; } /* x step */
+ } while (x0 <= x1);
+
+ while (y0-y1 < b) { /* too early stop of flat ellipses a=1 */
+ patternHLine(surface, patterns, fillType, x0-1, x0-1, y0, xO, yO); /* -> finish tip of ellipse */
+ patternHLine(surface, patterns, fillType, x1+1, x1+1, y0, xO, yO);
+ y0++;
+ patternHLine(surface, patterns, fillType, x0-1, x0-1, y1, xO, yO);
+ patternHLine(surface, patterns, fillType, x1+1, x1+1, y1, xO, yO);
+ y1--;
+ }
+}
+
+void Design::patternHLine(Graphics::Surface *surface, Patterns &patterns, byte fillType, int x1, int x2, int y, int x0, int y0) {
+ if (x1 > x2)
+ SWAP(x1, x2);
+
+ if (fillType > patterns.size())
+ return;
+
+ for (int x = x1; x < x2; x++)
+ if (x >= 0 && x < surface->w && y >= 0 && y < surface->h)
+ *((byte *)surface->getBasePtr(x, y)) =
+ (patterns[fillType - 1][(y - y0) % 8] & (1 << (7 - (x - x0) % 8))) ?
+ kColorBlack : kColorWhite;
+}
+
+
} // End of namespace Wage
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 76c66df..6fa25be 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -85,6 +85,8 @@ private:
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
void drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
+ void drawOval(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
+ Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
void patternThickRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &outer,
Common::Rect &inner, byte borderFillType, byte fillType);
@@ -92,6 +94,10 @@ private:
void patternRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &rect, byte fillType);
void patternThickPolygon(Graphics::Surface *surface, Patterns &patterns, int *xpoints,
int *ypoints, int npoints, Common::Rect &bbox, byte borderFillType, byte fillType);
+ void plotEllipseRect(Graphics::Surface *surface, Patterns &patterns,
+ int x0, int y0, int x1, int y1, byte fillType);
+ void patternHLine(Graphics::Surface *surface, Patterns &patterns, byte fillType, int x1, int x2, int y, int x0, int y0);
+
};
Commit: e112ffdf4885096a3f786cec12612ab9510f7193
https://github.com/scummvm/scummvm/commit/e112ffdf4885096a3f786cec12612ab9510f7193
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:46+01:00
Commit Message:
WAGE: Added detection for Camp Cantitoe
Changed paths:
engines/wage/detection.cpp
engines/wage/wage.cpp
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
index f8297c2..4bf8aa8 100644
--- a/engines/wage/detection.cpp
+++ b/engines/wage/detection.cpp
@@ -39,6 +39,7 @@ const char *WageEngine::getGameFile() const {
static const PlainGameDescriptor wageGames[] = {
{"afm", "Another Fine Mess"},
+ {"cantitoe", "Camp Cantitoe"},
{"wage", "World Adventure Game Engine game"},
{0, 0}
};
@@ -55,6 +56,15 @@ static const ADGameDescription gameDescriptions[] = {
ADGF_NO_FLAGS,
GUIO0()
},
+ {
+ "cantitoe",
+ "",
+ AD_ENTRY1s("Camp Cantitoe", "098aa5c11c58e1ef274a30a9e01b4755", 621440),
+ Common::EN_ANY,
+ Common::kPlatformMacintosh,
+ ADGF_NO_FLAGS,
+ GUIO0()
+ },
AD_TABLE_END_MARKER
};
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 1ee89d4..0266332 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -108,8 +108,8 @@ Common::Error WageEngine::run() {
Graphics::Surface screen;
screen.create(640, 400, Graphics::PixelFormat::createFormatCLUT8());
Common::Rect r(0, 0, screen.w, screen.h);
- _world->_scenes["entry"]->_design->setBounds(&r);
- _world->_scenes["entry"]->_design->paint(&screen, _world->_patterns, false);
+ _world->_scenes["front door"]->_design->setBounds(&r);
+ _world->_scenes["front door"]->_design->paint(&screen, _world->_patterns, false);
return Common::kNoError;
}
Commit: c00bd70f02f3523930dbe5072575b04eff37dd4d
https://github.com/scummvm/scummvm/commit/c00bd70f02f3523930dbe5072575b04eff37dd4d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:53+01:00
Commit Message:
WAGE: Implement drawBitmap
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 40a64ca..31835f8 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -92,11 +92,9 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
case 20:
drawPolygon(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
-/*
case 24:
drawBitmap(canvas, in, mask);
break;
-*/
default:
warning("Unknown type => %d", type);
while (true) {
@@ -230,6 +228,68 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
free(ypoints);
}
+void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool mask) {
+ int numBytes = in.readSint16BE();
+ int y1 = in.readSint16BE();
+ int x1 = in.readSint16BE();
+ int y2 = in.readSint16BE();
+ int x2 = in.readSint16BE();
+ int w = x2 - x1;
+ int h = y2 - y1;
+
+ numBytes -= 10;
+
+ int x = 0, y = 0;
+ while (numBytes) {
+ int n = in.readSByte();
+ int count;
+ int b;
+ int state;
+
+ numBytes--;
+
+ if ((n >= 0) && (n <= 127)) { // If n is between 0 and 127 inclusive, copy the next n+1 bytes literally.
+ count = n + 1;
+ state = 1;
+ } else if ((n >= -127) && (n <= -1)) { // Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times.
+ b = in.readByte();
+ numBytes--;
+ count = -n + 1;
+ state = 2;
+ } else { // Else if n is -128, noop.
+ count = 0;
+ }
+
+ for (int i = 0; i < count; i++) {
+ byte color;
+ if (state == 1) {
+ color = in.readByte();
+ numBytes--;
+ } else if (state == 2)
+ color = b;
+
+ for (int c = 0; c < 8; c++) {
+ if (x1 + x >= 0 && x1 + x < surface->w && y1 + y >= 0 && y1 + y < surface->h)
+ *((byte *)surface->getBasePtr(x1 + x, y1 + y)) =
+ (color & (1 << (7 - c % 8))) ?
+ kColorBlack : kColorWhite;
+ x++;
+ if (x == w) {
+ y++;
+
+ if (y == h)
+ return;
+
+ x = 0;
+ break;
+ }
+
+ }
+ }
+
+ }
+}
+
void Design::patternThickRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &outer,
Common::Rect &inner, byte borderFillType, byte fillType) {
patternRect(surface, patterns, outer, borderFillType);
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 6fa25be..6ae83c7 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -87,6 +87,8 @@ private:
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
void drawOval(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
+ void drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool mask);
+
void patternThickRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &outer,
Common::Rect &inner, byte borderFillType, byte fillType);
Commit: 8950bd52482e316f5d38e36332d6b1ea056fdd61
https://github.com/scummvm/scummvm/commit/8950bd52482e316f5d38e36332d6b1ea056fdd61
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:53+01:00
Commit Message:
WAGE: Implemented drawing of think lines
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
engines/wage/wage.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 31835f8..1388db9 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -51,6 +51,14 @@
namespace Wage {
+struct plotData {
+ Graphics::Surface *surface;
+ Patterns *patterns;
+ int fillType;
+ int x0;
+ int y0;
+};
+
Design::Design(Common::SeekableReadStream *data) {
_len = data->readUint16BE() - 2;
_data = (byte *)malloc(_len);
@@ -110,6 +118,15 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
}
}
+void drawPixel(int x, int y, int color, void *data) {
+ plotData *p = (plotData *)data;
+
+ if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h)
+ *((byte *)p->surface->getBasePtr(x, y)) =
+ ((*p->patterns)[p->fillType - 1][(y - p->y0) % 8] & (1 << (7 - (x - p->x0) % 8))) ?
+ kColorBlack : kColorWhite;
+}
+
void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
int16 y1 = in.readSint16BE();
@@ -129,6 +146,8 @@ void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool m
void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
+ plotData pd;
+
//surface->setColor(Color.BLACK);
//in.readUint16BE();
warning("ignored => %d", in.readSint16BE());
@@ -143,6 +162,12 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
Common::Rect bbox(bx1, by1, bx2, by2);
warning("Bbox: %d, %d, %d, %d", bx1, by1, bx2, by2);
+ pd.surface = surface;
+ pd.patterns = &patterns;
+ pd.fillType = fillType;
+ pd.x0 = bx1;
+ pd.y0 = by1;
+
numBytes -= 8;
int y1 = in.readSint16BE();
@@ -224,6 +249,12 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
// surface->setStroke(oldStroke);
// }
+ pd.fillType = borderFillType;
+ if (borderThickness > 0) {
+ for (int i = 1; i < npoints; i++)
+ drawThickLine(xpoints[i-1], ypoints[i-1], xpoints[i], ypoints[i], borderThickness, kColorBlack, drawPixel, &pd);
+ }
+
free(xpoints);
free(ypoints);
}
@@ -349,9 +380,6 @@ void Design::patternThickPolygon(Graphics::Surface *surface, Patterns &patterns,
}
free(nodeX);
-
- for (i = 1; i < npoints; i++)
- surface->drawLine(polyX[i-1], polyY[i-1], polyX[i], polyY[i], kColorBlack);
}
void Design::drawOval(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
@@ -410,5 +438,164 @@ void Design::patternHLine(Graphics::Surface *surface, Patterns &patterns, byte f
kColorBlack : kColorWhite;
}
+void Design::patternVLine(Graphics::Surface *surface, Patterns &patterns, byte fillType, int x, int y1, int y2, int x0, int y0) {
+ if (y1 > y2)
+ SWAP(y1, y2);
+
+ if (fillType > patterns.size())
+ return;
+
+ for (int y = y1; y < y2; y++)
+ if (x >= 0 && x < surface->w && y >= 0 && y < surface->h)
+ *((byte *)surface->getBasePtr(x, y)) =
+ (patterns[fillType - 1][(y - y0) % 8] & (1 << (7 - (x - x0) % 8))) ?
+ kColorBlack : kColorWhite;
+}
+
+/* Bresenham as presented in Foley & Van Dam */
+/* Code is based on GD lib http://libgd.github.io/ */
+void Design::drawThickLine (int x1, int y1, int x2, int y2, int thick, int color,
+ void (*plotProc)(int, int, int, void *), void *data) {
+ int incr1, incr2, d, x, y, xend, yend, xdirflag, ydirflag;
+ int wid;
+ int w, wstart;
+
+ int dx = abs(x2 - x1);
+ int dy = abs(y2 - y1);
+
+/*
+ if (dx == 0) {
+ patternVLine(surface, patterns, fillType, x1, y1, y2, x1, y1);
+ return;
+ } else if (dy == 0) {
+ patternHLine(surface, patterns, fillType, x1, x2, y1, x1, y1);
+ return;
+ }
+*/
+ if (dy <= dx) {
+ /* More-or-less horizontal. use wid for vertical stroke */
+ /* Doug Claar: watch out for NaN in atan2 (2.0.5) */
+
+ /* 2.0.12: Michael Schwartz: divide rather than multiply;
+ TBB: but watch out for /0! */
+ double ac = cos(atan2 (dy, dx));
+ if (ac != 0) {
+ wid = thick / ac;
+ } else {
+ wid = 1;
+ }
+ if (wid == 0) {
+ wid = 1;
+ }
+ d = 2 * dy - dx;
+ incr1 = 2 * dy;
+ incr2 = 2 * (dy - dx);
+ if (x1 > x2) {
+ x = x2;
+ y = y2;
+ ydirflag = (-1);
+ xend = x1;
+ } else {
+ x = x1;
+ y = y1;
+ ydirflag = 1;
+ xend = x2;
+ }
+
+ /* Set up line thickness */
+ wstart = y - wid / 2;
+ for (w = wstart; w < wstart + wid; w++)
+ (*plotProc)(x, y, color, data);
+
+ if (((y2 - y1) * ydirflag) > 0) {
+ while (x < xend) {
+ x++;
+ if (d < 0) {
+ d += incr1;
+ } else {
+ y++;
+ d += incr2;
+ }
+ wstart = y - wid / 2;
+ for (w = wstart; w < wstart + wid; w++)
+ (*plotProc)(x, w, color, data);
+ }
+ } else {
+ while (x < xend) {
+ x++;
+ if (d < 0) {
+ d += incr1;
+ } else {
+ y--;
+ d += incr2;
+ }
+ wstart = y - wid / 2;
+ for (w = wstart; w < wstart + wid; w++)
+ (*plotProc)(x, w, color, data);
+ }
+ }
+ } else {
+ /* More-or-less vertical. use wid for horizontal stroke */
+ /* 2.0.12: Michael Schwartz: divide rather than multiply;
+ TBB: but watch out for /0! */
+ double as = sin(atan2(dy, dx));
+ if (as != 0) {
+ wid = thick / as;
+ } else {
+ wid = 1;
+ }
+ if (wid == 0)
+ wid = 1;
+
+ d = 2 * dx - dy;
+ incr1 = 2 * dx;
+ incr2 = 2 * (dx - dy);
+ if (y1 > y2) {
+ y = y2;
+ x = x2;
+ yend = y1;
+ xdirflag = (-1);
+ } else {
+ y = y1;
+ x = x1;
+ yend = y2;
+ xdirflag = 1;
+ }
+
+ /* Set up line thickness */
+ wstart = x - wid / 2;
+ for (w = wstart; w < wstart + wid; w++)
+ (*plotProc)(w, y, color, data);
+
+ if (((x2 - x1) * xdirflag) > 0) {
+ while (y < yend) {
+ y++;
+ if (d < 0) {
+ d += incr1;
+ } else {
+ x++;
+ d += incr2;
+ }
+ wstart = x - wid / 2;
+ for (w = wstart; w < wstart + wid; w++)
+ (*plotProc)(w, y, color, data);
+ }
+ } else {
+ while (y < yend) {
+ y++;
+ if (d < 0) {
+ d += incr1;
+ } else {
+ x--;
+ d += incr2;
+ }
+ wstart = x - wid / 2;
+ for (w = wstart; w < wstart + wid; w++)
+ (*plotProc)(w, y, color, data);
+ }
+ }
+ }
+}
+
} // End of namespace Wage
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 6ae83c7..bfb0302 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -99,9 +99,9 @@ private:
void plotEllipseRect(Graphics::Surface *surface, Patterns &patterns,
int x0, int y0, int x1, int y1, byte fillType);
void patternHLine(Graphics::Surface *surface, Patterns &patterns, byte fillType, int x1, int x2, int y, int x0, int y0);
-
-
-
+ void patternVLine(Graphics::Surface *surface, Patterns &patterns, byte fillType, int x, int y1, int y2, int x0, int y0);
+ void drawThickLine (int x1, int y1, int x2, int y2, int thick, int color,
+ void (*plotProc)(int, int, int, void *), void *data);
};
} // End of namespace Wage
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 0266332..1ee89d4 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -108,8 +108,8 @@ Common::Error WageEngine::run() {
Graphics::Surface screen;
screen.create(640, 400, Graphics::PixelFormat::createFormatCLUT8());
Common::Rect r(0, 0, screen.w, screen.h);
- _world->_scenes["front door"]->_design->setBounds(&r);
- _world->_scenes["front door"]->_design->paint(&screen, _world->_patterns, false);
+ _world->_scenes["entry"]->_design->setBounds(&r);
+ _world->_scenes["entry"]->_design->paint(&screen, _world->_patterns, false);
return Common::kNoError;
}
Commit: b054e82dbe25063f5c83bd122830f756d32a2089
https://github.com/scummvm/scummvm/commit/b054e82dbe25063f5c83bd122830f756d32a2089
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:53+01:00
Commit Message:
WAGE: Switched polygon drawing to generic
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 1388db9..ff6ea49 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -121,10 +121,13 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
void drawPixel(int x, int y, int color, void *data) {
plotData *p = (plotData *)data;
+ if (p->fillType > (*p->patterns).size())
+ return;
+
if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h)
*((byte *)p->surface->getBasePtr(x, y)) =
((*p->patterns)[p->fillType - 1][(y - p->y0) % 8] & (1 << (7 - (x - p->x0) % 8))) ?
- kColorBlack : kColorWhite;
+ color : kColorWhite;
}
void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
@@ -146,7 +149,6 @@ void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool m
void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
- plotData pd;
//surface->setColor(Color.BLACK);
//in.readUint16BE();
@@ -162,12 +164,6 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
Common::Rect bbox(bx1, by1, bx2, by2);
warning("Bbox: %d, %d, %d, %d", bx1, by1, bx2, by2);
- pd.surface = surface;
- pd.patterns = &patterns;
- pd.fillType = fillType;
- pd.x0 = bx1;
- pd.y0 = by1;
-
numBytes -= 8;
int y1 = in.readSint16BE();
@@ -245,7 +241,15 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
//if (borderThickness != 1)
surface->setStroke(new BasicStroke(borderThickness - 0.5f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL));
*/
- patternThickPolygon(surface, patterns, xpoints, ypoints, npoints, bbox, borderFillType, fillType);
+ plotData pd;
+
+ pd.surface = surface;
+ pd.patterns = &patterns;
+ pd.fillType = fillType;
+ pd.x0 = bx1;
+ pd.y0 = by1;
+
+ drawPolygonScan(xpoints, ypoints, npoints, bbox, kColorBlack, drawPixel, &pd);
// surface->setStroke(oldStroke);
// }
@@ -335,8 +339,8 @@ void Design::patternRect(Graphics::Surface *surface, Patterns &patterns, Common:
// Based on public-domain code by Darel Rex Finley, 2007
// http://alienryderflex.com/polygon_fill/
-void Design::patternThickPolygon(Graphics::Surface *surface, Patterns &patterns, int *polyX,
- int *polyY, int npoints, Common::Rect &bbox, byte borderFillType, byte fillType) {
+void Design::drawPolygonScan(int *polyX, int *polyY, int npoints, Common::Rect &bbox, int color,
+ void (*plotProc)(int, int, int, void *), void *data) {
int *nodeX = (int *)calloc(npoints, sizeof(int));
int i, j;
@@ -374,7 +378,7 @@ void Design::patternThickPolygon(Graphics::Surface *surface, Patterns &patterns,
nodeX[i] = MAX<int16>(nodeX[i], bbox.left);
nodeX[i + 1] = MIN<int16>(nodeX[i + 1], bbox.right);
- patternHLine(surface, patterns, fillType, nodeX[i], nodeX[i + 1], pixelY, bbox.left, bbox.top);
+ drawHLine(nodeX[i], nodeX[i + 1], pixelY, color, plotProc, data);
}
}
}
@@ -424,6 +428,14 @@ void Design::plotEllipseRect(Graphics::Surface *surface, Patterns &patterns,
}
}
+void Design::drawHLine(int x1, int x2, int y, int color, void (*plotProc)(int, int, int, void *), void *data) {
+ if (x1 > x2)
+ SWAP(x1, x2);
+
+ for (int x = x1; x < x2; x++)
+ (*plotProc)(x, y, color, data);
+}
+
void Design::patternHLine(Graphics::Surface *surface, Patterns &patterns, byte fillType, int x1, int x2, int y, int x0, int y0) {
if (x1 > x2)
SWAP(x1, x2);
diff --git a/engines/wage/design.h b/engines/wage/design.h
index bfb0302..6fbcee3 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -94,10 +94,11 @@ private:
Common::Rect &inner, byte borderFillType, byte fillType);
void patternRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &rect, byte fillType);
- void patternThickPolygon(Graphics::Surface *surface, Patterns &patterns, int *xpoints,
- int *ypoints, int npoints, Common::Rect &bbox, byte borderFillType, byte fillType);
+ void drawPolygonScan(int *polyX, int *polyY, int npoints, Common::Rect &bbox, int color,
+ void (*plotProc)(int, int, int, void *), void *data);
void plotEllipseRect(Graphics::Surface *surface, Patterns &patterns,
int x0, int y0, int x1, int y1, byte fillType);
+ void drawHLine(int x1, int x2, int y, int color, void (*plotProc)(int, int, int, void *), void *data);
void patternHLine(Graphics::Surface *surface, Patterns &patterns, byte fillType, int x1, int x2, int y, int x0, int y0);
void patternVLine(Graphics::Surface *surface, Patterns &patterns, byte fillType, int x, int y1, int y2, int x0, int y0);
void drawThickLine (int x1, int y1, int x2, int y2, int thick, int color,
Commit: f483bc0d83c5039207f43a4d342890c2c2de4f71
https://github.com/scummvm/scummvm/commit/f483bc0d83c5039207f43a4d342890c2c2de4f71
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:53+01:00
Commit Message:
WAGE: Made ellipse drawing generic
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index ff6ea49..8ce9805 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -321,7 +321,6 @@ void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool
}
}
-
}
}
@@ -393,14 +392,22 @@ void Design::drawOval(Graphics::Surface *surface, Common::ReadStream &in, bool m
int16 y2 = in.readSint16BE();
int16 x2 = in.readSint16BE();
- plotEllipseRect(surface, patterns, x1, y1, x2, y2, borderFillType);
- plotEllipseRect(surface, patterns, x1+borderThickness, y1+borderThickness, x2-2*borderThickness, y2-2*borderThickness, fillType);
+ plotData pd;
+
+ pd.surface = surface;
+ pd.patterns = &patterns;
+ pd.fillType = borderFillType;
+ pd.x0 = x1;
+ pd.y0 = y1;
+
+ drawFilledEllipse(x1, y1, x2, y2, drawPixel, &pd);
+
+ pd.fillType = fillType;
+ drawFilledEllipse(x1+borderThickness, y1+borderThickness, x2-2*borderThickness, y2-2*borderThickness, drawPixel, &pd);
}
-void Design::plotEllipseRect(Graphics::Surface *surface, Patterns &patterns,
- int x0, int y0, int x1, int y1, byte fillType) {
- int xO = x0, yO = y0;
+void Design::drawFilledEllipse(int x0, int y0, int x1, int y1, void (*plotProc)(int, int, int, void *), void *data) {
int a = abs(x1-x0), b = abs(y1-y0), b1 = b&1; /* values of diameter */
long dx = 4*(1-a)*b*b, dy = 4*(b1+1)*a*a; /* error increment */
long err = dx+dy+b1*a*a, e2; /* error of 1.step */
@@ -411,19 +418,19 @@ void Design::plotEllipseRect(Graphics::Surface *surface, Patterns &patterns,
a *= 8*a; b1 = 8*b*b;
do {
- patternHLine(surface, patterns, fillType, x0, x1 + 1, y0, xO, yO);
- patternHLine(surface, patterns, fillType, x0, x1 + 1, y1, xO, yO);
+ drawHLine(x0, x1 + 1, y0, kColorBlack, plotProc, data);
+ drawHLine(x0, x1 + 1, y1, kColorBlack, plotProc, data);
e2 = 2*err;
if (e2 <= dy) { y0++; y1--; err += dy += a; } /* y step */
if (e2 >= dx || 2*err > dy) { x0++; x1--; err += dx += b1; } /* x step */
} while (x0 <= x1);
while (y0-y1 < b) { /* too early stop of flat ellipses a=1 */
- patternHLine(surface, patterns, fillType, x0-1, x0-1, y0, xO, yO); /* -> finish tip of ellipse */
- patternHLine(surface, patterns, fillType, x1+1, x1+1, y0, xO, yO);
+ drawHLine(x0-1, x0-1, y0, kColorBlack, plotProc, data); /* -> finish tip of ellipse */
+ drawHLine(x1+1, x1+1, y0, kColorBlack, plotProc, data);
y0++;
- patternHLine(surface, patterns, fillType, x0-1, x0-1, y1, xO, yO);
- patternHLine(surface, patterns, fillType, x1+1, x1+1, y1, xO, yO);
+ drawHLine(x0-1, x0-1, y1, kColorBlack, plotProc, data);
+ drawHLine(x1+1, x1+1, y1, kColorBlack, plotProc, data);
y1--;
}
}
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 6fbcee3..4bc781a 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -96,8 +96,7 @@ private:
void patternRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &rect, byte fillType);
void drawPolygonScan(int *polyX, int *polyY, int npoints, Common::Rect &bbox, int color,
void (*plotProc)(int, int, int, void *), void *data);
- void plotEllipseRect(Graphics::Surface *surface, Patterns &patterns,
- int x0, int y0, int x1, int y1, byte fillType);
+ void drawFilledEllipse(int x0, int y0, int x1, int y1, void (*plotProc)(int, int, int, void *), void *data);
void drawHLine(int x1, int x2, int y, int color, void (*plotProc)(int, int, int, void *), void *data);
void patternHLine(Graphics::Surface *surface, Patterns &patterns, byte fillType, int x1, int x2, int y, int x0, int y0);
void patternVLine(Graphics::Surface *surface, Patterns &patterns, byte fillType, int x, int y1, int y2, int x0, int y0);
Commit: 9ae6992c7c8b9479d2c0dc7fd238f07e7cf37dab
https://github.com/scummvm/scummvm/commit/9ae6992c7c8b9479d2c0dc7fd238f07e7cf37dab
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:53+01:00
Commit Message:
WAGE: Switched rectangle drawing to general code
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 8ce9805..f4d9299 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -144,7 +144,20 @@ void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool m
}
fillType = 7;
Common::Rect inner(x1 + borderThickness, y1 + borderThickness, x2 - borderThickness, y2 - borderThickness);
- patternThickRect(surface, patterns, outer, inner, borderFillType, fillType);
+
+ plotData pd;
+
+ pd.surface = surface;
+ pd.patterns = &patterns;
+ pd.fillType = borderFillType;
+ pd.x0 = x1;
+ pd.y0 = y1;
+
+ drawFilledRect(outer, kColorBlack, drawPixel, &pd);
+
+ pd.fillType = fillType;
+
+ drawFilledRect(inner, kColorBlack, drawPixel, &pd);
}
void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
@@ -324,15 +337,9 @@ void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool
}
}
-void Design::patternThickRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &outer,
- Common::Rect &inner, byte borderFillType, byte fillType) {
- patternRect(surface, patterns, outer, borderFillType);
- patternRect(surface, patterns, inner, fillType);
-}
-
-void Design::patternRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &rect, byte fillType) {
+void Design::drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data) {
for (int y = rect.top; y < rect.bottom; y++)
- patternHLine(surface, patterns, fillType, rect.left, rect.right, y, rect.left, rect.top);
+ drawHLine(rect.left, rect.right, y, color, plotProc, data);
}
@@ -443,20 +450,6 @@ void Design::drawHLine(int x1, int x2, int y, int color, void (*plotProc)(int, i
(*plotProc)(x, y, color, data);
}
-void Design::patternHLine(Graphics::Surface *surface, Patterns &patterns, byte fillType, int x1, int x2, int y, int x0, int y0) {
- if (x1 > x2)
- SWAP(x1, x2);
-
- if (fillType > patterns.size())
- return;
-
- for (int x = x1; x < x2; x++)
- if (x >= 0 && x < surface->w && y >= 0 && y < surface->h)
- *((byte *)surface->getBasePtr(x, y)) =
- (patterns[fillType - 1][(y - y0) % 8] & (1 << (7 - (x - x0) % 8))) ?
- kColorBlack : kColorWhite;
-}
-
void Design::patternVLine(Graphics::Surface *surface, Patterns &patterns, byte fillType, int x, int y1, int y2, int x0, int y0) {
if (y1 > y2)
SWAP(y1, y2);
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 4bc781a..2da3b6e 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -93,12 +93,11 @@ private:
void patternThickRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &outer,
Common::Rect &inner, byte borderFillType, byte fillType);
- void patternRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &rect, byte fillType);
+ void drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data);
void drawPolygonScan(int *polyX, int *polyY, int npoints, Common::Rect &bbox, int color,
void (*plotProc)(int, int, int, void *), void *data);
void drawFilledEllipse(int x0, int y0, int x1, int y1, void (*plotProc)(int, int, int, void *), void *data);
void drawHLine(int x1, int x2, int y, int color, void (*plotProc)(int, int, int, void *), void *data);
- void patternHLine(Graphics::Surface *surface, Patterns &patterns, byte fillType, int x1, int x2, int y, int x0, int y0);
void patternVLine(Graphics::Surface *surface, Patterns &patterns, byte fillType, int x, int y1, int y2, int x0, int y0);
void drawThickLine (int x1, int y1, int x2, int y2, int thick, int color,
void (*plotProc)(int, int, int, void *), void *data);
Commit: cce763ea2ebf93cb83580bb7fe5b8ed9b3b7ad3e
https://github.com/scummvm/scummvm/commit/cce763ea2ebf93cb83580bb7fe5b8ed9b3b7ad3e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:53+01:00
Commit Message:
WAGE: Completed drawFilledEllipse
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index f4d9299..13e631e 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -450,18 +450,12 @@ void Design::drawHLine(int x1, int x2, int y, int color, void (*plotProc)(int, i
(*plotProc)(x, y, color, data);
}
-void Design::patternVLine(Graphics::Surface *surface, Patterns &patterns, byte fillType, int x, int y1, int y2, int x0, int y0) {
+void Design::drawVLine(int x, int y1, int y2, int color, void (*plotProc)(int, int, int, void *), void *data) {
if (y1 > y2)
SWAP(y1, y2);
- if (fillType > patterns.size())
- return;
-
- for (int y = y1; y < y2; y++)
- if (x >= 0 && x < surface->w && y >= 0 && y < surface->h)
- *((byte *)surface->getBasePtr(x, y)) =
- (patterns[fillType - 1][(y - y0) % 8] & (1 << (7 - (x - x0) % 8))) ?
- kColorBlack : kColorWhite;
+ for (int y = y1; y < y2; x++)
+ (*plotProc)(x, y, color, data);
}
/* Bresenham as presented in Foley & Van Dam */
@@ -475,15 +469,14 @@ void Design::drawThickLine (int x1, int y1, int x2, int y2, int thick, int color
int dx = abs(x2 - x1);
int dy = abs(y2 - y1);
-/*
if (dx == 0) {
- patternVLine(surface, patterns, fillType, x1, y1, y2, x1, y1);
+ drawVLine(x1, y1, y2, color, plotProc, data);
return;
} else if (dy == 0) {
- patternHLine(surface, patterns, fillType, x1, x2, y1, x1, y1);
+ drawHLine(x1, x2, y1, color, plotProc, data);
return;
}
-*/
+
if (dy <= dx) {
/* More-or-less horizontal. use wid for vertical stroke */
/* Doug Claar: watch out for NaN in atan2 (2.0.5) */
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 2da3b6e..8b2c6b5 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -98,7 +98,7 @@ private:
void (*plotProc)(int, int, int, void *), void *data);
void drawFilledEllipse(int x0, int y0, int x1, int y1, void (*plotProc)(int, int, int, void *), void *data);
void drawHLine(int x1, int x2, int y, int color, void (*plotProc)(int, int, int, void *), void *data);
- void patternVLine(Graphics::Surface *surface, Patterns &patterns, byte fillType, int x, int y1, int y2, int x0, int y0);
+ void drawVLine(int x, int y1, int y2, int color, void (*plotProc)(int, int, int, void *), void *data);
void drawThickLine (int x1, int y1, int x2, int y2, int thick, int color,
void (*plotProc)(int, int, int, void *), void *data);
};
Commit: d9c61c16491d40180413eceb9be933ec0aaecfb6
https://github.com/scummvm/scummvm/commit/d9c61c16491d40180413eceb9be933ec0aaecfb6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:54+01:00
Commit Message:
WAGE: Cleanup
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 13e631e..e52b93c 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -57,6 +57,9 @@ struct plotData {
int fillType;
int x0;
int y0;
+
+ plotData(Graphics::Surface *s, Patterns *p, int f, int x, int y) :
+ surface(s), patterns(p), fillType(f), x0(x), y0(y) {}
};
Design::Design(Common::SeekableReadStream *data) {
@@ -130,29 +133,29 @@ void drawPixel(int x, int y, int color, void *data) {
color : kColorWhite;
}
+void drawPixelPlain(int x, int y, int color, void *data) {
+ plotData *p = (plotData *)data;
+
+ if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h)
+ *((byte *)p->surface->getBasePtr(x, y)) = (byte)color;
+}
+
void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
- Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
+ Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
int16 y1 = in.readSint16BE();
int16 x1 = in.readSint16BE();
int16 y2 = in.readSint16BE();
int16 x2 = in.readSint16BE();
Common::Rect outer(x1, y1, x2, y2);
+ plotData pd(surface, &patterns, borderFillType, x1, y1);
+
if (mask) {
- surface->fillRect(outer, kColorBlack);
+ drawFilledRect(outer, kColorBlack, drawPixelPlain, &pd);
return;
}
- fillType = 7;
Common::Rect inner(x1 + borderThickness, y1 + borderThickness, x2 - borderThickness, y2 - borderThickness);
- plotData pd;
-
- pd.surface = surface;
- pd.patterns = &patterns;
- pd.fillType = borderFillType;
- pd.x0 = x1;
- pd.y0 = y1;
-
drawFilledRect(outer, kColorBlack, drawPixel, &pd);
pd.fillType = fillType;
@@ -163,13 +166,8 @@ void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool m
void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
- //surface->setColor(Color.BLACK);
- //in.readUint16BE();
warning("ignored => %d", in.readSint16BE());
int numBytes = in.readSint16BE(); // #bytes used by polygon data, including the numBytes
- warning("Num bytes is %d", numBytes);
- // Ignoring these values works!!!
- //in.readUint16BE(); in.readUint16BE(); in.readUint16BE(); in.readUint16BE();
int16 by1 = in.readSint16BE();
int16 bx1 = in.readSint16BE();
int16 by2 = in.readSint16BE();
@@ -254,13 +252,7 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
//if (borderThickness != 1)
surface->setStroke(new BasicStroke(borderThickness - 0.5f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL));
*/
- plotData pd;
-
- pd.surface = surface;
- pd.patterns = &patterns;
- pd.fillType = fillType;
- pd.x0 = bx1;
- pd.y0 = by1;
+ plotData pd(surface, &patterns, fillType, bx1, by1);
drawPolygonScan(xpoints, ypoints, npoints, bbox, kColorBlack, drawPixel, &pd);
// surface->setStroke(oldStroke);
@@ -399,13 +391,12 @@ void Design::drawOval(Graphics::Surface *surface, Common::ReadStream &in, bool m
int16 y2 = in.readSint16BE();
int16 x2 = in.readSint16BE();
- plotData pd;
+ plotData pd(surface, &patterns, borderFillType, x1, y1);
- pd.surface = surface;
- pd.patterns = &patterns;
- pd.fillType = borderFillType;
- pd.x0 = x1;
- pd.y0 = y1;
+ if (mask) {
+ drawFilledEllipse(x1, y1, x2, y2, drawPixelPlain, &pd);
+ return;
+ }
drawFilledEllipse(x1, y1, x2, y2, drawPixel, &pd);
Commit: 0c37ed2c56dc30722d877e02b3e5f755e2d7f458
https://github.com/scummvm/scummvm/commit/0c37ed2c56dc30722d877e02b3e5f755e2d7f458
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:54+01:00
Commit Message:
WAGE: Fix hang up
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index e52b93c..0a86438 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -445,7 +445,7 @@ void Design::drawVLine(int x, int y1, int y2, int color, void (*plotProc)(int, i
if (y1 > y2)
SWAP(y1, y2);
- for (int y = y1; y < y2; x++)
+ for (int y = y1; y < y2; y++)
(*plotProc)(x, y, color, data);
}
Commit: 0d5c219885e1d04d61b7caf5e524c311eae19ce5
https://github.com/scummvm/scummvm/commit/0d5c219885e1d04d61b7caf5e524c311eae19ce5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:54+01:00
Commit Message:
WAGE: Cleanup, completed all routines
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 0a86438..a3a9d14 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -173,7 +173,6 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
int16 by2 = in.readSint16BE();
int16 bx2 = in.readSint16BE();
Common::Rect bbox(bx1, by1, bx2, by2);
- warning("Bbox: %d, %d, %d, %d", bx1, by1, bx2, by2);
numBytes -= 8;
@@ -183,38 +182,29 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
Common::Array<int> xcoords;
Common::Array<int> ycoords;
- warning("Start point is (%d,%d)", x1, y1);
numBytes -= 6;
while (numBytes > 0) {
int y2 = y1;
int x2 = x1;
int b = in.readSByte();
- //warning("YB = %x", b);
if (b == (byte)0x80) {
y2 = in.readSint16BE();
numBytes -= 3;
} else {
- //warning("Y");
y2 += b;
numBytes -= 1;
}
b = in.readSByte();
- //warning("XB = %x", b);
if (b == (byte) 0x80) {
x2 = in.readSint16BE();
numBytes -= 3;
} else {
- //warning("X");
x2 += b;
numBytes -= 1;
}
- //surface->setColor(colors[c++]);
- //surface->setColor(Color.black);
xcoords.push_back(x1);
ycoords.push_back(y1);
- debug(8, "%d %d %d %d", x1, y1, x2, y2);
- //surface->drawLine(x1, y1, x2, y2);
x1 = x2;
y1 = y2;
}
@@ -228,35 +218,15 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
xpoints[i] = xcoords[i];
ypoints[i] = ycoords[i];
}
- // warning(fillType);
-/*
+
+ plotData pd(surface, &patterns, fillType, bx1, by1);
+
if (mask) {
- surface->fillPolygon(xpoints, ypoints, npoints);
- if (borderThickness > 0) {
- Stroke oldStroke = surface->getStroke();
- surface->setStroke(new BasicStroke(borderThickness - 0.5f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL));
- for (int i = 1; i < npoints; i++)
- surface->drawLine(xpoints[i-1], ypoints[i-1], xpoints[i], ypoints[i]);
- surface->setStroke(oldStroke);
- }
+ drawPolygonScan(xpoints, ypoints, npoints, bbox, kColorBlack, drawPixelPlain, &pd);
return;
}
- if (setPattern(g2d, patterns, fillType - 1)) {
- surface->fillPolygon(xpoints, ypoints, npoints);
- }
- // warning(borderFillType);
- //surface->setColor(Color.black);
- //if (1==0)
- if (borderThickness > 0 && setPattern(g2d, patterns, borderFillType - 1)) {
- Stroke oldStroke = surface->getStroke();
- //if (borderThickness != 1)
- surface->setStroke(new BasicStroke(borderThickness - 0.5f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL));
-*/
- plotData pd(surface, &patterns, fillType, bx1, by1);
drawPolygonScan(xpoints, ypoints, npoints, bbox, kColorBlack, drawPixel, &pd);
- // surface->setStroke(oldStroke);
-// }
pd.fillType = borderFillType;
if (borderThickness > 0) {
Commit: b92e7f602f1fb0037047a56045b418597359db36
https://github.com/scummvm/scummvm/commit/b92e7f602f1fb0037047a56045b418597359db36
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:54+01:00
Commit Message:
WAGE: Added delay to avoid CPU hogging
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index a3a9d14..6b30954 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -111,6 +111,7 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
while (true) {
((WageEngine *)g_engine)->processEvents();
g_system->updateScreen();
+ g_system->delayMillis(50);
}
return;
}
Commit: e4d9f885f15475e82ba4fecb35f6a5be7e2033d8
https://github.com/scummvm/scummvm/commit/e4d9f885f15475e82ba4fecb35f6a5be7e2033d8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:54+01:00
Commit Message:
WAGE: Fixed h/v line
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 6b30954..1ba31bc 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -387,8 +387,8 @@ void Design::drawFilledEllipse(int x0, int y0, int x1, int y1, void (*plotProc)(
a *= 8*a; b1 = 8*b*b;
do {
- drawHLine(x0, x1 + 1, y0, kColorBlack, plotProc, data);
- drawHLine(x0, x1 + 1, y1, kColorBlack, plotProc, data);
+ drawHLine(x0, x1, y0, kColorBlack, plotProc, data);
+ drawHLine(x0, x1, y1, kColorBlack, plotProc, data);
e2 = 2*err;
if (e2 <= dy) { y0++; y1--; err += dy += a; } /* y step */
if (e2 >= dx || 2*err > dy) { x0++; x1--; err += dx += b1; } /* x step */
@@ -408,7 +408,7 @@ void Design::drawHLine(int x1, int x2, int y, int color, void (*plotProc)(int, i
if (x1 > x2)
SWAP(x1, x2);
- for (int x = x1; x < x2; x++)
+ for (int x = x1; x <= x2; x++)
(*plotProc)(x, y, color, data);
}
@@ -416,7 +416,7 @@ void Design::drawVLine(int x, int y1, int y2, int color, void (*plotProc)(int, i
if (y1 > y2)
SWAP(y1, y2);
- for (int y = y1; y < y2; y++)
+ for (int y = y1; y <= y2; y++)
(*plotProc)(x, y, color, data);
}
Commit: 57648a20c56e77619a96977e5fcef0b28364a0f5
https://github.com/scummvm/scummvm/commit/57648a20c56e77619a96977e5fcef0b28364a0f5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:54+01:00
Commit Message:
WAGE: Simplified code
Changed paths:
engines/wage/world.cpp
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 1b69559..ec1d894 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -185,9 +185,8 @@ bool World::loadWorld(Common::MacResManager *resMan) {
for (int i = 0; i < count; i++) {
byte *pattern = (byte *)malloc(8);
- for (int j = 0; j < 8; j++) {
- pattern[j] = res->readByte();
- }
+
+ res->read(pattern, 8);
_patterns.push_back(pattern);
}
Commit: 057753a77ab3fd0346725ca45fe122858008d9c8
https://github.com/scummvm/scummvm/commit/057753a77ab3fd0346725ca45fe122858008d9c8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:55+01:00
Commit Message:
WAGE: Fixed screen size
Changed paths:
engines/wage/wage.cpp
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 1ee89d4..f6477dd 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -87,7 +87,7 @@ static byte palette[] = {
};
Common::Error WageEngine::run() {
- initGraphics(640, 400, true);
+ initGraphics(640, 480, true);
g_system->getPaletteManager()->setPalette(palette, 0, 3);
@@ -106,7 +106,7 @@ Common::Error WageEngine::run() {
return Common::kNoGameDataFoundError;
Graphics::Surface screen;
- screen.create(640, 400, Graphics::PixelFormat::createFormatCLUT8());
+ screen.create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
Common::Rect r(0, 0, screen.w, screen.h);
_world->_scenes["entry"]->_design->setBounds(&r);
_world->_scenes["entry"]->_design->paint(&screen, _world->_patterns, false);
Commit: bebf1b4e86a108dd0d7d1b9b122414640136ed5b
https://github.com/scummvm/scummvm/commit/bebf1b4e86a108dd0d7d1b9b122414640136ed5b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:55+01:00
Commit Message:
WAGE: Added 'A mess O'Trouble' detection
Changed paths:
engines/wage/detection.cpp
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
index 4bf8aa8..cd6fe2b 100644
--- a/engines/wage/detection.cpp
+++ b/engines/wage/detection.cpp
@@ -39,6 +39,7 @@ const char *WageEngine::getGameFile() const {
static const PlainGameDescriptor wageGames[] = {
{"afm", "Another Fine Mess"},
+ {"amot", "A Mess O' Trouble"},
{"cantitoe", "Camp Cantitoe"},
{"wage", "World Adventure Game Engine game"},
{0, 0}
@@ -57,6 +58,15 @@ static const ADGameDescription gameDescriptions[] = {
GUIO0()
},
{
+ "amot",
+ "v1.8",
+ AD_ENTRY1s("A Mess O' Trouble 1.8", "b3ef53afed282671b704e45df829350c", 1895552),
+ Common::EN_ANY,
+ Common::kPlatformMacintosh,
+ ADGF_NO_FLAGS,
+ GUIO0()
+ },
+ {
"cantitoe",
"",
AD_ENTRY1s("Camp Cantitoe", "098aa5c11c58e1ef274a30a9e01b4755", 621440),
Commit: 7e23caa342389658db122ac668a7a5b9cf63d6ab
https://github.com/scummvm/scummvm/commit/7e23caa342389658db122ac668a7a5b9cf63d6ab
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:55+01:00
Commit Message:
WAGE: Cleanup
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 1ba31bc..e3cc73f 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -76,9 +76,7 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
Common::MemoryReadStream in(_data, _len);
if (mask || 1) {
- //canvas.setColor(Color.WHITE);
canvas->fillRect(Common::Rect(0, 0, _bounds->width(), _bounds->height()), kColorWhite);
- //canvas.setColor(Color.BLACK);
}
while (!in.eos()) {
@@ -239,6 +237,26 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
free(ypoints);
}
+void Design::drawOval(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
+ Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
+ int16 y1 = in.readSint16BE();
+ int16 x1 = in.readSint16BE();
+ int16 y2 = in.readSint16BE();
+ int16 x2 = in.readSint16BE();
+
+ plotData pd(surface, &patterns, borderFillType, x1, y1);
+
+ if (mask) {
+ drawFilledEllipse(x1, y1, x2, y2, drawPixelPlain, &pd);
+ return;
+ }
+
+ drawFilledEllipse(x1, y1, x2-1, y2-1, drawPixel, &pd);
+
+ pd.fillType = fillType;
+ drawFilledEllipse(x1+borderThickness, y1+borderThickness, x2-1-2*borderThickness, y2-2*borderThickness, drawPixel, &pd);
+}
+
void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool mask) {
int numBytes = in.readSint16BE();
int y1 = in.readSint16BE();
@@ -355,27 +373,7 @@ void Design::drawPolygonScan(int *polyX, int *polyY, int npoints, Common::Rect &
free(nodeX);
}
-void Design::drawOval(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
- Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
- int16 y1 = in.readSint16BE();
- int16 x1 = in.readSint16BE();
- int16 y2 = in.readSint16BE();
- int16 x2 = in.readSint16BE();
-
- plotData pd(surface, &patterns, borderFillType, x1, y1);
-
- if (mask) {
- drawFilledEllipse(x1, y1, x2, y2, drawPixelPlain, &pd);
- return;
- }
-
- drawFilledEllipse(x1, y1, x2, y2, drawPixel, &pd);
-
- pd.fillType = fillType;
- drawFilledEllipse(x1+borderThickness, y1+borderThickness, x2-2*borderThickness, y2-2*borderThickness, drawPixel, &pd);
-}
-
-
+// http://members.chello.at/easyfilter/bresenham.html
void Design::drawFilledEllipse(int x0, int y0, int x1, int y1, void (*plotProc)(int, int, int, void *), void *data) {
int a = abs(x1-x0), b = abs(y1-y0), b1 = b&1; /* values of diameter */
long dx = 4*(1-a)*b*b, dy = 4*(b1+1)*a*a; /* error increment */
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 8b2c6b5..da0a6bc 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -89,10 +89,6 @@ private:
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
void drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool mask);
-
- void patternThickRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &outer,
- Common::Rect &inner, byte borderFillType, byte fillType);
-
void drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data);
void drawPolygonScan(int *polyX, int *polyY, int npoints, Common::Rect &bbox, int color,
void (*plotProc)(int, int, int, void *), void *data);
Commit: 0d6b726fd82d1ecb36d784625c60a839b674f729
https://github.com/scummvm/scummvm/commit/0d6b726fd82d1ecb36d784625c60a839b674f729
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:55+01:00
Commit Message:
WAGE: First stub for rounded rectangles
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
engines/wage/wage.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index e3cc73f..ec98eb6 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -89,11 +89,9 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
case 4:
drawRect(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
- /*
case 8:
drawRoundRect(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
- */
case 12:
drawOval(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
@@ -123,13 +121,15 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
void drawPixel(int x, int y, int color, void *data) {
plotData *p = (plotData *)data;
- if (p->fillType > (*p->patterns).size())
+ if (p->fillType > p->patterns->size())
return;
- if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h)
+ if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h) {
+ byte *pat = p->patterns->operator[](p->fillType - 1);
*((byte *)p->surface->getBasePtr(x, y)) =
- ((*p->patterns)[p->fillType - 1][(y - p->y0) % 8] & (1 << (7 - (x - p->x0) % 8))) ?
+ (pat[(y - p->y0) % 8] & (1 << (7 - (x - p->x0) % 8))) ?
color : kColorWhite;
+ }
}
void drawPixelPlain(int x, int y, int color, void *data) {
@@ -162,6 +162,36 @@ void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool m
drawFilledRect(inner, kColorBlack, drawPixel, &pd);
}
+void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
+ Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
+ int16 y1 = in.readSint16BE();
+ int16 x1 = in.readSint16BE();
+ int16 y2 = in.readSint16BE();
+ int16 x2 = in.readSint16BE();
+ int16 arc = in.readSint16BE();
+ Common::Rect outer(x1, y1, x2, y2);
+
+ plotData pd(surface, &patterns, borderFillType, x1, y1);
+
+ if (mask) {
+ drawFilledRoundRect(outer, arc, kColorBlack, drawPixelPlain, &pd);
+ return;
+ }
+ Common::Rect inner(x1 + borderThickness, y1 + borderThickness, x2 - borderThickness, y2 - borderThickness);
+
+ //drawFilledRoundRect(outer, arc, kColorBlack, drawPixel, &pd);
+
+ pd.fillType = fillType;
+
+ //drawFilledRoundRect(inner, arc, kColorBlack, drawPixel, &pd);
+
+
+ Common::Rect inn(50, 50, 400, 400);
+ pd.fillType = 8;
+ drawFilledRect(inn, kColorBlack, drawPixel, &pd);
+ //drawFilledRoundRect(inn, arc, kColorBlack, drawPixel, &pd);
+}
+
void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
@@ -323,6 +353,33 @@ void Design::drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int,
drawHLine(rect.left, rect.right, y, color, plotProc, data);
}
+// http://members.chello.at/easyfilter/bresenham.html
+void Design::drawFilledRoundRect(Common::Rect &rect, int arc, int color, void (*plotProc)(int, int, int, void *), void *data) {
+ //drawFilledRect(rect, color, plotProc, data);
+ //return;
+ int x = -arc, y = 0, err = 2-2*arc; /* II. Quadrant */
+ int dx = rect.width() - arc * 2;
+ int dy = rect.height() - arc * 2;
+
+ do {
+ //drawHLine(rect.left, rect.right, y, color, plotProc, data);
+
+ //drawPixelPlain(rect.left-x, rect.top-y, color, data); /* I. Quadrant */
+ //drawPixelPlain(rect.left+x, rect.top-y, color, data); /* II. Quadrant */
+ drawHLine(rect.left+x, rect.right-x, rect.top-y, color, drawPixelPlain, data);
+ drawHLine(rect.left+x, rect.right-x, rect.top+y+dy, color, drawPixelPlain, data);
+ //drawPixelPlain(rect.left-y, rect.top-x, color, data); /* II. Quadrant */
+ //drawPixelPlain(rect.left+x, rect.top-y, color, data); /* III. Quadrant */
+ //drawPixelPlain(rect.left+y, rect.top+x, color, data); /* IV. Quadrant */
+ arc = err;
+ if (arc <= y) err += ++y*2+1; /* e_xy+e_y < 0 */
+ if (arc > x || err > y) err += ++x*2+1; /* e_xy+e_x > 0 or no 2nd y-step */
+ } while (x < 0);
+
+
+ for (int i = 0; i < dy; i++)
+ drawHLine(rect.left, rect.right, rect.top + arc + i, color, drawPixelPlain, data);
+}
// Based on public-domain code by Darel Rex Finley, 2007
// http://alienryderflex.com/polygon_fill/
diff --git a/engines/wage/design.h b/engines/wage/design.h
index da0a6bc..365f6c1 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -83,6 +83,8 @@ private:
private:
void drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
+ void drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
+ Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
void drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
void drawOval(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
@@ -90,6 +92,7 @@ private:
void drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool mask);
void drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data);
+ void drawFilledRoundRect(Common::Rect &rect, int arc, int color, void (*plotProc)(int, int, int, void *), void *data);
void drawPolygonScan(int *polyX, int *polyY, int npoints, Common::Rect &bbox, int color,
void (*plotProc)(int, int, int, void *), void *data);
void drawFilledEllipse(int x0, int y0, int x1, int y1, void (*plotProc)(int, int, int, void *), void *data);
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index f6477dd..0503168 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -108,8 +108,12 @@ Common::Error WageEngine::run() {
Graphics::Surface screen;
screen.create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
Common::Rect r(0, 0, screen.w, screen.h);
- _world->_scenes["entry"]->_design->setBounds(&r);
- _world->_scenes["entry"]->_design->paint(&screen, _world->_patterns, false);
+ //_world->_objs["frank.1"]->_design->setBounds(&r);
+ //_world->_objs["frank.1"]->_design->paint(&screen, _world->_patterns, false);
+ //_world->_scenes["temple of the holy mackeral"]->_design->setBounds(&r);
+ //_world->_scenes["temple of the holy mackeral"]->_design->paint(&screen, _world->_patterns, false);
+ _world->_scenes["tower level 3"]->_design->setBounds(&r);
+ _world->_scenes["tower level 3"]->_design->paint(&screen, _world->_patterns, false);
return Common::kNoError;
}
Commit: fd37094c82dcf022660208b277004890bf32aae2
https://github.com/scummvm/scummvm/commit/fd37094c82dcf022660208b277004890bf32aae2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:55+01:00
Commit Message:
WAGE: Firhter work on rounded rectangles
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index ec98eb6..d0c461c 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -124,8 +124,9 @@ void drawPixel(int x, int y, int color, void *data) {
if (p->fillType > p->patterns->size())
return;
+ byte *pat = p->patterns->operator[](p->fillType - 1);
+
if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h) {
- byte *pat = p->patterns->operator[](p->fillType - 1);
*((byte *)p->surface->getBasePtr(x, y)) =
(pat[(y - p->y0) % 8] & (1 << (7 - (x - p->x0) % 8))) ?
color : kColorWhite;
@@ -185,11 +186,12 @@ void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, b
//drawFilledRoundRect(inner, arc, kColorBlack, drawPixel, &pd);
-
Common::Rect inn(50, 50, 400, 400);
pd.fillType = 8;
+ pd.x0 = 50;
+ pd.y0 = 50;
drawFilledRect(inn, kColorBlack, drawPixel, &pd);
- //drawFilledRoundRect(inn, arc, kColorBlack, drawPixel, &pd);
+ drawFilledRoundRect(inn, arc, kColorGray, drawPixel, &pd);
}
void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
@@ -360,14 +362,15 @@ void Design::drawFilledRoundRect(Common::Rect &rect, int arc, int color, void (*
int x = -arc, y = 0, err = 2-2*arc; /* II. Quadrant */
int dx = rect.width() - arc * 2;
int dy = rect.height() - arc * 2;
+ int r = arc;
do {
//drawHLine(rect.left, rect.right, y, color, plotProc, data);
//drawPixelPlain(rect.left-x, rect.top-y, color, data); /* I. Quadrant */
//drawPixelPlain(rect.left+x, rect.top-y, color, data); /* II. Quadrant */
- drawHLine(rect.left+x, rect.right-x, rect.top-y, color, drawPixelPlain, data);
- drawHLine(rect.left+x, rect.right-x, rect.top+y+dy, color, drawPixelPlain, data);
+ drawHLine(rect.left+x+r, rect.right-x-r, rect.top-y+r, color, drawPixelPlain, data);
+ drawHLine(rect.left+x+r, rect.right-x-r, rect.top+y+dy+r, color, drawPixelPlain, data);
//drawPixelPlain(rect.left-y, rect.top-x, color, data); /* II. Quadrant */
//drawPixelPlain(rect.left+x, rect.top-y, color, data); /* III. Quadrant */
//drawPixelPlain(rect.left+y, rect.top+x, color, data); /* IV. Quadrant */
@@ -378,7 +381,7 @@ void Design::drawFilledRoundRect(Common::Rect &rect, int arc, int color, void (*
for (int i = 0; i < dy; i++)
- drawHLine(rect.left, rect.right, rect.top + arc + i, color, drawPixelPlain, data);
+ drawHLine(rect.left, rect.right, rect.top + r + i, color, drawPixelPlain, data);
}
// Based on public-domain code by Darel Rex Finley, 2007
Commit: 0b79d5611e5f2fc222ea4d7f1d60ff7905d83fbe
https://github.com/scummvm/scummvm/commit/0b79d5611e5f2fc222ea4d7f1d60ff7905d83fbe
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:55+01:00
Commit Message:
WAGE: Fixed rectangle drawing
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index d0c461c..2ed53d7 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -351,7 +351,7 @@ void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool
}
void Design::drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data) {
- for (int y = rect.top; y < rect.bottom; y++)
+ for (int y = rect.top; y <= rect.bottom; y++)
drawHLine(rect.left, rect.right, y, color, plotProc, data);
}
Commit: 08ffaf8055778f8b58bd630d30b782ba40dbb3a2
https://github.com/scummvm/scummvm/commit/08ffaf8055778f8b58bd630d30b782ba40dbb3a2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:55+01:00
Commit Message:
WAGE: Fixed rounded rect drawing
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 2ed53d7..cf06b02 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -180,18 +180,19 @@ void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, b
}
Common::Rect inner(x1 + borderThickness, y1 + borderThickness, x2 - borderThickness, y2 - borderThickness);
- //drawFilledRoundRect(outer, arc, kColorBlack, drawPixel, &pd);
+ drawFilledRoundRect(outer, arc, kColorBlack, drawPixel, &pd);
pd.fillType = fillType;
- //drawFilledRoundRect(inner, arc, kColorBlack, drawPixel, &pd);
-
+ drawFilledRoundRect(inner, arc, kColorBlack, drawPixel, &pd);
+/*
Common::Rect inn(50, 50, 400, 400);
pd.fillType = 8;
pd.x0 = 50;
pd.y0 = 50;
drawFilledRect(inn, kColorBlack, drawPixel, &pd);
drawFilledRoundRect(inn, arc, kColorGray, drawPixel, &pd);
+*/
}
void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
@@ -357,31 +358,20 @@ void Design::drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int,
// http://members.chello.at/easyfilter/bresenham.html
void Design::drawFilledRoundRect(Common::Rect &rect, int arc, int color, void (*plotProc)(int, int, int, void *), void *data) {
- //drawFilledRect(rect, color, plotProc, data);
- //return;
int x = -arc, y = 0, err = 2-2*arc; /* II. Quadrant */
- int dx = rect.width() - arc * 2;
int dy = rect.height() - arc * 2;
int r = arc;
do {
- //drawHLine(rect.left, rect.right, y, color, plotProc, data);
-
- //drawPixelPlain(rect.left-x, rect.top-y, color, data); /* I. Quadrant */
- //drawPixelPlain(rect.left+x, rect.top-y, color, data); /* II. Quadrant */
- drawHLine(rect.left+x+r, rect.right-x-r, rect.top-y+r, color, drawPixelPlain, data);
- drawHLine(rect.left+x+r, rect.right-x-r, rect.top+y+dy+r, color, drawPixelPlain, data);
- //drawPixelPlain(rect.left-y, rect.top-x, color, data); /* II. Quadrant */
- //drawPixelPlain(rect.left+x, rect.top-y, color, data); /* III. Quadrant */
- //drawPixelPlain(rect.left+y, rect.top+x, color, data); /* IV. Quadrant */
+ drawHLine(rect.left+x+r, rect.right-x-r, rect.top-y+r, color, plotProc, data);
+ drawHLine(rect.left+x+r, rect.right-x-r, rect.top+y+dy+r, color, plotProc, data);
arc = err;
if (arc <= y) err += ++y*2+1; /* e_xy+e_y < 0 */
if (arc > x || err > y) err += ++x*2+1; /* e_xy+e_x > 0 or no 2nd y-step */
} while (x < 0);
-
for (int i = 0; i < dy; i++)
- drawHLine(rect.left, rect.right, rect.top + r + i, color, drawPixelPlain, data);
+ drawHLine(rect.left, rect.right, rect.top + r + i, color, plotProc, data);
}
// Based on public-domain code by Darel Rex Finley, 2007
Commit: 3adda8284f6232f0a2728d325890135c8b0fa9ac
https://github.com/scummvm/scummvm/commit/3adda8284f6232f0a2728d325890135c8b0fa9ac
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:56+01:00
Commit Message:
WAGE: Fix to roundrect rendering
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index cf06b02..42dca86 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -180,19 +180,11 @@ void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, b
}
Common::Rect inner(x1 + borderThickness, y1 + borderThickness, x2 - borderThickness, y2 - borderThickness);
- drawFilledRoundRect(outer, arc, kColorBlack, drawPixel, &pd);
+ drawFilledRoundRect(outer, arc/2, kColorBlack, drawPixel, &pd);
pd.fillType = fillType;
- drawFilledRoundRect(inner, arc, kColorBlack, drawPixel, &pd);
-/*
- Common::Rect inn(50, 50, 400, 400);
- pd.fillType = 8;
- pd.x0 = 50;
- pd.y0 = 50;
- drawFilledRect(inn, kColorBlack, drawPixel, &pd);
- drawFilledRoundRect(inn, arc, kColorGray, drawPixel, &pd);
-*/
+ drawFilledRoundRect(inner, arc/2, kColorBlack, drawPixel, &pd);
}
void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
Commit: 36e4722922ed6d92bac3ef7fe6d45511fb1a17c2
https://github.com/scummvm/scummvm/commit/36e4722922ed6d92bac3ef7fe6d45511fb1a17c2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:56+01:00
Commit Message:
WAGE: Fix polygon rendering
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 42dca86..8b3a661 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -212,7 +212,7 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
int y2 = y1;
int x2 = x1;
int b = in.readSByte();
- if (b == (byte)0x80) {
+ if ((b & 0xff) == 0x80) {
y2 = in.readSint16BE();
numBytes -= 3;
} else {
@@ -220,7 +220,7 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
numBytes -= 1;
}
b = in.readSByte();
- if (b == (byte) 0x80) {
+ if ((b & 0xff) == 0x80) {
x2 = in.readSint16BE();
numBytes -= 3;
} else {
Commit: 27adb22abab116c8ae092d37164326194545e9b4
https://github.com/scummvm/scummvm/commit/27adb22abab116c8ae092d37164326194545e9b4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:56+01:00
Commit Message:
WAGE: Cleanup
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 8b3a661..1f2e8b7 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -83,8 +83,8 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
byte fillType = in.readByte();
byte borderThickness = in.readByte();
byte borderFillType = in.readByte();
- warning("fill: %d border: %d borderFill: %d", fillType, borderThickness, borderFillType);
int type = in.readByte();
+ warning("fill: %d border: %d borderFill: %d type: %d", fillType, borderThickness, borderFillType, type);
switch (type) {
case 4:
drawRect(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
@@ -114,7 +114,6 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
g_system->copyRectToScreen(canvas->getPixels(), canvas->pitch, 0, 0, canvas->w, canvas->h);
g_system->updateScreen();
-
}
}
Commit: cd84abb2f34b23a64ae67b3247d001462f58dd19
https://github.com/scummvm/scummvm/commit/cd84abb2f34b23a64ae67b3247d001462f58dd19
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:56+01:00
Commit Message:
WAGE: Fix pattern filling
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 1f2e8b7..d914aa2 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -127,7 +127,7 @@ void drawPixel(int x, int y, int color, void *data) {
if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h) {
*((byte *)p->surface->getBasePtr(x, y)) =
- (pat[(y - p->y0) % 8] & (1 << (7 - (x - p->x0) % 8))) ?
+ (pat[y % 8] & (1 << (7 - x % 8))) ?
color : kColorWhite;
}
}
Commit: efab4a1a5bbc2c80046ef955149a56fdc50010d8
https://github.com/scummvm/scummvm/commit/efab4a1a5bbc2c80046ef955149a56fdc50010d8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:56+01:00
Commit Message:
WAGE: Simplify code
Changed paths:
engines/wage/design.cpp
engines/wage/wage.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index d914aa2..d17b131 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -55,11 +55,9 @@ struct plotData {
Graphics::Surface *surface;
Patterns *patterns;
int fillType;
- int x0;
- int y0;
- plotData(Graphics::Surface *s, Patterns *p, int f, int x, int y) :
- surface(s), patterns(p), fillType(f), x0(x), y0(y) {}
+ plotData(Graphics::Surface *s, Patterns *p, int f) :
+ surface(s), patterns(p), fillType(f) {}
};
Design::Design(Common::SeekableReadStream *data) {
@@ -147,7 +145,7 @@ void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool m
int16 x2 = in.readSint16BE();
Common::Rect outer(x1, y1, x2, y2);
- plotData pd(surface, &patterns, borderFillType, x1, y1);
+ plotData pd(surface, &patterns, borderFillType);
if (mask) {
drawFilledRect(outer, kColorBlack, drawPixelPlain, &pd);
@@ -171,7 +169,7 @@ void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, b
int16 arc = in.readSint16BE();
Common::Rect outer(x1, y1, x2, y2);
- plotData pd(surface, &patterns, borderFillType, x1, y1);
+ plotData pd(surface, &patterns, borderFillType);
if (mask) {
drawFilledRoundRect(outer, arc, kColorBlack, drawPixelPlain, &pd);
@@ -242,7 +240,7 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
ypoints[i] = ycoords[i];
}
- plotData pd(surface, &patterns, fillType, bx1, by1);
+ plotData pd(surface, &patterns, fillType);
if (mask) {
drawPolygonScan(xpoints, ypoints, npoints, bbox, kColorBlack, drawPixelPlain, &pd);
@@ -268,7 +266,7 @@ void Design::drawOval(Graphics::Surface *surface, Common::ReadStream &in, bool m
int16 y2 = in.readSint16BE();
int16 x2 = in.readSint16BE();
- plotData pd(surface, &patterns, borderFillType, x1, y1);
+ plotData pd(surface, &patterns, borderFillType);
if (mask) {
drawFilledEllipse(x1, y1, x2, y2, drawPixelPlain, &pd);
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 0503168..52a5f5c 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -110,10 +110,10 @@ Common::Error WageEngine::run() {
Common::Rect r(0, 0, screen.w, screen.h);
//_world->_objs["frank.1"]->_design->setBounds(&r);
//_world->_objs["frank.1"]->_design->paint(&screen, _world->_patterns, false);
- //_world->_scenes["temple of the holy mackeral"]->_design->setBounds(&r);
- //_world->_scenes["temple of the holy mackeral"]->_design->paint(&screen, _world->_patterns, false);
- _world->_scenes["tower level 3"]->_design->setBounds(&r);
- _world->_scenes["tower level 3"]->_design->paint(&screen, _world->_patterns, false);
+ _world->_scenes["temple of the holy mackeral"]->_design->setBounds(&r);
+ _world->_scenes["temple of the holy mackeral"]->_design->paint(&screen, _world->_patterns, false);
+ //_world->_scenes["tower level 3"]->_design->setBounds(&r);
+ //_world->_scenes["tower level 3"]->_design->paint(&screen, _world->_patterns, false);
return Common::kNoError;
}
Commit: 3b94913e174b6ba19226a78b6d55872d0b7576aa
https://github.com/scummvm/scummvm/commit/3b94913e174b6ba19226a78b6d55872d0b7576aa
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:56+01:00
Commit Message:
WAGE: Made drawing process visible for debugging purposes
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index d17b131..05727cd 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -111,6 +111,7 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
}
g_system->copyRectToScreen(canvas->getPixels(), canvas->pitch, 0, 0, canvas->w, canvas->h);
+ ((WageEngine *)g_engine)->processEvents();
g_system->updateScreen();
}
}
Commit: 6c214c2c4a9d1f0047009fd5eddbcd78aaa3542f
https://github.com/scummvm/scummvm/commit/6c214c2c4a9d1f0047009fd5eddbcd78aaa3542f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:57+01:00
Commit Message:
WAGE: Special case for 1-pixel wide ellipses, support for transparent pattern
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 05727cd..9bd2fe6 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -270,14 +270,23 @@ void Design::drawOval(Graphics::Surface *surface, Common::ReadStream &in, bool m
plotData pd(surface, &patterns, borderFillType);
if (mask) {
- drawFilledEllipse(x1, y1, x2, y2, drawPixelPlain, &pd);
+ drawEllipse(x1, y1, x2, y2, true, drawPixelPlain, &pd);
return;
}
- drawFilledEllipse(x1, y1, x2-1, y2-1, drawPixel, &pd);
+ if (borderThickness > 0) {
+ if (borderThickness == 1) {
+ drawEllipse(x1, y1, x2-1, y2-1, false, drawPixel, &pd);
+ } else {
+ drawEllipse(x1, y1, x2-1, y2-1, true, drawPixel, &pd);
+ warning("Ellips thickness >1: borderThickness");
+ }
+ }
- pd.fillType = fillType;
- drawFilledEllipse(x1+borderThickness, y1+borderThickness, x2-1-2*borderThickness, y2-2*borderThickness, drawPixel, &pd);
+ if (fillType <= patterns.size()) {
+ pd.fillType = fillType;
+ drawEllipse(x1+borderThickness, y1+borderThickness, x2-1-2*borderThickness, y2-2*borderThickness, true, drawPixel, &pd);
+ }
}
void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool mask) {
@@ -414,7 +423,7 @@ void Design::drawPolygonScan(int *polyX, int *polyY, int npoints, Common::Rect &
}
// http://members.chello.at/easyfilter/bresenham.html
-void Design::drawFilledEllipse(int x0, int y0, int x1, int y1, void (*plotProc)(int, int, int, void *), void *data) {
+void Design::drawEllipse(int x0, int y0, int x1, int y1, bool filled, void (*plotProc)(int, int, int, void *), void *data) {
int a = abs(x1-x0), b = abs(y1-y0), b1 = b&1; /* values of diameter */
long dx = 4*(1-a)*b*b, dy = 4*(b1+1)*a*a; /* error increment */
long err = dx+dy+b1*a*a, e2; /* error of 1.step */
@@ -425,19 +434,33 @@ void Design::drawFilledEllipse(int x0, int y0, int x1, int y1, void (*plotProc)(
a *= 8*a; b1 = 8*b*b;
do {
- drawHLine(x0, x1, y0, kColorBlack, plotProc, data);
- drawHLine(x0, x1, y1, kColorBlack, plotProc, data);
+ if (filled) {
+ drawHLine(x0, x1, y0, kColorBlack, plotProc, data);
+ drawHLine(x0, x1, y1, kColorBlack, plotProc, data);
+ } else {
+ (*plotProc)(x1, y0, kColorBlack, data); /* I. Quadrant */
+ (*plotProc)(x0, y0, kColorBlack, data); /* II. Quadrant */
+ (*plotProc)(x0, y1, kColorBlack, data); /* III. Quadrant */
+ (*plotProc)(x1, y1, kColorBlack, data); /* IV. Quadrant */
+ }
e2 = 2*err;
if (e2 <= dy) { y0++; y1--; err += dy += a; } /* y step */
if (e2 >= dx || 2*err > dy) { x0++; x1--; err += dx += b1; } /* x step */
} while (x0 <= x1);
while (y0-y1 < b) { /* too early stop of flat ellipses a=1 */
- drawHLine(x0-1, x0-1, y0, kColorBlack, plotProc, data); /* -> finish tip of ellipse */
- drawHLine(x1+1, x1+1, y0, kColorBlack, plotProc, data);
+ if (filled) {
+ drawHLine(x0-1, x0-1, y0, kColorBlack, plotProc, data); /* -> finish tip of ellipse */
+ drawHLine(x1+1, x1+1, y0, kColorBlack, plotProc, data);
+ drawHLine(x0-1, x0-1, y1, kColorBlack, plotProc, data);
+ drawHLine(x1+1, x1+1, y1, kColorBlack, plotProc, data);
+ } else {
+ (*plotProc)(x0-1, y0, kColorBlack, data); /* -> finish tip of ellipse */
+ (*plotProc)(x1+1, y0, kColorBlack, data);
+ (*plotProc)(x0-1, y1, kColorBlack, data);
+ (*plotProc)(x1+1, y1, kColorBlack, data);
+ }
y0++;
- drawHLine(x0-1, x0-1, y1, kColorBlack, plotProc, data);
- drawHLine(x1+1, x1+1, y1, kColorBlack, plotProc, data);
y1--;
}
}
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 365f6c1..998682c 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -95,7 +95,7 @@ private:
void drawFilledRoundRect(Common::Rect &rect, int arc, int color, void (*plotProc)(int, int, int, void *), void *data);
void drawPolygonScan(int *polyX, int *polyY, int npoints, Common::Rect &bbox, int color,
void (*plotProc)(int, int, int, void *), void *data);
- void drawFilledEllipse(int x0, int y0, int x1, int y1, void (*plotProc)(int, int, int, void *), void *data);
+ void drawEllipse(int x0, int y0, int x1, int y1, bool filled, void (*plotProc)(int, int, int, void *), void *data);
void drawHLine(int x1, int x2, int y, int color, void (*plotProc)(int, int, int, void *), void *data);
void drawVLine(int x, int y1, int y2, int color, void (*plotProc)(int, int, int, void *), void *data);
void drawThickLine (int x1, int y1, int x2, int y2, int thick, int color,
Commit: a616e9fb093bc3c0aeea8f5dbaf088f201c414c3
https://github.com/scummvm/scummvm/commit/a616e9fb093bc3c0aeea8f5dbaf088f201c414c3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:57+01:00
Commit Message:
WAGE: More support for transparent primitives
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 9bd2fe6..0c0d205 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -154,11 +154,18 @@ void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool m
}
Common::Rect inner(x1 + borderThickness, y1 + borderThickness, x2 - borderThickness, y2 - borderThickness);
- drawFilledRect(outer, kColorBlack, drawPixel, &pd);
+ if (fillType <= patterns.size()) {
+ drawFilledRect(outer, kColorBlack, drawPixel, &pd);
- pd.fillType = fillType;
+ pd.fillType = fillType;
- drawFilledRect(inner, kColorBlack, drawPixel, &pd);
+ drawFilledRect(inner, kColorBlack, drawPixel, &pd);
+ } else {
+ drawThickLine(x1, y1, x2, y1, borderThickness, kColorBlack, drawPixel, &pd);
+ drawThickLine(x2, y1, x2, y2, borderThickness, kColorBlack, drawPixel, &pd);
+ drawThickLine(x2, y2, x1, y2, borderThickness, kColorBlack, drawPixel, &pd);
+ drawThickLine(x1, y2, x1, y1, borderThickness, kColorBlack, drawPixel, &pd);
+ }
}
void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
@@ -182,6 +189,10 @@ void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, b
pd.fillType = fillType;
+ if (fillType > patterns.size()) {
+ warning("Transparent roundrect");
+ }
+
drawFilledRoundRect(inner, arc/2, kColorBlack, drawPixel, &pd);
}
@@ -248,10 +259,12 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
return;
}
- drawPolygonScan(xpoints, ypoints, npoints, bbox, kColorBlack, drawPixel, &pd);
+ if (fillType <= patterns.size()) {
+ drawPolygonScan(xpoints, ypoints, npoints, bbox, kColorBlack, drawPixel, &pd);
+ }
pd.fillType = borderFillType;
- if (borderThickness > 0) {
+ if (borderThickness > 0 && borderFillType <= patterns.size()) {
for (int i = 1; i < npoints; i++)
drawThickLine(xpoints[i-1], ypoints[i-1], xpoints[i], ypoints[i], borderThickness, kColorBlack, drawPixel, &pd);
}
@@ -274,12 +287,12 @@ void Design::drawOval(Graphics::Surface *surface, Common::ReadStream &in, bool m
return;
}
- if (borderThickness > 0) {
+ if (borderThickness > 0 && borderFillType <= patterns.size()) {
if (borderThickness == 1) {
drawEllipse(x1, y1, x2-1, y2-1, false, drawPixel, &pd);
} else {
drawEllipse(x1, y1, x2-1, y2-1, true, drawPixel, &pd);
- warning("Ellips thickness >1: borderThickness");
+ warning("Ellipse thickness >1: borderThickness");
}
}
Commit: c17c2421f42e3cf67dbfcc956502c00652a14fec
https://github.com/scummvm/scummvm/commit/c17c2421f42e3cf67dbfcc956502c00652a14fec
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:57+01:00
Commit Message:
WAGE: Improved rounded rects. Now rects with radius > side are drawn correctly
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 0c0d205..7d78df8 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -60,6 +60,9 @@ struct plotData {
surface(s), patterns(p), fillType(f) {}
};
+void drawPixel(int x, int y, int color, void *data);
+void drawPixelPlain(int x, int y, int color, void *data);
+
Design::Design(Common::SeekableReadStream *data) {
_len = data->readUint16BE() - 2;
_data = (byte *)malloc(_len);
@@ -77,6 +80,24 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
canvas->fillRect(Common::Rect(0, 0, _bounds->width(), _bounds->height()), kColorWhite);
}
+/*
+ plotData pd(canvas, &patterns, 8);
+ Common::Rect inn(50, 50, 80, 150);
+ drawFilledRect(inn, kColorGray, drawPixelPlain, &pd);
+ drawFilledRoundRect(inn, 10, kColorBlack, drawPixelPlain, &pd);
+ Common::Rect inn2(100, 100, 200, 110);
+ drawFilledRect(inn2, kColorGray, drawPixelPlain, &pd);
+ drawFilledRoundRect(inn2, 10, kColorBlack, drawPixelPlain, &pd);
+ g_system->copyRectToScreen(canvas->getPixels(), canvas->pitch, 0, 0, canvas->w, canvas->h);
+
+ while (true) {
+ ((WageEngine *)g_engine)->processEvents();
+ g_system->updateScreen();
+ g_system->delayMillis(50);
+ }
+ return;
+*/
+
while (!in.eos()) {
byte fillType = in.readByte();
byte borderThickness = in.readByte();
@@ -370,20 +391,48 @@ void Design::drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int,
// http://members.chello.at/easyfilter/bresenham.html
void Design::drawFilledRoundRect(Common::Rect &rect, int arc, int color, void (*plotProc)(int, int, int, void *), void *data) {
- int x = -arc, y = 0, err = 2-2*arc; /* II. Quadrant */
- int dy = rect.height() - arc * 2;
- int r = arc;
+ if (rect.height() < rect.width()) {
+ int x = -arc, y = 0, err = 2-2*arc; /* II. Quadrant */
+ int dy = rect.height() - arc * 2;
+ int r = arc;
+ int stop = 0;
+ if (dy < 0)
+ stop = -dy / 2;
+
+ do {
+ drawHLine(rect.left+x+r, rect.right-x-r, rect.top-y+r-stop, color, plotProc, data);
+ drawHLine(rect.left+x+r, rect.right-x-r, rect.bottom+y-r+stop, color, plotProc, data);
+ arc = err;
+ if (arc <= y) err += ++y*2+1; /* e_xy+e_y < 0 */
+ if (arc > x || err > y) err += ++x*2+1; /* e_xy+e_x > 0 or no 2nd y-step */
+ if (stop && y > stop)
+ break;
+ } while (x < 0);
- do {
- drawHLine(rect.left+x+r, rect.right-x-r, rect.top-y+r, color, plotProc, data);
- drawHLine(rect.left+x+r, rect.right-x-r, rect.top+y+dy+r, color, plotProc, data);
- arc = err;
- if (arc <= y) err += ++y*2+1; /* e_xy+e_y < 0 */
- if (arc > x || err > y) err += ++x*2+1; /* e_xy+e_x > 0 or no 2nd y-step */
- } while (x < 0);
-
- for (int i = 0; i < dy; i++)
- drawHLine(rect.left, rect.right, rect.top + r + i, color, plotProc, data);
+ for (int i = 0; i < dy; i++)
+ drawHLine(rect.left, rect.right, rect.top + r + i, color, plotProc, data);
+ } else {
+ int y = -arc, x = 0, err = 2-2*arc; /* II. Quadrant */
+ int dx = rect.width() - arc * 2;
+ int r = arc;
+ int stop = 0;
+ if (dx < 0)
+ stop = -dx / 2;
+
+ do {
+ drawVLine(rect.left-x+r-stop, rect.top+y+r, rect.bottom-y-r, color, plotProc, data);
+ drawVLine(rect.right+x-r+stop, rect.top+y+r, rect.bottom-y-r, color, plotProc, data);
+
+ arc = err;
+ if (arc <= x) err += ++x*2+1; /* e_xy+e_y < 0 */
+ if (arc > y || err > x) err += ++y*2+1; /* e_xy+e_x > 0 or no 2nd y-step */
+ if (stop && x > stop)
+ break;
+ } while (y < 0);
+
+ for (int i = 0; i < dx; i++)
+ drawVLine(rect.left + r + i, rect.top, rect.bottom, color, plotProc, data);
+ }
}
// Based on public-domain code by Darel Rex Finley, 2007
Commit: 900903324d0adda5f8bd574b9b914088a13b5ac5
https://github.com/scummvm/scummvm/commit/900903324d0adda5f8bd574b9b914088a13b5ac5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:57+01:00
Commit Message:
WAGE: Fixed think vertical/horizontal lines
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 7d78df8..aab2eb7 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -378,7 +378,6 @@ void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool
x = 0;
break;
}
-
}
}
}
@@ -555,10 +554,16 @@ void Design::drawThickLine (int x1, int y1, int x2, int y2, int thick, int color
int dy = abs(y2 - y1);
if (dx == 0) {
- drawVLine(x1, y1, y2, color, plotProc, data);
+ if (y1 > y2)
+ SWAP(y1, y2);
+ Common::Rect r(x1, y1, x1 + thick, y2);
+ drawFilledRect(r, color, plotProc, data);
return;
} else if (dy == 0) {
- drawHLine(x1, x2, y1, color, plotProc, data);
+ if (x1 > x2)
+ SWAP(x1, x2);
+ Common::Rect r(x1, y1, x2, y1 + thick);
+ drawFilledRect(r, color, plotProc, data);
return;
}
Commit: a4ba9313be311637ac9c1a6185184b497182c540
https://github.com/scummvm/scummvm/commit/a4ba9313be311637ac9c1a6185184b497182c540
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:57+01:00
Commit Message:
WAGE: Fixed think transparent rectangles
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index aab2eb7..bafb3ad 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -82,12 +82,16 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
/*
plotData pd(canvas, &patterns, 8);
- Common::Rect inn(50, 50, 80, 150);
+ int x1 = 50, y1 = 50, x2 = 200, y2 = 200, borderThickness = 30;
+ Common::Rect inn(x1-5, y1-5, x2+5, y2+5);
drawFilledRect(inn, kColorGray, drawPixelPlain, &pd);
- drawFilledRoundRect(inn, 10, kColorBlack, drawPixelPlain, &pd);
- Common::Rect inn2(100, 100, 200, 110);
- drawFilledRect(inn2, kColorGray, drawPixelPlain, &pd);
- drawFilledRoundRect(inn2, 10, kColorBlack, drawPixelPlain, &pd);
+
+ drawThickLine(x1, y1, x2-borderThickness, y1, borderThickness, kColorBlack, drawPixel, &pd);
+ drawThickLine(x2-borderThickness, y1, x2-borderThickness, y2, borderThickness, kColorBlack, drawPixel, &pd);
+ drawThickLine(x2-borderThickness, y2-borderThickness, x1, y2-borderThickness, borderThickness, kColorBlack, drawPixel, &pd);
+ drawThickLine(x1, y2-borderThickness, x1, y1, borderThickness, kColorBlack, drawPixel, &pd);
+ drawThickLine(x2+10, y2+10, x2+100, y2+100, borderThickness, kColorBlack, drawPixel, &pd);
+
g_system->copyRectToScreen(canvas->getPixels(), canvas->pitch, 0, 0, canvas->w, canvas->h);
while (true) {
@@ -182,10 +186,10 @@ void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool m
drawFilledRect(inner, kColorBlack, drawPixel, &pd);
} else {
- drawThickLine(x1, y1, x2, y1, borderThickness, kColorBlack, drawPixel, &pd);
- drawThickLine(x2, y1, x2, y2, borderThickness, kColorBlack, drawPixel, &pd);
- drawThickLine(x2, y2, x1, y2, borderThickness, kColorBlack, drawPixel, &pd);
- drawThickLine(x1, y2, x1, y1, borderThickness, kColorBlack, drawPixel, &pd);
+ drawThickLine(x1, y1, x2-borderThickness, y1, borderThickness, kColorBlack, drawPixel, &pd);
+ drawThickLine(x2-borderThickness, y1, x2-borderThickness, y2, borderThickness, kColorBlack, drawPixel, &pd);
+ drawThickLine(x2-borderThickness, y2-borderThickness, x1, y2-borderThickness, borderThickness, kColorBlack, drawPixel, &pd);
+ drawThickLine(x1, y2-borderThickness, x1, y1, borderThickness, kColorBlack, drawPixel, &pd);
}
}
Commit: bb46957defcc1dc5182af6b8efe91086e572e991
https://github.com/scummvm/scummvm/commit/bb46957defcc1dc5182af6b8efe91086e572e991
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:57+01:00
Commit Message:
WAGE: Fixed ver/horisontal lines thickness
Changed paths:
engines/wage/design.cpp
engines/wage/wage.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index bafb3ad..0b9db3b 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -560,13 +560,13 @@ void Design::drawThickLine (int x1, int y1, int x2, int y2, int thick, int color
if (dx == 0) {
if (y1 > y2)
SWAP(y1, y2);
- Common::Rect r(x1, y1, x1 + thick, y2);
+ Common::Rect r(x1, y1, x1 + thick - 1, y2);
drawFilledRect(r, color, plotProc, data);
return;
} else if (dy == 0) {
if (x1 > x2)
SWAP(x1, x2);
- Common::Rect r(x1, y1, x2, y1 + thick);
+ Common::Rect r(x1, y1, x2, y1 + thick - 1);
drawFilledRect(r, color, plotProc, data);
return;
}
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 52a5f5c..093c94a 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -108,8 +108,8 @@ Common::Error WageEngine::run() {
Graphics::Surface screen;
screen.create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
Common::Rect r(0, 0, screen.w, screen.h);
- //_world->_objs["frank.1"]->_design->setBounds(&r);
- //_world->_objs["frank.1"]->_design->paint(&screen, _world->_patterns, false);
+ _world->_objs["frank.1"]->_design->setBounds(&r);
+ _world->_objs["frank.1"]->_design->paint(&screen, _world->_patterns, false);
_world->_scenes["temple of the holy mackeral"]->_design->setBounds(&r);
_world->_scenes["temple of the holy mackeral"]->_design->paint(&screen, _world->_patterns, false);
//_world->_scenes["tower level 3"]->_design->setBounds(&r);
Commit: 5b957c4b06b3b1160b97d17ab78d86d7e78c46c1
https://github.com/scummvm/scummvm/commit/5b957c4b06b3b1160b97d17ab78d86d7e78c46c1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:58+01:00
Commit Message:
WAGE: Implementing loading service dialog strings
Changed paths:
engines/wage/world.cpp
engines/wage/world.h
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index ec1d894..776d5df 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -60,6 +60,11 @@ World::World() {
_storageScene._name = STORAGESCENE;
_orderedScenes.push_back(&_storageScene);
_scenes[STORAGESCENE] = &_storageScene;
+
+ _gameOverMessage = nullptr;
+ _saveBeforeQuitMessage = nullptr;
+ _saveBeforeCloseMessage = nullptr;
+ _revertMessage = nullptr;
}
bool World::loadWorld(Common::MacResManager *resMan) {
@@ -106,6 +111,28 @@ bool World::loadWorld(Common::MacResManager *resMan) {
delete res;
}
+ Common::String *message;
+ if ((message = loadStringFromDITL(resMan, 2910, 1)) != NULL) {
+ message->trim();
+ warning("_gameOverMessage: %s", message->c_str());
+ _gameOverMessage = message;
+ }
+ if ((message = loadStringFromDITL(resMan, 2480, 3)) != NULL) {
+ message->trim();
+ warning("_saveBeforeQuitMessage: %s", message->c_str());
+ _saveBeforeQuitMessage = message;
+ }
+ if ((message = loadStringFromDITL(resMan, 2490, 3)) != NULL) {
+ message->trim();
+ warning("_saveBeforeCloseMessage: %s", message->c_str());
+ _saveBeforeCloseMessage = message;
+ }
+ if ((message = loadStringFromDITL(resMan, 2940, 2)) != NULL) {
+ message->trim();
+ warning("_revertMessage: %s", message->c_str());
+ _revertMessage = message;
+ }
+
// Load scenes
resArray = resMan->getResIDArray(MKTAG('A','S','C','N'));
debug(3, "Loading %d scenes", resArray.size());
@@ -221,4 +248,22 @@ void World::loadExternalSounds(String fname) {
}
}
+Common::String *World::loadStringFromDITL(Common::MacResManager *resMan, int resourceId, int itemIndex) {
+ Common::SeekableReadStream *res = resMan->getResource(MKTAG('D','I','T','L'), resourceId);
+ if (res) {
+ int itemCount = res->readSint16BE();
+ for (int i = 0; i <= itemCount; i++) {
+ // int placeholder; short rect[4]; byte flags; pstring str;
+ res->skip(13);
+ Common::String message = readPascalString(res);
+ if (i == itemIndex) {
+ Common::String *msg = new Common::String(message);
+ return msg;
+ }
+ }
+ }
+
+ return NULL;
+}
+
} // End of namespace Wage
diff --git a/engines/wage/world.h b/engines/wage/world.h
index 1b1bc73..1514b57 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -59,6 +59,7 @@ public:
bool loadWorld(Common::MacResManager *resMan);
void loadExternalSounds(String fname);
+ Common::String *loadStringFromDITL(Common::MacResManager *resMan, int resourceId, int itemIndex);
String _name;
String _aboutMessage;
@@ -80,6 +81,11 @@ public:
Chr *_player;
//List<MoveListener> moveListeners;
+ Common::String *_gameOverMessage;
+ Common::String *_saveBeforeQuitMessage;
+ Common::String *_saveBeforeCloseMessage;
+ Common::String *_revertMessage;
+
void addScene(Scene *room) {
if (room->_name.size() != 0) {
String s = room->_name;
Commit: d5c3b45756b7aced60b39d621920ba9b6b8ab09b
https://github.com/scummvm/scummvm/commit/d5c3b45756b7aced60b39d621920ba9b6b8ab09b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:58+01:00
Commit Message:
WAGE: Added enhanced Skepters pattern loading
Changed paths:
engines/wage/world.cpp
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 776d5df..d84f31b 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -218,6 +218,18 @@ bool World::loadWorld(Common::MacResManager *resMan) {
}
delete res;
+ } else {
+ /* Enchanted Scepters did not use the PAT# resource for the textures. */
+ res = resMan->getResource(MKTAG('C','O','D','E'), 1);
+ if (res != NULL) {
+ res->skip(0x55ac);
+ for (int i = 0; i < 29; i++) {
+ byte *pattern = (byte *)malloc(8);
+
+ res->read(pattern, 8);
+ _patterns.push_back(pattern);
+ }
+ }
}
return true;
Commit: 6590f2c3f7ab594ae728409d6dca3251b36798cf
https://github.com/scummvm/scummvm/commit/6590f2c3f7ab594ae728409d6dca3251b36798cf
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:58+01:00
Commit Message:
WAGE: Added stubs for menu loading
Changed paths:
engines/wage/entities.cpp
engines/wage/world.cpp
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index d75a348..c499283 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -62,8 +62,6 @@ Scene::Scene(String name, Common::SeekableReadStream *data) {
_name = name;
_design = new Design(data);
- warning("Scene %s", _name.c_str());
-
setDesignBounds(readRect(data));
_worldY = data->readSint16BE();
_worldX = data->readSint16BE();
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index d84f31b..0fd31c6 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -230,7 +230,33 @@ bool World::loadWorld(Common::MacResManager *resMan) {
_patterns.push_back(pattern);
}
}
+ delete res;
+ }
+
+ res = resMan->getResource(MKTAG('M','E','N','U'), 2001);
+ if (res != NULL) {
+ warning("STUB: aboutMenu");
+ //String aboutMenuItemName = appleMenu[1].split(";")[0];
+ //world.setAboutMenuItemName(aboutMenuItemName);
+ delete res;
+ }
+ res = resMan->getResource(MKTAG('M','E','N','U'), 2004);
+ if (res != NULL) {
+ warning("STUB: commandsMenu");
+ //world.setCommandsMenuName(commandsMenu[0]);
+ //world.setDefaultCommandsMenu(commandsMenu[1]);
+ delete res;
+ }
+ res = resMan->getResource(MKTAG('M','E','N','U'), 2005);
+ if (res != NULL) {
+ warning("STUB: weaponsMenu");
+ //world.setWeaponsMenuName(weaponsMenu[0]);
+ delete res;
}
+ // TODO: Read Apple menu and get the name of that menu item..
+
+ // store global info in state object for use with save/load actions
+ //world.setCurrentState(initialState); // pass off the state object to the world
return true;
}
Commit: c1d051da65e9790330f712c9e3962e31af965851
https://github.com/scummvm/scummvm/commit/c1d051da65e9790330f712c9e3962e31af965851
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:58+01:00
Commit Message:
WAGE: More work on menu reading
Changed paths:
engines/wage/world.cpp
engines/wage/world.h
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 0fd31c6..96f3faf 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -45,15 +45,16 @@
*
*/
+#include "common/file.h"
+#include "common/macresman.h"
+#include "common/memstream.h"
+#include "common/str-array.h"
+
#include "wage/wage.h"
#include "wage/entities.h"
#include "wage/script.h"
#include "wage/world.h"
-#include "common/file.h"
-#include "common/macresman.h"
-#include "common/memstream.h"
-
namespace Wage {
World::World() {
@@ -235,6 +236,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
res = resMan->getResource(MKTAG('M','E','N','U'), 2001);
if (res != NULL) {
+ readMenu(res);
warning("STUB: aboutMenu");
//String aboutMenuItemName = appleMenu[1].split(";")[0];
//world.setAboutMenuItemName(aboutMenuItemName);
@@ -242,6 +244,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
}
res = resMan->getResource(MKTAG('M','E','N','U'), 2004);
if (res != NULL) {
+ readMenu(res);
warning("STUB: commandsMenu");
//world.setCommandsMenuName(commandsMenu[0]);
//world.setDefaultCommandsMenu(commandsMenu[1]);
@@ -249,6 +252,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
}
res = resMan->getResource(MKTAG('M','E','N','U'), 2005);
if (res != NULL) {
+ readMenu(res);
warning("STUB: weaponsMenu");
//world.setWeaponsMenuName(weaponsMenu[0]);
delete res;
@@ -261,6 +265,48 @@ bool World::loadWorld(Common::MacResManager *resMan) {
return true;
}
+Common::StringArray World::readMenu(Common::SeekableReadStream *res) {
+ res->skip(10);
+ int enableFlags = res->readUint32BE();
+ String menuName = readPascalString(res);
+ String menuItem = readPascalString(res);
+ int menuItemNumber = 1;
+ Common::String sb;
+ byte itemData[4];
+
+ while (menuItem.size() > 0) {
+ if (sb.size() > 0) {
+ sb += ';';
+ }
+ if ((enableFlags & (1 << menuItemNumber)) == 0) {
+ sb += '(';
+ }
+ sb += menuItem;
+ res->read(itemData, 4);
+ static const char styles[] = {'B', 'I', 'U', 'O', 'S', 'C', 'E', 0};
+ for (int i = 0; styles[i] != 0; i++) {
+ if ((itemData[3] & (1 << i)) != 0) {
+ sb += '<';
+ sb += styles[i];
+ }
+ }
+ if (itemData[1] != 0) {
+ sb += '/';
+ sb += (char)itemData[1];
+ }
+ menuItem = readPascalString(res);
+ menuItemNumber++;
+ }
+
+ Common::StringArray result;
+ result.push_back(menuName);
+ result.push_back(sb);
+
+ warning("menuName: %s", menuName.c_str());
+ warning("sb: %s", sb.c_str());
+ return result;
+}
+
void World::loadExternalSounds(String fname) {
Common::File in;
diff --git a/engines/wage/world.h b/engines/wage/world.h
index 1514b57..8e45dcb 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -117,6 +117,9 @@ public:
_sounds[s] = sound;
_orderedSounds.push_back(sound);
}
+
+private:
+ Common::StringArray readMenu(Common::SeekableReadStream *res);
};
} // End of namespace Wage
Commit: 5c2f3301f0b02d080de43f06efabec117903cec2
https://github.com/scummvm/scummvm/commit/5c2f3301f0b02d080de43f06efabec117903cec2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:58+01:00
Commit Message:
WAGE: More robust rectangle drawing
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 0b9db3b..f347c33 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -169,6 +169,12 @@ void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool m
int16 x1 = in.readSint16BE();
int16 y2 = in.readSint16BE();
int16 x2 = in.readSint16BE();
+
+ if (x1 > x2)
+ SWAP(x1, x2);
+ if (y1 > y2)
+ SWAP(y1, y2);
+
Common::Rect outer(x1, y1, x2, y2);
plotData pd(surface, &patterns, borderFillType);
@@ -200,6 +206,12 @@ void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, b
int16 y2 = in.readSint16BE();
int16 x2 = in.readSint16BE();
int16 arc = in.readSint16BE();
+
+ if (x1 > x2)
+ SWAP(x1, x2);
+ if (y1 > y2)
+ SWAP(y1, y2);
+
Common::Rect outer(x1, y1, x2, y2);
plotData pd(surface, &patterns, borderFillType);
@@ -215,7 +227,7 @@ void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, b
pd.fillType = fillType;
if (fillType > patterns.size()) {
- warning("Transparent roundrect");
+ warning("Transparent roundrect, border: %d", borderThickness);
}
drawFilledRoundRect(inner, arc/2, kColorBlack, drawPixel, &pd);
Commit: 80af9c9c711392ff888c747ce980a69518423d31
https://github.com/scummvm/scummvm/commit/80af9c9c711392ff888c747ce980a69518423d31
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:58+01:00
Commit Message:
WAGE: Stubs for command processing
Changed paths:
engines/wage/script.cpp
engines/wage/script.h
engines/wage/wage.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 65d4fbb..19de26e 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -120,41 +120,38 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
}
}
-
if (_world->_globalScript != this) {
debug(0, "Executing global script...");
bool globalHandled = _world->_globalScript->execute(_world, _loopCount, _inputText, _inputClick, _callbacks);
if (globalHandled)
_handled = true;
- }
-
-#if 0
- else if (inputText != null) {
- String input = inputText.toLowerCase();
+ } else if (inputText != NULL) {
+ Common::String input(*inputText);
+ input.toLowercase();
if (input.equals("n") || input.contains("north")) {
- handleMoveCommand(Scene.NORTH, "north");
+ handleMoveCommand(Scene::NORTH, "north");
} else if (input.equals("e") || input.contains("east")) {
- handleMoveCommand(Scene.EAST, "east");
+ handleMoveCommand(Scene::EAST, "east");
} else if (input.equals("s") || input.contains("south")) {
- handleMoveCommand(Scene.SOUTH, "south");
+ handleMoveCommand(Scene::SOUTH, "south");
} else if (input.equals("w") || input.contains("west")) {
- handleMoveCommand(Scene.WEST, "west");
- } else if (input.startsWith("take ")) {
- handleTakeCommand(input.substring(5));
- } else if (input.startsWith("get ")) {
- handleTakeCommand(input.substring(4));
- } else if (input.startsWith("pick up ")) {
- handleTakeCommand(input.substring(8));
- } else if (input.startsWith("drop ")) {
- handleDropCommand(input.substring(5));
- } else if (input.startsWith("aim ")) {
- handleAimCommand(input.substring(4));
- } else if (input.startsWith("wear ")) {
- handleWearCommand(input.substring(5));
- } else if (input.startsWith("put on ")) {
- handleWearCommand(input.substring(7));
- } else if (input.startsWith("offer ")) {
- handleOfferCommand(input.substring(6));
+ handleMoveCommand(Scene::WEST, "west");
+ } else if (input.hasPrefix("take ")) {
+ handleTakeCommand(&input.c_str()[5]);
+ } else if (input.hasPrefix("get ")) {
+ handleTakeCommand(&input.c_str()[4]);
+ } else if (input.hasPrefix("pick up ")) {
+ handleTakeCommand(&input.c_str()[8]);
+ } else if (input.hasPrefix("drop ")) {
+ handleDropCommand(&input.c_str()[5]);
+ } else if (input.hasPrefix("aim ")) {
+ handleAimCommand(&input.c_str()[4]);
+ } else if (input.hasPrefix("wear ")) {
+ handleWearCommand(&input.c_str()[5]);
+ } else if (input.hasPrefix("put on ")) {
+ handleWearCommand(&input.c_str()[7]);
+ } else if (input.hasPrefix("offer ")) {
+ handleOfferCommand(&input.c_str()[6]);
} else if (input.contains("look")) {
handleLookCommand();
} else if (input.contains("inventory")) {
@@ -163,7 +160,8 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
handleStatusCommand();
} else if (input.contains("rest") || input.equals("wait")) {
handleRestCommand();
- } else if (callbacks.getOffer() != null && input.contains("accept")) {
+ /*
+ } else if (callbacks.getOffer() != NULL && input.contains("accept")) {
handleAcceptCommand();
} else {
Chr player = world.getPlayer();
@@ -173,7 +171,9 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
break;
}
}
+ */
}
+/*
// TODO: weapons, offer, etc...
} else if (inputClick instanceof Obj) {
Obj obj = (Obj) inputClick;
@@ -182,12 +182,12 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
} else {
appendText(obj.getClickMessage());
}
+*/
}
-#endif
return _handled;
}
-
+
Script::Operand *Script::readOperand() {
byte operandType = _data->readByte();
switch (operandType) {
@@ -318,4 +318,37 @@ void Script::appendText(String str) {
_callbacks->appendText(str);
}
+void Script::handleMoveCommand(Scene::Directions dir, const char *dirName) {
+}
+
+void Script::handleLookCommand() {
+}
+
+void Script::handleInventoryCommand() {
+}
+
+void Script::handleStatusCommand() {
+}
+
+void Script::handleRestCommand() {
+}
+
+void Script::handleAcceptCommand() {
+}
+
+void Script::handleTakeCommand(const char *target) {
+}
+
+void Script::handleDropCommand(const char *target) {
+}
+
+void Script::handleAimCommand(const char *target) {
+}
+
+void Script::handleWearCommand(const char *target) {
+}
+
+void Script::handleOfferCommand(const char *target) {
+}
+
} // End of namespace Wage
diff --git a/engines/wage/script.h b/engines/wage/script.h
index e898d51..5d5f9ef 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -47,7 +47,7 @@
#ifndef WAGE_SCRIPT_H
#define WAGE_SCRIPT_H
-
+
namespace Wage {
class Script {
@@ -77,7 +77,7 @@ private:
CLICK_INPUT = 5,
TEXT_INPUT = 6
};
-
+
union {
Obj *obj;
Chr *chr;
@@ -88,7 +88,7 @@ private:
} _value;
OperandTypes _type;
String _str;
-
+
Operand(Obj *value, OperandTypes type) {
_value.obj = value;
_str = value->toString();
@@ -135,9 +135,20 @@ private:
void processLet();
void appendText(String str);
-
+ void handleMoveCommand(Scene::Directions dir, const char *dirName);
+ void handleLookCommand();
+ void handleInventoryCommand();
+ void handleStatusCommand();
+ void handleRestCommand();
+ void handleAcceptCommand();
+
+ void handleTakeCommand(const char *target);
+ void handleDropCommand(const char *target);
+ void handleAimCommand(const char *target);
+ void handleWearCommand(const char *target);
+ void handleOfferCommand(const char *target);
};
} // End of namespace Wage
-
+
#endif
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 093c94a..0689d90 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -108,6 +108,8 @@ Common::Error WageEngine::run() {
Graphics::Surface screen;
screen.create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
Common::Rect r(0, 0, screen.w, screen.h);
+
+ _world->_orderedScenes[1]->_design->paint(&screen, _world->_patterns, false);
_world->_objs["frank.1"]->_design->setBounds(&r);
_world->_objs["frank.1"]->_design->paint(&screen, _world->_patterns, false);
_world->_scenes["temple of the holy mackeral"]->_design->setBounds(&r);
Commit: c40b5a30c035729b953979e709e5b35a8d1b5b63
https://github.com/scummvm/scummvm/commit/c40b5a30c035729b953979e709e5b35a8d1b5b63
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:59+01:00
Commit Message:
WAGE: Implement proper design drawing quitting
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index f347c33..8ea5501 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -102,12 +102,16 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
return;
*/
- while (!in.eos()) {
+ while (true) {
byte fillType = in.readByte();
+
+ if (in.eos())
+ return;
+
byte borderThickness = in.readByte();
byte borderFillType = in.readByte();
int type = in.readByte();
- warning("fill: %d border: %d borderFill: %d type: %d", fillType, borderThickness, borderFillType, type);
+ debug(2, "fill: %d borderFill: %d border: %d type: %d", fillType, borderFillType, borderThickness, type);
switch (type) {
case 4:
drawRect(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
Commit: 423d3642960e2187d90eae17b5ce0115b2219c48
https://github.com/scummvm/scummvm/commit/423d3642960e2187d90eae17b5ce0115b2219c48
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:59+01:00
Commit Message:
WAGE: Implemented processLet()
Changed paths:
engines/wage/script.cpp
engines/wage/script.h
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 19de26e..0c550da 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -190,6 +190,7 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
Script::Operand *Script::readOperand() {
byte operandType = _data->readByte();
+ Context *cont = &_world->_player->_context;
switch (operandType) {
case 0xA0: // TEXT$
return new Operand(_inputText, Operand::TEXT_INPUT);
@@ -210,7 +211,7 @@ Script::Operand *Script::readOperand() {
case 0xC6: // RANDOMOBJ@
return new Operand(_world->_orderedObjs[_callbacks->_rnd->getRandomNumber(_world->_orderedObjs.size())], Operand::OBJ);
case 0xB0: // VISITS#
- return new Operand(_world->_player->_context._visits, Operand::NUMBER);
+ return new Operand(cont->_visits, Operand::NUMBER);
case 0xB1: // RANDOM# for Star Trek, but VISITS# for some other games?
return new Operand(1 + _callbacks->_rnd->getRandomNumber(100), Operand::NUMBER);
case 0xB5: // RANDOM# // A random number between 1 and 100.
@@ -218,55 +219,55 @@ Script::Operand *Script::readOperand() {
case 0xB2: // LOOP#
return new Operand(_loopCount, Operand::NUMBER);
case 0xB3: // VICTORY#
- return new Operand(_world->_player->_context._kills, Operand::NUMBER);
+ return new Operand(cont->_kills, Operand::NUMBER);
case 0xB4: // BADCOPY#
return new Operand(0, Operand::NUMBER); // ????
case 0xFF:
{
// user variable
- int value = _data->readByte();
+ int value = _data->readSByte();
if (value < 0)
value += 256;
// TODO: Verify that we're using the right index.
- return new Operand(_world->_player->_context._userVariables[value], Operand::NUMBER);
+ return new Operand(cont->_userVariables[value - 1], Operand::NUMBER);
}
case 0xD0:
- return new Operand(_world->_player->_context._statVariables[Context::PHYS_STR_BAS], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::PHYS_STR_BAS], Operand::NUMBER);
case 0xD1:
- return new Operand(_world->_player->_context._statVariables[Context::PHYS_HIT_BAS], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::PHYS_HIT_BAS], Operand::NUMBER);
case 0xD2:
- return new Operand(_world->_player->_context._statVariables[Context::PHYS_ARM_BAS], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::PHYS_ARM_BAS], Operand::NUMBER);
case 0xD3:
- return new Operand(_world->_player->_context._statVariables[Context::PHYS_ACC_BAS], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::PHYS_ACC_BAS], Operand::NUMBER);
case 0xD4:
- return new Operand(_world->_player->_context._statVariables[Context::SPIR_STR_BAS], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::SPIR_STR_BAS], Operand::NUMBER);
case 0xD5:
- return new Operand(_world->_player->_context._statVariables[Context::SPIR_HIT_BAS], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::SPIR_HIT_BAS], Operand::NUMBER);
case 0xD6:
- return new Operand(_world->_player->_context._statVariables[Context::SPIR_ARM_BAS], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::SPIR_ARM_BAS], Operand::NUMBER);
case 0xD7:
- return new Operand(_world->_player->_context._statVariables[Context::SPIR_ACC_BAS], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::SPIR_ACC_BAS], Operand::NUMBER);
case 0xD8:
- return new Operand(_world->_player->_context._statVariables[Context::PHYS_SPE_BAS], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::PHYS_SPE_BAS], Operand::NUMBER);
case 0xE0:
- return new Operand(_world->_player->_context._statVariables[Context::PHYS_STR_CUR], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::PHYS_STR_CUR], Operand::NUMBER);
case 0xE1:
- return new Operand(_world->_player->_context._statVariables[Context::PHYS_HIT_CUR], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::PHYS_HIT_CUR], Operand::NUMBER);
case 0xE2:
- return new Operand(_world->_player->_context._statVariables[Context::PHYS_ARM_CUR], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::PHYS_ARM_CUR], Operand::NUMBER);
case 0xE3:
- return new Operand(_world->_player->_context._statVariables[Context::PHYS_ACC_CUR], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::PHYS_ACC_CUR], Operand::NUMBER);
case 0xE4:
- return new Operand(_world->_player->_context._statVariables[Context::SPIR_STR_CUR], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::SPIR_STR_CUR], Operand::NUMBER);
case 0xE5:
- return new Operand(_world->_player->_context._statVariables[Context::SPIR_HIT_CUR], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::SPIR_HIT_CUR], Operand::NUMBER);
case 0xE6:
- return new Operand(_world->_player->_context._statVariables[Context::SPIR_ARM_CUR], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::SPIR_ARM_CUR], Operand::NUMBER);
case 0xE7:
- return new Operand(_world->_player->_context._statVariables[Context::SPIR_ACC_CUR], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::SPIR_ACC_CUR], Operand::NUMBER);
case 0xE8:
- return new Operand(_world->_player->_context._statVariables[Context::PHYS_SPE_CUR], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::PHYS_SPE_CUR], Operand::NUMBER);
default:
if (operandType >= 0x20 && operandType < 0x80) {
return readStringOperand();
@@ -277,6 +278,77 @@ Script::Operand *Script::readOperand() {
}
}
+void Script::assign(byte operandType, int uservar, uint16 value) {
+ Context *cont = &_world->_player->_context;
+
+ switch (operandType) {
+ case 0xFF:
+ {
+ // user variable
+ if (uservar < 0)
+ uservar += 256;
+
+ cont->_userVariables[uservar - 1] = value;
+ }
+ case 0xD0:
+ cont->_statVariables[Context::PHYS_STR_BAS] = value;
+ break;
+ case 0xD1:
+ cont->_statVariables[Context::PHYS_HIT_BAS] = value;
+ break;
+ case 0xD2:
+ cont->_statVariables[Context::PHYS_ARM_BAS] = value;
+ break;
+ case 0xD3:
+ cont->_statVariables[Context::PHYS_ACC_BAS] = value;
+ break;
+ case 0xD4:
+ cont->_statVariables[Context::SPIR_STR_BAS] = value;
+ break;
+ case 0xD5:
+ cont->_statVariables[Context::SPIR_HIT_BAS] = value;
+ break;
+ case 0xD6:
+ cont->_statVariables[Context::SPIR_ARM_BAS] = value;
+ break;
+ case 0xD7:
+ cont->_statVariables[Context::SPIR_ACC_BAS] = value;
+ break;
+ case 0xD8:
+ cont->_statVariables[Context::PHYS_SPE_BAS] = value;
+ break;
+ case 0xE0:
+ cont->_statVariables[Context::PHYS_STR_CUR] = value;
+ break;
+ case 0xE1:
+ cont->_statVariables[Context::PHYS_HIT_CUR] = value;
+ break;
+ case 0xE2:
+ cont->_statVariables[Context::PHYS_ARM_CUR] = value;
+ break;
+ case 0xE3:
+ cont->_statVariables[Context::PHYS_ACC_CUR] = value;
+ break;
+ case 0xE4:
+ cont->_statVariables[Context::SPIR_STR_CUR] = value;
+ break;
+ case 0xE5:
+ cont->_statVariables[Context::SPIR_HIT_CUR] = value;
+ break;
+ case 0xE6:
+ cont->_statVariables[Context::SPIR_ARM_CUR] = value;
+ break;
+ case 0xE7:
+ cont->_statVariables[Context::SPIR_ACC_CUR] = value;
+ break;
+ case 0xE8:
+ cont->_statVariables[Context::PHYS_SPE_CUR] = value;
+ break;
+ default:
+ debug("No idea what I'm supposed to assign! (%x at %d)!\n", operandType, _data->pos()-1);
+ }
+}
+
Script::Operand *Script::readStringOperand() {
String *sb;
bool allDigits = true;
@@ -304,13 +376,78 @@ Script::Operand *Script::readStringOperand() {
}
}
+const char *Script::readOperator() {
+ byte cmd = _data->readByte();
+
+ switch (cmd) {
+ case 0x81:
+ return "=";
+ case 0x82:
+ return "<";
+ case 0x83:
+ return ">";
+ case 0x8f:
+ return "+";
+ case 0x90:
+ return "-";
+ case 0x91:
+ return "*";
+ case 0x92:
+ return "/";
+ case 0x93:
+ return "==";
+ case 0x94:
+ return ">>";
+ case 0xfd:
+ return ";";
+ default:
+ warning("UNKNOWN OP %x", cmd);
+ }
+ return NULL;
+}
+
void Script::processIf() {
+ warning("STUB: processIf");
}
void Script::processMove() {
+ warning("STUB: processMove");
}
void Script::processLet() {
+ const char *lastOp = NULL;
+ int16 result = 0;
+ int operandType = _data->readByte();
+ int uservar = 0;
+
+ if (operandType == 0xff)
+ uservar = _data->readSByte();
+
+ _data->readByte(); // skip "=" operator
+ do {
+ Operand *operand = readOperand();
+ // TODO assert that value is NUMBER
+ int16 value = operand->_value.number;
+ if (lastOp != NULL) {
+ if (lastOp[0] == '+')
+ result += value;
+ else if (lastOp[0] == '-')
+ result -= value;
+ else if (lastOp[0] == '/')
+ result = (int16)(value == 0 ? 0 : result / value);
+ else if (lastOp[0] == '*')
+ result *= value;
+ } else {
+ result = value;
+ }
+ lastOp = readOperator();
+
+ if (lastOp[0] == ';')
+ break;
+ } while (true);
+ //System.out.println("processLet " + buildStringFromOffset(oldIndex - 1, index - oldIndex + 1) + "}");
+
+ assign(operandType, uservar, result);
}
void Script::appendText(String str) {
@@ -319,36 +456,47 @@ void Script::appendText(String str) {
}
void Script::handleMoveCommand(Scene::Directions dir, const char *dirName) {
+ warning("STUB: handleMoveCommand");
}
void Script::handleLookCommand() {
+ warning("STUB: handleLookCommand");
}
void Script::handleInventoryCommand() {
+ warning("STUB: handleInventoryCommand");
}
void Script::handleStatusCommand() {
+ warning("STUB: handleStatusCommand");
}
void Script::handleRestCommand() {
+ warning("STUB: handleRestCommand");
}
void Script::handleAcceptCommand() {
+ warning("STUB: handleAcceptCommand");
}
void Script::handleTakeCommand(const char *target) {
+ warning("STUB: handleTakeCommand");
}
void Script::handleDropCommand(const char *target) {
+ warning("STUB: handleDropCommand");
}
void Script::handleAimCommand(const char *target) {
+ warning("STUB: handleAimCommand");
}
void Script::handleWearCommand(const char *target) {
+ warning("STUB: handleWearCommand");
}
void Script::handleOfferCommand(const char *target) {
+ warning("STUB: handleOfferCommand");
}
} // End of namespace Wage
diff --git a/engines/wage/script.h b/engines/wage/script.h
index 5d5f9ef..f99e6d9 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -130,10 +130,13 @@ private:
bool execute(World *world, int loopCount, String *inputText, Designed *inputClick, WageEngine *callbacks);
Operand *readOperand();
Operand *readStringOperand();
+ const char *readOperator();
void processIf();
void processMove();
void processLet();
+ void assign(byte operandType, int uservar, uint16 value);
+
void appendText(String str);
void handleMoveCommand(Scene::Directions dir, const char *dirName);
void handleLookCommand();
Commit: 878d1dc78bf62fda3ccfc9ffb04e63f7ad7d3742
https://github.com/scummvm/scummvm/commit/878d1dc78bf62fda3ccfc9ffb04e63f7ad7d3742
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:59+01:00
Commit Message:
WAGE: Fixed uservar addressing
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 0c550da..60a7e95 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -225,9 +225,7 @@ Script::Operand *Script::readOperand() {
case 0xFF:
{
// user variable
- int value = _data->readSByte();
- if (value < 0)
- value += 256;
+ int value = _data->readByte();
// TODO: Verify that we're using the right index.
return new Operand(cont->_userVariables[value - 1], Operand::NUMBER);
@@ -283,13 +281,8 @@ void Script::assign(byte operandType, int uservar, uint16 value) {
switch (operandType) {
case 0xFF:
- {
- // user variable
- if (uservar < 0)
- uservar += 256;
-
- cont->_userVariables[uservar - 1] = value;
- }
+ cont->_userVariables[uservar - 1] = value;
+ break;
case 0xD0:
cont->_statVariables[Context::PHYS_STR_BAS] = value;
break;
@@ -421,7 +414,7 @@ void Script::processLet() {
int uservar = 0;
if (operandType == 0xff)
- uservar = _data->readSByte();
+ uservar = _data->readByte();
_data->readByte(); // skip "=" operator
do {
Commit: e71fe81d0900c8f6797386251f5ea3ad9ca5c9ed
https://github.com/scummvm/scummvm/commit/e71fe81d0900c8f6797386251f5ea3ad9ca5c9ed
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:59+01:00
Commit Message:
WAGE: stubbed attack handling
Changed paths:
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/script.cpp
engines/wage/script.h
engines/wage/wage.cpp
engines/wage/wage.h
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index c499283..75b624c 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -192,4 +192,12 @@ Chr::Chr(String name, Common::SeekableReadStream *data) {
_weaponSound2 = readPascalString(data);
}
+WeaponArray *Chr::getWeapons() {
+ WeaponArray *list = new WeaponArray;
+
+ warning("STUB: getWeapons");
+
+ return list;
+}
+
} // End of namespace Wage
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 43bc55f..edb63ef 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -54,6 +54,9 @@ class Design;
class Obj;
class Scene;
class Script;
+class Weapon;
+
+typedef Common::Array<Weapon *> WeaponArray;
class Context {
public:
@@ -111,7 +114,7 @@ public:
Design *_design;
Common::Rect *_designBounds;
- Common::Rect *getDesignBounds() {
+ Common::Rect *getDesignBounds() {
return _designBounds == NULL ? NULL : new Common::Rect(*_designBounds);
}
@@ -139,7 +142,7 @@ public:
BODY_ARMOR = 1,
SHIELD_ARMOR = 2
};
-
+
Chr(String name, Common::SeekableReadStream *data);
int _index;
@@ -149,7 +152,7 @@ public:
bool _playerCharacter;
int _maximumCarriedObjects;
int _returnTo;
-
+
int _physicalStrength;
int _physicalHp;
int _naturalArmor;
@@ -161,7 +164,7 @@ public:
int _runningSpeed;
int _rejectsOffers;
int _followsOpponent;
-
+
String _initialSound;
String _scoresHitSound;
String _receivesHitSound;
@@ -171,12 +174,12 @@ public:
String _operativeVerb1;
int _weaponDamage1;
String _weaponSound1;
-
+
String _nativeWeapon2;
String _operativeVerb2;
int _weaponDamage2;
String _weaponSound2;
-
+
int _winningWeapons;
int _winningMagic;
int _winningRun;
@@ -185,7 +188,7 @@ public:
int _losingMagic;
int _losingRun;
int _losingOffer;
-
+
String _initialComment;
String _scoresHitComment;
String _receivesHitComment;
@@ -201,6 +204,8 @@ public:
Context _context;
+ WeaponArray *getWeapons();
+
public:
#if 0
Weapon[] getWeapons() {
@@ -283,7 +288,7 @@ public:
Weapon() : _numberOfUses(0) {}
- void decrementNumberOfUses() {
+ void decrementNumberOfUses() {
if (_numberOfUses != -1) {
_numberOfUses--;
}
@@ -328,7 +333,7 @@ public:
String _clickMessage;
String _failureMessage;
String _useMessage;
-
+
Scene *_currentScene;
Chr *_currentOwner;
@@ -355,7 +360,7 @@ public:
EAST = 2,
WEST = 3
};
-
+
enum SceneTypes {
PERIODIC = 0,
RANDOM = 1
@@ -373,7 +378,7 @@ public:
String _soundName;
int _worldX;
int _worldY;
-
+
Common::List<Obj> _objs;
Common::List<Chr> _chrs;
@@ -385,7 +390,7 @@ public:
}
#if 0
- String getFontName() {
+ String getFontName() {
String[] fonts = {
"Chicago", // system font
"Geneva", // application font
@@ -396,7 +401,7 @@ public:
"Venice",
"London",
"Athens",
-
+
"San Francisco",
"Toronto",
"Cairo",
@@ -448,5 +453,5 @@ public:
};
} // End of namespace Wage
-
+
#endif
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 60a7e95..e1f3c67 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -160,18 +160,19 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
handleStatusCommand();
} else if (input.contains("rest") || input.equals("wait")) {
handleRestCommand();
- /*
- } else if (callbacks.getOffer() != NULL && input.contains("accept")) {
+ } else if (callbacks->getOffer() != NULL && input.contains("accept")) {
handleAcceptCommand();
} else {
- Chr player = world.getPlayer();
- for (Weapon weapon : player.getWeapons()) {
- if (tryAttack(weapon, input)) {
- handleAttack(weapon);
+ Chr *player = _world->_player;
+ WeaponArray *weapons = player->getWeapons();
+ for (WeaponArray::const_iterator weapon = weapons->begin(); weapon != weapons->end(); ++weapon) {
+ if (tryAttack(*weapon, input)) {
+ handleAttack(*weapon);
break;
}
}
- */
+
+ delete weapons;
}
/*
// TODO: weapons, offer, etc...
@@ -492,4 +493,14 @@ void Script::handleOfferCommand(const char *target) {
warning("STUB: handleOfferCommand");
}
+bool Script::tryAttack(Weapon *weapon, Common::String &input) {
+ warning("STUB: tryAttack");
+
+ return false;
+}
+
+void Script::handleAttack(Weapon *weapon) {
+ warning("STUB: handleAttack");
+}
+
} // End of namespace Wage
diff --git a/engines/wage/script.h b/engines/wage/script.h
index f99e6d9..4c8ce45 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -150,6 +150,10 @@ private:
void handleAimCommand(const char *target);
void handleWearCommand(const char *target);
void handleOfferCommand(const char *target);
+
+ bool tryAttack(Weapon *weapon, Common::String &input);
+ void handleAttack(Weapon *weapon);
+
};
} // End of namespace Wage
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 0689d90..00a7aad 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -134,4 +134,23 @@ void WageEngine::processEvents() {
}
}
+void WageEngine::playSound(String soundName) {
+ warning("STUB: playSound");
+}
+
+void WageEngine::setMenu(String soundName) {
+ warning("STUB: setMenu");
+}
+
+void WageEngine::appendText(String str) {
+ warning("STUB: appendText");
+}
+
+Obj *WageEngine::getOffer() {
+ warning("STUB: getOffer");
+
+ return NULL;
+}
+
+
} // End of namespace Wage
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index d7c3386..2ad28c9 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -107,16 +107,16 @@ public:
//PrintStream out;
int _loopCount;
int _turn;
- //Callbacks callbacks;
Chr *_monster;
Obj *_offer;
bool _commandWasQuick;
int _aim;
bool _temporarilyHidden;
- void playSound(String soundName) {}
- void setMenu(String soundName) {}
- void appendText(String str) {}
+ void playSound(String soundName);
+ void setMenu(String soundName);
+ void appendText(String str);
+ Obj *getOffer();
void processEvents();
private:
Commit: 0b3e161d8536e832a84b3de80604f1bf68622523
https://github.com/scummvm/scummvm/commit/0b3e161d8536e832a84b3de80604f1bf68622523
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:59+01:00
Commit Message:
WAGE: Test script execution
Changed paths:
engines/wage/script.cpp
engines/wage/script.h
engines/wage/wage.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index e1f3c67..f5e4cd4 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -64,7 +64,11 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
_data->skip(12);
while (_data->pos() < _data->size()) {
- switch(_data->readByte()) {
+ byte command = _data->readByte();
+
+ debug(1, "Command: %x", command);
+
+ switch(command) {
case 0x80: // IF
processIf();
break;
diff --git a/engines/wage/script.h b/engines/wage/script.h
index 4c8ce45..97d52f0 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -126,8 +126,10 @@ private:
}
};
-
+public:
bool execute(World *world, int loopCount, String *inputText, Designed *inputClick, WageEngine *callbacks);
+
+private:
Operand *readOperand();
Operand *readStringOperand();
const char *readOperator();
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 00a7aad..5ab2a90 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -59,9 +59,10 @@
#include "graphics/palette.h"
#include "wage/wage.h"
+#include "wage/design.h"
#include "wage/entities.h"
+#include "wage/script.h"
#include "wage/world.h"
-#include "wage/design.h"
namespace Wage {
@@ -109,6 +110,9 @@ Common::Error WageEngine::run() {
screen.create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
Common::Rect r(0, 0, screen.w, screen.h);
+ Common::String input("look");
+ _world->_globalScript->execute(_world, 1, &input, NULL, this);
+
_world->_orderedScenes[1]->_design->paint(&screen, _world->_patterns, false);
_world->_objs["frank.1"]->_design->setBounds(&r);
_world->_objs["frank.1"]->_design->paint(&screen, _world->_patterns, false);
Commit: e11aef1a7d6f2d3aeb6f509800143f0aac8d3e20
https://github.com/scummvm/scummvm/commit/e11aef1a7d6f2d3aeb6f509800143f0aac8d3e20
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:40:59+01:00
Commit Message:
WAGE: Fixes to script execution
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index f5e4cd4..432b226 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -195,6 +195,9 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
Script::Operand *Script::readOperand() {
byte operandType = _data->readByte();
+
+ debug(2, "readOperand: 0x%x", operandType);
+
Context *cont = &_world->_player->_context;
switch (operandType) {
case 0xA0: // TEXT$
@@ -273,6 +276,7 @@ Script::Operand *Script::readOperand() {
return new Operand(cont->_statVariables[Context::PHYS_SPE_CUR], Operand::NUMBER);
default:
if (operandType >= 0x20 && operandType < 0x80) {
+ _data->seek(-1, SEEK_CUR);
return readStringOperand();
} else {
debug("Dunno what %x is (index=%d)!\n", operandType, _data->pos()-1);
@@ -360,6 +364,7 @@ Script::Operand *Script::readStringOperand() {
allDigits = false;
*sb += c;
}
+ _data->seek(-1, SEEK_CUR);
if (allDigits && sb->size() > 0) {
debug(0, "Read number %s", sb->c_str());
@@ -377,6 +382,7 @@ Script::Operand *Script::readStringOperand() {
const char *Script::readOperator() {
byte cmd = _data->readByte();
+ debug(2, "readOperator: 0x%x", cmd);
switch (cmd) {
case 0x81:
return "=";
@@ -418,10 +424,14 @@ void Script::processLet() {
int operandType = _data->readByte();
int uservar = 0;
- if (operandType == 0xff)
+ if (operandType == 0xff) {
uservar = _data->readByte();
+ }
+
+ byte eq = _data->readByte(); // skip "=" operator
+
+ debug(2, "processLet: 0x%x, uservar: 0x%x, eq: 0x%x", operandType, uservar, eq);
- _data->readByte(); // skip "=" operator
do {
Operand *operand = readOperand();
// TODO assert that value is NUMBER
Commit: 60ce5fa557a82f120065d18d135e282352688c51
https://github.com/scummvm/scummvm/commit/60ce5fa557a82f120065d18d135e282352688c51
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:00+01:00
Commit Message:
WAGE: Unstub processIf()
Changed paths:
engines/wage/script.cpp
engines/wage/script.h
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 432b226..355c5da 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -411,7 +411,83 @@ const char *Script::readOperator() {
}
void Script::processIf() {
- warning("STUB: processIf");
+ int logicalOp = 0; // 0 => initial, 1 => and, 2 => or
+ bool result = true;
+ bool done = false;
+
+ do {
+ Operand *lhs = readOperand();
+ const char *op = readOperator();
+ Operand *rhs = readOperand();
+
+ bool condResult = eval(lhs, op, rhs);
+
+ if (logicalOp == 1) {
+ result = (result && condResult);
+ } else if (logicalOp == 2) {
+ result = (result || condResult);
+ } else { // logicalOp == 0
+ result = condResult;
+ }
+
+ byte logical = _data->readByte();
+
+ if (logical == 0x84) {
+ logicalOp = 1; // and
+ } else if (logical == 0x85) {
+ logicalOp = 2; // or
+ } else if (logical == 0xFE) {
+ done = true; // then
+ }
+ } while (!done);
+
+ if (result == false) {
+ skipBlock();
+ }
+}
+
+void Script::skipIf() {
+ do {
+ readOperand();
+ readOperator();
+ readOperand();
+ } while (_data->readByte() != 0xFE);
+}
+
+void Script::skipBlock() {
+ int nesting = 1;
+
+ while (true) {
+ byte op = _data->readByte();
+
+ if (_data->eos())
+ return;
+
+ if (op == 0x80) { // IF
+ nesting++;
+ skipIf();
+ } else if (op == 0x88 || op == 0x87) { // END or EXIT
+ _data->seek(-1, SEEK_CUR); // We need to reread it higher
+ nesting--;
+ if (nesting == 0) {
+ _data->readByte(); // skiping
+ return;
+ }
+ } else switch (op) {
+ case 0x8B: // PRINT
+ case 0x8C: // SOUND
+ case 0x8E: // LET
+ case 0x95: // MENU
+ while (_data->readByte() != 0xFD)
+ ;
+ }
+ }
+}
+
+bool Script::eval(Operand *lhs, const char *op, Operand *rhs) {
+ warning("STUB: eval");
+
+ return false;
}
void Script::processMove() {
diff --git a/engines/wage/script.h b/engines/wage/script.h
index 97d52f0..7ac8356 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -134,6 +134,9 @@ private:
Operand *readStringOperand();
const char *readOperator();
void processIf();
+ void skipBlock();
+ void skipIf();
+ bool eval(Operand *lhs, const char *op, Operand *rhs);
void processMove();
void processLet();
Commit: a2ac4ea859da2257bba0d60f466be4037204d4d9
https://github.com/scummvm/scummvm/commit/a2ac4ea859da2257bba0d60f466be4037204d4d9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:00+01:00
Commit Message:
WAGE: Handle NULL value Operands
Changed paths:
engines/wage/script.cpp
engines/wage/script.h
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 355c5da..eb500d7 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -88,7 +88,7 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
{
Operand *op = readOperand();
// TODO check op type is string or number, or something good...
- appendText(op->_str);
+ appendText(op->toString());
byte d = _data->readByte();
if (d != 0xFD)
warning("Operand 0x8B (PRINT) End Byte != 0xFD");
@@ -99,7 +99,7 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
Operand *op = readOperand();
// TODO check op type is string.
_handled = true;
- callbacks->playSound(op->_str);
+ callbacks->playSound(op->toString());
byte d = _data->readByte();
if (d != 0xFD)
warning("Operand 0x8B (PRINT) End Byte != 0xFD");
@@ -112,7 +112,7 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
{
Operand *op = readStringOperand(); // allows empty menu
// TODO check op type is string.
- _callbacks->setMenu(op->_str);
+ _callbacks->setMenu(op->toString());
byte d = _data->readByte();
if (d != 0xFD)
warning("Operand 0x8B (PRINT) End Byte != 0xFD");
@@ -196,7 +196,7 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
Script::Operand *Script::readOperand() {
byte operandType = _data->readByte();
- debug(2, "readOperand: 0x%x", operandType);
+ debug(2, "%x: readOperand: 0x%x", _data->pos(), operandType);
Context *cont = &_world->_player->_context;
switch (operandType) {
diff --git a/engines/wage/script.h b/engines/wage/script.h
index 7ac8356..1c69eb0 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -87,43 +87,63 @@ private:
Designed *inputClick;
} _value;
OperandTypes _type;
- String _str;
+ Common::String _str;
Operand(Obj *value, OperandTypes type) {
_value.obj = value;
- _str = value->toString();
_type = type;
}
Operand(Chr *value, OperandTypes type) {
_value.chr = value;
- _str = value->toString();
_type = type;
}
Operand(Scene *value, OperandTypes type) {
_value.scene = value;
- _str = value->toString();
_type = type;
}
Operand(int value, OperandTypes type) {
_value.number = value;
- _str = value;
_type = type;
}
Operand(String *value, OperandTypes type) {
_value.string = value;
- _str = *value;
_type = type;
}
Operand(Designed *value, OperandTypes type) {
_value.inputClick = value;
- _str = value->toString();
_type = type;
}
+
+ Common::String toString() {
+ char buf[128];
+
+ if (_value.obj == NULL)
+ _str = "";
+
+ switch(_type) {
+ case NUMBER:
+ _str = snprintf(buf, 128, "%d", _value.number);
+ return _str;
+ case STRING:
+ case TEXT_INPUT:
+ return *_value.string;
+ case OBJ:
+ return _value.obj->toString();
+ case CHR:
+ return _value.chr->toString();
+ case SCENE:
+ return _value.scene->toString();
+ case CLICK_INPUT:
+ return _value.inputClick->toString();
+ default:
+ error("Unhandled operand type: _type");
+ }
+ }
};
public:
Commit: 29cb01f71c5947f77d57c686666132db705593dc
https://github.com/scummvm/scummvm/commit/29cb01f71c5947f77d57c686666132db705593dc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:00+01:00
Commit Message:
WAGE: Unstubbed Script::eval()
Changed paths:
engines/wage/script.cpp
engines/wage/script.h
engines/wage/wage.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index eb500d7..b9e51c0 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -201,79 +201,79 @@ Script::Operand *Script::readOperand() {
Context *cont = &_world->_player->_context;
switch (operandType) {
case 0xA0: // TEXT$
- return new Operand(_inputText, Operand::TEXT_INPUT);
+ return new Operand(_inputText, TEXT_INPUT);
case 0xA1:
- return new Operand(_inputClick, Operand::CLICK_INPUT);
+ return new Operand(_inputClick, CLICK_INPUT);
case 0xC0: // STORAGE@
- return new Operand(&_world->_storageScene, Operand::SCENE);
+ return new Operand(&_world->_storageScene, SCENE);
case 0xC1: // SCENE@
- return new Operand(_world->_player->_currentScene, Operand::SCENE);
+ return new Operand(_world->_player->_currentScene, SCENE);
case 0xC2: // PLAYER@
- return new Operand(_world->_player, Operand::CHR);
+ return new Operand(_world->_player, CHR);
case 0xC3: // MONSTER@
- return new Operand(_callbacks->_monster, Operand::CHR);
+ return new Operand(_callbacks->_monster, CHR);
case 0xC4: // RANDOMSCN@
- return new Operand(_world->_orderedScenes[_callbacks->_rnd->getRandomNumber(_world->_orderedScenes.size())], Operand::SCENE);
+ return new Operand(_world->_orderedScenes[_callbacks->_rnd->getRandomNumber(_world->_orderedScenes.size())], SCENE);
case 0xC5: // RANDOMCHR@
- return new Operand(_world->_orderedChrs[_callbacks->_rnd->getRandomNumber(_world->_orderedChrs.size())], Operand::CHR);
+ return new Operand(_world->_orderedChrs[_callbacks->_rnd->getRandomNumber(_world->_orderedChrs.size())], CHR);
case 0xC6: // RANDOMOBJ@
- return new Operand(_world->_orderedObjs[_callbacks->_rnd->getRandomNumber(_world->_orderedObjs.size())], Operand::OBJ);
+ return new Operand(_world->_orderedObjs[_callbacks->_rnd->getRandomNumber(_world->_orderedObjs.size())], OBJ);
case 0xB0: // VISITS#
- return new Operand(cont->_visits, Operand::NUMBER);
+ return new Operand(cont->_visits, NUMBER);
case 0xB1: // RANDOM# for Star Trek, but VISITS# for some other games?
- return new Operand(1 + _callbacks->_rnd->getRandomNumber(100), Operand::NUMBER);
+ return new Operand(1 + _callbacks->_rnd->getRandomNumber(100), NUMBER);
case 0xB5: // RANDOM# // A random number between 1 and 100.
- return new Operand(1 + _callbacks->_rnd->getRandomNumber(100), Operand::NUMBER);
+ return new Operand(1 + _callbacks->_rnd->getRandomNumber(100), NUMBER);
case 0xB2: // LOOP#
- return new Operand(_loopCount, Operand::NUMBER);
+ return new Operand(_loopCount, NUMBER);
case 0xB3: // VICTORY#
- return new Operand(cont->_kills, Operand::NUMBER);
+ return new Operand(cont->_kills, NUMBER);
case 0xB4: // BADCOPY#
- return new Operand(0, Operand::NUMBER); // ????
+ return new Operand(0, NUMBER); // ????
case 0xFF:
{
// user variable
int value = _data->readByte();
// TODO: Verify that we're using the right index.
- return new Operand(cont->_userVariables[value - 1], Operand::NUMBER);
+ return new Operand(cont->_userVariables[value - 1], NUMBER);
}
case 0xD0:
- return new Operand(cont->_statVariables[Context::PHYS_STR_BAS], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::PHYS_STR_BAS], NUMBER);
case 0xD1:
- return new Operand(cont->_statVariables[Context::PHYS_HIT_BAS], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::PHYS_HIT_BAS], NUMBER);
case 0xD2:
- return new Operand(cont->_statVariables[Context::PHYS_ARM_BAS], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::PHYS_ARM_BAS], NUMBER);
case 0xD3:
- return new Operand(cont->_statVariables[Context::PHYS_ACC_BAS], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::PHYS_ACC_BAS], NUMBER);
case 0xD4:
- return new Operand(cont->_statVariables[Context::SPIR_STR_BAS], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::SPIR_STR_BAS], NUMBER);
case 0xD5:
- return new Operand(cont->_statVariables[Context::SPIR_HIT_BAS], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::SPIR_HIT_BAS], NUMBER);
case 0xD6:
- return new Operand(cont->_statVariables[Context::SPIR_ARM_BAS], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::SPIR_ARM_BAS], NUMBER);
case 0xD7:
- return new Operand(cont->_statVariables[Context::SPIR_ACC_BAS], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::SPIR_ACC_BAS], NUMBER);
case 0xD8:
- return new Operand(cont->_statVariables[Context::PHYS_SPE_BAS], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::PHYS_SPE_BAS], NUMBER);
case 0xE0:
- return new Operand(cont->_statVariables[Context::PHYS_STR_CUR], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::PHYS_STR_CUR], NUMBER);
case 0xE1:
- return new Operand(cont->_statVariables[Context::PHYS_HIT_CUR], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::PHYS_HIT_CUR], NUMBER);
case 0xE2:
- return new Operand(cont->_statVariables[Context::PHYS_ARM_CUR], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::PHYS_ARM_CUR], NUMBER);
case 0xE3:
- return new Operand(cont->_statVariables[Context::PHYS_ACC_CUR], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::PHYS_ACC_CUR], NUMBER);
case 0xE4:
- return new Operand(cont->_statVariables[Context::SPIR_STR_CUR], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::SPIR_STR_CUR], NUMBER);
case 0xE5:
- return new Operand(cont->_statVariables[Context::SPIR_HIT_CUR], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::SPIR_HIT_CUR], NUMBER);
case 0xE6:
- return new Operand(cont->_statVariables[Context::SPIR_ARM_CUR], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::SPIR_ARM_CUR], NUMBER);
case 0xE7:
- return new Operand(cont->_statVariables[Context::SPIR_ACC_CUR], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::SPIR_ACC_CUR], NUMBER);
case 0xE8:
- return new Operand(cont->_statVariables[Context::PHYS_SPE_CUR], Operand::NUMBER);
+ return new Operand(cont->_statVariables[Context::PHYS_SPE_CUR], NUMBER);
default:
if (operandType >= 0x20 && operandType < 0x80) {
_data->seek(-1, SEEK_CUR);
@@ -371,11 +371,11 @@ Script::Operand *Script::readStringOperand() {
int r = atol(sb->c_str());
delete sb;
- return new Operand(r, Operand::NUMBER);
+ return new Operand(r, NUMBER);
} else {
// TODO: This string could be a room name or something like that.
debug(0, "Read string %s", sb->c_str());
- return new Operand(sb, Operand::STRING);
+ return new Operand(sb, STRING);
}
}
@@ -484,8 +484,173 @@ void Script::skipBlock() {
}
}
+enum {
+ kCompEqNumNum,
+ kCompEqObjScene,
+ kCompEqChrScene,
+ kCompEqObjChr,
+ kCompEqChrChr,
+ kCompEqSceneScene,
+ kCompEqStringTextInput,
+ kCompEqTextInputString,
+ kCompEqNumberTextInput,
+ kCompEqTextInputNumber,
+ kCompLtNumNum,
+ kCompLtStringTextInput,
+ kCompLtTextInputString,
+ kCompLtObjChr,
+ kCompLtChrObj,
+ kCompLtObjScene,
+ kCompGtNumNum,
+ kCompGtStringString,
+ kCompGtChrScene
+};
+
+struct Comparator {
+ char operation;
+ OperandTypes o1;
+ OperandTypes o2;
+ int compfunc;
+} static comparators[] = {
+ { '=', NUMBER, NUMBER, kCompEqNumNum },
+ { '=', OBJ, SCENE, kCompEqObjScene },
+ { '=', CHR, SCENE, kCompEqChrScene },
+ { '=', OBJ, CHR, kCompEqObjChr },
+ { '=', CHR, CHR, kCompEqChrChr },
+ { '=', SCENE, SCENE, kCompEqSceneScene },
+ { '=', STRING, TEXT_INPUT, kCompEqStringTextInput },
+ { '=', TEXT_INPUT, STRING, kCompEqTextInputString },
+ { '=', NUMBER, TEXT_INPUT, kCompEqNumberTextInput },
+ { '=', TEXT_INPUT, NUMBER, kCompEqTextInputNumber },
+
+ { '<', NUMBER, NUMBER, kCompLtNumNum },
+ { '<', STRING, TEXT_INPUT, kCompLtStringTextInput },
+ { '<', TEXT_INPUT, STRING, kCompLtTextInputString },
+ { '<', OBJ, CHR, kCompLtObjChr },
+ { '<', CHR, OBJ, kCompLtChrObj },
+ { '<', OBJ, SCENE, kCompLtObjScene },
+ { '<', CHR, CHR, kCompEqChrChr }, // Same logic as =
+ { '<', SCENE, SCENE, kCompEqSceneScene },
+
+ { '>', NUMBER, NUMBER, kCompGtNumNum },
+ { '>', TEXT_INPUT, STRING, kCompLtTextInputString }, // Same logic as <
+ //FIXME: this prevents the below cases from working due to exact
+ //matches taking precedence over conversions...
+ //{ '>', STRING, STRING, kCompGtStringString }, // Same logic as <
+ { '>', OBJ, CHR, kCompLtObjChr }, // Same logic as <
+ { '>', OBJ, SCENE, kCompLtObjScene }, // Same logic as <
+ { '>', CHR, SCENE, kCompGtChrScene },
+ { 0, OBJ, OBJ, 0 }
+};
+
+bool Script::compare(Operand *o1, Operand *o2, int comparator) {
+ switch(comparator) {
+ case kCompEqNumNum:
+ return o1->_value.number == o2->_value.number;
+ case kCompEqObjScene:
+ error("FIXME kCompEqObjScene");
+ //return o2->_value.scene->_objs.contains(*o1->_value.obj);
+ case kCompEqChrScene:
+ error("FIXME kCompEqChrScene");
+ //return o2->_value.scene->_chrs.contains(*o1->_value.chr);
+ case kCompEqObjChr:
+ error("FIXME kCompEqObjChr");
+ //return o2->_value.chr->_inventory.contains(*o1->_value.obj);
+ case kCompEqChrChr:
+ return o1->_value.chr == o2->_value.chr;
+ case kCompEqSceneScene:
+ return o1->_value.scene == o2->_value.scene;
+ case kCompEqStringTextInput:
+ if (_inputText == NULL) {
+ return false;
+ } else {
+ Common::String s1(*_inputText), s2(*o1->_value.string);
+ s1.toLowercase();
+ s2.toLowercase();
+
+ return s1.contains(s2);
+ }
+ case kCompEqTextInputString:
+ return compare(o2, o1, kCompEqStringTextInput);
+ case kCompEqNumberTextInput:
+ if (_inputText == NULL) {
+ return false;
+ } else {
+ Common::String s1(*_inputText), s2(o1->toString());
+ s1.toLowercase();
+ s2.toLowercase();
+
+ return s1.contains(s2);
+ }
+ case kCompEqTextInputNumber:
+ if (_inputText == NULL) {
+ return false;
+ } else {
+ Common::String s1(*_inputText), s2(o2->toString());
+ s1.toLowercase();
+ s2.toLowercase();
+
+ return s1.contains(s2);
+ }
+ case kCompLtNumNum:
+ return o1->_value.number < o2->_value.number;
+ case kCompLtStringTextInput:
+ return !compare(o1, o2, kCompEqStringTextInput);
+ case kCompLtTextInputString:
+ return !compare(o2, o1, kCompEqStringTextInput);
+ case kCompLtObjChr:
+ return o1->_value.obj->_currentOwner != o2->_value.chr;
+ case kCompLtChrObj:
+ return compare(o2, o1, kCompLtObjChr);
+ case kCompLtObjScene:
+ return o1->_value.obj->_currentScene != o2->_value.scene;
+ case kCompGtNumNum:
+ return o1->_value.number > o2->_value.number;
+ case kCompGtStringString:
+ return o1->_value.string == o2->_value.string;
+ case kCompGtChrScene:
+ return (o1->_value.chr != NULL && o1->_value.chr->_currentScene != o2->_value.scene);
+ }
+
+ return false;
+}
+
bool Script::eval(Operand *lhs, const char *op, Operand *rhs) {
- warning("STUB: eval");
+ bool result = false;
+
+ if (lhs->_type == CLICK_INPUT || rhs->_type == CLICK_INPUT) {
+ return evalClickCondition(lhs, op, rhs);
+ } else if (!strcmp(op, "==") || !strcmp(op, ">>")) {
+ // TODO: check if >> can be used for click inputs and if == can be used for other things
+ // exact string match
+ if (lhs->_type == TEXT_INPUT) {
+ if ((rhs->_type != STRING && rhs->_type != NUMBER) || _inputText == NULL) {
+ result = false;
+ } else {
+ result = _inputText->equalsIgnoreCase(rhs->toString());
+ }
+ } else if (rhs->_type == TEXT_INPUT) {
+ if ((lhs->_type != STRING && lhs->_type != NUMBER) || _inputText == NULL) {
+ result = false;
+ } else {
+ result = _inputText->equalsIgnoreCase(lhs->toString());
+ }
+ } else {
+ error("UNHANDLED CASE: [lhs=%d/%s, rhs=%d/%s]",
+ lhs->_type, lhs->toString().c_str(), rhs->_type, rhs->toString().c_str());
+ }
+ if (!strcmp(op, ">>")) {
+ result = !result;
+ }
+
+ return result;
+ }
+
+ return false;
+}
+
+bool Script::evalClickCondition(Operand *lhs, const char *op, Operand *rhs) {
+ warning("STUB: evalClickCondition");
return false;
}
diff --git a/engines/wage/script.h b/engines/wage/script.h
index 1c69eb0..d1d3d21 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -50,6 +50,16 @@
namespace Wage {
+enum OperandTypes {
+ OBJ = 0,
+ CHR = 1,
+ SCENE = 2,
+ NUMBER = 3,
+ STRING = 4,
+ CLICK_INPUT = 5,
+ TEXT_INPUT = 6
+};
+
class Script {
public:
Script(Common::SeekableReadStream *data) : _data(data) {}
@@ -68,16 +78,6 @@ private:
class Operand {
public:
- enum OperandTypes {
- OBJ = 0,
- CHR = 1,
- SCENE = 2,
- NUMBER = 3,
- STRING = 4,
- CLICK_INPUT = 5,
- TEXT_INPUT = 6
- };
-
union {
Obj *obj;
Chr *chr;
@@ -156,7 +156,9 @@ private:
void processIf();
void skipBlock();
void skipIf();
+ bool compare(Operand *o1, Operand *o2, int comparator);
bool eval(Operand *lhs, const char *op, Operand *rhs);
+ bool evalClickCondition(Operand *lhs, const char *op, Operand *rhs);
void processMove();
void processLet();
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 5ab2a90..533b30f 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -113,11 +113,11 @@ Common::Error WageEngine::run() {
Common::String input("look");
_world->_globalScript->execute(_world, 1, &input, NULL, this);
- _world->_orderedScenes[1]->_design->paint(&screen, _world->_patterns, false);
- _world->_objs["frank.1"]->_design->setBounds(&r);
- _world->_objs["frank.1"]->_design->paint(&screen, _world->_patterns, false);
- _world->_scenes["temple of the holy mackeral"]->_design->setBounds(&r);
- _world->_scenes["temple of the holy mackeral"]->_design->paint(&screen, _world->_patterns, false);
+ //_world->_orderedScenes[1]->_design->paint(&screen, _world->_patterns, false);
+ //_world->_objs["frank.1"]->_design->setBounds(&r);
+ //_world->_objs["frank.1"]->_design->paint(&screen, _world->_patterns, false);
+ //_world->_scenes["temple of the holy mackeral"]->_design->setBounds(&r);
+ //_world->_scenes["temple of the holy mackeral"]->_design->paint(&screen, _world->_patterns, false);
//_world->_scenes["tower level 3"]->_design->setBounds(&r);
//_world->_scenes["tower level 3"]->_design->paint(&screen, _world->_patterns, false);
Commit: 6d4a9f54e1f41ebc506cbf177bf2d18ae056a99f
https://github.com/scummvm/scummvm/commit/6d4a9f54e1f41ebc506cbf177bf2d18ae056a99f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:00+01:00
Commit Message:
WAGE: Implement first round of comparisons
Changed paths:
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/script.cpp
engines/wage/script.h
engines/wage/wage.h
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 75b624c..e6ce4e9 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -60,6 +60,7 @@ void Designed::setDesignBounds(Common::Rect *bounds) {
Scene::Scene(String name, Common::SeekableReadStream *data) {
_name = name;
+ _classType = SCENE;
_design = new Design(data);
setDesignBounds(readRect(data));
@@ -81,7 +82,7 @@ Scene::Scene(String name, Common::SeekableReadStream *data) {
Obj::Obj(String name, Common::SeekableReadStream *data) : _currentOwner(NULL), _currentScene(NULL) {
_name = name;
-
+ _classType = OBJ;
_design = new Design(data);
setDesignBounds(readRect(data));
@@ -125,6 +126,7 @@ Obj::Obj(String name, Common::SeekableReadStream *data) : _currentOwner(NULL), _
Chr::Chr(String name, Common::SeekableReadStream *data) {
_name = name;
+ _classType = CHR;
_design = new Design(data);
setDesignBounds(readRect(data));
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index edb63ef..eb3609c 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -108,11 +108,12 @@ public:
class Designed {
public:
- Designed() : _design(NULL), _designBounds(NULL) {}
+ Designed() : _design(NULL), _designBounds(NULL), _classType(UNKNOWN) {}
String _name;
Design *_design;
Common::Rect *_designBounds;
+ OperandType _classType;
Common::Rect *getDesignBounds() {
return _designBounds == NULL ? NULL : new Common::Rect(*_designBounds);
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index b9e51c0..8953fe1 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -507,10 +507,10 @@ enum {
};
struct Comparator {
- char operation;
- OperandTypes o1;
- OperandTypes o2;
- int compfunc;
+ char op;
+ OperandType o1;
+ OperandType o2;
+ int cmp;
} static comparators[] = {
{ '=', NUMBER, NUMBER, kCompEqNumNum },
{ '=', OBJ, SCENE, kCompEqObjScene },
@@ -644,11 +644,82 @@ bool Script::eval(Operand *lhs, const char *op, Operand *rhs) {
}
return result;
+ } else {
+ for (int cmp = 0; comparators[cmp].op != 0; cmp++) {
+ if (comparators[cmp].op == op[0] &&
+ comparators[cmp].o1 == lhs->_type && comparators[cmp].o2 == rhs->_type)
+ return compare(lhs, rhs, comparators[cmp].cmp);
+ }
+
+#if 0
+ // Now, try partial matches.
+ for (int cmp = 0; comparators[cmp].op != 0; cmp++) {
+ if (comparators[cmp].op == op[0])
+ if (lhs->_typecomparators[cmp].o1 == lhs->_type)
+ }
+
+ for (PairEvaluator e : handlers) {
+ Operand converted;
+ if (e.lhsType == o1.type && (converted = convertOperand(o2, e.rhsType)) != null) {
+ e.evaluatePair(o1, converted);
+ return;
+ } else if (e.rhsType == o2.type && (converted = convertOperand(o1, e.lhsType)) != null) {
+ e.evaluatePair(converted, o2);
+ return;
+ }
+ }
+
+ // Now, try double conversion.
+ for (PairEvaluator e : handlers) {
+ Operand c1, c2;
+ if ((c1 = convertOperand(o1, e.lhsType)) != null &&
+ (c2 = convertOperand(o2, e.rhsType)) != null) {
+ e.evaluatePair(c1, c2);
+ return;
+ }
+ }
+#endif
}
return false;
}
+Script::Operand *Script::convertOperand(Operand *operand, int type) {
+ if (operand->_type == type)
+ return operand;
+
+ if (type == SCENE) {
+ if (operand->_type == STRING || operand->_type == NUMBER) {
+ Common::String key(operand->toString());
+ key.toLowercase();
+ if (_world->_scenes.contains(key))
+ return new Operand(_world->_scenes[key], SCENE);
+ }
+ } else if (type == OBJ) {
+ if (operand->_type == STRING || operand->_type == NUMBER) {
+ Common::String key = operand->toString();
+ key.toLowercase();
+ if (_world->_objs.contains(key))
+ return new Operand(_world->_objs[key], OBJ);
+ } else if (operand->_type == CLICK_INPUT) {
+ if (_inputClick->_classType == OBJ)
+ return new Operand(_inputClick, OBJ);
+ }
+ } else if (type == CHR) {
+ if (operand->_type == STRING || operand->_type == NUMBER) {
+ Common::String key = operand->toString();
+ key.toLowercase();
+ if (_world->_chrs.contains(key))
+ return new Operand(_world->_chrs[key], CHR);
+ } else if (operand->_type == CLICK_INPUT) {
+ if (_inputClick->_classType == CHR)
+ return new Operand(_inputClick, CHR);
+ }
+ }
+
+ return NULL;
+}
+
bool Script::evalClickCondition(Operand *lhs, const char *op, Operand *rhs) {
warning("STUB: evalClickCondition");
diff --git a/engines/wage/script.h b/engines/wage/script.h
index d1d3d21..b9249c3 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -50,16 +50,6 @@
namespace Wage {
-enum OperandTypes {
- OBJ = 0,
- CHR = 1,
- SCENE = 2,
- NUMBER = 3,
- STRING = 4,
- CLICK_INPUT = 5,
- TEXT_INPUT = 6
-};
-
class Script {
public:
Script(Common::SeekableReadStream *data) : _data(data) {}
@@ -86,35 +76,35 @@ private:
String *string;
Designed *inputClick;
} _value;
- OperandTypes _type;
+ OperandType _type;
Common::String _str;
- Operand(Obj *value, OperandTypes type) {
+ Operand(Obj *value, OperandType type) {
_value.obj = value;
_type = type;
}
- Operand(Chr *value, OperandTypes type) {
+ Operand(Chr *value, OperandType type) {
_value.chr = value;
_type = type;
}
- Operand(Scene *value, OperandTypes type) {
+ Operand(Scene *value, OperandType type) {
_value.scene = value;
_type = type;
}
- Operand(int value, OperandTypes type) {
+ Operand(int value, OperandType type) {
_value.number = value;
_type = type;
}
- Operand(String *value, OperandTypes type) {
+ Operand(String *value, OperandType type) {
_value.string = value;
_type = type;
}
- Operand(Designed *value, OperandTypes type) {
+ Operand(Designed *value, OperandType type) {
_value.inputClick = value;
_type = type;
}
@@ -158,6 +148,7 @@ private:
void skipIf();
bool compare(Operand *o1, Operand *o2, int comparator);
bool eval(Operand *lhs, const char *op, Operand *rhs);
+ Operand *convertOperand(Operand *operand, int type);
bool evalClickCondition(Operand *lhs, const char *op, Operand *rhs);
void processMove();
void processLet();
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 2ad28c9..1e57ef5 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -68,6 +68,17 @@ class Chr;
using Common::String;
+enum OperandType {
+ OBJ = 0,
+ CHR = 1,
+ SCENE = 2,
+ NUMBER = 3,
+ STRING = 4,
+ CLICK_INPUT = 5,
+ TEXT_INPUT = 6,
+ UNKNOWN = 100
+};
+
// our engine debug levels
enum {
kWageDebugExample = 1 << 0,
Commit: 5478cbe9c8f9f119d621b91d3fe01f62691bde57
https://github.com/scummvm/scummvm/commit/5478cbe9c8f9f119d621b91d3fe01f62691bde57
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:00+01:00
Commit Message:
WAGE: Implement non0direct comparisons
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 8953fe1..ae31d63 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -651,34 +651,38 @@ bool Script::eval(Operand *lhs, const char *op, Operand *rhs) {
return compare(lhs, rhs, comparators[cmp].cmp);
}
-#if 0
// Now, try partial matches.
+ Operand *c1, *c2;
for (int cmp = 0; comparators[cmp].op != 0; cmp++) {
- if (comparators[cmp].op == op[0])
- if (lhs->_typecomparators[cmp].o1 == lhs->_type)
- }
-
- for (PairEvaluator e : handlers) {
- Operand converted;
- if (e.lhsType == o1.type && (converted = convertOperand(o2, e.rhsType)) != null) {
- e.evaluatePair(o1, converted);
- return;
- } else if (e.rhsType == o2.type && (converted = convertOperand(o1, e.lhsType)) != null) {
- e.evaluatePair(converted, o2);
- return;
+ if (comparators[cmp].op == op[0]) {
+ if (comparators[cmp].o1 == lhs->_type &&
+ (c2 = convertOperand(rhs, comparators[cmp].o2)) != NULL) {
+ bool res = compare(lhs, c2, comparators[cmp].cmp);
+ delete c2;
+
+ return res;
+ } else if (comparators[cmp].o2 == rhs->_type &&
+ (c1 = convertOperand(lhs, comparators[cmp].o1)) != NULL) {
+ bool res = compare(c1, rhs, comparators[cmp].cmp);
+ delete c1;
+ return res;
+ }
}
}
// Now, try double conversion.
- for (PairEvaluator e : handlers) {
- Operand c1, c2;
- if ((c1 = convertOperand(o1, e.lhsType)) != null &&
- (c2 = convertOperand(o2, e.rhsType)) != null) {
- e.evaluatePair(c1, c2);
- return;
+ for (int cmp = 0; comparators[cmp].op != 0; cmp++) {
+ if ((c1 = convertOperand(lhs, comparators[cmp].o1)) != NULL) {
+ if ((c2 = convertOperand(rhs, comparators[cmp].o2)) != NULL) {
+ bool res = compare(c1, c2, comparators[cmp].cmp);
+ delete c1;
+ delete c2;
+
+ return res;
+ }
+ delete c1;
}
}
-#endif
}
return false;
Commit: 870d6748fed63733a5a4f35b7e4485fb9cfcf56b
https://github.com/scummvm/scummvm/commit/870d6748fed63733a5a4f35b7e4485fb9cfcf56b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:00+01:00
Commit Message:
WAGE: Fix crash on double free()
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index ae31d63..cb07109 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -690,7 +690,7 @@ bool Script::eval(Operand *lhs, const char *op, Operand *rhs) {
Script::Operand *Script::convertOperand(Operand *operand, int type) {
if (operand->_type == type)
- return operand;
+ return new Operand(*operand);
if (type == SCENE) {
if (operand->_type == STRING || operand->_type == NUMBER) {
Commit: 88faad5d08bc10272f04ebc1ce122b8b446d31a8
https://github.com/scummvm/scummvm/commit/88faad5d08bc10272f04ebc1ce122b8b446d31a8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:00+01:00
Commit Message:
WAGE: Simplified code and avoid extra object allocations
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index cb07109..5ef1b6e 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -646,38 +646,45 @@ bool Script::eval(Operand *lhs, const char *op, Operand *rhs) {
return result;
} else {
for (int cmp = 0; comparators[cmp].op != 0; cmp++) {
- if (comparators[cmp].op == op[0] &&
- comparators[cmp].o1 == lhs->_type && comparators[cmp].o2 == rhs->_type)
- return compare(lhs, rhs, comparators[cmp].cmp);
+ if (comparators[cmp].op != op[0])
+ continue;
+
+ if (comparators[cmp].o1 == lhs->_type && comparators[cmp].o2 == rhs->_type)
+ return compare(lhs, rhs, comparators[cmp].cmp);
}
// Now, try partial matches.
Operand *c1, *c2;
for (int cmp = 0; comparators[cmp].op != 0; cmp++) {
- if (comparators[cmp].op == op[0]) {
- if (comparators[cmp].o1 == lhs->_type &&
- (c2 = convertOperand(rhs, comparators[cmp].o2)) != NULL) {
- bool res = compare(lhs, c2, comparators[cmp].cmp);
- delete c2;
-
- return res;
- } else if (comparators[cmp].o2 == rhs->_type &&
- (c1 = convertOperand(lhs, comparators[cmp].o1)) != NULL) {
- bool res = compare(c1, rhs, comparators[cmp].cmp);
- delete c1;
- return res;
- }
+ if (comparators[cmp].op != op[0])
+ continue;
+
+ if (comparators[cmp].o1 == lhs->_type &&
+ (c2 = convertOperand(rhs, comparators[cmp].o2)) != NULL) {
+ bool res = compare(lhs, c2, comparators[cmp].cmp);
+ delete c2;
+ return res;
+ } else if (comparators[cmp].o2 == rhs->_type &&
+ (c1 = convertOperand(lhs, comparators[cmp].o1)) != NULL) {
+ bool res = compare(c1, rhs, comparators[cmp].cmp);
+ delete c1;
+ return res;
}
}
// Now, try double conversion.
for (int cmp = 0; comparators[cmp].op != 0; cmp++) {
+ if (comparators[cmp].op != op[0])
+ continue;
+
+ if (comparators[cmp].o1 == lhs->_type || comparators[cmp].o2 == rhs->_type)
+ continue;
+
if ((c1 = convertOperand(lhs, comparators[cmp].o1)) != NULL) {
if ((c2 = convertOperand(rhs, comparators[cmp].o2)) != NULL) {
bool res = compare(c1, c2, comparators[cmp].cmp);
delete c1;
delete c2;
-
return res;
}
delete c1;
@@ -690,7 +697,7 @@ bool Script::eval(Operand *lhs, const char *op, Operand *rhs) {
Script::Operand *Script::convertOperand(Operand *operand, int type) {
if (operand->_type == type)
- return new Operand(*operand);
+ error("Incorrect conversion to type %d", type);
if (type == SCENE) {
if (operand->_type == STRING || operand->_type == NUMBER) {
Commit: f76eb1831cce8177a3cc477fb1e5d4954635f982
https://github.com/scummvm/scummvm/commit/f76eb1831cce8177a3cc477fb1e5d4954635f982
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:01+01:00
Commit Message:
WAGE: Implemented object taking logic
Changed paths:
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/script.cpp
engines/wage/script.h
engines/wage/world.cpp
engines/wage/world.h
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index e6ce4e9..15fbbb9 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -192,6 +192,9 @@ Chr::Chr(String name, Common::SeekableReadStream *data) {
_weaponSound1 = readPascalString(data);
_weaponSound2 = readPascalString(data);
+
+ for (int i = 0; i < NUMBER_OF_ARMOR_TYPES; i++)
+ _armor[i] = NULL;
}
WeaponArray *Chr::getWeapons() {
@@ -202,4 +205,38 @@ WeaponArray *Chr::getWeapons() {
return list;
}
+int Chr::wearObjIfPossible(Obj *obj) {
+ switch (obj->_type) {
+ case Obj::HELMET:
+ if (_armor[HEAD_ARMOR] == NULL) {
+ _armor[HEAD_ARMOR] = obj;
+ return Chr::HEAD_ARMOR;
+ }
+ break;
+ case Obj::CHEST_ARMOR:
+ if (_armor[BODY_ARMOR] == NULL) {
+ _armor[BODY_ARMOR] = obj;
+ return Chr::BODY_ARMOR;
+ }
+ break;
+ case Obj::SHIELD:
+ if (_armor[SHIELD_ARMOR] == NULL) {
+ _armor[SHIELD_ARMOR] = obj;
+ return Chr::SHIELD_ARMOR;
+ }
+ break;
+ case Obj::SPIRITUAL_ARMOR:
+ if (_armor[MAGIC_ARMOR] == NULL) {
+ _armor[MAGIC_ARMOR] = obj;
+ return Chr::MAGIC_ARMOR;
+ }
+ break;
+ default:
+ return -1;
+ }
+
+ return -1;
+}
+
+
} // End of namespace Wage
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index eb3609c..28ce42a 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -60,7 +60,7 @@ typedef Common::Array<Weapon *> WeaponArray;
class Context {
public:
- enum StatVariables {
+ enum StatVariable {
/** The base physical accuracy of the player. */
PHYS_ACC_BAS = 0,
/** The current physical accuracy of the player. */
@@ -141,7 +141,9 @@ public:
enum ChrArmorType {
HEAD_ARMOR = 0,
BODY_ARMOR = 1,
- SHIELD_ARMOR = 2
+ SHIELD_ARMOR = 2,
+ MAGIC_ARMOR = 3,
+ NUMBER_OF_ARMOR_TYPES = 4
};
Chr(String name, Common::SeekableReadStream *data);
@@ -201,7 +203,7 @@ public:
Scene *_currentScene;
Common::List<Obj> _inventory;
- Obj *_armor[3];
+ Obj *_armor[NUMBER_OF_ARMOR_TYPES];
Context _context;
@@ -276,6 +278,7 @@ public:
bool hasNativeWeapon2() {
return (_nativeWeapon2.size() > 0 && _operativeVerb2.size() > 0);
}
+ int wearObjIfPossible(Obj *obj);
};
class Weapon {
@@ -301,7 +304,7 @@ public:
Obj() : _currentOwner(NULL), _currentScene(NULL) {}
Obj(String name, Common::SeekableReadStream *data);
- enum ObjectTypes {
+ enum ObjectType {
REGULAR_WEAPON = 1,
THROW_WEAPON = 2,
MAGICAL_OBJECT = 3,
@@ -313,7 +316,7 @@ public:
IMMOBILE_OBJECT = 9
};
- enum AttackTypes {
+ enum AttackType {
CAUSES_PHYSICAL_DAMAGE = 0,
CAUSES_SPIRITUAL_DAMAGE = 1,
CAUSES_PHYSICAL_AND_SPIRITUAL_DAMAGE = 2,
@@ -350,7 +353,6 @@ public:
if (currentScene != NULL)
_currentOwner = NULL;
}
-
};
class Scene : public Designed {
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 5ef1b6e..dcb993a 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -178,16 +178,14 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
delete weapons;
}
-/*
// TODO: weapons, offer, etc...
- } else if (inputClick instanceof Obj) {
- Obj obj = (Obj) inputClick;
- if (obj.getType() != Obj.IMMOBILE_OBJECT) {
+ } else if (_inputClick->_classType == OBJ) {
+ Obj *obj = (Obj *)_inputClick;
+ if (obj->_type != Obj::IMMOBILE_OBJECT) {
takeObj(obj);
} else {
- appendText(obj.getClickMessage());
+ appendText(obj->_clickMessage);
}
-*/
}
return _handled;
@@ -737,6 +735,27 @@ bool Script::evalClickCondition(Operand *lhs, const char *op, Operand *rhs) {
return false;
}
+void Script::takeObj(Obj *obj) {
+ if (_world->_player->_inventory.size() >= _world->_player->_maximumCarriedObjects) {
+ appendText("Your pack is full, you must drop something.");
+ } else {
+ _world->move(obj, _world->_player);
+ int type = _world->_player->wearObjIfPossible(obj);
+ if (type == Chr::HEAD_ARMOR) {
+ appendText(String("You are now wearing the ") + obj->_name + ".");
+ } else if (type == Chr::BODY_ARMOR) {
+ appendText(String("You are now wearing the ") + obj->_name + ".");
+ } else if (type == Chr::SHIELD_ARMOR) {
+ appendText(String("You are now wearing the ") + obj->_name + ".");
+ } else if (type == Chr::MAGIC_ARMOR) {
+ appendText(String("You are now wearing the ") + obj->_name + ".");
+ } else {
+ appendText(String("You now have the ") + obj->_name + ".");
+ }
+ appendText(obj->_clickMessage);
+ }
+}
+
void Script::processMove() {
warning("STUB: processMove");
}
diff --git a/engines/wage/script.h b/engines/wage/script.h
index b9249c3..77b6d7d 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -150,6 +150,7 @@ private:
bool eval(Operand *lhs, const char *op, Operand *rhs);
Operand *convertOperand(Operand *operand, int type);
bool evalClickCondition(Operand *lhs, const char *op, Operand *rhs);
+ void takeObj(Obj *obj);
void processMove();
void processLet();
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 96f3faf..b404736 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -350,4 +350,8 @@ Common::String *World::loadStringFromDITL(Common::MacResManager *resMan, int res
return NULL;
}
+void World::move(Obj *obj, Chr *chr) {
+ warning("STUB: World::move()");
+}
+
} // End of namespace Wage
diff --git a/engines/wage/world.h b/engines/wage/world.h
index 8e45dcb..15a65d8 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -60,6 +60,7 @@ public:
bool loadWorld(Common::MacResManager *resMan);
void loadExternalSounds(String fname);
Common::String *loadStringFromDITL(Common::MacResManager *resMan, int resourceId, int itemIndex);
+ void move(Obj *obj, Chr *chr);
String _name;
String _aboutMessage;
Commit: 9dc5a516609422a8fddee7898815e0ac26477d08
https://github.com/scummvm/scummvm/commit/9dc5a516609422a8fddee7898815e0ac26477d08
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:01+01:00
Commit Message:
WAGE: Implement script decoding
Changed paths:
engines/wage/script.cpp
engines/wage/script.h
engines/wage/wage.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index dcb993a..f03b364 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -54,6 +54,30 @@
namespace Wage {
+Script::Script(Common::SeekableReadStream *data) : _data(data) {
+ convertToText();
+}
+
+Script::~Script() {
+ for (int i = 0; i < _scriptText.size(); i++) {
+ delete _scriptText[i];
+ }
+}
+
+void Script::print() {
+ for (int i = 0; i < _scriptText.size(); i++) {
+ debug(0, "%d [%04x]: %s", i, _scriptText[i]->offset, _scriptText[i]->line.c_str());
+ }
+}
+
+void Script::printLine(int offset) {
+ for (int i = 0; i < _scriptText.size(); i++)
+ if (_scriptText[i]->offset >= offset) {
+ debug(0, "%d [%04x]: %s", i, _scriptText[i]->offset, _scriptText[i]->line.c_str());
+ break;
+ }
+}
+
bool Script::execute(World *world, int loopCount, String *inputText, Designed *inputClick, WageEngine *callbacks) {
_world = world;
_loopCount = loopCount;
@@ -62,11 +86,11 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
_callbacks = callbacks;
_handled = false;
- _data->skip(12);
+ _data->seek(12);
while (_data->pos() < _data->size()) {
- byte command = _data->readByte();
+ printLine(_data->pos());
- debug(1, "Command: %x", command);
+ byte command = _data->readByte();
switch(command) {
case 0x80: // IF
@@ -227,7 +251,7 @@ Script::Operand *Script::readOperand() {
case 0xB3: // VICTORY#
return new Operand(cont->_kills, NUMBER);
case 0xB4: // BADCOPY#
- return new Operand(0, NUMBER); // ????
+ return new Operand(0, NUMBER); // \?\?\??
case 0xFF:
{
// user variable
@@ -859,4 +883,204 @@ void Script::handleAttack(Weapon *weapon) {
warning("STUB: handleAttack");
}
+enum {
+ BLOCK_START,
+ BLOCK_END,
+ STATEMENT,
+ OPERATOR,
+ OPCODE
+};
+
+struct {
+ const char *cmd;
+ int type;
+} mapping[] = {
+ { "IF{", STATEMENT }, // 0x80
+ { "=", OPERATOR },
+ { "<", OPERATOR },
+ { ">", OPERATOR },
+ { "}AND{", OPCODE },
+ { "}OR{", OPCODE },
+ { "\?\?\?(0x86)", OPCODE },
+ { "EXIT\n", BLOCK_END },
+ { "END\n", BLOCK_END }, // 0x88
+ { "MOVE{", STATEMENT },
+ { "}TO{", OPCODE },
+ { "PRINT{", STATEMENT },
+ { "SOUND{", STATEMENT },
+ { "\?\?\?(0x8d)", OPCODE },
+ { "LET{", STATEMENT },
+ { "+", OPERATOR },
+ { "-", OPERATOR }, // 0x90
+ { "*", OPERATOR },
+ { "/", OPERATOR },
+ { "==", OPERATOR },
+ { ">>", OPERATOR },
+ { "MENU{", STATEMENT },
+ { "\?\?\?(0x96)", OPCODE },
+ { "\?\?\?(0x97)", OPCODE },
+ { "\?\?\?(0x98)", OPCODE }, // 0x98
+ { "\?\?\?(0x99)", OPCODE },
+ { "\?\?\?(0x9a)", OPCODE },
+ { "\?\?\?(0x9b)", OPCODE },
+ { "\?\?\?(0x9c)", OPCODE },
+ { "\?\?\?(0x9d)", OPCODE },
+ { "\?\?\?(0x9e)", OPCODE },
+ { "\?\?\?(0x9f)", OPCODE },
+ { "TEXT$", OPCODE }, // 0xa0
+ { "CLICK$", OPCODE },
+ { "\?\?\?(0xa2)", OPCODE },
+ { "\?\?\?(0xa3)", OPCODE },
+ { "\?\?\?(0xa4)", OPCODE },
+ { "\?\?\?(0xa5)", OPCODE },
+ { "\?\?\?(0xa6)", OPCODE },
+ { "\?\?\?(0xa7)", OPCODE },
+ { "\?\?\?(0xa8)", OPCODE }, // 0xa8
+ { "\?\?\?(0xa9)", OPCODE },
+ { "\?\?\?(0xaa)", OPCODE },
+ { "\?\?\?(0xab)", OPCODE },
+ { "\?\?\?(0xac)", OPCODE },
+ { "\?\?\?(0xad)", OPCODE },
+ { "\?\?\?(0xae)", OPCODE },
+ { "\?\?\?(0xaf)", OPCODE },
+ { "VISITS#", OPCODE }, // 0xb0 // The number of scenes the player has visited, including repeated visits.
+ { "RANDOM#", OPCODE }, // RANDOM# for Star Trek, but VISITS# for some other games?
+ { "LOOP#", OPCODE }, // The number of commands the player has given in the current scene.
+ { "VICTORY#", OPCODE }, // The number of characters killed.
+ { "BADCOPY#", OPCODE },
+ { "RANDOM#", OPCODE }, // A random number between 1 and 100.
+ { "\?\?\?(0xb6)", OPCODE },
+ { "\?\?\?(0xb7)", OPCODE },
+ { "\?\?\?(0xb8)", OPCODE }, // 0xb8
+ { "\?\?\?(0xb9)", OPCODE },
+ { "\?\?\?(0xba)", OPCODE },
+ { "\?\?\?(0xbb)", OPCODE },
+ { "\?\?\?(0xbc)", OPCODE },
+ { "\?\?\?(0xbd)", OPCODE },
+ { "\?\?\?(0xbe)", OPCODE },
+ { "\?\?\?(0xbf)", OPCODE },
+ { "STORAGE@", OPCODE }, // 0xc0
+ { "SCENE@", OPCODE },
+ { "PLAYER@", OPCODE },
+ { "MONSTER@", OPCODE },
+ { "RANDOMSCN@", OPCODE },
+ { "RANDOMCHR@", OPCODE },
+ { "RANDOMOBJ@", OPCODE },
+ { "\?\?\?(0xc7)", OPCODE },
+ { "\?\?\?(0xc8)", OPCODE }, // 0xc8
+ { "\?\?\?(0xc9)", OPCODE },
+ { "\?\?\?(0xca)", OPCODE },
+ { "\?\?\?(0xcb)", OPCODE },
+ { "\?\?\?(0xcc)", OPCODE },
+ { "\?\?\?(0xcd)", OPCODE },
+ { "\?\?\?(0xce)", OPCODE },
+ { "\?\?\?(0xcf)", OPCODE },
+ { "PHYS.STR.BAS#", OPCODE }, // 0xd0
+ { "PHYS.HIT.BAS#", OPCODE },
+ { "PHYS.ARM.BAS#", OPCODE },
+ { "PHYS.ACC.BAS#", OPCODE },
+ { "SPIR.STR.BAS#", OPCODE },
+ { "SPIR.HIT.BAS#", OPCODE },
+ { "SPIR.ARM.BAS#", OPCODE },
+ { "SPIR.ACC.BAS#", OPCODE },
+ { "PHYS.SPE.BAS#", OPCODE }, // 0xd8
+ { "\?\?\?(0xd9)", OPCODE },
+ { "\?\?\?(0xda)", OPCODE },
+ { "\?\?\?(0xdb)", OPCODE },
+ { "\?\?\?(0xdc)", OPCODE },
+ { "\?\?\?(0xdd)", OPCODE },
+ { "\?\?\?(0xde)", OPCODE },
+ { "\?\?\?(0xdf)", OPCODE },
+ { "PHYS.STR.CUR#", OPCODE }, // 0xe0
+ { "PHYS.HIT.CUR#", OPCODE },
+ { "PHYS.ARM.CUR#", OPCODE },
+ { "PHYS.ACC.CUR#", OPCODE },
+ { "SPIR.STR.CUR#", OPCODE },
+ { "SPIR.HIT.CUR#", OPCODE },
+ { "SPIR.ARM.CUR#", OPCODE },
+ { "SPIR.ACC.CUR#", OPCODE },
+ { "PHYS.SPE.CUR#", OPCODE }, // 0xe8
+ { "\?\?\?(0xe9)", OPCODE },
+ { "\?\?\?(0xea)", OPCODE },
+ { "\?\?\?(0xeb)", OPCODE },
+ { "\?\?\?(0xec)", OPCODE },
+ { "\?\?\?(0xed)", OPCODE },
+ { "\?\?\?(0xee)", OPCODE },
+ { "\?\?\?(0xef)", OPCODE },
+ { "\?\?\?(0xf0)", OPCODE },
+ { "\?\?\?(0xf1)", OPCODE },
+ { "\?\?\?(0xf2)", OPCODE },
+ { "\?\?\?(0xf3)", OPCODE },
+ { "\?\?\?(0xf4)", OPCODE },
+ { "\?\?\?(0xf5)", OPCODE },
+ { "\?\?\?(0xf6)", OPCODE },
+ { "\?\?\?(0xf7)", OPCODE },
+ { "\?\?\?(0xf8)", OPCODE }, // 0xa8
+ { "\?\?\?(0xf9)", OPCODE },
+ { "\?\?\?(0xfa)", OPCODE },
+ { "\?\?\?(0xfb)", OPCODE },
+ { "\?\?\?(0xfc)", OPCODE },
+ { "}\n", OPCODE },
+ { "}THEN\n", BLOCK_START },
+ { "\?\?\?(0xff)", OPCODE } // Uservar
+};
+
+void Script::convertToText() {
+ _data->seek(12);
+
+ int indentLevel = 0;
+ ScriptText *scr = new ScriptText;
+ scr->offset = _data->pos();
+
+ while(true) {
+ int c = _data->readByte();
+
+ if (_data->eos())
+ break;
+
+ if (c < 0x80) {
+ if (c < 0x20)
+ error("Unknown code 0x%02x at %d", c, _data->pos());
+
+ do {
+ scr->line += c;
+ c = _data->readByte();
+ } while (c < 0x80);
+
+ _data->seek(-1, SEEK_CUR);
+ } else if (c == 0xff) {
+ int value = _data->readByte();
+ value -= 1;
+ scr->line += (char)('A' + (value / 9));
+ scr->line += (char)('0' + (value % 9) + 1);
+ scr->line += '#';
+ } else {
+ const char *cmd = mapping[c - 0x80].cmd;
+ int type = mapping[c - 0x80].type;
+
+ if (type == STATEMENT) {
+ for (int i = 0; i < indentLevel; i++)
+ scr->line += ' ';
+ } else if (type == BLOCK_START) {
+ indentLevel += 2;
+ } else if (type == BLOCK_END) {
+ indentLevel -= 2;
+ for (int i = 0; i < indentLevel; i++)
+ scr->line += ' ';
+ }
+
+ scr->line += cmd;
+
+ if (strchr(cmd, '\n')) {
+ scr->line.deleteLastChar();
+
+ _scriptText.push_back(scr);
+
+ scr = new ScriptText;
+ scr->offset = _data->pos();
+ }
+ }
+ }
+}
+
} // End of namespace Wage
diff --git a/engines/wage/script.h b/engines/wage/script.h
index 77b6d7d..fde7395 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -52,7 +52,7 @@ namespace Wage {
class Script {
public:
- Script(Common::SeekableReadStream *data) : _data(data) {}
+ Script(Common::SeekableReadStream *data);
~Script();
private:
@@ -136,7 +136,14 @@ private:
}
};
+ struct ScriptText {
+ int offset;
+ Common::String line;
+ };
+
public:
+ void print();
+ void printLine(int offset);
bool execute(World *world, int loopCount, String *inputText, Designed *inputClick, WageEngine *callbacks);
private:
@@ -173,6 +180,8 @@ private:
bool tryAttack(Weapon *weapon, Common::String &input);
void handleAttack(Weapon *weapon);
+ Common::Array<ScriptText *> _scriptText;
+ void convertToText();
};
} // End of namespace Wage
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 533b30f..f91b5fa 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -111,6 +111,7 @@ Common::Error WageEngine::run() {
Common::Rect r(0, 0, screen.w, screen.h);
Common::String input("look");
+ _world->_globalScript->print();
_world->_globalScript->execute(_world, 1, &input, NULL, this);
//_world->_orderedScenes[1]->_design->paint(&screen, _world->_patterns, false);
Commit: 370c1932f608085c94cb37be15487ccdfc0163da
https://github.com/scummvm/scummvm/commit/370c1932f608085c94cb37be15487ccdfc0163da
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:01+01:00
Commit Message:
WAGE: Fix bug with skipping nested IF's
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index f03b364..547a850 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -489,10 +489,8 @@ void Script::skipBlock() {
nesting++;
skipIf();
} else if (op == 0x88 || op == 0x87) { // END or EXIT
- _data->seek(-1, SEEK_CUR); // We need to reread it higher
nesting--;
if (nesting == 0) {
- _data->readByte(); // skiping
return;
}
} else switch (op) {
Commit: 9902ac2454561dc8abd37551539a8ad2cda2d538
https://github.com/scummvm/scummvm/commit/9902ac2454561dc8abd37551539a8ad2cda2d538
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:01+01:00
Commit Message:
WAGE: Implement handleLookCommand()
Changed paths:
engines/wage/script.cpp
engines/wage/script.h
engines/wage/wage.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 547a850..3be3d59 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -832,9 +832,22 @@ void Script::handleMoveCommand(Scene::Directions dir, const char *dirName) {
}
void Script::handleLookCommand() {
- warning("STUB: handleLookCommand");
+ appendText(_world->_player->_currentScene->_text);
+
+ Common::String *items = getGroundItemsList(_world->_player->_currentScene);
+ if (items != NULL) {
+ appendText(*items);
+
+ delete items;
+ }
}
+Common::String *Script::getGroundItemsList(Scene *scene) {
+ warning("STUB: getGroundItemsList");
+ return NULL;
+}
+
+
void Script::handleInventoryCommand() {
warning("STUB: handleInventoryCommand");
}
diff --git a/engines/wage/script.h b/engines/wage/script.h
index fde7395..1061219 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -166,6 +166,7 @@ private:
void appendText(String str);
void handleMoveCommand(Scene::Directions dir, const char *dirName);
void handleLookCommand();
+ Common::String *getGroundItemsList(Scene *scene);
void handleInventoryCommand();
void handleStatusCommand();
void handleRestCommand();
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index f91b5fa..1a8c85c 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -111,6 +111,8 @@ Common::Error WageEngine::run() {
Common::Rect r(0, 0, screen.w, screen.h);
Common::String input("look");
+
+ _world->_player->_currentScene = _world->_orderedScenes[1];
_world->_globalScript->print();
_world->_globalScript->execute(_world, 1, &input, NULL, this);
@@ -148,7 +150,7 @@ void WageEngine::setMenu(String soundName) {
}
void WageEngine::appendText(String str) {
- warning("STUB: appendText");
+ warning("STUB: appendText(%s)", str.c_str());
}
Obj *WageEngine::getOffer() {
Commit: 35cce4123c61f8cfbc80ced25a9c7a3f9b46b6e7
https://github.com/scummvm/scummvm/commit/35cce4123c61f8cfbc80ced25a9c7a3f9b46b6e7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:01+01:00
Commit Message:
WAGE: Cleanup
Changed paths:
engines/wage/script.cpp
engines/wage/script.h
engines/wage/wage.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 3be3d59..8b842f8 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -389,14 +389,12 @@ Script::Operand *Script::readStringOperand() {
_data->seek(-1, SEEK_CUR);
if (allDigits && sb->size() > 0) {
- debug(0, "Read number %s", sb->c_str());
int r = atol(sb->c_str());
delete sb;
return new Operand(r, NUMBER);
} else {
// TODO: This string could be a room name or something like that.
- debug(0, "Read string %s", sb->c_str());
return new Operand(sb, STRING);
}
}
diff --git a/engines/wage/script.h b/engines/wage/script.h
index 1061219..0cf6785 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -63,7 +63,6 @@ private:
int _loopCount;
String *_inputText;
Designed *_inputClick;
- bool _evalResult;
bool _handled;
class Operand {
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 1a8c85c..1cf0dde 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -113,7 +113,6 @@ Common::Error WageEngine::run() {
Common::String input("look");
_world->_player->_currentScene = _world->_orderedScenes[1];
- _world->_globalScript->print();
_world->_globalScript->execute(_world, 1, &input, NULL, this);
//_world->_orderedScenes[1]->_design->paint(&screen, _world->_patterns, false);
Commit: d4afcf99f2b21319251fcb7e8a3de2854808e161
https://github.com/scummvm/scummvm/commit/d4afcf99f2b21319251fcb7e8a3de2854808e161
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:01+01:00
Commit Message:
WAGE: Initial code for world initialization
Changed paths:
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/wage.cpp
engines/wage/wage.h
engines/wage/world.cpp
engines/wage/world.h
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 15fbbb9..6ec3b7c 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -205,6 +205,11 @@ WeaponArray *Chr::getWeapons() {
return list;
}
+void Chr::wearObjs() {
+ for (int i = 0; i < _inventory.size(); i++)
+ wearObjIfPossible(&_inventory[i]);
+}
+
int Chr::wearObjIfPossible(Obj *obj) {
switch (obj->_type) {
case Obj::HELMET:
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 28ce42a..7573cc8 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -201,7 +201,7 @@ public:
String _dyingWords;
Scene *_currentScene;
- Common::List<Obj> _inventory;
+ Common::Array<Obj> _inventory;
Obj *_armor[NUMBER_OF_ARMOR_TYPES];
@@ -279,6 +279,7 @@ public:
return (_nativeWeapon2.size() > 0 && _operativeVerb2.size() > 0);
}
int wearObjIfPossible(Obj *obj);
+ void wearObjs();
};
class Weapon {
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 1cf0dde..173646b 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -101,7 +101,7 @@ Common::Error WageEngine::run() {
_resManager = new Common::MacResManager();
_resManager->open(getGameFile());
- _world = new World();
+ _world = new World(this);
if (!_world->loadWorld(_resManager))
return Common::kNoGameDataFoundError;
@@ -110,6 +110,8 @@ Common::Error WageEngine::run() {
screen.create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
Common::Rect r(0, 0, screen.w, screen.h);
+ performInitialSetup();
+
Common::String input("look");
_world->_player->_currentScene = _world->_orderedScenes[1];
@@ -158,5 +160,57 @@ Obj *WageEngine::getOffer() {
return NULL;
}
+void WageEngine::performInitialSetup() {
+ for (int i = 0; i < _world->_orderedObjs.size(); i++)
+ _world->move(_world->_orderedObjs[i], &_world->_storageScene);
+ for (int i = 0; i < _world->_orderedChrs.size(); i++)
+ _world->move(_world->_orderedChrs[i], &_world->_storageScene);
+
+ warning("STUB: performInitialSetup");
+/*
+ for (int i = 0; i < _world->_orderedObjs.size(); i++)
+ Obj obj = _world->_orderedObjs[i];
+ if (!obj.getSceneOrOwner().equalsIgnoreCase(World.STORAGE)) {
+ String location = obj.getSceneOrOwner().toLowerCase();
+ Scene scene = getSceneByName(location);
+ if (scene != null) {
+ world.move(obj, scene);
+ } else {
+ Chr chr = world.getChrs().get(location);
+ if (chr == null) {
+ // Note: PLAYER@ is not a valid target here.
+ System.err.printf("Couldn't move %s to %s\n", obj.getName(), obj.getSceneOrOwner());
+ } else {
+ // TODO: Add check for max items.
+ world.move(obj, chr);
+ }
+ }
+ }
+ }
+*/
+ bool playerPlaced = false;
+ for (int i = 0; i < _world->_orderedChrs.size(); i++) {
+ Chr *chr = _world->_orderedChrs[i];
+ if (!chr->_initialScene.equalsIgnoreCase(STORAGESCENE)) {
+ String key = chr->_initialScene;
+ key.toLowercase();
+ if (_world->_scenes.contains(key)) {
+ _world->move(chr, _world->_scenes[key]);
+
+ if (chr->_playerCharacter)
+ warning("Initial scene: %s", key.c_str());
+ } else {
+ _world->move(chr, _world->getRandomScene());
+ }
+ if (chr->_playerCharacter) {
+ playerPlaced = true;
+ }
+ }
+ chr->wearObjs();
+ }
+ if (!playerPlaced) {
+ _world->move(_world->_player, _world->getRandomScene());
+ }
+}
} // End of namespace Wage
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 1e57ef5..91f4b67 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -108,6 +108,8 @@ public:
private:
bool loadWorld(Common::MacResManager *resMan);
+ void performInitialSetup();
+ void wearObjs(Chr *chr);
public:
Common::RandomSource *_rnd;
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index b404736..8ae775a 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -57,7 +57,7 @@
namespace Wage {
-World::World() {
+World::World(WageEngine *engine) {
_storageScene._name = STORAGESCENE;
_orderedScenes.push_back(&_storageScene);
_scenes[STORAGESCENE] = &_storageScene;
@@ -66,6 +66,8 @@ World::World() {
_saveBeforeQuitMessage = nullptr;
_saveBeforeCloseMessage = nullptr;
_revertMessage = nullptr;
+
+ _engine = engine;
}
bool World::loadWorld(Common::MacResManager *resMan) {
@@ -351,7 +353,20 @@ Common::String *World::loadStringFromDITL(Common::MacResManager *resMan, int res
}
void World::move(Obj *obj, Chr *chr) {
- warning("STUB: World::move()");
+ warning("STUB: World::move(obj, chr)");
+}
+
+void World::move(Obj *obj, Scene *scene) {
+ warning("STUB: World::move(obj, scene)");
+}
+
+void World::move(Chr *chr, Scene *scene) {
+ warning("STUB: World::move(chr, scene)");
+}
+
+Scene *World::getRandomScene() {
+ // Not including storage:
+ return _orderedScenes[1 + _engine->_rnd->getRandomNumber(_orderedScenes.size() - 1)];
}
} // End of namespace Wage
diff --git a/engines/wage/world.h b/engines/wage/world.h
index 15a65d8..1bd71f1 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -54,13 +54,18 @@ namespace Wage {
class World {
public:
- World();
+ World(WageEngine *engine);
~World();
bool loadWorld(Common::MacResManager *resMan);
void loadExternalSounds(String fname);
Common::String *loadStringFromDITL(Common::MacResManager *resMan, int resourceId, int itemIndex);
void move(Obj *obj, Chr *chr);
+ void move(Obj *obj, Scene *scene);
+ void move(Chr *chr, Scene *scene);
+ Scene *getRandomScene();
+
+ WageEngine *_engine;
String _name;
String _aboutMessage;
Commit: 59b2809f3740923cc63477a25eaabde2535f6f2e
https://github.com/scummvm/scummvm/commit/59b2809f3740923cc63477a25eaabde2535f6f2e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:02+01:00
Commit Message:
WAGE: Finished WageEngine::performInitialSetup()
Changed paths:
engines/wage/wage.cpp
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 173646b..615a7a0 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -166,28 +166,25 @@ void WageEngine::performInitialSetup() {
for (int i = 0; i < _world->_orderedChrs.size(); i++)
_world->move(_world->_orderedChrs[i], &_world->_storageScene);
- warning("STUB: performInitialSetup");
-/*
- for (int i = 0; i < _world->_orderedObjs.size(); i++)
- Obj obj = _world->_orderedObjs[i];
- if (!obj.getSceneOrOwner().equalsIgnoreCase(World.STORAGE)) {
- String location = obj.getSceneOrOwner().toLowerCase();
- Scene scene = getSceneByName(location);
- if (scene != null) {
- world.move(obj, scene);
+ for (int i = 0; i < _world->_orderedObjs.size(); i++) {
+ Obj *obj = _world->_orderedObjs[i];
+ if (!obj->_sceneOrOwner.equalsIgnoreCase(STORAGESCENE)) {
+ String location = obj->_sceneOrOwner;
+ location.toLowercase();
+ if (_world->_scenes.contains(location)) {
+ _world->move(obj, _world->_scenes[location]);
} else {
- Chr chr = world.getChrs().get(location);
- if (chr == null) {
+ if (!_world->_chrs.contains(location)) {
// Note: PLAYER@ is not a valid target here.
- System.err.printf("Couldn't move %s to %s\n", obj.getName(), obj.getSceneOrOwner());
+ warning("Couldn't move %s to %s", obj->_name.c_str(), obj->_sceneOrOwner.c_str());
} else {
// TODO: Add check for max items.
- world.move(obj, chr);
+ _world->move(obj, _world->_chrs[location]);
}
}
}
}
-*/
+
bool playerPlaced = false;
for (int i = 0; i < _world->_orderedChrs.size(); i++) {
Chr *chr = _world->_orderedChrs[i];
Commit: 5f2ef620c18b36fe0d480474135aa78eb9eb0c01
https://github.com/scummvm/scummvm/commit/5f2ef620c18b36fe0d480474135aa78eb9eb0c01
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:02+01:00
Commit Message:
WAGE: Implemented World::move(Obj *obj, Chr *chr)
Changed paths:
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/wage.cpp
engines/wage/wage.h
engines/wage/world.cpp
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 6ec3b7c..8bde170 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -124,6 +124,33 @@ Obj::Obj(String name, Common::SeekableReadStream *data) : _currentOwner(NULL), _
_sound = readPascalString(data);
}
+Chr *Obj::removeFromChr() {
+ if (_currentOwner != NULL) {
+ for (int i = _currentOwner->_inventory.size() - 1; i >= 0; i--)
+ if (_currentOwner->_inventory[i] == this)
+ _currentOwner->_inventory.remove_at(i);
+
+ for (int i = 0; i < Chr::NUMBER_OF_ARMOR_TYPES; i++) {
+ if (_currentOwner->_armor[i] == this) {
+ _currentOwner->_armor[i] = NULL;
+ }
+ }
+ }
+
+ return _currentOwner;
+}
+
+Designed *Obj::removeFromCharOrScene() {
+ Designed *from = removeFromChr();
+
+ if (_currentScene != NULL) {
+ _currentScene->_objs.remove(this);
+ from = _currentScene;
+ }
+
+ return from;
+}
+
Chr::Chr(String name, Common::SeekableReadStream *data) {
_name = name;
_classType = CHR;
@@ -207,7 +234,7 @@ WeaponArray *Chr::getWeapons() {
void Chr::wearObjs() {
for (int i = 0; i < _inventory.size(); i++)
- wearObjIfPossible(&_inventory[i]);
+ wearObjIfPossible(_inventory[i]);
}
int Chr::wearObjIfPossible(Obj *obj) {
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 7573cc8..d24252f 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -201,7 +201,7 @@ public:
String _dyingWords;
Scene *_currentScene;
- Common::Array<Obj> _inventory;
+ Common::Array<Obj *> _inventory;
Obj *_armor[NUMBER_OF_ARMOR_TYPES];
@@ -354,6 +354,9 @@ public:
if (currentScene != NULL)
_currentOwner = NULL;
}
+
+ Chr *removeFromChr();
+ Designed *removeFromCharOrScene();
};
class Scene : public Designed {
@@ -383,8 +386,8 @@ public:
int _worldX;
int _worldY;
- Common::List<Obj> _objs;
- Common::List<Chr> _chrs;
+ Common::List<Obj *> _objs;
+ Common::List<Chr *> _chrs;
Scene() {}
Scene(String name, Common::SeekableReadStream *data);
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 615a7a0..145a316 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -210,4 +210,8 @@ void WageEngine::performInitialSetup() {
}
}
+void WageEngine::onMove(Designed *what, Designed *from, Designed *to) {
+ warning("STUB WageEngine::onMove()");
+}
+
} // End of namespace Wage
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 91f4b67..5a7d5a0 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -61,10 +61,11 @@ struct ADGameDescription;
namespace Wage {
class Console;
-class World;
-class Scene;
-class Obj;
class Chr;
+class Designed;
+class Obj;
+class Scene;
+class World;
using Common::String;
@@ -131,6 +132,7 @@ public:
void appendText(String str);
Obj *getOffer();
void processEvents();
+ void onMove(Designed *what, Designed *from, Designed *to);
private:
Console *_console;
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 8ae775a..a177d329 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -352,8 +352,21 @@ Common::String *World::loadStringFromDITL(Common::MacResManager *resMan, int res
return NULL;
}
+bool ChrComparator(Obj *l, Obj *r) {
+ return l->_index < r->_index;
+}
+
void World::move(Obj *obj, Chr *chr) {
- warning("STUB: World::move(obj, chr)");
+ if (obj == NULL)
+ return;
+
+ Designed *from = obj->removeFromCharOrScene();
+ obj->_currentOwner = chr;
+ chr->_inventory.push_back(obj);
+
+ Common::sort(chr->_inventory.begin(), chr->_inventory.end(), ChrComparator);
+
+ _engine->onMove(obj, from, chr);
}
void World::move(Obj *obj, Scene *scene) {
Commit: 113a274027f41a4c51b8d5bbbf8fec46ce176bf0
https://github.com/scummvm/scummvm/commit/113a274027f41a4c51b8d5bbbf8fec46ce176bf0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:02+01:00
Commit Message:
WAGE: Implemented World::move(Obj *obj, Scene *scene)
Changed paths:
engines/wage/world.cpp
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index a177d329..c04fc14 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -352,7 +352,7 @@ Common::String *World::loadStringFromDITL(Common::MacResManager *resMan, int res
return NULL;
}
-bool ChrComparator(Obj *l, Obj *r) {
+bool InvComparator(Obj *l, Obj *r) {
return l->_index < r->_index;
}
@@ -364,13 +364,31 @@ void World::move(Obj *obj, Chr *chr) {
obj->_currentOwner = chr;
chr->_inventory.push_back(obj);
- Common::sort(chr->_inventory.begin(), chr->_inventory.end(), ChrComparator);
+ Common::sort(chr->_inventory.begin(), chr->_inventory.end(), InvComparator);
_engine->onMove(obj, from, chr);
}
+bool ObjComparator(Obj *o1, Obj *o2) {
+ bool o1Immobile = (o1->_type == Obj::IMMOBILE_OBJECT);
+ bool o2Immobile = (o2->_type == Obj::IMMOBILE_OBJECT);
+ if (o1Immobile == o2Immobile) {
+ return o1->_index - o2->_index;
+ }
+ return o1Immobile;
+}
+
void World::move(Obj *obj, Scene *scene) {
- warning("STUB: World::move(obj, scene)");
+ if (obj == NULL)
+ return;
+
+ Designed *from = obj->removeFromCharOrScene();
+ obj->_currentScene = scene;
+ scene->_objs.push_back(obj);
+
+ Common::sort(scene->_objs.begin(), scene->_objs.end(), ObjComparator);
+
+ _engine->onMove(obj, from, scene);
}
void World::move(Chr *chr, Scene *scene) {
Commit: 81dc7cd98ff385fed4523f6b3f8ddc04ed7bea62
https://github.com/scummvm/scummvm/commit/81dc7cd98ff385fed4523f6b3f8ddc04ed7bea62
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:02+01:00
Commit Message:
WAGE: Implement World::move(Chr *chr, Scene *scene)
Changed paths:
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/script.cpp
engines/wage/wage.cpp
engines/wage/world.cpp
engines/wage/world.h
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 8bde170..0e7e4bc 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -78,6 +78,8 @@ Scene::Scene(String name, Common::SeekableReadStream *data) {
_messages[Scene::EAST] = readPascalString(data);
_messages[Scene::WEST] = readPascalString(data);
_soundName = readPascalString(data);
+
+ _visited = false;
}
Obj::Obj(String name, Common::SeekableReadStream *data) : _currentOwner(NULL), _currentScene(NULL) {
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index d24252f..66f966a 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -385,6 +385,7 @@ public:
String _soundName;
int _worldX;
int _worldY;
+ bool _visited;
Common::List<Obj *> _objs;
Common::List<Chr *> _chrs;
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 8b842f8..3be74cc 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -227,7 +227,7 @@ Script::Operand *Script::readOperand() {
case 0xA1:
return new Operand(_inputClick, CLICK_INPUT);
case 0xC0: // STORAGE@
- return new Operand(&_world->_storageScene, SCENE);
+ return new Operand(_world->_storageScene, SCENE);
case 0xC1: // SCENE@
return new Operand(_world->_player->_currentScene, SCENE);
case 0xC2: // PLAYER@
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 145a316..677737f 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -162,9 +162,9 @@ Obj *WageEngine::getOffer() {
void WageEngine::performInitialSetup() {
for (int i = 0; i < _world->_orderedObjs.size(); i++)
- _world->move(_world->_orderedObjs[i], &_world->_storageScene);
+ _world->move(_world->_orderedObjs[i], _world->_storageScene);
for (int i = 0; i < _world->_orderedChrs.size(); i++)
- _world->move(_world->_orderedChrs[i], &_world->_storageScene);
+ _world->move(_world->_orderedChrs[i], _world->_storageScene);
for (int i = 0; i < _world->_orderedObjs.size(); i++) {
Obj *obj = _world->_orderedObjs[i];
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index c04fc14..a99300e 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -58,9 +58,11 @@
namespace Wage {
World::World(WageEngine *engine) {
- _storageScene._name = STORAGESCENE;
- _orderedScenes.push_back(&_storageScene);
- _scenes[STORAGESCENE] = &_storageScene;
+ _storageScene = new Scene;
+ _storageScene->_name = STORAGESCENE;
+
+ _orderedScenes.push_back(_storageScene);
+ _scenes[STORAGESCENE] = _storageScene;
_gameOverMessage = nullptr;
_saveBeforeQuitMessage = nullptr;
@@ -70,6 +72,10 @@ World::World(WageEngine *engine) {
_engine = engine;
}
+World::~World() {
+ delete _storageScene;
+}
+
bool World::loadWorld(Common::MacResManager *resMan) {
Common::MacResIDArray resArray;
Common::SeekableReadStream *res;
@@ -391,8 +397,34 @@ void World::move(Obj *obj, Scene *scene) {
_engine->onMove(obj, from, scene);
}
+bool ChrComparator(Chr *l, Chr *r) {
+ return l->_index < r->_index;
+}
+
void World::move(Chr *chr, Scene *scene) {
- warning("STUB: World::move(chr, scene)");
+ if (chr == NULL)
+ return;
+ Scene *from = chr->_currentScene;
+ if (from == scene)
+ return;
+ if (from != NULL)
+ from->_chrs.remove(chr);
+ scene->_chrs.push_back(chr);
+
+ Common::sort(scene->_chrs.begin(), scene->_chrs.end(), ChrComparator);
+
+ if (scene == _storageScene) {
+ warning("STUB: World::move (chrState)");
+ //chr.setState(new Chr.State(chr));
+ } else if (chr->_playerCharacter) {
+ scene->_visited = true;
+ warning("STUB: World::move (visits)");
+ //Context context = getPlayerContext();
+ //context.setVisits(context.getVisits() + 1);
+ }
+ chr->_currentScene = scene;
+
+ _engine->onMove(chr, from, scene);
}
Scene *World::getRandomScene() {
diff --git a/engines/wage/world.h b/engines/wage/world.h
index 1bd71f1..ed93386 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -83,7 +83,7 @@ public:
Common::Array<Chr *> _orderedChrs;
Common::Array<Sound *> _orderedSounds;
Patterns _patterns;
- Scene _storageScene;
+ Scene *_storageScene;
Chr *_player;
//List<MoveListener> moveListeners;
Commit: 6d3fe9568955ff2475f2091d0edb866c68635522
https://github.com/scummvm/scummvm/commit/6d3fe9568955ff2475f2091d0edb866c68635522
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:02+01:00
Commit Message:
WAGE: Implemented WageEngine::onMove()
Changed paths:
engines/wage/script.cpp
engines/wage/wage.cpp
engines/wage/wage.h
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 3be74cc..a26a733 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -233,7 +233,7 @@ Script::Operand *Script::readOperand() {
case 0xC2: // PLAYER@
return new Operand(_world->_player, CHR);
case 0xC3: // MONSTER@
- return new Operand(_callbacks->_monster, CHR);
+ return new Operand(_callbacks->getMonster(), CHR);
case 0xC4: // RANDOMSCN@
return new Operand(_world->_orderedScenes[_callbacks->_rnd->getRandomNumber(_world->_orderedScenes.size())], SCENE);
case 0xC5: // RANDOMCHR@
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 677737f..ff57d88 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -70,6 +70,10 @@ WageEngine::WageEngine(OSystem *syst, const ADGameDescription *desc) : Engine(sy
_rnd = new Common::RandomSource("wage");
_aim = -1;
+ _temporarilyHidden = false;
+ _isGameOver = false;
+ _monster = NULL;
+ _lastScene = NULL;
debug("WageEngine::WageEngine()");
}
@@ -110,7 +114,9 @@ Common::Error WageEngine::run() {
screen.create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
Common::Rect r(0, 0, screen.w, screen.h);
+ _temporarilyHidden = true;
performInitialSetup();
+ _temporarilyHidden = false;
Common::String input("look");
@@ -143,23 +149,34 @@ void WageEngine::processEvents() {
}
void WageEngine::playSound(String soundName) {
- warning("STUB: playSound");
+ warning("STUB: WageEngine::playSound(%s)", soundName.c_str());
}
void WageEngine::setMenu(String soundName) {
- warning("STUB: setMenu");
+ warning("STUB: WageEngine::setMenu");
}
void WageEngine::appendText(String str) {
- warning("STUB: appendText(%s)", str.c_str());
+ warning("STUB: WageEngine::appendText(%s)", str.c_str());
}
Obj *WageEngine::getOffer() {
- warning("STUB: getOffer");
+ warning("STUB: WageEngine::getOffer");
return NULL;
}
+Chr *WageEngine::getMonster() {
+ if (_monster != NULL && _monster->_currentScene != _world->_player->_currentScene) {
+ _monster = NULL;
+ }
+ return _monster;
+}
+
+void WageEngine::gameOver() {
+ warning("STUB: WageEngine::gameOver()");
+}
+
void WageEngine::performInitialSetup() {
for (int i = 0; i < _world->_orderedObjs.size(); i++)
_world->move(_world->_orderedObjs[i], _world->_storageScene);
@@ -210,8 +227,82 @@ void WageEngine::performInitialSetup() {
}
}
+Scene *WageEngine::getSceneByName(String &location) {
+ Scene *scene;
+ if (location.equals("random@")) {
+ scene = _world->getRandomScene();
+ } else {
+ scene = _world->_scenes[location];
+ }
+ return scene;
+}
+
void WageEngine::onMove(Designed *what, Designed *from, Designed *to) {
- warning("STUB WageEngine::onMove()");
+ Chr *player = _world->_player;
+ Scene *currentScene = player->_currentScene;
+ if (currentScene == _world->_storageScene && !_temporarilyHidden) {
+ if (!_isGameOver) {
+ _isGameOver = true;
+ gameOver();
+ }
+ return;
+ }
+
+ if (what != player && what->_classType == CHR) {
+ Chr *chr = (Chr *)what;
+ if (to == _world->_storageScene) {
+ int returnTo = chr->_returnTo;
+ if (returnTo != Chr::RETURN_TO_STORAGE) {
+ String returnToSceneName;
+ if (returnTo == Chr::RETURN_TO_INITIAL_SCENE) {
+ returnToSceneName = chr->_initialScene;
+ returnToSceneName.toLowercase();
+ } else {
+ returnToSceneName = "random@";
+ }
+ Scene *scene = getSceneByName(returnToSceneName);
+ if (scene != NULL && scene != _world->_storageScene) {
+ _world->move(chr, scene);
+ // To avoid sleeping twice, return if the above move command would cause a sleep.
+ if (scene == currentScene)
+ return;
+ }
+ }
+ } else if (to == player->_currentScene) {
+ if (getMonster() == NULL) {
+ _monster = chr;
+ encounter(player, chr);
+ }
+ }
+ }
+ if (!_temporarilyHidden) {
+ if (to == currentScene || from == currentScene) {
+ redrawScene();
+ g_system->delayMillis(100);
+ }
+ }
+}
+
+void WageEngine::encounter(Chr *player, Chr *chr) {
+ warning("STUB WageEngine::encounter()");
+}
+
+void WageEngine::redrawScene() {
+ Scene *currentScene = _world->_player->_currentScene;
+ if (currentScene != NULL) {
+ //bool firstTime = (_lastScene != currentScene);
+ _lastScene = currentScene;
+
+ warning("STUB: WageEngine::redrawScene()");
+
+ //updateConsoleForScene(console, currentScene);
+ //updateSceneViewerForScene(viewer, currentScene);
+ //viewer.paintImmediately(viewer.getBounds());
+ //getContentPane().validate();
+ //getContentPane().repaint();
+ //console.postUpdateUI();
+ //soundManager.updateSoundTimerForScene(currentScene, firstTime);
+ }
}
} // End of namespace Wage
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 5a7d5a0..4d75ace 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -126,13 +126,19 @@ public:
bool _commandWasQuick;
int _aim;
bool _temporarilyHidden;
+ bool _isGameOver;
void playSound(String soundName);
void setMenu(String soundName);
void appendText(String str);
+ void gameOver();
Obj *getOffer();
+ Chr *getMonster();
void processEvents();
+ Scene *getSceneByName(String &location);
void onMove(Designed *what, Designed *from, Designed *to);
+ void encounter(Chr *player, Chr *chr);
+ void redrawScene();
private:
Console *_console;
Commit: ab34bafc31475d79ff74887f38631c993e4db9b2
https://github.com/scummvm/scummvm/commit/ab34bafc31475d79ff74887f38631c993e4db9b2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:02+01:00
Commit Message:
WAGE: Implement scene drawing
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/wage.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 8ea5501..e3a63fa 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -73,11 +73,11 @@ Design::~Design() {
free(_data);
}
-void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
+void Design::paint(Graphics::Surface *surface, Patterns &patterns, bool mask) {
Common::MemoryReadStream in(_data, _len);
- if (mask || 1) {
- canvas->fillRect(Common::Rect(0, 0, _bounds->width(), _bounds->height()), kColorWhite);
+ if (mask) {
+ surface->fillRect(Common::Rect(0, 0, _bounds->width(), _bounds->height()), kColorWhite);
}
/*
@@ -104,30 +104,30 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
while (true) {
byte fillType = in.readByte();
+ byte borderThickness = in.readByte();
+ byte borderFillType = in.readByte();
+ int type = in.readByte();
if (in.eos())
return;
- byte borderThickness = in.readByte();
- byte borderFillType = in.readByte();
- int type = in.readByte();
debug(2, "fill: %d borderFill: %d border: %d type: %d", fillType, borderFillType, borderThickness, type);
switch (type) {
case 4:
- drawRect(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
+ drawRect(surface, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
case 8:
- drawRoundRect(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
+ drawRoundRect(surface, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
case 12:
- drawOval(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
+ drawOval(surface, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
case 16:
case 20:
- drawPolygon(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
+ drawPolygon(surface, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
case 24:
- drawBitmap(canvas, in, mask);
+ drawBitmap(surface, in, mask);
break;
default:
warning("Unknown type => %d", type);
@@ -139,9 +139,9 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
return;
}
- g_system->copyRectToScreen(canvas->getPixels(), canvas->pitch, 0, 0, canvas->w, canvas->h);
- ((WageEngine *)g_engine)->processEvents();
- g_system->updateScreen();
+ //g_system->copyRectToScreen(surface->getPixels(), surface->pitch, 0, 0, surface->w, surface->h);
+ //((WageEngine *)g_engine)->processEvents();
+ //g_system->updateScreen();
}
}
@@ -240,7 +240,9 @@ void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, b
void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
- warning("ignored => %d", in.readSint16BE());
+ byte ignored = in.readSint16BE(); // ignored
+ assert(ignored == 0);
+
int numBytes = in.readSint16BE(); // #bytes used by polygon data, including the numBytes
int16 by1 = in.readSint16BE();
int16 bx1 = in.readSint16BE();
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 998682c..f5f707e 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -70,7 +70,7 @@ public:
}
Common::Rect *getBounds() {
- return new Common::Rect(*_bounds);
+ return _bounds;
}
void paint(Graphics::Surface *canvas, Patterns &patterns, bool mask);
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 0e7e4bc..210ca3e 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -48,6 +48,7 @@
#include "wage/wage.h"
#include "wage/entities.h"
#include "wage/design.h"
+#include "wage/world.h"
#include "common/memstream.h"
@@ -82,6 +83,22 @@ Scene::Scene(String name, Common::SeekableReadStream *data) {
_visited = false;
}
+void Scene::paint(Graphics::Surface *surface) {
+ surface->fillRect(Common::Rect(0, 0, _design->getBounds()->width(), _design->getBounds()->height()), kColorWhite);
+
+ _design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, false);
+
+ for (Common::List<Obj *>::const_iterator it = _objs.begin(); it != _objs.end(); ++it) {
+ debug(2, "paining Obj: %s", (*it)->_name.c_str());
+ (*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, false);
+ }
+
+ for (Common::List<Chr *>::const_iterator it = _chrs.begin(); it != _chrs.end(); ++it) {
+ debug(2, "paining Chr: %s", (*it)->_name.c_str());
+ (*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, false);
+ }
+}
+
Obj::Obj(String name, Common::SeekableReadStream *data) : _currentOwner(NULL), _currentScene(NULL) {
_name = name;
_classType = OBJ;
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 66f966a..8a8044b 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -48,6 +48,10 @@
#ifndef WAGE_ENTITIES_H
#define WAGE_ENTITIES_H
+namespace Graphics {
+ struct Surface;
+}
+
namespace Wage {
class Design;
@@ -397,6 +401,8 @@ public:
return _textBounds == NULL ? NULL : new Common::Rect(*_textBounds);
}
+ void paint(Graphics::Surface *screen);
+
#if 0
String getFontName() {
String[] fonts = {
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index ff57d88..99d8205 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -112,7 +112,6 @@ Common::Error WageEngine::run() {
Graphics::Surface screen;
screen.create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
- Common::Rect r(0, 0, screen.w, screen.h);
_temporarilyHidden = true;
performInitialSetup();
@@ -121,7 +120,16 @@ Common::Error WageEngine::run() {
Common::String input("look");
_world->_player->_currentScene = _world->_orderedScenes[1];
- _world->_globalScript->execute(_world, 1, &input, NULL, this);
+ //_world->_globalScript->execute(_world, 1, &input, NULL, this);
+
+ _world->_orderedScenes[4]->paint(&screen);
+ g_system->copyRectToScreen(screen.getPixels(), screen.pitch, 0, 0, screen.w, screen.h);
+
+ while (true) {
+ processEvents();
+ g_system->updateScreen();
+ g_system->delayMillis(50);
+ }
//_world->_orderedScenes[1]->_design->paint(&screen, _world->_patterns, false);
//_world->_objs["frank.1"]->_design->setBounds(&r);
Commit: 91d5b8b17e7a600ab4e2d8def5a2d24b14cb1d57
https://github.com/scummvm/scummvm/commit/91d5b8b17e7a600ab4e2d8def5a2d24b14cb1d57
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:03+01:00
Commit Message:
WAGE: Started border drawing implementation
Changed paths:
A engines/wage/gui.cpp
A engines/wage/gui.h
engines/wage/design.h
engines/wage/module.mk
engines/wage/wage.cpp
engines/wage/wage.h
diff --git a/engines/wage/design.h b/engines/wage/design.h
index f5f707e..97ee92f 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -54,12 +54,6 @@
namespace Wage {
-enum {
- kColorBlack = 0,
- kColorGray = 1,
- kColorWhite = 2
-};
-
class Design {
public:
Design(Common::SeekableReadStream *data);
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
new file mode 100644
index 0000000..420a584
--- /dev/null
+++ b/engines/wage/gui.cpp
@@ -0,0 +1,141 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "wage/wage.h"
+#include "wage/gui.h"
+
+namespace Wage {
+
+Gui::Gui() {
+}
+
+Gui::~Gui() {
+}
+
+void Gui::drawBox(Graphics::Surface *g, int x, int y, int w, int h) {
+ Common::Rect r(x, y, x + w, y + h);
+
+ g->frameRect(r, kColorBlack);
+}
+
+void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height) {
+ int size = 17;
+ drawBox(g, x, y, size, size);
+ drawBox(g, x+width-size-1, y, size, size);
+ drawBox(g, x+width-size-1, y+height-size-1, size, size);
+ drawBox(g, x, y+height-size-1, size, size);
+ drawBox(g, x + size, y + 2, width - 2*size - 1, size - 4);
+ drawBox(g, x + size, y + height - size + 1, width - 2*size - 1, size - 4);
+ drawBox(g, x + 2, y + size, size - 4, height - 2*size - 1);
+ drawBox(g, x + width - size + 1, y + size, size - 4, height - 2*size-1);
+
+#if 0
+ if (active) {
+ g.setColor(Color.BLACK);
+ g.fillRect(x + size, y + 5, width - 2*size - 1, 8);
+ g.fillRect(x + size, y + height - 13, width - 2*size - 1, 8);
+ g.fillRect(x + 5, y + size, 8, height - 2*size - 1);
+ if (!scrollable) {
+ g.fillRect(x + width - 13, y + size, 8, height - 2*size - 1);
+ } else {
+ int pixels[][] = new int[][] {
+ {0,0,0,0,0,1,1,0,0,0,0,0},
+ {0,0,0,0,1,1,1,1,0,0,0,0},
+ {0,0,0,1,1,1,1,1,1,0,0,0},
+ {0,0,1,1,1,1,1,1,1,1,0,0},
+ {0,1,1,1,1,1,1,1,1,1,1,0},
+ {1,1,1,1,1,1,1,1,1,1,1,1}};
+ final int h = pixels.length;
+ final int w = pixels[0].length;
+ int x1 = x + width - 15;
+ int y1 = y + size + 1;
+ for (int yy = 0; yy < h; yy++) {
+ for (int xx = 0; xx < w; xx++) {
+ if (pixels[yy][xx] != 0) {
+ g.drawRect(x1+xx, y1+yy, 0, 0);
+ }
+ }
+ }
+ g.fillRect(x + width - 13, y + size + h, 8, height - 2*size - 1 - h*2);
+ y1 += height - 2*size - h - 2;
+ for (int yy = 0; yy < h; yy++) {
+ for (int xx = 0; xx < w; xx++) {
+ if (pixels[h-yy-1][xx] != 0) {
+ g.drawRect(x1+xx, y1+yy, 0, 0);
+ }
+ }
+ }
+ }
+ if (closeable) {
+ if (closeBoxPressed) {
+ g.fillRect(x + 6, y + 6, 6, 6);
+ } else {
+ drawBox(g, x + 5, y + 5, 7, 7);
+ }
+ }
+ }
+
+ if (title != null) {
+ // TODO: This "Chicago" is not faithful to the original one on the Mac.
+ Font f = new Font("Chicago", Font.BOLD, 12);
+ int w = g.getFontMetrics(f).stringWidth(title) + 6;
+ int maxWidth = width - size*2 - 7;
+ if (w > maxWidth) {
+ w = maxWidth;
+ }
+ drawBox(g, x + (width - w) / 2, y, w, size);
+ g.setFont(f);
+ Shape clip = g.getClip();
+ g.setClip(x + (width - w) / 2, y, w, size);
+ g.drawString(title, x + (width - w) / 2 + 3, y + size - 4);
+ g.setClip(clip);
+ }
+#endif
+}
+
+
+} // End of namespace Wage
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
new file mode 100644
index 0000000..0e5be4f
--- /dev/null
+++ b/engines/wage/gui.h
@@ -0,0 +1,70 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef WAGE_GUI_H
+#define WAGE_GUI_H
+
+#include "graphics/surface.h"
+#include "common/rect.h"
+
+namespace Wage {
+
+class Gui {
+public:
+ Gui();
+ ~Gui();
+
+ void paintBorder(Graphics::Surface *g, int x, int y, int width, int height);
+
+private:
+ void drawBox(Graphics::Surface *g, int x, int y, int w, int h);
+
+};
+
+} // End of namespace Wage
+
+#endif
diff --git a/engines/wage/module.mk b/engines/wage/module.mk
index 19d56cf..5356902 100644
--- a/engines/wage/module.mk
+++ b/engines/wage/module.mk
@@ -4,6 +4,7 @@ MODULE_OBJS := \
design.o \
detection.o \
entities.o \
+ gui.o \
script.o \
util.o \
wage.o \
@@ -17,5 +18,5 @@ ifeq ($(ENABLE_WAGE), DYNAMIC_PLUGIN)
PLUGIN := 1
endif
-# Include common rules
+# Include common rules
include $(srcdir)/rules.mk
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 99d8205..acff92f 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -61,6 +61,7 @@
#include "wage/wage.h"
#include "wage/design.h"
#include "wage/entities.h"
+#include "wage/gui.h"
#include "wage/script.h"
#include "wage/world.h"
@@ -101,6 +102,8 @@ Common::Error WageEngine::run() {
debug("WageEngine::init");
+ _gui = new Gui();
+
// Your main event loop should be (invoked from) here.
_resManager = new Common::MacResManager();
_resManager->open(getGameFile());
@@ -122,7 +125,11 @@ Common::Error WageEngine::run() {
_world->_player->_currentScene = _world->_orderedScenes[1];
//_world->_globalScript->execute(_world, 1, &input, NULL, this);
- _world->_orderedScenes[4]->paint(&screen);
+ Scene *scene = _world->_orderedScenes[1];
+
+ scene->paint(&screen);
+ _gui->paintBorder(&screen, 0, 0, scene->_design->getBounds()->width(), scene->_design->getBounds()->height());
+
g_system->copyRectToScreen(screen.getPixels(), screen.pitch, 0, 0, screen.w, screen.h);
while (true) {
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 4d75ace..614b5a1 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -63,6 +63,7 @@ namespace Wage {
class Console;
class Chr;
class Designed;
+class Gui;
class Obj;
class Scene;
class World;
@@ -88,6 +89,12 @@ enum {
// the current limitation is 32 debug levels (1 << 31 is the last one)
};
+enum {
+ kColorBlack = 0,
+ kColorGray = 1,
+ kColorWhite = 2
+};
+
Common::String readPascalString(Common::SeekableReadStream *in);
Common::Rect *readRect(Common::SeekableReadStream *in);
@@ -115,6 +122,7 @@ private:
public:
Common::RandomSource *_rnd;
+ Gui *_gui;
World *_world;
Scene *_lastScene;
Commit: 069735d0b7ab1d182c21100521ebc4691da34ceb
https://github.com/scummvm/scummvm/commit/069735d0b7ab1d182c21100521ebc4691da34ceb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:03+01:00
Commit Message:
WAGE: Fix border drawing
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 420a584..377b89b 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -57,8 +57,9 @@ Gui::~Gui() {
}
void Gui::drawBox(Graphics::Surface *g, int x, int y, int w, int h) {
- Common::Rect r(x, y, x + w, y + h);
+ Common::Rect r(x, y, x + w + 1, y + h + 1);
+ g->fillRect(r, kColorWhite);
g->frameRect(r, kColorBlack);
}
Commit: cd063ec0e8e3870f1d2386bd138010b370c79a85
https://github.com/scummvm/scummvm/commit/cd063ec0e8e3870f1d2386bd138010b370c79a85
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:03+01:00
Commit Message:
WAGE: Further work on border drawing
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/wage.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 377b89b..2207e8e 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -63,7 +63,25 @@ void Gui::drawBox(Graphics::Surface *g, int x, int y, int w, int h) {
g->frameRect(r, kColorBlack);
}
-void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height) {
+void Gui::fillRect(Graphics::Surface *g, int x, int y, int w, int h) {
+ Common::Rect r(x, y, x + w + 1, y + h + 1);
+
+ g->fillRect(r, kColorBlack);
+}
+
+#define ARROW_W 12
+#define ARROW_H 6
+const int arrowPixels[ARROW_H][ARROW_W] = {
+ {0,0,0,0,0,1,1,0,0,0,0,0},
+ {0,0,0,0,1,1,1,1,0,0,0,0},
+ {0,0,0,1,1,1,1,1,1,0,0,0},
+ {0,0,1,1,1,1,1,1,1,1,0,0},
+ {0,1,1,1,1,1,1,1,1,1,1,0},
+ {1,1,1,1,1,1,1,1,1,1,1,1}};
+
+
+void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height,
+ bool active, bool scrollable, bool closeable, bool closeBoxPressed) {
int size = 17;
drawBox(g, x, y, size, size);
drawBox(g, x+width-size-1, y, size, size);
@@ -74,52 +92,42 @@ void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height)
drawBox(g, x + 2, y + size, size - 4, height - 2*size - 1);
drawBox(g, x + width - size + 1, y + size, size - 4, height - 2*size-1);
-#if 0
if (active) {
- g.setColor(Color.BLACK);
- g.fillRect(x + size, y + 5, width - 2*size - 1, 8);
- g.fillRect(x + size, y + height - 13, width - 2*size - 1, 8);
- g.fillRect(x + 5, y + size, 8, height - 2*size - 1);
+ fillRect(g, x + size, y + 5, width - 2*size - 1, 8);
+ fillRect(g, x + size, y + height - 13, width - 2*size - 1, 8);
+ fillRect(g, x + 5, y + size, 8, height - 2*size - 1);
if (!scrollable) {
- g.fillRect(x + width - 13, y + size, 8, height - 2*size - 1);
+ fillRect(g, x + width - 13, y + size, 8, height - 2*size - 1);
} else {
- int pixels[][] = new int[][] {
- {0,0,0,0,0,1,1,0,0,0,0,0},
- {0,0,0,0,1,1,1,1,0,0,0,0},
- {0,0,0,1,1,1,1,1,1,0,0,0},
- {0,0,1,1,1,1,1,1,1,1,0,0},
- {0,1,1,1,1,1,1,1,1,1,1,0},
- {1,1,1,1,1,1,1,1,1,1,1,1}};
- final int h = pixels.length;
- final int w = pixels[0].length;
int x1 = x + width - 15;
int y1 = y + size + 1;
- for (int yy = 0; yy < h; yy++) {
- for (int xx = 0; xx < w; xx++) {
- if (pixels[yy][xx] != 0) {
- g.drawRect(x1+xx, y1+yy, 0, 0);
+ for (int yy = 0; yy < ARROW_H; yy++) {
+ for (int xx = 0; xx < ARROW_W; xx++) {
+ if (arrowPixels[yy][xx] != 0) {
+ g->hLine(x1+xx, y1+yy, 1, 0);
}
}
}
- g.fillRect(x + width - 13, y + size + h, 8, height - 2*size - 1 - h*2);
- y1 += height - 2*size - h - 2;
- for (int yy = 0; yy < h; yy++) {
- for (int xx = 0; xx < w; xx++) {
- if (pixels[h-yy-1][xx] != 0) {
- g.drawRect(x1+xx, y1+yy, 0, 0);
+ fillRect(g, x + width - 13, y + size + ARROW_H, 8, height - 2*size - 1 - ARROW_H*2);
+ y1 += height - 2*size - ARROW_H - 2;
+ for (int yy = 0; yy < ARROW_H; yy++) {
+ for (int xx = 0; xx < ARROW_W; xx++) {
+ if (arrowPixels[ARROW_H-yy-1][xx] != 0) {
+ g->hLine(x1+xx, y1+yy, 1, 0);
}
}
}
}
if (closeable) {
if (closeBoxPressed) {
- g.fillRect(x + 6, y + 6, 6, 6);
+ fillRect(g, x + 6, y + 6, 6, 6);
} else {
drawBox(g, x + 5, y + 5, 7, 7);
}
}
}
+#if 0
if (title != null) {
// TODO: This "Chicago" is not faithful to the original one on the Mac.
Font f = new Font("Chicago", Font.BOLD, 12);
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 0e5be4f..0410686 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -58,10 +58,12 @@ public:
Gui();
~Gui();
- void paintBorder(Graphics::Surface *g, int x, int y, int width, int height);
+ void paintBorder(Graphics::Surface *g, int x, int y, int width, int height,
+ bool active, bool scrollable, bool closeable, bool closeBoxPressed);
private:
void drawBox(Graphics::Surface *g, int x, int y, int w, int h);
+ void fillRect(Graphics::Surface *g, int x, int y, int w, int h);
};
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index acff92f..882b115 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -128,7 +128,8 @@ Common::Error WageEngine::run() {
Scene *scene = _world->_orderedScenes[1];
scene->paint(&screen);
- _gui->paintBorder(&screen, 0, 0, scene->_design->getBounds()->width(), scene->_design->getBounds()->height());
+ _gui->paintBorder(&screen, 0, 0, scene->_design->getBounds()->width(), scene->_design->getBounds()->height(),
+ true, false, true, false);
g_system->copyRectToScreen(screen.getPixels(), screen.pitch, 0, 0, screen.w, screen.h);
Commit: 357d956a839c6c419fde11b2fa72450234c1c183
https://github.com/scummvm/scummvm/commit/357d956a839c6c419fde11b2fa72450234c1c183
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:03+01:00
Commit Message:
WAGE: More improvements to the border drawing
Changed paths:
engines/wage/gui.cpp
engines/wage/wage.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 2207e8e..053abbf 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -104,7 +104,9 @@ void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height,
for (int yy = 0; yy < ARROW_H; yy++) {
for (int xx = 0; xx < ARROW_W; xx++) {
if (arrowPixels[yy][xx] != 0) {
- g->hLine(x1+xx, y1+yy, 1, 0);
+ g->hLine(x1+xx, y1+yy, x1+xx+1, kColorBlack);
+ } else {
+ g->hLine(x1+xx, y1+yy, x1+xx+1, kColorWhite);
}
}
}
@@ -113,7 +115,9 @@ void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height,
for (int yy = 0; yy < ARROW_H; yy++) {
for (int xx = 0; xx < ARROW_W; xx++) {
if (arrowPixels[ARROW_H-yy-1][xx] != 0) {
- g->hLine(x1+xx, y1+yy, 1, 0);
+ g->hLine(x1+xx, y1+yy, x1+xx+1, kColorBlack);
+ } else {
+ g->hLine(x1+xx, y1+yy, x1+xx+1, kColorWhite);
}
}
}
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 882b115..b9ee574 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -129,7 +129,7 @@ Common::Error WageEngine::run() {
scene->paint(&screen);
_gui->paintBorder(&screen, 0, 0, scene->_design->getBounds()->width(), scene->_design->getBounds()->height(),
- true, false, true, false);
+ true, true, true, false);
g_system->copyRectToScreen(screen.getPixels(), screen.pitch, 0, 0, screen.w, screen.h);
Commit: 9ecb9f5bab9a8907d12b588b0ac3be170c46f24e
https://github.com/scummvm/scummvm/commit/9ecb9f5bab9a8907d12b588b0ac3be170c46f24e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:03+01:00
Commit Message:
WAGE: Implement font mapping
Changed paths:
engines/wage/entities.cpp
engines/wage/entities.h
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 210ca3e..a70ac5e 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -99,6 +99,40 @@ void Scene::paint(Graphics::Surface *surface) {
}
}
+// Source: Apple IIGS Technical Note #41, "Font Family Numbers"
+// http://apple2.boldt.ca/?page=til/tn.iigs.041
+const char *fontNames[] = {
+ "Chicago", // system font
+ "Geneva", // application font
+ "New York",
+ "Geneva",
+
+ "Monaco",
+ "Venice",
+ "London",
+ "Athens",
+
+ "San Francisco",
+ "Toronto",
+ "Cairo",
+ "Los Angeles", // 12
+
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, // not in Inside Macintosh
+
+ "Times", // 20
+ "Helvetica",
+ "Courier",
+ "Symbol",
+ "Taliesin" // mobile?
+};
+
+const char *Scene::getFontName() {
+ if (_fontType >= 0 && _fontType < ARRAYSIZE(fontNames) && fontNames[_fontType] != NULL) {
+ return fontNames[_fontType];
+ }
+ return "Unknown";
+}
+
Obj::Obj(String name, Common::SeekableReadStream *data) : _currentOwner(NULL), _currentScene(NULL) {
_name = name;
_classType = OBJ;
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 8a8044b..29f28d7 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -403,58 +403,7 @@ public:
void paint(Graphics::Surface *screen);
-#if 0
- String getFontName() {
- String[] fonts = {
- "Chicago", // system font
- "Geneva", // application font
- "New York",
- "Geneva",
-
- "Monaco",
- "Venice",
- "London",
- "Athens",
-
- "San Francisco",
- "Toronto",
- "Cairo",
- "Los Angeles", // 12
-
- null, null, null, null, null, null, null, // not in Inside Macintosh
-
- "Times", // 20
- "Helvetica",
- "Courier",
- "Symbol",
- "Taliesin" // mobile?
- };
- /*
-mappings found on some forums:
-systemFont(0):System(Swiss)
-times(20):Times New Roman(Roman)
-helvetica(21):Arial(Modern)
-courier(22):Courier New(Modern)
-symbol(23):Symbol(Decorative)
-applFont(1):Arial(Swiss)
-newYork(2):Times New Roman(Roman)
-geneva(3):Arial(Swiss)
-monaco(4):Courier New(Modern)
-venice(5):Times New Roman(Roman)
-london(6):Times New Roman(Roman)
-athens(7):Times New Roman(Roman)
-sanFran(8):Times New Roman(Roman)
-toronto(9):Times New Roman(Roman)
-cairo(11):Wingdings(Decorative)
-losAngeles(12):Times New Roman(Roman)
-taliesin(24):Wingdings(Decorative)
- */
- if (fontType >= 0 && fontType < fonts.length && fonts[fontType] != null) {
- return _fonts[fontType];
- }
- return _"Unknown";
- }
-#endif
+ const char *getFontName();
};
class Sound {
Commit: 88e864a553ad66c3b6b8631afd96a8d619eac3f5
https://github.com/scummvm/scummvm/commit/88e864a553ad66c3b6b8631afd96a8d619eac3f5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:03+01:00
Commit Message:
WAGE: Implemented script for downloading fonts
Changed paths:
A devtools/create_wage/create_wage.sh
diff --git a/devtools/create_wage/create_wage.sh b/devtools/create_wage/create_wage.sh
new file mode 100644
index 0000000..bb0e9ee
--- /dev/null
+++ b/devtools/create_wage/create_wage.sh
@@ -0,0 +1,101 @@
+#bash
+#
+# Based on instructions posted at
+# http://apple.stackexchange.com/questions/58243/can-i-get-the-original-mac-font-chicago-on-a-mountain-lion-mac
+
+echo_n() {
+ printf "$@"
+}
+
+echo_n "Downloading System 7.0.1 image..."
+if test ! -f System_7.0.1.smi.bin; then
+ curl -s http://download.info.apple.com/Apple_Support_Area/Apple_Software_Updates/English-North_American/Macintosh/System/Older_System/System_7.0.x/System_7.0.1.smi.bin -o System_7.0.1.smi.bin
+fi
+
+if test ! -f System_7.0.1.smi.bin; then
+ echo "Cannot download System_7.0.1.smi.bin"
+ exit
+fi
+
+echo done
+
+echo_n "Mounting System 7.0.1 image..."
+
+macbinary decode System_7.0.1.smi.bin
+hdiutil convert -quiet System\ 7.0.1.smi -format UDRO -o sys7.dmg
+hdiutil attach -quiet sys7.dmg
+
+if test ! -f /Volumes/7.0.1\ \(1440k.images\)/Fonts.image; then
+ echo "Failed to attach sys7.dmg"
+ exit
+fi
+
+echo done
+
+echo_n "Mounting Fonts disk image..."
+
+hdiutil convert -quiet /Volumes/7.0.1\ \(1440k.images\)/Fonts.image -format UDRO -o fonts.dmg
+hdiutil detach -quiet `hdiutil info|grep "/Volumes/7.0.1 (1440k.images)"|cut -f 1`
+hdiutil attach -quiet fonts.dmg
+
+if test ! -f /Volumes/Fonts/Chicago; then
+ echo "Failed to attach fonts.dmg"
+ exit
+fi
+
+echo done
+
+echo_n "Copying fonts..."
+
+for i in Athens Cairo Chicago Courier Geneva Helvetica London "Los Angeles" Monaco "New York" Palatino "San Francisco" Symbol Times Venice
+do
+ echo $i
+ macbinary encode "/Volumes/Fonts/$i" -o "$i.bin" -n
+done
+
+echo ...Done
+
+hdiutil detach -quiet `hdiutil info|grep "/Volumes/Fonts"|cut -f 1`
+
+if test ! -f fondu_src-060102.tgz; then
+ echo_n "Getting fondu_src-060102.tgz..."
+ curl -s http://fondu.sourceforge.net/fondu_src-060102.tgz -o fondu_src-060102.tgz
+ tar xf fondu_src-060102.tgz
+fi
+
+if test ! -d fondu-060102; then
+ echo "Failed to download fondu_src-060102.tgz"
+ exit
+fi
+
+echo done
+
+if test ! -x fondu-060102/fondu; then
+ echo_n "Compiling fondu..."
+ cd fondu-060102
+ ./configure >configure.log 2>&1 && make 2>&1 >make.log
+ cd ..
+fi
+
+if test ! -x fondu-060102/fondu; then
+ echo "Failed to build fondu. See configure.log and make.log"
+ exit
+else
+ rm -f configure.log make.log
+fi
+
+echo done
+
+echo_n "Converting fonts..."
+fondu-060102/fondu -force *.bin
+echo done
+
+zip -9 wage *.bdf
+mv wage.zip wage.dat
+
+echo_n "Cleaning up..."
+rm *.bdf
+rm *.ttf
+rm *.bin
+rm *.dmg
+echo done
Commit: c020cd7e960de1977ab84db596f353c506620296
https://github.com/scummvm/scummvm/commit/c020cd7e960de1977ab84db596f353c506620296
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T15:41:04+01:00
Commit Message:
WAGE: More debug output
Changed paths:
engines/wage/world.cpp
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index a99300e..65c562d 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -160,6 +160,9 @@ bool World::loadWorld(Common::MacResManager *resMan) {
scene->_fontType = res->readUint16BE();
scene->_fontSize = res->readUint16BE();
+ if (scene->_fontType != 3 || scene->_fontSize != 9)
+ warning("scene: %s font: %s size: %d", scene->_name.c_str(), scene->getFontName(), scene->_fontSize);
+
String text;
while (res->pos() < res->size()) {
char c = res->readByte();
Commit: 2802566f43bfe19f940051746abf8ff8b1c6d776
https://github.com/scummvm/scummvm/commit/2802566f43bfe19f940051746abf8ff8b1c6d776
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-27T23:26:28+01:00
Commit Message:
WAGE: Fix font downloading script
Changed paths:
devtools/create_wage/create_wage.sh
diff --git a/devtools/create_wage/create_wage.sh b/devtools/create_wage/create_wage.sh
old mode 100644
new mode 100755
index bb0e9ee..fb3c047
--- a/devtools/create_wage/create_wage.sh
+++ b/devtools/create_wage/create_wage.sh
@@ -1,4 +1,4 @@
-#bash
+#!bash
#
# Based on instructions posted at
# http://apple.stackexchange.com/questions/58243/can-i-get-the-original-mac-font-chicago-on-a-mountain-lion-mac
Commit: 0d6b87b785ffba32f166411e6c44fc7abc33e0eb
https://github.com/scummvm/scummvm/commit/0d6b87b785ffba32f166411e6c44fc7abc33e0eb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-28T01:08:39+01:00
Commit Message:
WAGE: Added more documentation to the script
Changed paths:
devtools/create_wage/create_wage.sh
diff --git a/devtools/create_wage/create_wage.sh b/devtools/create_wage/create_wage.sh
index fb3c047..1ec7ef3 100755
--- a/devtools/create_wage/create_wage.sh
+++ b/devtools/create_wage/create_wage.sh
@@ -1,4 +1,12 @@
-#!bash
+#!/bin/bash
+#
+# This script downloads System 7.0.1 image from Apple and extracts fonts
+# from it. Mac only, unfortunately.
+#
+# On Windows you perhaps can perform the extraction manually with use of
+# HFV Explorer: https://web.archive.org/web/20011202005455/http://gamma.nic.fi/~lpesonen/HFVExplorer/
+#
+# More information could be found in the vMac documentation: http://www.gryphel.com/c/image/
#
# Based on instructions posted at
# http://apple.stackexchange.com/questions/58243/can-i-get-the-original-mac-font-chicago-on-a-mountain-lion-mac
@@ -7,6 +15,11 @@ echo_n() {
printf "$@"
}
+if test `uname` != "Darwin"; then
+ echo This script is Mac OS X-only
+ exit
+fi
+
echo_n "Downloading System 7.0.1 image..."
if test ! -f System_7.0.1.smi.bin; then
curl -s http://download.info.apple.com/Apple_Support_Area/Apple_Software_Updates/English-North_American/Macintosh/System/Older_System/System_7.0.x/System_7.0.1.smi.bin -o System_7.0.1.smi.bin
Commit: 13a62ce1a130631cd42fba0901bd5f4b908a5376
https://github.com/scummvm/scummvm/commit/13a62ce1a130631cd42fba0901bd5f4b908a5376
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-28T01:15:27+01:00
Commit Message:
WAGE: Cleanup
Changed paths:
devtools/create_wage/create_wage.sh
diff --git a/devtools/create_wage/create_wage.sh b/devtools/create_wage/create_wage.sh
index 1ec7ef3..5e8fe35 100755
--- a/devtools/create_wage/create_wage.sh
+++ b/devtools/create_wage/create_wage.sh
@@ -8,6 +8,9 @@
#
# More information could be found in the vMac documentation: http://www.gryphel.com/c/image/
#
+# Alternatively you may use vMac instructions for extracting these disk images:
+# http://www.gryphel.com/c/minivmac/recipes/sys7inst/
+#
# Based on instructions posted at
# http://apple.stackexchange.com/questions/58243/can-i-get-the-original-mac-font-chicago-on-a-mountain-lion-mac
@@ -22,7 +25,7 @@ fi
echo_n "Downloading System 7.0.1 image..."
if test ! -f System_7.0.1.smi.bin; then
- curl -s http://download.info.apple.com/Apple_Support_Area/Apple_Software_Updates/English-North_American/Macintosh/System/Older_System/System_7.0.x/System_7.0.1.smi.bin -o System_7.0.1.smi.bin
+ curl -s http://download.info.apple.com/Apple_Support_Area/Apple_Software_Updates/English-North_American/Macintosh/System/Older_System/System_7.0.x/System_7.0.1.smi.bin -o System_7.0.1.smi.bin
fi
if test ! -f System_7.0.1.smi.bin; then
@@ -62,8 +65,8 @@ echo_n "Copying fonts..."
for i in Athens Cairo Chicago Courier Geneva Helvetica London "Los Angeles" Monaco "New York" Palatino "San Francisco" Symbol Times Venice
do
- echo $i
- macbinary encode "/Volumes/Fonts/$i" -o "$i.bin" -n
+ echo $i
+ macbinary encode "/Volumes/Fonts/$i" -o "$i.bin" -n
done
echo ...Done
@@ -71,9 +74,9 @@ echo ...Done
hdiutil detach -quiet `hdiutil info|grep "/Volumes/Fonts"|cut -f 1`
if test ! -f fondu_src-060102.tgz; then
- echo_n "Getting fondu_src-060102.tgz..."
- curl -s http://fondu.sourceforge.net/fondu_src-060102.tgz -o fondu_src-060102.tgz
- tar xf fondu_src-060102.tgz
+ echo_n "Getting fondu_src-060102.tgz..."
+ curl -s http://fondu.sourceforge.net/fondu_src-060102.tgz -o fondu_src-060102.tgz
+ tar xf fondu_src-060102.tgz
fi
if test ! -d fondu-060102; then
@@ -84,10 +87,10 @@ fi
echo done
if test ! -x fondu-060102/fondu; then
- echo_n "Compiling fondu..."
- cd fondu-060102
- ./configure >configure.log 2>&1 && make 2>&1 >make.log
- cd ..
+ echo_n "Compiling fondu..."
+ cd fondu-060102
+ ./configure >configure.log 2>&1 && make 2>&1 >make.log
+ cd ..
fi
if test ! -x fondu-060102/fondu; then
@@ -112,3 +115,5 @@ rm *.ttf
rm *.bin
rm *.dmg
echo done
+
+ls -l wage.dat
Commit: 3fe3ad7ee35c8bdb4aef298e2cfa52b43b94d88e
https://github.com/scummvm/scummvm/commit/3fe3ad7ee35c8bdb4aef298e2cfa52b43b94d88e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-28T12:38:26+01:00
Commit Message:
WAGE: Moved scene drawing calls to Gui class
Changed paths:
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/wage.cpp
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index a70ac5e..d557f08 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -59,11 +59,36 @@ void Designed::setDesignBounds(Common::Rect *bounds) {
_design->setBounds(bounds);
}
+Scene::Scene() {
+ _script = NULL;
+ _surface = NULL;
+ _design = NULL;
+ _textBounds = NULL;
+ _fontSize = 0;
+ _fontType = 0;
+
+ for (int i = 0; i < 4; i++)
+ _blocked[i] = false;
+
+ _soundFrequency = 0;
+ _soundType = 0;
+ _worldX = 0;
+ _worldY = 0;
+
+ _visited = false;
+}
+
Scene::Scene(String name, Common::SeekableReadStream *data) {
_name = name;
_classType = SCENE;
_design = new Design(data);
+ _script = NULL;
+ _surface = NULL;
+ _textBounds = NULL;
+ _fontSize = 0;
+ _fontType = 0;
+
setDesignBounds(readRect(data));
_worldY = data->readSint16BE();
_worldX = data->readSint16BE();
@@ -83,20 +108,32 @@ Scene::Scene(String name, Common::SeekableReadStream *data) {
_visited = false;
}
-void Scene::paint(Graphics::Surface *surface) {
- surface->fillRect(Common::Rect(0, 0, _design->getBounds()->width(), _design->getBounds()->height()), kColorWhite);
+Scene::~Scene() {
+ delete _surface;
+}
+
+void Scene::paint(Graphics::Surface *surface, int x, int y) {
+ if (_surface == NULL) {
+ _surface = new Graphics::Surface;
+ _surface->create(_design->getBounds()->width(), _design->getBounds()->height(), Graphics::PixelFormat::createFormatCLUT8());
+ }
- _design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, false);
+ Common::Rect r(0, 0, _design->getBounds()->width(), _design->getBounds()->height());
+ _surface->fillRect(r, kColorWhite);
+
+ _design->paint(_surface, ((WageEngine *)g_engine)->_world->_patterns, false);
for (Common::List<Obj *>::const_iterator it = _objs.begin(); it != _objs.end(); ++it) {
debug(2, "paining Obj: %s", (*it)->_name.c_str());
- (*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, false);
+ (*it)->_design->paint(_surface, ((WageEngine *)g_engine)->_world->_patterns, false);
}
for (Common::List<Chr *>::const_iterator it = _chrs.begin(); it != _chrs.end(); ++it) {
debug(2, "paining Chr: %s", (*it)->_name.c_str());
- (*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, false);
+ (*it)->_design->paint(_surface, ((WageEngine *)g_engine)->_world->_patterns, false);
}
+
+ surface->copyRectToSurface(*_surface, x, y, r);
}
// Source: Apple IIGS Technical Note #41, "Font Family Numbers"
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 29f28d7..0e20d2e 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -394,16 +394,20 @@ public:
Common::List<Obj *> _objs;
Common::List<Chr *> _chrs;
- Scene() {}
+ Scene();
Scene(String name, Common::SeekableReadStream *data);
+ ~Scene();
Common::Rect *getTextBounds() {
return _textBounds == NULL ? NULL : new Common::Rect(*_textBounds);
}
- void paint(Graphics::Surface *screen);
+ void paint(Graphics::Surface *screen, int x, int y);
const char *getFontName();
+
+private:
+ Graphics::Surface *_surface;
};
class Sound {
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 053abbf..317fcc8 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -45,17 +45,48 @@
*
*/
+#include "common/system.h"
#include "wage/wage.h"
+#include "wage/design.h"
+#include "wage/entities.h"
#include "wage/gui.h"
namespace Wage {
+enum {
+ kMenuHeight = 19,
+ kMenuPadding = 6,
+ kMenuItemHeight = 19
+};
+
Gui::Gui() {
+ _scene = NULL;
+ _sceneDirty = true;
+ _screen.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8());
}
Gui::~Gui() {
}
+void Gui::setScene(Scene *scene) {
+ if (_scene != scene)
+ _sceneDirty = true;
+
+ _scene = scene;
+}
+
+void Gui::draw() {
+ if (_scene != NULL && _sceneDirty) {
+ _scene->paint(&_screen, 0, kMenuHeight);
+ paintBorder(&_screen, 0, kMenuHeight, _scene->_design->getBounds()->width(), _scene->_design->getBounds()->height(),
+ true, true, true, false);
+
+ _sceneDirty = false;
+ }
+
+ g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, _screen.h);
+}
+
void Gui::drawBox(Graphics::Surface *g, int x, int y, int w, int h) {
Common::Rect r(x, y, x + w + 1, y + h + 1);
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 0410686..4689902 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -58,13 +58,20 @@ public:
Gui();
~Gui();
+ void draw();
+ void setScene(Scene *scene);
+
+private:
void paintBorder(Graphics::Surface *g, int x, int y, int width, int height,
bool active, bool scrollable, bool closeable, bool closeBoxPressed);
-private:
void drawBox(Graphics::Surface *g, int x, int y, int w, int h);
void fillRect(Graphics::Surface *g, int x, int y, int w, int h);
+private:
+ Graphics::Surface _screen;
+ Scene *_scene;
+ bool _sceneDirty;
};
} // End of namespace Wage
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index b9ee574..9e30fe6 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -93,7 +93,7 @@ static byte palette[] = {
};
Common::Error WageEngine::run() {
- initGraphics(640, 480, true);
+ initGraphics(444, 333, true);
g_system->getPaletteManager()->setPalette(palette, 0, 3);
@@ -113,9 +113,6 @@ Common::Error WageEngine::run() {
if (!_world->loadWorld(_resManager))
return Common::kNoGameDataFoundError;
- Graphics::Surface screen;
- screen.create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
-
_temporarilyHidden = true;
performInitialSetup();
_temporarilyHidden = false;
@@ -125,13 +122,8 @@ Common::Error WageEngine::run() {
_world->_player->_currentScene = _world->_orderedScenes[1];
//_world->_globalScript->execute(_world, 1, &input, NULL, this);
- Scene *scene = _world->_orderedScenes[1];
-
- scene->paint(&screen);
- _gui->paintBorder(&screen, 0, 0, scene->_design->getBounds()->width(), scene->_design->getBounds()->height(),
- true, true, true, false);
-
- g_system->copyRectToScreen(screen.getPixels(), screen.pitch, 0, 0, screen.w, screen.h);
+ _gui->setScene(_world->_orderedScenes[1]);
+ _gui->draw();
while (true) {
processEvents();
Commit: 438eb457047f0dee7a4555de91b1ea46c34082e7
https://github.com/scummvm/scummvm/commit/438eb457047f0dee7a4555de91b1ea46c34082e7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-28T19:13:13+01:00
Commit Message:
WAGE: Increased startup speed
Changed paths:
engines/wage/wage.cpp
engines/wage/world.cpp
engines/wage/world.h
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 9e30fe6..ff867e5 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -186,11 +186,19 @@ void WageEngine::gameOver() {
}
void WageEngine::performInitialSetup() {
- for (int i = 0; i < _world->_orderedObjs.size(); i++)
- _world->move(_world->_orderedObjs[i], _world->_storageScene);
- for (int i = 0; i < _world->_orderedChrs.size(); i++)
- _world->move(_world->_orderedChrs[i], _world->_storageScene);
+ debug(5, "Resetting Objs: %d", _world->_orderedObjs.size());
+ for (int i = 0; i < _world->_orderedObjs.size() - 1; i++)
+ _world->move(_world->_orderedObjs[i], _world->_storageScene, true);
+ _world->move(_world->_orderedObjs[_world->_orderedObjs.size() - 1], _world->_storageScene);
+
+ debug(5, "Resetting Chrs: %d", _world->_orderedChrs.size());
+ for (int i = 0; i < _world->_orderedChrs.size() - 1; i++)
+ _world->move(_world->_orderedChrs[i], _world->_storageScene, true);
+
+ _world->move(_world->_orderedChrs[_world->_orderedChrs.size() - 1], _world->_storageScene);
+
+ debug(5, "Resetting Owners: %d", _world->_orderedObjs.size());
for (int i = 0; i < _world->_orderedObjs.size(); i++) {
Obj *obj = _world->_orderedObjs[i];
if (!obj->_sceneOrOwner.equalsIgnoreCase(STORAGESCENE)) {
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 65c562d..e4ce936 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -387,7 +387,7 @@ bool ObjComparator(Obj *o1, Obj *o2) {
return o1Immobile;
}
-void World::move(Obj *obj, Scene *scene) {
+void World::move(Obj *obj, Scene *scene, bool skipSort) {
if (obj == NULL)
return;
@@ -395,7 +395,8 @@ void World::move(Obj *obj, Scene *scene) {
obj->_currentScene = scene;
scene->_objs.push_back(obj);
- Common::sort(scene->_objs.begin(), scene->_objs.end(), ObjComparator);
+ if (!skipSort)
+ Common::sort(scene->_objs.begin(), scene->_objs.end(), ObjComparator);
_engine->onMove(obj, from, scene);
}
@@ -404,7 +405,7 @@ bool ChrComparator(Chr *l, Chr *r) {
return l->_index < r->_index;
}
-void World::move(Chr *chr, Scene *scene) {
+void World::move(Chr *chr, Scene *scene, bool skipSort) {
if (chr == NULL)
return;
Scene *from = chr->_currentScene;
@@ -414,7 +415,8 @@ void World::move(Chr *chr, Scene *scene) {
from->_chrs.remove(chr);
scene->_chrs.push_back(chr);
- Common::sort(scene->_chrs.begin(), scene->_chrs.end(), ChrComparator);
+ if (!skipSort)
+ Common::sort(scene->_chrs.begin(), scene->_chrs.end(), ChrComparator);
if (scene == _storageScene) {
warning("STUB: World::move (chrState)");
diff --git a/engines/wage/world.h b/engines/wage/world.h
index ed93386..ea00322 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -61,8 +61,8 @@ public:
void loadExternalSounds(String fname);
Common::String *loadStringFromDITL(Common::MacResManager *resMan, int resourceId, int itemIndex);
void move(Obj *obj, Chr *chr);
- void move(Obj *obj, Scene *scene);
- void move(Chr *chr, Scene *scene);
+ void move(Obj *obj, Scene *scene, bool skipSort = false);
+ void move(Chr *chr, Scene *scene, bool skipSort = false);
Scene *getRandomScene();
WageEngine *_engine;
Commit: 0c682799a10ea5e4757399ccf7505be8cae404d7
https://github.com/scummvm/scummvm/commit/0c682799a10ea5e4757399ccf7505be8cae404d7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-29T01:46:39+01:00
Commit Message:
WAGE: Draw checkered background to simulate desktop
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
engines/wage/gui.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index e3a63fa..d61c7ac 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -405,6 +405,14 @@ void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool
}
}
+void Design::drawFilledRect(Graphics::Surface *surface, Common::Rect &rect, int color, Patterns &patterns, byte fillType) {
+ plotData pd(surface, &patterns, fillType);
+
+ for (int y = rect.top; y <= rect.bottom; y++)
+ drawHLine(rect.left, rect.right, y, color, drawPixel, &pd);
+}
+
+
void Design::drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data) {
for (int y = rect.top; y <= rect.bottom; y++)
drawHLine(rect.left, rect.right, y, color, plotProc, data);
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 97ee92f..118fbbb 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -68,6 +68,7 @@ public:
}
void paint(Graphics::Surface *canvas, Patterns &patterns, bool mask);
+ static void drawFilledRect(Graphics::Surface *surface, Common::Rect &rect, int color, Patterns &patterns, byte fillType);
private:
byte *_data;
@@ -90,7 +91,7 @@ private:
void drawPolygonScan(int *polyX, int *polyY, int npoints, Common::Rect &bbox, int color,
void (*plotProc)(int, int, int, void *), void *data);
void drawEllipse(int x0, int y0, int x1, int y1, bool filled, void (*plotProc)(int, int, int, void *), void *data);
- void drawHLine(int x1, int x2, int y, int color, void (*plotProc)(int, int, int, void *), void *data);
+ static void drawHLine(int x1, int x2, int y, int color, void (*plotProc)(int, int, int, void *), void *data);
void drawVLine(int x, int y1, int y2, int color, void (*plotProc)(int, int, int, void *), void *data);
void drawThickLine (int x1, int y1, int x2, int y2, int thick, int color,
void (*plotProc)(int, int, int, void *), void *data);
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 317fcc8..4f05328 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -59,10 +59,18 @@ enum {
kMenuItemHeight = 19
};
+byte checkers[8] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa };
+
Gui::Gui() {
_scene = NULL;
_sceneDirty = true;
_screen.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8());
+
+ Patterns p;
+ p.push_back(checkers);
+ Common::Rect r(0, 0, _screen.w, _screen.h);
+
+ Design::drawFilledRect(&_screen, r, kColorBlack, p, 1);
}
Gui::~Gui() {
Commit: 0dde7a94a99292258226f70c7c6cde2bd84dead6
https://github.com/scummvm/scummvm/commit/0dde7a94a99292258226f70c7c6cde2bd84dead6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-29T10:46:51+01:00
Commit Message:
WAGE: Implement design caching
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/wage.cpp
engines/wage/wage.h
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index d61c7ac..c75d1f7 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -67,17 +67,30 @@ Design::Design(Common::SeekableReadStream *data) {
_len = data->readUint16BE() - 2;
_data = (byte *)malloc(_len);
data->read(_data, _len);
+
+ _surface = NULL;
}
Design::~Design() {
free(_data);
+ delete _surface;
}
-void Design::paint(Graphics::Surface *surface, Patterns &patterns, bool mask) {
+void Design::paint(Graphics::Surface *surface, Patterns &patterns, bool mask, int x, int y) {
Common::MemoryReadStream in(_data, _len);
+ Common::Rect r(0, 0, _bounds->width(), _bounds->height());
+ bool needRender = false;
+
+ if (_surface == NULL) {
+ _surface = new Graphics::Surface;
+ _surface->create(_bounds->width(), _bounds->height(), Graphics::PixelFormat::createFormatCLUT8());
+ _surface->fillRect(r, kColorGreen);
+
+ needRender = true;
+ }
if (mask) {
- surface->fillRect(Common::Rect(0, 0, _bounds->width(), _bounds->height()), kColorWhite);
+ _surface->fillRect(r, kColorWhite);
}
/*
@@ -102,32 +115,32 @@ void Design::paint(Graphics::Surface *surface, Patterns &patterns, bool mask) {
return;
*/
- while (true) {
+ while (true && needRender) {
byte fillType = in.readByte();
byte borderThickness = in.readByte();
byte borderFillType = in.readByte();
int type = in.readByte();
if (in.eos())
- return;
+ break;
debug(2, "fill: %d borderFill: %d border: %d type: %d", fillType, borderFillType, borderThickness, type);
switch (type) {
case 4:
- drawRect(surface, in, mask, patterns, fillType, borderThickness, borderFillType);
+ drawRect(_surface, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
case 8:
- drawRoundRect(surface, in, mask, patterns, fillType, borderThickness, borderFillType);
+ drawRoundRect(_surface, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
case 12:
- drawOval(surface, in, mask, patterns, fillType, borderThickness, borderFillType);
+ drawOval(_surface, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
case 16:
case 20:
- drawPolygon(surface, in, mask, patterns, fillType, borderThickness, borderFillType);
+ drawPolygon(_surface, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
case 24:
- drawBitmap(surface, in, mask);
+ drawBitmap(_surface, in, mask);
break;
default:
warning("Unknown type => %d", type);
@@ -136,13 +149,24 @@ void Design::paint(Graphics::Surface *surface, Patterns &patterns, bool mask) {
g_system->updateScreen();
g_system->delayMillis(50);
}
- return;
+ break;
}
- //g_system->copyRectToScreen(surface->getPixels(), surface->pitch, 0, 0, surface->w, surface->h);
+ //g_system->copyRectToScreen(_surface->getPixels(), _surface->pitch, 0, 0, _surface->w, _surface->h);
//((WageEngine *)g_engine)->processEvents();
//g_system->updateScreen();
}
+
+ for (int i = 0; i < _bounds->height(); i++) {
+ const byte *src = (const byte *)_surface->getBasePtr(0, i);
+ byte *dst = (byte *)surface->getBasePtr(0, i);
+ for (int j = 0; j < _bounds->width(); j++) {
+ if (*src != kColorGreen)
+ *dst = *src;
+ src++;
+ dst++;
+ }
+ }
}
void drawPixel(int x, int y, int color, void *data) {
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 118fbbb..8e79a84 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -67,13 +67,14 @@ public:
return _bounds;
}
- void paint(Graphics::Surface *canvas, Patterns &patterns, bool mask);
+ void paint(Graphics::Surface *canvas, Patterns &patterns, bool mask, int x, int y);
static void drawFilledRect(Graphics::Surface *surface, Common::Rect &rect, int color, Patterns &patterns, byte fillType);
private:
byte *_data;
int _len;
Common::Rect *_bounds;
+ Graphics::Surface *_surface;
private:
void drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index d557f08..96d6855 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -61,7 +61,6 @@ void Designed::setDesignBounds(Common::Rect *bounds) {
Scene::Scene() {
_script = NULL;
- _surface = NULL;
_design = NULL;
_textBounds = NULL;
_fontSize = 0;
@@ -84,7 +83,6 @@ Scene::Scene(String name, Common::SeekableReadStream *data) {
_design = new Design(data);
_script = NULL;
- _surface = NULL;
_textBounds = NULL;
_fontSize = 0;
_fontType = 0;
@@ -109,31 +107,23 @@ Scene::Scene(String name, Common::SeekableReadStream *data) {
}
Scene::~Scene() {
- delete _surface;
}
void Scene::paint(Graphics::Surface *surface, int x, int y) {
- if (_surface == NULL) {
- _surface = new Graphics::Surface;
- _surface->create(_design->getBounds()->width(), _design->getBounds()->height(), Graphics::PixelFormat::createFormatCLUT8());
- }
-
Common::Rect r(0, 0, _design->getBounds()->width(), _design->getBounds()->height());
- _surface->fillRect(r, kColorWhite);
+ surface->fillRect(r, kColorWhite);
- _design->paint(_surface, ((WageEngine *)g_engine)->_world->_patterns, false);
+ _design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, false, x, y);
for (Common::List<Obj *>::const_iterator it = _objs.begin(); it != _objs.end(); ++it) {
debug(2, "paining Obj: %s", (*it)->_name.c_str());
- (*it)->_design->paint(_surface, ((WageEngine *)g_engine)->_world->_patterns, false);
+ (*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, false, x, y);
}
for (Common::List<Chr *>::const_iterator it = _chrs.begin(); it != _chrs.end(); ++it) {
debug(2, "paining Chr: %s", (*it)->_name.c_str());
- (*it)->_design->paint(_surface, ((WageEngine *)g_engine)->_world->_patterns, false);
+ (*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, false, x, y);
}
-
- surface->copyRectToSurface(*_surface, x, y, r);
}
// Source: Apple IIGS Technical Note #41, "Font Family Numbers"
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 0e20d2e..5ecd33c 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -405,9 +405,6 @@ public:
void paint(Graphics::Surface *screen, int x, int y);
const char *getFontName();
-
-private:
- Graphics::Surface *_surface;
};
class Sound {
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index ff867e5..2b919e1 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -87,15 +87,16 @@ WageEngine::~WageEngine() {
}
static byte palette[] = {
- 0, 0, 0,
- 0x80, 0x80, 0x80,
- 0xff, 0xff, 0xff
+ 0, 0, 0, // Black
+ 0x80, 0x80, 0x80, // Gray
+ 0xff, 0xff, 0xff, // White
+ 0x00, 0xff, 0x00 // Green
};
Common::Error WageEngine::run() {
initGraphics(444, 333, true);
- g_system->getPaletteManager()->setPalette(palette, 0, 3);
+ g_system->getPaletteManager()->setPalette(palette, 0, 4);
// Create debugger console. It requires GFX to be initialized
_console = new Console(this);
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 614b5a1..c93e4e7 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -90,9 +90,10 @@ enum {
};
enum {
- kColorBlack = 0,
- kColorGray = 1,
- kColorWhite = 2
+ kColorBlack = 0,
+ kColorGray = 1,
+ kColorWhite = 2,
+ kColorGreen = 3
};
Common::String readPascalString(Common::SeekableReadStream *in);
Commit: 97c17ed199c22fefc33cf12286867a2390af47f3
https://github.com/scummvm/scummvm/commit/97c17ed199c22fefc33cf12286867a2390af47f3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-30T01:46:51+01:00
Commit Message:
WAGE; Fix border drawing
Changed paths:
engines/wage/design.cpp
engines/wage/entities.cpp
engines/wage/gui.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index c75d1f7..bfe35fb 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -159,7 +159,7 @@ void Design::paint(Graphics::Surface *surface, Patterns &patterns, bool mask, in
for (int i = 0; i < _bounds->height(); i++) {
const byte *src = (const byte *)_surface->getBasePtr(0, i);
- byte *dst = (byte *)surface->getBasePtr(0, i);
+ byte *dst = (byte *)surface->getBasePtr(x, y+i);
for (int j = 0; j < _bounds->width(); j++) {
if (*src != kColorGreen)
*dst = *src;
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 96d6855..bb3cff8 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -110,7 +110,7 @@ Scene::~Scene() {
}
void Scene::paint(Graphics::Surface *surface, int x, int y) {
- Common::Rect r(0, 0, _design->getBounds()->width(), _design->getBounds()->height());
+ Common::Rect r(x + 5, y + 5, _design->getBounds()->width() + x - 10, _design->getBounds()->height() + y - 10);
surface->fillRect(r, kColorWhite);
_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, false, x, y);
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 4f05328..3d3c58b 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -103,7 +103,7 @@ void Gui::drawBox(Graphics::Surface *g, int x, int y, int w, int h) {
}
void Gui::fillRect(Graphics::Surface *g, int x, int y, int w, int h) {
- Common::Rect r(x, y, x + w + 1, y + h + 1);
+ Common::Rect r(x, y, x + w, y + h);
g->fillRect(r, kColorBlack);
}
@@ -143,9 +143,9 @@ void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height,
for (int yy = 0; yy < ARROW_H; yy++) {
for (int xx = 0; xx < ARROW_W; xx++) {
if (arrowPixels[yy][xx] != 0) {
- g->hLine(x1+xx, y1+yy, x1+xx+1, kColorBlack);
+ g->hLine(x1+xx, y1+yy, x1+xx, kColorBlack);
} else {
- g->hLine(x1+xx, y1+yy, x1+xx+1, kColorWhite);
+ g->hLine(x1+xx, y1+yy, x1+xx, kColorWhite);
}
}
}
@@ -154,9 +154,9 @@ void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height,
for (int yy = 0; yy < ARROW_H; yy++) {
for (int xx = 0; xx < ARROW_W; xx++) {
if (arrowPixels[ARROW_H-yy-1][xx] != 0) {
- g->hLine(x1+xx, y1+yy, x1+xx+1, kColorBlack);
+ g->hLine(x1+xx, y1+yy, x1+xx, kColorBlack);
} else {
- g->hLine(x1+xx, y1+yy, x1+xx+1, kColorWhite);
+ g->hLine(x1+xx, y1+yy, x1+xx, kColorWhite);
}
}
}
Commit: 1c3560cd65eb03efcc5db31cd62196db712af99e
https://github.com/scummvm/scummvm/commit/1c3560cd65eb03efcc5db31cd62196db712af99e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-30T01:58:42+01:00
Commit Message:
WAGE: Draw console window border.
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 3d3c58b..01b9422 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -87,11 +87,16 @@ void Gui::draw() {
if (_scene != NULL && _sceneDirty) {
_scene->paint(&_screen, 0, kMenuHeight);
paintBorder(&_screen, 0, kMenuHeight, _scene->_design->getBounds()->width(), _scene->_design->getBounds()->height(),
- true, true, true, false);
+ false, false, false, false);
_sceneDirty = false;
}
+ int sceneW = _scene->_design->getBounds()->width();
+ paintBorder(&_screen, sceneW, kMenuHeight, _screen.w - sceneW, _scene->_design->getBounds()->height(),
+ true, true, true, false);
+
+
g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, _screen.h);
}
Commit: a712a1d80b2bf7e35d729475e9522456b6a90e27
https://github.com/scummvm/scummvm/commit/a712a1d80b2bf7e35d729475e9522456b6a90e27
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-30T18:22:46+01:00
Commit Message:
WAGE: Implement appendText()
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/wage.cpp
engines/wage/wage.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 01b9422..6f168eb 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -83,6 +83,11 @@ void Gui::setScene(Scene *scene) {
_scene = scene;
}
+void Gui::appendText(String &str) {
+ _out += str;
+ _out += '\n';
+}
+
void Gui::draw() {
if (_scene != NULL && _sceneDirty) {
_scene->paint(&_screen, 0, kMenuHeight);
@@ -92,11 +97,12 @@ void Gui::draw() {
_sceneDirty = false;
}
+ // Render console
int sceneW = _scene->_design->getBounds()->width();
paintBorder(&_screen, sceneW, kMenuHeight, _screen.w - sceneW, _scene->_design->getBounds()->height(),
true, true, true, false);
-
+ // Blit to screen
g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, _screen.h);
}
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 4689902..2e6cd65 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -60,6 +60,7 @@ public:
void draw();
void setScene(Scene *scene);
+ void appendText(Common::String &str);
private:
void paintBorder(Graphics::Surface *g, int x, int y, int width, int height,
@@ -72,6 +73,8 @@ private:
Graphics::Surface _screen;
Scene *_scene;
bool _sceneDirty;
+
+ Common::String _out;
};
} // End of namespace Wage
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 2b919e1..39a2ce6 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -165,8 +165,8 @@ void WageEngine::setMenu(String soundName) {
warning("STUB: WageEngine::setMenu");
}
-void WageEngine::appendText(String str) {
- warning("STUB: WageEngine::appendText(%s)", str.c_str());
+void WageEngine::appendText(String &str) {
+ _gui->appendText(str);
}
Obj *WageEngine::getOffer() {
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index c93e4e7..3e29471 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -139,7 +139,7 @@ public:
void playSound(String soundName);
void setMenu(String soundName);
- void appendText(String str);
+ void appendText(String &str);
void gameOver();
Obj *getOffer();
Chr *getMonster();
Commit: 141bddbf57393a5cf24c35b63f5d802d10f36149
https://github.com/scummvm/scummvm/commit/141bddbf57393a5cf24c35b63f5d802d10f36149
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-30T18:41:18+01:00
Commit Message:
WAGE: Stub for console rendering
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 6f168eb..c092b5b 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -56,7 +56,8 @@ namespace Wage {
enum {
kMenuHeight = 19,
kMenuPadding = 6,
- kMenuItemHeight = 19
+ kMenuItemHeight = 19,
+ kBorderWidth = 17
};
byte checkers[8] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa };
@@ -99,6 +100,10 @@ void Gui::draw() {
// Render console
int sceneW = _scene->_design->getBounds()->width();
+ int consoleW = _screen.w - sceneW - 2 * kBorderWidth;
+ int consoleH = _scene->_design->getBounds()->height() - 2 * kBorderWidth;
+
+ renderConsole(&_screen, sceneW + kBorderWidth, kMenuHeight + kBorderWidth, consoleW, consoleH);
paintBorder(&_screen, sceneW, kMenuHeight, _screen.w - sceneW, _scene->_design->getBounds()->height(),
true, true, true, false);
@@ -132,7 +137,7 @@ const int arrowPixels[ARROW_H][ARROW_W] = {
void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height,
bool active, bool scrollable, bool closeable, bool closeBoxPressed) {
- int size = 17;
+ const int size = kBorderWidth;
drawBox(g, x, y, size, size);
drawBox(g, x+width-size-1, y, size, size);
drawBox(g, x+width-size-1, y+height-size-1, size, size);
@@ -200,5 +205,22 @@ void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height,
#endif
}
+void Gui::renderConsole(Graphics::Surface *g, int x, int y, int width, int height) {
+ bool fullRedraw = false;
+ Common::Rect fullR(0, 0, width, height);
+
+ if (_console.w != width || _console.h != height) {
+ _console.free();
+
+ _console.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
+ fullRedraw = true;
+ }
+
+ if (fullRedraw)
+ _console.fillRect(fullR, kColorWhite);
+
+ g->copyRectToSurface(_console, x, y, fullR);
+}
+
} // End of namespace Wage
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 2e6cd65..0ac81e2 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -66,11 +66,13 @@ private:
void paintBorder(Graphics::Surface *g, int x, int y, int width, int height,
bool active, bool scrollable, bool closeable, bool closeBoxPressed);
+ void renderConsole(Graphics::Surface *g, int x, int y, int width, int height);
void drawBox(Graphics::Surface *g, int x, int y, int w, int h);
void fillRect(Graphics::Surface *g, int x, int y, int w, int h);
private:
Graphics::Surface _screen;
+ Graphics::Surface _console;
Scene *_scene;
bool _sceneDirty;
Commit: f25663605bcb63c615bb4be9d6161b847ea5ce22
https://github.com/scummvm/scummvm/commit/f25663605bcb63c615bb4be9d6161b847ea5ce22
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-31T17:45:36+01:00
Commit Message:
WAGE: Implement console drawing
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/wage.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index c092b5b..c274601 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -46,6 +46,8 @@
*/
#include "common/system.h"
+#include "graphics/fontman.h"
+#include "graphics/font.h"
#include "wage/wage.h"
#include "wage/design.h"
#include "wage/entities.h"
@@ -71,6 +73,8 @@ Gui::Gui() {
p.push_back(checkers);
Common::Rect r(0, 0, _screen.w, _screen.h);
+ _scrollPos = 0;
+
Design::drawFilledRect(&_screen, r, kColorBlack, p, 1);
}
@@ -85,8 +89,26 @@ void Gui::setScene(Scene *scene) {
}
void Gui::appendText(String &str) {
- _out += str;
- _out += '\n';
+ if (!str.contains('\n')) {
+ _out.push_back(str);
+ return;
+ }
+
+ // Okay, we got new lines, need to split it
+ // and push substrings individually
+ Common::String tmp = "";
+
+ for (int i = 0; i < str.size(); i++) {
+ if (str[i] == '\n') {
+ _out.push_back(tmp);
+ tmp = "";
+ continue;
+ }
+
+ tmp += str[i];
+ }
+
+ _out.push_back(tmp);
}
void Gui::draw() {
@@ -205,21 +227,72 @@ void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height,
#endif
}
+enum {
+ kConWOverlap = 20,
+ kConHOverlap = 20,
+ kConWPadding = 2,
+ kConHPadding = 10,
+ kConOverscan = 3,
+ kLineSpacing = 1
+};
+
void Gui::renderConsole(Graphics::Surface *g, int x, int y, int width, int height) {
bool fullRedraw = false;
- Common::Rect fullR(0, 0, width, height);
+ bool textReflow = false;
+ int surfW = width + kConWOverlap * 2;
+ int surfH = height + kConHOverlap * 2;
+
+ Common::Rect boundsR(kConWOverlap - kConOverscan, kConHOverlap - kConOverscan, width + kConWOverlap + kConOverscan, height + kConHOverlap + kConOverscan);
+ Common::Rect fullR(0, 0, surfW, surfH);
+
+ if (_console.w != surfW || _console.h != surfH) {
+ if (_console.w != surfW)
+ textReflow = true;
- if (_console.w != width || _console.h != height) {
_console.free();
- _console.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
+ _console.create(surfW, surfH, Graphics::PixelFormat::createFormatCLUT8());
fullRedraw = true;
}
if (fullRedraw)
_console.fillRect(fullR, kColorWhite);
- g->copyRectToSurface(_console, x, y, fullR);
+ const Graphics::Font *font = FontMan.getFontByUsage(Graphics::FontManager::kConsoleFont);
+ int lineHeight = font->getFontHeight() + kLineSpacing;
+ int textW = width - kConWPadding * 2;
+ int textH = height - kConHPadding * 2;
+
+ if (textReflow) {
+ _lines.clear();
+
+ for (int i = 0; i < _out.size(); i++) {
+ Common::StringArray wrappedLines;
+
+ font->wordWrapText(_out[i], textW, wrappedLines);
+
+ for (Common::StringArray::const_iterator j = wrappedLines.begin(); j != wrappedLines.end(); ++j)
+ _lines.push_back(*j);
+ }
+ }
+
+ const int firstLine = _scrollPos / lineHeight;
+ const int lastLine = MIN((_scrollPos + textH) / lineHeight + 1, _lines.size());
+ const int xOff = kConWOverlap;
+ const int yOff = kConHOverlap;
+ int x1 = xOff + kConWPadding;
+ int y1 = yOff - (_scrollPos % lineHeight) + kConHPadding;
+
+ for (int line = firstLine; line < lastLine; line++) {
+ const char *str = _lines[line].c_str();
+
+ if (*str)
+ font->drawString(&_console, _lines[line], x1, y1, textW, kColorBlack);
+
+ y1 += lineHeight;
+ }
+
+ g->copyRectToSurface(_console, x - kConOverscan, y - kConOverscan, boundsR);
}
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 0ac81e2..ea6af1e 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -48,6 +48,7 @@
#ifndef WAGE_GUI_H
#define WAGE_GUI_H
+#include "common/str-array.h"
#include "graphics/surface.h"
#include "common/rect.h"
@@ -76,7 +77,9 @@ private:
Scene *_scene;
bool _sceneDirty;
- Common::String _out;
+ Common::StringArray _out;
+ Common::StringArray _lines;
+ uint _scrollPos;
};
} // End of namespace Wage
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 39a2ce6..4e980ea 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -121,7 +121,7 @@ Common::Error WageEngine::run() {
Common::String input("look");
_world->_player->_currentScene = _world->_orderedScenes[1];
- //_world->_globalScript->execute(_world, 1, &input, NULL, this);
+ _world->_globalScript->execute(_world, 1, &input, NULL, this);
_gui->setScene(_world->_orderedScenes[1]);
_gui->draw();
Commit: 849220b6b6c8544f145ba9c480c499b4638b3c2b
https://github.com/scummvm/scummvm/commit/849220b6b6c8544f145ba9c480c499b4638b3c2b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-31T17:55:33+01:00
Commit Message:
WAGE: Simplified border drawing API
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index c274601..54b0a7c 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -115,7 +115,7 @@ void Gui::draw() {
if (_scene != NULL && _sceneDirty) {
_scene->paint(&_screen, 0, kMenuHeight);
paintBorder(&_screen, 0, kMenuHeight, _scene->_design->getBounds()->width(), _scene->_design->getBounds()->height(),
- false, false, false, false);
+ kWindowScene);
_sceneDirty = false;
}
@@ -127,7 +127,7 @@ void Gui::draw() {
renderConsole(&_screen, sceneW + kBorderWidth, kMenuHeight + kBorderWidth, consoleW, consoleH);
paintBorder(&_screen, sceneW, kMenuHeight, _screen.w - sceneW, _scene->_design->getBounds()->height(),
- true, true, true, false);
+ kWindowConsole);
// Blit to screen
g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, _screen.h);
@@ -157,8 +157,24 @@ const int arrowPixels[ARROW_H][ARROW_W] = {
{1,1,1,1,1,1,1,1,1,1,1,1}};
-void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height,
- bool active, bool scrollable, bool closeable, bool closeBoxPressed) {
+void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height, WindowType windowType) {
+ bool active, scrollable, closeable, closeBoxPressed;
+
+ switch (windowType) {
+ case kWindowScene:
+ active = false;
+ scrollable = false;
+ closeable = false;
+ closeBoxPressed = false;
+ break;
+ case kWindowConsole:
+ active = true;
+ scrollable = true;
+ closeable = true;
+ closeBoxPressed = false;
+ break;
+ }
+
const int size = kBorderWidth;
drawBox(g, x, y, size, size);
drawBox(g, x+width-size-1, y, size, size);
@@ -242,7 +258,8 @@ void Gui::renderConsole(Graphics::Surface *g, int x, int y, int width, int heigh
int surfW = width + kConWOverlap * 2;
int surfH = height + kConHOverlap * 2;
- Common::Rect boundsR(kConWOverlap - kConOverscan, kConHOverlap - kConOverscan, width + kConWOverlap + kConOverscan, height + kConHOverlap + kConOverscan);
+ Common::Rect boundsR(kConWOverlap - kConOverscan, kConHOverlap - kConOverscan,
+ width + kConWOverlap + kConOverscan, height + kConHOverlap + kConOverscan);
Common::Rect fullR(0, 0, surfW, surfH);
if (_console.w != surfW || _console.h != surfH) {
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index ea6af1e..7be81ba 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -54,6 +54,11 @@
namespace Wage {
+enum WindowType {
+ kWindowScene,
+ kWindowConsole
+};
+
class Gui {
public:
Gui();
@@ -64,9 +69,7 @@ public:
void appendText(Common::String &str);
private:
- void paintBorder(Graphics::Surface *g, int x, int y, int width, int height,
- bool active, bool scrollable, bool closeable, bool closeBoxPressed);
-
+ void paintBorder(Graphics::Surface *g, int x, int y, int width, int height, WindowType windowType);
void renderConsole(Graphics::Surface *g, int x, int y, int width, int height);
void drawBox(Graphics::Surface *g, int x, int y, int w, int h);
void fillRect(Graphics::Surface *g, int x, int y, int w, int h);
Commit: a3cc6cdddcd49d95fc377f282a70e4894e1e0d59
https://github.com/scummvm/scummvm/commit/a3cc6cdddcd49d95fc377f282a70e4894e1e0d59
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-31T18:07:01+01:00
Commit Message:
WAGE: Draw scene title
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 54b0a7c..e4c7a45 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -156,9 +156,8 @@ const int arrowPixels[ARROW_H][ARROW_W] = {
{0,1,1,1,1,1,1,1,1,1,1,0},
{1,1,1,1,1,1,1,1,1,1,1,1}};
-
void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height, WindowType windowType) {
- bool active, scrollable, closeable, closeBoxPressed;
+ bool active, scrollable, closeable, closeBoxPressed, drawTitle;
switch (windowType) {
case kWindowScene:
@@ -166,12 +165,14 @@ void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height,
scrollable = false;
closeable = false;
closeBoxPressed = false;
+ drawTitle = true;
break;
case kWindowConsole:
active = true;
scrollable = true;
closeable = true;
closeBoxPressed = false;
+ drawTitle = false;
break;
}
@@ -224,23 +225,18 @@ void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height,
}
}
-#if 0
- if (title != null) {
+ if (drawTitle) {
// TODO: This "Chicago" is not faithful to the original one on the Mac.
- Font f = new Font("Chicago", Font.BOLD, 12);
- int w = g.getFontMetrics(f).stringWidth(title) + 6;
+ //Font f = new Font("Chicago", Font.BOLD, 12);
+ const Graphics::Font *font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
+
+ int w = font->getStringWidth(_scene->_name) + 6;
int maxWidth = width - size*2 - 7;
- if (w > maxWidth) {
+ if (w > maxWidth)
w = maxWidth;
- }
drawBox(g, x + (width - w) / 2, y, w, size);
- g.setFont(f);
- Shape clip = g.getClip();
- g.setClip(x + (width - w) / 2, y, w, size);
- g.drawString(title, x + (width - w) / 2 + 3, y + size - 4);
- g.setClip(clip);
+ font->drawString(g, _scene->_name, x + (width - w) / 2 + 3, y + 3, w, kColorBlack);
}
-#endif
}
enum {
Commit: dad200e50eb1096db39a282d5110225da92dbade
https://github.com/scummvm/scummvm/commit/dad200e50eb1096db39a282d5110225da92dbade
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-31T18:50:34+01:00
Commit Message:
WAGE: Load fonts from wage.dat
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index e4c7a45..cbaba94 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -46,8 +46,10 @@
*/
#include "common/system.h"
+#include "common/unzip.h"
#include "graphics/fontman.h"
#include "graphics/font.h"
+#include "graphics/fonts/bdf.h"
#include "wage/wage.h"
#include "wage/design.h"
#include "wage/entities.h"
@@ -74,8 +76,11 @@ Gui::Gui() {
Common::Rect r(0, 0, _screen.w, _screen.h);
_scrollPos = 0;
+ _builtInFonts = false;
Design::drawFilledRect(&_screen, r, kColorBlack, p, 1);
+
+ loadFonts();
}
Gui::~Gui() {
@@ -308,5 +313,46 @@ void Gui::renderConsole(Graphics::Surface *g, int x, int y, int width, int heigh
g->copyRectToSurface(_console, x - kConOverscan, y - kConOverscan, boundsR);
}
+void Gui::loadFonts() {
+ Common::Archive *dat;
+
+ dat = Common::makeZipArchive("wage.dat");
+
+ if (!dat) {
+ warning("Could not find wage.dat. Falling back to built-in fonts");
+ _builtInFonts = true;
+ }
+
+ Common::ArchiveMemberList list;
+ dat->listMembers(list);
+
+ for (Common::ArchiveMemberList::iterator it = list.begin(); it != list.end(); ++it) {
+ Common::SeekableReadStream *stream = dat->createReadStreamForMember((*it)->getName());
+
+ Graphics::BdfFont *font = Graphics::BdfFont::loadFont(*stream);
+
+ delete stream;
+
+ Common::String fontName = (*it)->getName();
+
+ // Trim the .bdf extension
+ for (int i = fontName.size() - 1; i >= 0; --i) {
+ if (fontName[i] == '.') {
+ while ((uint)i < fontName.size()) {
+ fontName.deleteLastChar();
+ }
+ break;
+ }
+ }
+
+ FontMan.assignFontToName(fontName, font);
+
+ debug(2, " %s", fontName.c_str());
+ }
+
+ _builtInFonts = false;
+
+ delete dat;
+}
} // End of namespace Wage
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 7be81ba..91acfb3 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -73,6 +73,7 @@ private:
void renderConsole(Graphics::Surface *g, int x, int y, int width, int height);
void drawBox(Graphics::Surface *g, int x, int y, int w, int h);
void fillRect(Graphics::Surface *g, int x, int y, int w, int h);
+ void loadFonts();
private:
Graphics::Surface _screen;
@@ -83,6 +84,8 @@ private:
Common::StringArray _out;
Common::StringArray _lines;
uint _scrollPos;
+
+ bool _builtInFonts;
};
} // End of namespace Wage
Commit: 18990b49ae7c4a10e0c64d6d97356d5d9d536ec6
https://github.com/scummvm/scummvm/commit/18990b49ae7c4a10e0c64d6d97356d5d9d536ec6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-31T19:01:26+01:00
Commit Message:
WAGE: Use Mac fonts for rendering
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index cbaba94..131077e 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -231,16 +231,27 @@ void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height,
}
if (drawTitle) {
- // TODO: This "Chicago" is not faithful to the original one on the Mac.
- //Font f = new Font("Chicago", Font.BOLD, 12);
- const Graphics::Font *font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
+ const Graphics::Font *font;
+ int yOff = 1;
+
+ if (!_builtInFonts) {
+ font = FontMan.getFontByName("Chicago-12");
+
+ if (!font)
+ warning("Cannot load font Chicago-12");
+ }
+
+ if (_builtInFonts || !font) {
+ font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
+ yOff = 3;
+ }
int w = font->getStringWidth(_scene->_name) + 6;
int maxWidth = width - size*2 - 7;
if (w > maxWidth)
w = maxWidth;
drawBox(g, x + (width - w) / 2, y, w, size);
- font->drawString(g, _scene->_name, x + (width - w) / 2 + 3, y + 3, w, kColorBlack);
+ font->drawString(g, _scene->_name, x + (width - w) / 2 + 3, y + yOff, w, kColorBlack);
}
}
@@ -276,7 +287,21 @@ void Gui::renderConsole(Graphics::Surface *g, int x, int y, int width, int heigh
if (fullRedraw)
_console.fillRect(fullR, kColorWhite);
- const Graphics::Font *font = FontMan.getFontByUsage(Graphics::FontManager::kConsoleFont);
+ const Graphics::Font *font;
+
+ if (!_builtInFonts) {
+ char fontName[128];
+
+ snprintf(fontName, 128, "%s-%d", _scene->getFontName(), _scene->_fontSize);
+ font = FontMan.getFontByName(fontName);
+
+ if (!font)
+ warning("Cannot load font %s", fontName);
+ }
+
+ if (_builtInFonts || !font)
+ font = FontMan.getFontByUsage(Graphics::FontManager::kConsoleFont);
+
int lineHeight = font->getFontHeight() + kLineSpacing;
int textW = width - kConWPadding * 2;
int textH = height - kConHPadding * 2;
Commit: 3835f9f626806a640f88cf7d3ec69397131d5d2a
https://github.com/scummvm/scummvm/commit/3835f9f626806a640f88cf7d3ec69397131d5d2a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-31T19:07:50+01:00
Commit Message:
WAGE: Matched game screen size to Macintosh, fixed line spacing
Changed paths:
engines/wage/gui.cpp
engines/wage/wage.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 131077e..3734def 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -261,7 +261,7 @@ enum {
kConWPadding = 2,
kConHPadding = 10,
kConOverscan = 3,
- kLineSpacing = 1
+ kLineSpacing = 0
};
void Gui::renderConsole(Graphics::Surface *g, int x, int y, int width, int height) {
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 4e980ea..d398311 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -94,7 +94,7 @@ static byte palette[] = {
};
Common::Error WageEngine::run() {
- initGraphics(444, 333, true);
+ initGraphics(512, 342, true);
g_system->getPaletteManager()->setPalette(palette, 0, 4);
Commit: b0990b7100adafc13e9e898d64129622216ecf9c
https://github.com/scummvm/scummvm/commit/b0990b7100adafc13e9e898d64129622216ecf9c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-31T19:30:34+01:00
Commit Message:
WAGE: Hide noisy debug messages deeper
Changed paths:
engines/wage/design.cpp
engines/wage/script.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index bfe35fb..e65bbd4 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -124,7 +124,7 @@ void Design::paint(Graphics::Surface *surface, Patterns &patterns, bool mask, in
if (in.eos())
break;
- debug(2, "fill: %d borderFill: %d border: %d type: %d", fillType, borderFillType, borderThickness, type);
+ debug(8, "fill: %d borderFill: %d border: %d type: %d", fillType, borderFillType, borderThickness, type);
switch (type) {
case 4:
drawRect(_surface, in, mask, patterns, fillType, borderThickness, borderFillType);
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index a26a733..b66e517 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -66,14 +66,14 @@ Script::~Script() {
void Script::print() {
for (int i = 0; i < _scriptText.size(); i++) {
- debug(0, "%d [%04x]: %s", i, _scriptText[i]->offset, _scriptText[i]->line.c_str());
+ debug(4, "%d [%04x]: %s", i, _scriptText[i]->offset, _scriptText[i]->line.c_str());
}
}
void Script::printLine(int offset) {
for (int i = 0; i < _scriptText.size(); i++)
if (_scriptText[i]->offset >= offset) {
- debug(0, "%d [%04x]: %s", i, _scriptText[i]->offset, _scriptText[i]->line.c_str());
+ debug(4, "%d [%04x]: %s", i, _scriptText[i]->offset, _scriptText[i]->line.c_str());
break;
}
}
@@ -97,7 +97,7 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
processIf();
break;
case 0x87: // EXIT
- debug(0, "exit at offset %d", _data->pos() - 1);
+ debug(6, "exit at offset %d", _data->pos() - 1);
return true;
case 0x89: // MOVE
@@ -149,7 +149,7 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
}
if (_world->_globalScript != this) {
- debug(0, "Executing global script...");
+ debug(1, "Executing global script...");
bool globalHandled = _world->_globalScript->execute(_world, _loopCount, _inputText, _inputClick, _callbacks);
if (globalHandled)
_handled = true;
@@ -218,7 +218,7 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
Script::Operand *Script::readOperand() {
byte operandType = _data->readByte();
- debug(2, "%x: readOperand: 0x%x", _data->pos(), operandType);
+ debug(7, "%x: readOperand: 0x%x", _data->pos(), operandType);
Context *cont = &_world->_player->_context;
switch (operandType) {
@@ -402,7 +402,7 @@ Script::Operand *Script::readStringOperand() {
const char *Script::readOperator() {
byte cmd = _data->readByte();
- debug(2, "readOperator: 0x%x", cmd);
+ debug(7, "readOperator: 0x%x", cmd);
switch (cmd) {
case 0x81:
return "=";
@@ -792,7 +792,7 @@ void Script::processLet() {
byte eq = _data->readByte(); // skip "=" operator
- debug(2, "processLet: 0x%x, uservar: 0x%x, eq: 0x%x", operandType, uservar, eq);
+ debug(7, "processLet: 0x%x, uservar: 0x%x, eq: 0x%x", operandType, uservar, eq);
do {
Operand *operand = readOperand();
Commit: 1b6663a7bbb25f628b181326a769b301e0fd8598
https://github.com/scummvm/scummvm/commit/1b6663a7bbb25f628b181326a769b301e0fd8598
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-31T19:40:46+01:00
Commit Message:
WAGE: Fix random crash on start
Changed paths:
engines/wage/entities.cpp
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index bb3cff8..036bbe6 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -160,9 +160,12 @@ const char *Scene::getFontName() {
return "Unknown";
}
-Obj::Obj(String name, Common::SeekableReadStream *data) : _currentOwner(NULL), _currentScene(NULL) {
+Obj::Obj(String name, Common::SeekableReadStream *data) {
_name = name;
_classType = OBJ;
+ _currentOwner = NULL;
+ _currentScene = NULL;
+
_design = new Design(data);
setDesignBounds(readRect(data));
@@ -236,6 +239,8 @@ Chr::Chr(String name, Common::SeekableReadStream *data) {
_classType = CHR;
_design = new Design(data);
+ _currentScene = NULL;
+
setDesignBounds(readRect(data));
_physicalStrength = data->readByte();
Commit: 6852fc9e2a7dc65c553790c85e6bf50223db31f7
https://github.com/scummvm/scummvm/commit/6852fc9e2a7dc65c553790c85e6bf50223db31f7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-31T19:49:52+01:00
Commit Message:
WAGE: Initialize class variables
Changed paths:
engines/wage/entities.cpp
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 036bbe6..c5dd36e 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -166,6 +166,8 @@ Obj::Obj(String name, Common::SeekableReadStream *data) {
_currentOwner = NULL;
_currentScene = NULL;
+ _index = 0;
+
_design = new Design(data);
setDesignBounds(readRect(data));
@@ -239,6 +241,7 @@ Chr::Chr(String name, Common::SeekableReadStream *data) {
_classType = CHR;
_design = new Design(data);
+ _index = 0;
_currentScene = NULL;
setDesignBounds(readRect(data));
@@ -267,6 +270,9 @@ Chr::Chr(String name, Common::SeekableReadStream *data) {
if (data->readSByte() == 1)
_playerCharacter = true;
+ else
+ _playerCharacter = false;
+
_maximumCarriedObjects = data->readByte();
_returnTo = data->readSByte();
@@ -282,6 +288,8 @@ Chr::Chr(String name, Common::SeekableReadStream *data) {
_gender = data->readSByte();
if (data->readSByte() == 1)
_nameProperNoun = true;
+ else
+ _nameProperNoun = false;
_initialScene = readPascalString(data);
_nativeWeapon1 = readPascalString(data);
Commit: 130a671e8f29d2e6598ff3a67c17947ff2f29b4e
https://github.com/scummvm/scummvm/commit/130a671e8f29d2e6598ff3a67c17947ff2f29b4e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-31T19:56:32+01:00
Commit Message:
WAGE: Remove obsolete README
Changed paths:
R engines/wage/README
diff --git a/engines/wage/README b/engines/wage/README
deleted file mode 100644
index 1a0d0ab..0000000
--- a/engines/wage/README
+++ /dev/null
@@ -1,5 +0,0 @@
-WAGE Engine For ScummVM
-
-Engine to play games built with http://en.wikipedia.org/wiki/World_Builder
-
-Currently WIP, incomplete and not usable.
Commit: c001c30547af9197f07227de70a85f09a8c8920a
https://github.com/scummvm/scummvm/commit/c001c30547af9197f07227de70a85f09a8c8920a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-31T22:34:44+01:00
Commit Message:
WAGE: Finished world reset
Changed paths:
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/script.cpp
engines/wage/world.cpp
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index c5dd36e..f9a68d6 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -59,6 +59,19 @@ void Designed::setDesignBounds(Common::Rect *bounds) {
_design->setBounds(bounds);
}
+Context::Context() {
+ _visits = 0;
+ _kills = 0;
+ _experience = 0;
+ _frozen = false;
+
+ for (int i = 0; i < 26 * 9; i++)
+ _userVariables[i] = 0;
+
+ for (int i = 0; i < 18; i++)
+ _statVariables[i] = 0;
+}
+
Scene::Scene() {
_script = NULL;
_design = NULL;
@@ -317,6 +330,20 @@ Chr::Chr(String name, Common::SeekableReadStream *data) {
_armor[i] = NULL;
}
+void Chr::resetState() {
+ _context._statVariables[PHYS_STR_BAS] = _context._statVariables[PHYS_STR_CUR] = _physicalStrength;
+ _context._statVariables[PHYS_HIT_BAS] = _context._statVariables[PHYS_HIT_CUR] = _physicalHp;
+ _context._statVariables[PHYS_ARM_BAS] = _context._statVariables[PHYS_ARM_CUR] = _naturalArmor;
+ _context._statVariables[PHYS_ACC_BAS] = _context._statVariables[PHYS_ACC_CUR] = _physicalAccuracy;
+
+ _context._statVariables[SPIR_STR_BAS] = _context._statVariables[SPIR_STR_CUR] = _spiritualStength;
+ _context._statVariables[SPIR_HIT_BAS] = _context._statVariables[SPIR_HIT_CUR] = _spiritialHp;
+ _context._statVariables[SPIR_ARM_BAS] = _context._statVariables[SPIR_ARM_CUR] = _naturalArmor;
+ _context._statVariables[SPIR_ACC_BAS] = _context._statVariables[SPIR_ACC_CUR] = _physicalAccuracy;
+
+ _context._statVariables[PHYS_SPE_BAS] = _context._statVariables[PHYS_SPE_CUR] = _runningSpeed;
+}
+
WeaponArray *Chr::getWeapons() {
WeaponArray *list = new WeaponArray;
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 5ecd33c..5c1a902 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -62,50 +62,53 @@ class Weapon;
typedef Common::Array<Weapon *> WeaponArray;
+enum StatVariable {
+/** The base physical accuracy of the player. */
+ PHYS_ACC_BAS = 0,
+/** The current physical accuracy of the player. */
+ PHYS_ACC_CUR = 1,
+/** The base physical armor of the player. */
+ PHYS_ARM_BAS = 2,
+/** The current physical armor of the player. */
+ PHYS_ARM_CUR = 3,
+/** The base physical hit points of the player. */
+ PHYS_HIT_BAS = 4,
+/** The current physical hit points of the player. */
+ PHYS_HIT_CUR = 5,
+/** The base physical speed of the player. */
+ PHYS_SPE_BAS = 6,
+/** The current physical speed of the player. */
+ PHYS_SPE_CUR = 7,
+/** The base physical strength of the player. */
+ PHYS_STR_BAS = 8,
+/** The current physical strength of the player. */
+ PHYS_STR_CUR = 9,
+/** The base spiritual accuracy of the player. */
+ SPIR_ACC_BAS = 10,
+/** The current spiritual accuracy of the player. */
+ SPIR_ACC_CUR = 11,
+/** The base spiritual armor of the player. */
+ SPIR_ARM_BAS = 12,
+/** The current spiritual armor of the player. */
+ SPIR_ARM_CUR = 13,
+/** The base spiritual hit points of the player. */
+ SPIR_HIT_BAS = 14,
+/** The current spiritual hit points of the player. */
+ SPIR_HIT_CUR = 15,
+/** The base spiritual strength of the player. */
+ SPIR_STR_BAS = 16,
+/** The current spiritual strength of the player. */
+ SPIR_STR_CUR = 17
+};
+
class Context {
public:
- enum StatVariable {
- /** The base physical accuracy of the player. */
- PHYS_ACC_BAS = 0,
- /** The current physical accuracy of the player. */
- PHYS_ACC_CUR = 1,
- /** The base physical armor of the player. */
- PHYS_ARM_BAS = 2,
- /** The current physical armor of the player. */
- PHYS_ARM_CUR = 3,
- /** The base physical hit points of the player. */
- PHYS_HIT_BAS = 4,
- /** The current physical hit points of the player. */
- PHYS_HIT_CUR = 5,
- /** The base physical speed of the player. */
- PHYS_SPE_BAS = 6,
- /** The current physical speed of the player. */
- PHYS_SPE_CUR = 7,
- /** The base physical strength of the player. */
- PHYS_STR_BAS = 8,
- /** The current physical strength of the player. */
- PHYS_STR_CUR = 9,
- /** The base spiritual accuracy of the player. */
- SPIR_ACC_BAS = 10,
- /** The current spiritual accuracy of the player. */
- SPIR_ACC_CUR = 11,
- /** The base spiritual armor of the player. */
- SPIR_ARM_BAS = 12,
- /** The current spiritual armor of the player. */
- SPIR_ARM_CUR = 13,
- /** The base spiritual hit points of the player. */
- SPIR_HIT_BAS = 14,
- /** The current spiritual hit points of the player. */
- SPIR_HIT_CUR = 15,
- /** The base spiritual strength of the player. */
- SPIR_STR_BAS = 16,
- /** The current spiritual strength of the player. */
- SPIR_STR_CUR = 17
- };
+ Context();
int16 _visits; // Number of scenes visited, including repeated visits
int16 _kills; // Number of characters killed
int16 _experience;
+ bool _frozen;
int16 _userVariables[26 * 9];
int16 _statVariables[18];
};
@@ -284,6 +287,8 @@ public:
}
int wearObjIfPossible(Obj *obj);
void wearObjs();
+
+ void resetState();
};
class Weapon {
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index b66e517..778c0c8 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -261,41 +261,41 @@ Script::Operand *Script::readOperand() {
return new Operand(cont->_userVariables[value - 1], NUMBER);
}
case 0xD0:
- return new Operand(cont->_statVariables[Context::PHYS_STR_BAS], NUMBER);
+ return new Operand(cont->_statVariables[PHYS_STR_BAS], NUMBER);
case 0xD1:
- return new Operand(cont->_statVariables[Context::PHYS_HIT_BAS], NUMBER);
+ return new Operand(cont->_statVariables[PHYS_HIT_BAS], NUMBER);
case 0xD2:
- return new Operand(cont->_statVariables[Context::PHYS_ARM_BAS], NUMBER);
+ return new Operand(cont->_statVariables[PHYS_ARM_BAS], NUMBER);
case 0xD3:
- return new Operand(cont->_statVariables[Context::PHYS_ACC_BAS], NUMBER);
+ return new Operand(cont->_statVariables[PHYS_ACC_BAS], NUMBER);
case 0xD4:
- return new Operand(cont->_statVariables[Context::SPIR_STR_BAS], NUMBER);
+ return new Operand(cont->_statVariables[SPIR_STR_BAS], NUMBER);
case 0xD5:
- return new Operand(cont->_statVariables[Context::SPIR_HIT_BAS], NUMBER);
+ return new Operand(cont->_statVariables[SPIR_HIT_BAS], NUMBER);
case 0xD6:
- return new Operand(cont->_statVariables[Context::SPIR_ARM_BAS], NUMBER);
+ return new Operand(cont->_statVariables[SPIR_ARM_BAS], NUMBER);
case 0xD7:
- return new Operand(cont->_statVariables[Context::SPIR_ACC_BAS], NUMBER);
+ return new Operand(cont->_statVariables[SPIR_ACC_BAS], NUMBER);
case 0xD8:
- return new Operand(cont->_statVariables[Context::PHYS_SPE_BAS], NUMBER);
+ return new Operand(cont->_statVariables[PHYS_SPE_BAS], NUMBER);
case 0xE0:
- return new Operand(cont->_statVariables[Context::PHYS_STR_CUR], NUMBER);
+ return new Operand(cont->_statVariables[PHYS_STR_CUR], NUMBER);
case 0xE1:
- return new Operand(cont->_statVariables[Context::PHYS_HIT_CUR], NUMBER);
+ return new Operand(cont->_statVariables[PHYS_HIT_CUR], NUMBER);
case 0xE2:
- return new Operand(cont->_statVariables[Context::PHYS_ARM_CUR], NUMBER);
+ return new Operand(cont->_statVariables[PHYS_ARM_CUR], NUMBER);
case 0xE3:
- return new Operand(cont->_statVariables[Context::PHYS_ACC_CUR], NUMBER);
+ return new Operand(cont->_statVariables[PHYS_ACC_CUR], NUMBER);
case 0xE4:
- return new Operand(cont->_statVariables[Context::SPIR_STR_CUR], NUMBER);
+ return new Operand(cont->_statVariables[SPIR_STR_CUR], NUMBER);
case 0xE5:
- return new Operand(cont->_statVariables[Context::SPIR_HIT_CUR], NUMBER);
+ return new Operand(cont->_statVariables[SPIR_HIT_CUR], NUMBER);
case 0xE6:
- return new Operand(cont->_statVariables[Context::SPIR_ARM_CUR], NUMBER);
+ return new Operand(cont->_statVariables[SPIR_ARM_CUR], NUMBER);
case 0xE7:
- return new Operand(cont->_statVariables[Context::SPIR_ACC_CUR], NUMBER);
+ return new Operand(cont->_statVariables[SPIR_ACC_CUR], NUMBER);
case 0xE8:
- return new Operand(cont->_statVariables[Context::PHYS_SPE_CUR], NUMBER);
+ return new Operand(cont->_statVariables[PHYS_SPE_CUR], NUMBER);
default:
if (operandType >= 0x20 && operandType < 0x80) {
_data->seek(-1, SEEK_CUR);
@@ -315,58 +315,58 @@ void Script::assign(byte operandType, int uservar, uint16 value) {
cont->_userVariables[uservar - 1] = value;
break;
case 0xD0:
- cont->_statVariables[Context::PHYS_STR_BAS] = value;
+ cont->_statVariables[PHYS_STR_BAS] = value;
break;
case 0xD1:
- cont->_statVariables[Context::PHYS_HIT_BAS] = value;
+ cont->_statVariables[PHYS_HIT_BAS] = value;
break;
case 0xD2:
- cont->_statVariables[Context::PHYS_ARM_BAS] = value;
+ cont->_statVariables[PHYS_ARM_BAS] = value;
break;
case 0xD3:
- cont->_statVariables[Context::PHYS_ACC_BAS] = value;
+ cont->_statVariables[PHYS_ACC_BAS] = value;
break;
case 0xD4:
- cont->_statVariables[Context::SPIR_STR_BAS] = value;
+ cont->_statVariables[SPIR_STR_BAS] = value;
break;
case 0xD5:
- cont->_statVariables[Context::SPIR_HIT_BAS] = value;
+ cont->_statVariables[SPIR_HIT_BAS] = value;
break;
case 0xD6:
- cont->_statVariables[Context::SPIR_ARM_BAS] = value;
+ cont->_statVariables[SPIR_ARM_BAS] = value;
break;
case 0xD7:
- cont->_statVariables[Context::SPIR_ACC_BAS] = value;
+ cont->_statVariables[SPIR_ACC_BAS] = value;
break;
case 0xD8:
- cont->_statVariables[Context::PHYS_SPE_BAS] = value;
+ cont->_statVariables[PHYS_SPE_BAS] = value;
break;
case 0xE0:
- cont->_statVariables[Context::PHYS_STR_CUR] = value;
+ cont->_statVariables[PHYS_STR_CUR] = value;
break;
case 0xE1:
- cont->_statVariables[Context::PHYS_HIT_CUR] = value;
+ cont->_statVariables[PHYS_HIT_CUR] = value;
break;
case 0xE2:
- cont->_statVariables[Context::PHYS_ARM_CUR] = value;
+ cont->_statVariables[PHYS_ARM_CUR] = value;
break;
case 0xE3:
- cont->_statVariables[Context::PHYS_ACC_CUR] = value;
+ cont->_statVariables[PHYS_ACC_CUR] = value;
break;
case 0xE4:
- cont->_statVariables[Context::SPIR_STR_CUR] = value;
+ cont->_statVariables[SPIR_STR_CUR] = value;
break;
case 0xE5:
- cont->_statVariables[Context::SPIR_HIT_CUR] = value;
+ cont->_statVariables[SPIR_HIT_CUR] = value;
break;
case 0xE6:
- cont->_statVariables[Context::SPIR_ARM_CUR] = value;
+ cont->_statVariables[SPIR_ARM_CUR] = value;
break;
case 0xE7:
- cont->_statVariables[Context::SPIR_ACC_CUR] = value;
+ cont->_statVariables[SPIR_ACC_CUR] = value;
break;
case 0xE8:
- cont->_statVariables[Context::PHYS_SPE_CUR] = value;
+ cont->_statVariables[PHYS_SPE_CUR] = value;
break;
default:
debug("No idea what I'm supposed to assign! (%x at %d)!\n", operandType, _data->pos()-1);
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index e4ce936..e7c37c1 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -419,13 +419,10 @@ void World::move(Chr *chr, Scene *scene, bool skipSort) {
Common::sort(scene->_chrs.begin(), scene->_chrs.end(), ChrComparator);
if (scene == _storageScene) {
- warning("STUB: World::move (chrState)");
- //chr.setState(new Chr.State(chr));
+ chr->resetState();
} else if (chr->_playerCharacter) {
scene->_visited = true;
- warning("STUB: World::move (visits)");
- //Context context = getPlayerContext();
- //context.setVisits(context.getVisits() + 1);
+ _player->_context._visits++;
}
chr->_currentScene = scene;
Commit: ac87bc9671822ce26e9dd4a5f77b23de83a71b63
https://github.com/scummvm/scummvm/commit/ac87bc9671822ce26e9dd4a5f77b23de83a71b63
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-01T01:46:27+01:00
Commit Message:
WAGE: Implement cursor drawing and handling
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/wage.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 3734def..92758c0 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -47,9 +47,11 @@
#include "common/system.h"
#include "common/unzip.h"
+#include "graphics/cursorman.h"
#include "graphics/fontman.h"
#include "graphics/font.h"
#include "graphics/fonts/bdf.h"
+#include "graphics/palette.h"
#include "wage/wage.h"
#include "wage/design.h"
#include "wage/entities.h"
@@ -64,7 +66,52 @@ enum {
kBorderWidth = 17
};
-byte checkers[8] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa };
+static const byte palette[] = {
+ 0, 0, 0, // Black
+ 0x80, 0x80, 0x80, // Gray
+ 0xff, 0xff, 0xff, // White
+ 0x00, 0xff, 0x00 // Green
+};
+
+static byte checkers[8] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa };
+
+static const byte macCursorArrow[] = {
+ 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 2, 0, 2, 3, 3, 3, 3, 3, 3, 3, 3,
+ 2, 0, 0, 2, 3, 3, 3, 3, 3, 3, 3,
+ 2, 0, 0, 0, 2, 3, 3, 3, 3, 3, 3,
+ 2, 0, 0, 0, 0, 2, 3, 3, 3, 3, 3,
+ 2, 0, 0, 0, 0, 0, 2, 3, 3, 3, 3,
+ 2, 0, 0, 0, 0, 0, 0, 2, 3, 3, 3,
+ 2, 0, 0, 0, 0, 0, 0, 0, 2, 3, 3,
+ 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3,
+ 2, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2,
+ 2, 0, 0, 2, 0, 0, 2, 3, 3, 3, 3,
+ 2, 0, 2, 3, 2, 0, 0, 2, 3, 3, 3,
+ 2, 2, 3, 3, 2, 0, 0, 2, 3, 3, 3,
+ 2, 3, 3, 3, 3, 2, 0, 0, 2, 3, 3,
+ 3, 3, 3, 3, 3, 2, 0, 0, 2, 3, 3,
+ 3, 3, 3, 3, 3, 3, 2, 2, 2, 3, 3
+};
+
+static const byte macCursorBeam[] = {
+ 0, 0, 3, 3, 3, 0, 0, 3, 3, 3, 3,
+ 3, 3, 0, 3, 0, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 0, 3, 0, 3, 3, 3, 3, 3, 3,
+ 0, 0, 3, 3, 3, 0, 0, 3, 3, 3, 3,
+};
Gui::Gui() {
_scene = NULL;
@@ -78,6 +125,13 @@ Gui::Gui() {
_scrollPos = 0;
_builtInFonts = false;
+ g_system->getPaletteManager()->setPalette(palette, 0, 4);
+
+ CursorMan.replaceCursorPalette(palette, 0, 4);
+ CursorMan.replaceCursor(macCursorArrow, 11, 16, 1, 1, 3);
+ _cursorIsArrow = true;
+ CursorMan.showMouse(true);
+
Design::drawFilledRect(&_screen, r, kColorBlack, p, 1);
loadFonts();
@@ -335,6 +389,11 @@ void Gui::renderConsole(Graphics::Surface *g, int x, int y, int width, int heigh
y1 += lineHeight;
}
+ _consoleTextArea.left = x;
+ _consoleTextArea.top = y;
+ _consoleTextArea.right = x + width;
+ _consoleTextArea.bottom = y + height;
+
g->copyRectToSurface(_console, x - kConOverscan, y - kConOverscan, boundsR);
}
@@ -380,4 +439,16 @@ void Gui::loadFonts() {
delete dat;
}
+void Gui::mouseMove(int x, int y) {
+ if (_consoleTextArea.contains(x, y)) {
+ if (_cursorIsArrow) {
+ CursorMan.replaceCursor(macCursorBeam, 11, 16, 3, 8, 3);
+ _cursorIsArrow = false;
+ }
+ } else if (_cursorIsArrow == false) {
+ CursorMan.replaceCursor(macCursorArrow, 11, 16, 1, 1, 3);
+ _cursorIsArrow = true;
+ }
+}
+
} // End of namespace Wage
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 91acfb3..216a63c 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -67,6 +67,7 @@ public:
void draw();
void setScene(Scene *scene);
void appendText(Common::String &str);
+ void mouseMove(int x, int y);
private:
void paintBorder(Graphics::Surface *g, int x, int y, int width, int height, WindowType windowType);
@@ -86,6 +87,9 @@ private:
uint _scrollPos;
bool _builtInFonts;
+
+ Common::Rect _consoleTextArea;
+ bool _cursorIsArrow;
};
} // End of namespace Wage
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index d398311..2ff0c66 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -56,7 +56,6 @@
#include "engines/engine.h"
#include "engines/util.h"
#include "gui/EventRecorder.h"
-#include "graphics/palette.h"
#include "wage/wage.h"
#include "wage/design.h"
@@ -86,18 +85,9 @@ WageEngine::~WageEngine() {
delete _rnd;
}
-static byte palette[] = {
- 0, 0, 0, // Black
- 0x80, 0x80, 0x80, // Gray
- 0xff, 0xff, 0xff, // White
- 0x00, 0xff, 0x00 // Green
-};
-
Common::Error WageEngine::run() {
initGraphics(512, 342, true);
- g_system->getPaletteManager()->setPalette(palette, 0, 4);
-
// Create debugger console. It requires GFX to be initialized
_console = new Console(this);
@@ -151,6 +141,9 @@ void WageEngine::processEvents() {
case Common::EVENT_QUIT:
error("Exiting");
break;
+ case Common::EVENT_MOUSEMOVE:
+ _gui->mouseMove(event.mouse.x, event.mouse.y);
+ break;
default:
break;
}
Commit: 03e3f80bffcb24c2524b62b6602aad8698315b42
https://github.com/scummvm/scummvm/commit/03e3f80bffcb24c2524b62b6602aad8698315b42
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-01T02:16:00+01:00
Commit Message:
WAGE: Mac has roundrect on desktop. Render it
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
engines/wage/gui.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index e65bbd4..555ab5e 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -436,12 +436,17 @@ void Design::drawFilledRect(Graphics::Surface *surface, Common::Rect &rect, int
drawHLine(rect.left, rect.right, y, color, drawPixel, &pd);
}
-
void Design::drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data) {
for (int y = rect.top; y <= rect.bottom; y++)
drawHLine(rect.left, rect.right, y, color, plotProc, data);
}
+void Design::drawFilledRoundRect(Graphics::Surface *surface, Common::Rect &rect, int arc, int color, Patterns &patterns, byte fillType) {
+ plotData pd(surface, &patterns, fillType);
+
+ drawFilledRoundRect(rect, arc, color, drawPixel, &pd);
+}
+
// http://members.chello.at/easyfilter/bresenham.html
void Design::drawFilledRoundRect(Common::Rect &rect, int arc, int color, void (*plotProc)(int, int, int, void *), void *data) {
if (rect.height() < rect.width()) {
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 8e79a84..f876d1b 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -69,6 +69,7 @@ public:
void paint(Graphics::Surface *canvas, Patterns &patterns, bool mask, int x, int y);
static void drawFilledRect(Graphics::Surface *surface, Common::Rect &rect, int color, Patterns &patterns, byte fillType);
+ static void drawFilledRoundRect(Graphics::Surface *surface, Common::Rect &rect, int arc, int color, Patterns &patterns, byte fillType);
private:
byte *_data;
@@ -88,12 +89,12 @@ private:
void drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool mask);
void drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data);
- void drawFilledRoundRect(Common::Rect &rect, int arc, int color, void (*plotProc)(int, int, int, void *), void *data);
+ static void drawFilledRoundRect(Common::Rect &rect, int arc, int color, void (*plotProc)(int, int, int, void *), void *data);
void drawPolygonScan(int *polyX, int *polyY, int npoints, Common::Rect &bbox, int color,
void (*plotProc)(int, int, int, void *), void *data);
void drawEllipse(int x0, int y0, int x1, int y1, bool filled, void (*plotProc)(int, int, int, void *), void *data);
static void drawHLine(int x1, int x2, int y, int color, void (*plotProc)(int, int, int, void *), void *data);
- void drawVLine(int x, int y1, int y2, int color, void (*plotProc)(int, int, int, void *), void *data);
+ static void drawVLine(int x, int y1, int y2, int color, void (*plotProc)(int, int, int, void *), void *data);
void drawThickLine (int x1, int y1, int x2, int y2, int thick, int color,
void (*plotProc)(int, int, int, void *), void *data);
};
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 92758c0..713a1c2 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -120,7 +120,6 @@ Gui::Gui() {
Patterns p;
p.push_back(checkers);
- Common::Rect r(0, 0, _screen.w, _screen.h);
_scrollPos = 0;
_builtInFonts = false;
@@ -132,7 +131,8 @@ Gui::Gui() {
_cursorIsArrow = true;
CursorMan.showMouse(true);
- Design::drawFilledRect(&_screen, r, kColorBlack, p, 1);
+ Common::Rect r(0, 0, _screen.w - 1, _screen.h - 1);
+ Design::drawFilledRoundRect(&_screen, r, 7, kColorBlack, p, 1);
loadFonts();
}
Commit: 1332958c9a951e74f1d3d93b4827c63ba052ad8f
https://github.com/scummvm/scummvm/commit/1332958c9a951e74f1d3d93b4827c63ba052ad8f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-01T02:23:43+01:00
Commit Message:
WAGE: Stub for menu drawing
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 713a1c2..0bf176a 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -63,7 +63,8 @@ enum {
kMenuHeight = 19,
kMenuPadding = 6,
kMenuItemHeight = 19,
- kBorderWidth = 17
+ kBorderWidth = 17,
+ kDesktopArc = 7
};
static const byte palette[] = {
@@ -73,7 +74,8 @@ static const byte palette[] = {
0x00, 0xff, 0x00 // Green
};
-static byte checkers[8] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa };
+static byte checkersPattern[8] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa };
+static byte fillPattern[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
static const byte macCursorArrow[] = {
2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3,
@@ -119,7 +121,7 @@ Gui::Gui() {
_screen.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8());
Patterns p;
- p.push_back(checkers);
+ p.push_back(checkersPattern);
_scrollPos = 0;
_builtInFonts = false;
@@ -131,8 +133,9 @@ Gui::Gui() {
_cursorIsArrow = true;
CursorMan.showMouse(true);
+ // Draw desktop
Common::Rect r(0, 0, _screen.w - 1, _screen.h - 1);
- Design::drawFilledRoundRect(&_screen, r, 7, kColorBlack, p, 1);
+ Design::drawFilledRoundRect(&_screen, r, kDesktopArc, kColorBlack, p, 1);
loadFonts();
}
@@ -188,6 +191,8 @@ void Gui::draw() {
paintBorder(&_screen, sceneW, kMenuHeight, _screen.w - sceneW, _scene->_design->getBounds()->height(),
kWindowConsole);
+ renderMenu();
+
// Blit to screen
g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, _screen.h);
}
@@ -451,4 +456,16 @@ void Gui::mouseMove(int x, int y) {
}
}
+void Gui::renderMenu() {
+ Common::Rect r(0, 0, _screen.w - 1, kMenuHeight - 1);
+ Patterns p;
+ p.push_back(fillPattern);
+
+ Design::drawFilledRoundRect(&_screen, r, kDesktopArc, kColorWhite, p, 1);
+ r.top = 7;
+ Design::drawFilledRect(&_screen, r, kColorWhite, p, 1);
+ r.top = kMenuHeight - 1;
+ Design::drawFilledRect(&_screen, r, kColorBlack, p, 1);
+}
+
} // End of namespace Wage
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 216a63c..9573f57 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -75,6 +75,7 @@ private:
void drawBox(Graphics::Surface *g, int x, int y, int w, int h);
void fillRect(Graphics::Surface *g, int x, int y, int w, int h);
void loadFonts();
+ void renderMenu();
private:
Graphics::Surface _screen;
Commit: 584dcae75cbd0dc5e5bfb4c762170376783b4cc4
https://github.com/scummvm/scummvm/commit/584dcae75cbd0dc5e5bfb4c762170376783b4cc4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-01T02:36:44+01:00
Commit Message:
WAGE: Pad windows to match the original
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 0bf176a..286f3b9 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -64,7 +64,8 @@ enum {
kMenuPadding = 6,
kMenuItemHeight = 19,
kBorderWidth = 17,
- kDesktopArc = 7
+ kDesktopArc = 7,
+ kComponentsPadding = 10
};
static const byte palette[] = {
@@ -175,8 +176,8 @@ void Gui::appendText(String &str) {
void Gui::draw() {
if (_scene != NULL && _sceneDirty) {
- _scene->paint(&_screen, 0, kMenuHeight);
- paintBorder(&_screen, 0, kMenuHeight, _scene->_design->getBounds()->width(), _scene->_design->getBounds()->height(),
+ _scene->paint(&_screen, 0 + kComponentsPadding, kMenuHeight + kComponentsPadding);
+ paintBorder(&_screen, 0 + kComponentsPadding, kMenuHeight + kComponentsPadding, _scene->_design->getBounds()->width(), _scene->_design->getBounds()->height(),
kWindowScene);
_sceneDirty = false;
@@ -184,12 +185,13 @@ void Gui::draw() {
// Render console
int sceneW = _scene->_design->getBounds()->width();
- int consoleW = _screen.w - sceneW - 2 * kBorderWidth;
- int consoleH = _scene->_design->getBounds()->height() - 2 * kBorderWidth;
+ int consoleW = _screen.w - sceneW - 2 * kComponentsPadding;
+ int consoleH = _scene->_design->getBounds()->height();
+ int consoleX = sceneW + kComponentsPadding;
+ int consoleY = kMenuHeight + kComponentsPadding;
- renderConsole(&_screen, sceneW + kBorderWidth, kMenuHeight + kBorderWidth, consoleW, consoleH);
- paintBorder(&_screen, sceneW, kMenuHeight, _screen.w - sceneW, _scene->_design->getBounds()->height(),
- kWindowConsole);
+ renderConsole(&_screen, consoleX + kBorderWidth , consoleY + kBorderWidth, consoleW - 2 * kBorderWidth, consoleH - 2 * kBorderWidth);
+ paintBorder(&_screen, consoleX, consoleY, consoleW, consoleH, kWindowConsole);
renderMenu();
Commit: 02a8291c5bce90b1d6a26580a5522258c97dd1aa
https://github.com/scummvm/scummvm/commit/02a8291c5bce90b1d6a26580a5522258c97dd1aa
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-01T02:49:23+01:00
Commit Message:
WAGE: Fix console padding
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 286f3b9..74315f7 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -319,8 +319,8 @@ void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height,
enum {
kConWOverlap = 20,
kConHOverlap = 20,
- kConWPadding = 2,
- kConHPadding = 10,
+ kConWPadding = 4,
+ kConHPadding = 4,
kConOverscan = 3,
kLineSpacing = 0
};
Commit: c65f15e7e4011f50b673e5c1c781fd64c689170e
https://github.com/scummvm/scummvm/commit/c65f15e7e4011f50b673e5c1c781fd64c689170e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-01T02:58:34+01:00
Commit Message:
WAGE: Fix console output for empty lines
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 74315f7..4f72611 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -319,7 +319,7 @@ void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height,
enum {
kConWOverlap = 20,
kConHOverlap = 20,
- kConWPadding = 4,
+ kConWPadding = 3,
kConHPadding = 4,
kConOverscan = 3,
kLineSpacing = 0
@@ -375,6 +375,9 @@ void Gui::renderConsole(Graphics::Surface *g, int x, int y, int width, int heigh
font->wordWrapText(_out[i], textW, wrappedLines);
+ if (wrappedLines.size() == 0) // Sometimes we have empty lines
+ _lines.push_back("");
+
for (Common::StringArray::const_iterator j = wrappedLines.begin(); j != wrappedLines.end(); ++j)
_lines.push_back(*j);
}
Commit: 559e486034cf978ff782e229ee13a24e0946e0e3
https://github.com/scummvm/scummvm/commit/559e486034cf978ff782e229ee13a24e0946e0e3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-01T13:09:39+01:00
Commit Message:
WAGE: Stub for rendering menu items
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 4f72611..631a2f7 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -461,6 +461,10 @@ void Gui::mouseMove(int x, int y) {
}
}
+static const char *menuItems[] = {
+ "\xf0", "File", "Edit", "Commands", "Weapons", 0
+};
+
void Gui::renderMenu() {
Common::Rect r(0, 0, _screen.w - 1, kMenuHeight - 1);
Patterns p;
@@ -471,6 +475,35 @@ void Gui::renderMenu() {
Design::drawFilledRect(&_screen, r, kColorWhite, p, 1);
r.top = kMenuHeight - 1;
Design::drawFilledRect(&_screen, r, kColorBlack, p, 1);
+
+ const Graphics::Font *font = NULL;
+ int y = 1;
+
+ if (!_builtInFonts) {
+ font = FontMan.getFontByName("Chicago-12");
+
+ if (!font)
+ warning("Cannot load font Chicago-12");
+ }
+
+ if (_builtInFonts || !font) {
+ font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
+ y = 3;
+ }
+
+ int x = 18;
+
+ for (int i = 0; menuItems[i]; i++) {
+ const char *s = menuItems[i];
+
+ if (i == 0 && _builtInFonts)
+ s = "\xa9"; // (c) Symbol as the most resembling apple
+
+ int w = font->getStringWidth(s);
+ font->drawString(&_screen, s, x, y, w, kColorBlack);
+
+ x += w + 13;
+ }
}
} // End of namespace Wage
Commit: 1ef7beb8e80797d79ef7aa33275f391b8642d51c
https://github.com/scummvm/scummvm/commit/1ef7beb8e80797d79ef7aa33275f391b8642d51c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-01T18:48:16+01:00
Commit Message:
WAGE: Stub for object clicking
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/wage.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 555ab5e..3b44566 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -169,6 +169,15 @@ void Design::paint(Graphics::Surface *surface, Patterns &patterns, bool mask, in
}
}
+bool Design::isPointOpaque(int x, int y) {
+ if (_surface == NULL)
+ error("Surface is null");
+
+ byte pixel = ((byte *)_surface->getBasePtr(x, y))[0];
+
+ return pixel != kColorGreen;
+}
+
void drawPixel(int x, int y, int color, void *data) {
plotData *p = (plotData *)data;
diff --git a/engines/wage/design.h b/engines/wage/design.h
index f876d1b..2a051f1 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -68,6 +68,7 @@ public:
}
void paint(Graphics::Surface *canvas, Patterns &patterns, bool mask, int x, int y);
+ bool isPointOpaque(int x, int y);
static void drawFilledRect(Graphics::Surface *surface, Common::Rect &rect, int color, Patterns &patterns, byte fillType);
static void drawFilledRoundRect(Graphics::Surface *surface, Common::Rect &rect, int arc, int color, Patterns &patterns, byte fillType);
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 631a2f7..789c350 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -119,6 +119,7 @@ static const byte macCursorBeam[] = {
Gui::Gui() {
_scene = NULL;
_sceneDirty = true;
+ _bordersDirty = true;
_screen.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8());
Patterns p;
@@ -126,6 +127,7 @@ Gui::Gui() {
_scrollPos = 0;
_builtInFonts = false;
+ _sceneIsActive = false;
g_system->getPaletteManager()->setPalette(palette, 0, 4);
@@ -177,8 +179,11 @@ void Gui::appendText(String &str) {
void Gui::draw() {
if (_scene != NULL && _sceneDirty) {
_scene->paint(&_screen, 0 + kComponentsPadding, kMenuHeight + kComponentsPadding);
- paintBorder(&_screen, 0 + kComponentsPadding, kMenuHeight + kComponentsPadding, _scene->_design->getBounds()->width(), _scene->_design->getBounds()->height(),
- kWindowScene);
+
+ _sceneArea.left = 0 + kComponentsPadding + kBorderWidth;
+ _sceneArea.top = kMenuHeight + kComponentsPadding + kBorderWidth;
+ _sceneArea.setWidth(_scene->_design->getBounds()->width() - 2 * kBorderWidth);
+ _sceneArea.setHeight(_scene->_design->getBounds()->height() - 2 * kBorderWidth);
_sceneDirty = false;
}
@@ -191,7 +196,15 @@ void Gui::draw() {
int consoleY = kMenuHeight + kComponentsPadding;
renderConsole(&_screen, consoleX + kBorderWidth , consoleY + kBorderWidth, consoleW - 2 * kBorderWidth, consoleH - 2 * kBorderWidth);
- paintBorder(&_screen, consoleX, consoleY, consoleW, consoleH, kWindowConsole);
+
+ if (_bordersDirty) {
+ if (_scene)
+ paintBorder(&_screen, 0 + kComponentsPadding, kMenuHeight + kComponentsPadding, _scene->_design->getBounds()->width(), _scene->_design->getBounds()->height(),
+ kWindowScene);
+ paintBorder(&_screen, consoleX, consoleY, consoleW, consoleH, kWindowConsole);
+
+ _bordersDirty = false;
+ }
renderMenu();
@@ -227,16 +240,16 @@ void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height,
switch (windowType) {
case kWindowScene:
- active = false;
+ active = _sceneIsActive;
scrollable = false;
- closeable = false;
+ closeable = _sceneIsActive;
closeBoxPressed = false;
drawTitle = true;
break;
case kWindowConsole:
- active = true;
+ active = !_sceneIsActive;
scrollable = true;
- closeable = true;
+ closeable = !_sceneIsActive;
closeBoxPressed = false;
drawTitle = false;
break;
@@ -506,4 +519,30 @@ void Gui::renderMenu() {
}
}
+Designed *Gui::getClickTarget(int x, int y) {
+ if (_sceneArea.contains(x, y)) {
+ if (!_sceneIsActive) {
+ _sceneIsActive = true;
+ _bordersDirty = true;
+ }
+
+ for (Common::List<Obj *>::const_iterator it = _scene->_objs.begin(); it != _scene->_objs.end(); ++it) {
+ if ((*it)->_design->isPointOpaque(x - _sceneArea.left + kBorderWidth, y - _sceneArea.top + kBorderWidth))
+ return *it;
+ }
+
+ for (Common::List<Chr *>::const_iterator it = _scene->_chrs.begin(); it != _scene->_chrs.end(); ++it) {
+ if ((*it)->_design->isPointOpaque(x - _sceneArea.left + kBorderWidth, y - _sceneArea.top + kBorderWidth))
+ return *it;
+ }
+ } else if (_consoleTextArea.contains(x, y)) {
+ if (_sceneIsActive) {
+ _sceneIsActive = false;
+ _bordersDirty = true;
+ }
+ }
+
+ return NULL;
+}
+
} // End of namespace Wage
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 9573f57..f5e1ef5 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -68,6 +68,7 @@ public:
void setScene(Scene *scene);
void appendText(Common::String &str);
void mouseMove(int x, int y);
+ Designed *getClickTarget(int x, int y);
private:
void paintBorder(Graphics::Surface *g, int x, int y, int width, int height, WindowType windowType);
@@ -82,6 +83,7 @@ private:
Graphics::Surface _console;
Scene *_scene;
bool _sceneDirty;
+ bool _bordersDirty;
Common::StringArray _out;
Common::StringArray _lines;
@@ -90,6 +92,8 @@ private:
bool _builtInFonts;
Common::Rect _consoleTextArea;
+ Common::Rect _sceneArea;
+ bool _sceneIsActive;
bool _cursorIsArrow;
};
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 2ff0c66..bc0aff7 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -144,6 +144,14 @@ void WageEngine::processEvents() {
case Common::EVENT_MOUSEMOVE:
_gui->mouseMove(event.mouse.x, event.mouse.y);
break;
+ case Common::EVENT_LBUTTONDOWN:
+ break;
+ case Common::EVENT_LBUTTONUP:
+ {
+ Designed *obj = _gui->getClickTarget(event.mouse.x, event.mouse.y);
+ if (obj != NULL)
+ debug(0, "Clicked: %s", obj->_name.c_str());
+ }
default:
break;
}
Commit: 2e6732171d6dcec60eaaead55de28d18d5427941
https://github.com/scummvm/scummvm/commit/2e6732171d6dcec60eaaead55de28d18d5427941
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-02T00:55:45+01:00
Commit Message:
WAGE: More work on object interaction
Changed paths:
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/wage.cpp
engines/wage/wage.h
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index f9a68d6..614b831 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -390,5 +390,15 @@ int Chr::wearObjIfPossible(Obj *obj) {
return -1;
}
+String &Chr::getNameWithDefiniteArticle(bool capitalize) {
+ Common::String *res = new Common::String;
+
+ if (!_nameProperNoun)
+ *res += capitalize ? "The " : "the ";
+ *res += _name;
+
+ return *res;
+}
+
} // End of namespace Wage
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 5c1a902..f6cb525 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -215,6 +215,7 @@ public:
Context _context;
WeaponArray *getWeapons();
+ String &getNameWithDefiniteArticle(bool capitalize);
public:
#if 0
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 789c350..8ec904e 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -153,6 +153,10 @@ void Gui::setScene(Scene *scene) {
_scene = scene;
}
+void Gui::clearOutput() {
+ _out.clear();
+}
+
void Gui::appendText(String &str) {
if (!str.contains('\n')) {
_out.push_back(str);
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index f5e1ef5..25629f6 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -67,6 +67,7 @@ public:
void draw();
void setScene(Scene *scene);
void appendText(Common::String &str);
+ void clearOutput();
void mouseMove(int x, int y);
Designed *getClickTarget(int x, int y);
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index bc0aff7..e492bdb 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -73,8 +73,11 @@ WageEngine::WageEngine(OSystem *syst, const ADGameDescription *desc) : Engine(sy
_temporarilyHidden = false;
_isGameOver = false;
_monster = NULL;
+ _running = NULL;
_lastScene = NULL;
+ _commandWasQuick = false;
+
debug("WageEngine::WageEngine()");
}
@@ -150,7 +153,7 @@ void WageEngine::processEvents() {
{
Designed *obj = _gui->getClickTarget(event.mouse.x, event.mouse.y);
if (obj != NULL)
- debug(0, "Clicked: %s", obj->_name.c_str());
+ processTurn(NULL, obj);
}
default:
break;
@@ -305,6 +308,10 @@ void WageEngine::encounter(Chr *player, Chr *chr) {
warning("STUB WageEngine::encounter()");
}
+void WageEngine::performCombatAction(Chr *npc, Chr *player) {
+ warning("STUB WageEngine::performCombatAction()");
+}
+
void WageEngine::redrawScene() {
Scene *currentScene = _world->_player->_currentScene;
if (currentScene != NULL) {
@@ -323,4 +330,104 @@ void WageEngine::redrawScene() {
}
}
+void WageEngine::regen() {
+ warning("STUB WageEngine::regen()");
+}
+
+void WageEngine::processTurnInternal(Common::String *textInput, Designed *clickInput) {
+ Scene *playerScene = _world->_player->_currentScene;
+ if (playerScene == _world->_storageScene)
+ return;
+
+ bool shouldEncounter = false;
+
+ if (playerScene != _lastScene) {
+ _loopCount = 0;
+ _lastScene = playerScene;
+ _monster = NULL;
+ _running = NULL;
+ _offer = NULL;
+
+ for (Common::List<Chr *>::const_iterator it = playerScene->_chrs.begin(); it != playerScene->_chrs.end(); ++it) {
+ if (!(*it)->_playerCharacter) {
+ _monster = *it;
+ shouldEncounter = true;
+ break;
+ }
+ }
+ }
+
+ bool monsterWasNull = (_monster == NULL);
+ bool handled = playerScene->_script->execute(_world, _loopCount++, textInput, clickInput, this);
+
+ playerScene = _world->_player->_currentScene;
+
+ if (playerScene == _world->_storageScene)
+ return;
+
+ if (playerScene != _lastScene) {
+ _temporarilyHidden = true;
+ _gui->clearOutput();
+ regen();
+ Common::String input("look");
+ processTurnInternal(&input, NULL);
+ redrawScene();
+ _temporarilyHidden = false;
+ } else if (_loopCount == 1) {
+ redrawScene();
+ if (shouldEncounter && _monster != NULL) {
+ encounter(_world->_player, _monster);
+ }
+ } else if (textInput != NULL && !handled) {
+ if (monsterWasNull && _monster != NULL)
+ return;
+
+ Common::String rant(_rnd->getRandomNumber(1) ? "What?" : "Huh?");
+
+ appendText(rant);
+ _commandWasQuick = true;
+ }
+}
+
+void WageEngine::processTurn(Common::String *textInput, Designed *clickInput) {
+ _commandWasQuick = false;
+ Scene *prevScene = _world->_player->_currentScene;
+ Chr *prevMonster = _monster;
+ processTurnInternal(textInput, clickInput);
+ Scene *playerScene = _world->_player->_currentScene;
+
+ if (prevScene != playerScene && playerScene != _world->_storageScene) {
+ if (prevMonster != NULL) {
+ bool followed = false;
+ if (_monster == NULL) {
+ warning("STUB: processTurn(), monster");
+ //Set<Scene> scenes = world.getAdjacentScenes(prevMonster.getState().getCurrentScene());
+ // TODO: adjacent scenes doesn't contain up/down etc... verify that monsters can't follow these...
+ //if (scenes.contains(playerScene)) {
+ // int chance = (int) (Math.random() * 255);
+ // followed = (chance < prevMonster.getFollowsOpponent());
+ //}
+ }
+
+ Common::String msg;
+
+ if (followed) {
+ msg = prevMonster->getNameWithDefiniteArticle(true);
+ msg += " follows you.";
+ appendText(msg);
+ _world->move(prevMonster, playerScene);
+ } else {
+ msg = "You escape ";
+ msg += prevMonster->getNameWithDefiniteArticle(false);
+ msg += ".";
+ appendText(msg);
+ }
+ }
+ }
+ if (!_commandWasQuick && _monster != NULL) {
+ performCombatAction(_monster, _world->_player);
+ }
+}
+
+
} // End of namespace Wage
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 3e29471..e96e298 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -119,6 +119,10 @@ private:
bool loadWorld(Common::MacResManager *resMan);
void performInitialSetup();
void wearObjs(Chr *chr);
+ void processTurn(Common::String *textInput, Designed *clickInput);
+ void processTurnInternal(Common::String *textInput, Designed *clickInput);
+ void regen();
+ void performCombatAction(Chr *npc, Chr *player);
public:
Common::RandomSource *_rnd;
@@ -131,8 +135,8 @@ public:
int _loopCount;
int _turn;
Chr *_monster;
+ Chr *_running;
Obj *_offer;
- bool _commandWasQuick;
int _aim;
bool _temporarilyHidden;
bool _isGameOver;
@@ -156,6 +160,8 @@ private:
Common::MacResManager *_resManager;
+ bool _commandWasQuick;
+
};
// Example console class
Commit: e825eadb80794ea9bdf767b5f9c0e897502a7666
https://github.com/scummvm/scummvm/commit/e825eadb80794ea9bdf767b5f9c0e897502a7666
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-02T02:39:47+01:00
Commit Message:
WAGE: Made Gui autosense scene change
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/wage.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 8ec904e..c2b0223 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -56,6 +56,7 @@
#include "wage/design.h"
#include "wage/entities.h"
#include "wage/gui.h"
+#include "wage/world.h"
namespace Wage {
@@ -116,7 +117,8 @@ static const byte macCursorBeam[] = {
0, 0, 3, 3, 3, 0, 0, 3, 3, 3, 3,
};
-Gui::Gui() {
+Gui::Gui(WageEngine *engine) {
+ _engine = engine;
_scene = NULL;
_sceneDirty = true;
_bordersDirty = true;
@@ -146,13 +148,6 @@ Gui::Gui() {
Gui::~Gui() {
}
-void Gui::setScene(Scene *scene) {
- if (_scene != scene)
- _sceneDirty = true;
-
- _scene = scene;
-}
-
void Gui::clearOutput() {
_out.clear();
}
@@ -181,7 +176,9 @@ void Gui::appendText(String &str) {
}
void Gui::draw() {
- if (_scene != NULL && _sceneDirty) {
+ if (_scene != _engine->_world->_player->_currentScene || _sceneDirty) {
+ _scene = _engine->_world->_player->_currentScene;
+
_scene->paint(&_screen, 0 + kComponentsPadding, kMenuHeight + kComponentsPadding);
_sceneArea.left = 0 + kComponentsPadding + kBorderWidth;
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 25629f6..dc04e90 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -61,11 +61,10 @@ enum WindowType {
class Gui {
public:
- Gui();
+ Gui(WageEngine *engine);
~Gui();
void draw();
- void setScene(Scene *scene);
void appendText(Common::String &str);
void clearOutput();
void mouseMove(int x, int y);
@@ -80,6 +79,7 @@ private:
void renderMenu();
private:
+ WageEngine *_engine;
Graphics::Surface _screen;
Graphics::Surface _console;
Scene *_scene;
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index e492bdb..1f4c372 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -96,7 +96,7 @@ Common::Error WageEngine::run() {
debug("WageEngine::init");
- _gui = new Gui();
+ _gui = new Gui(this);
// Your main event loop should be (invoked from) here.
_resManager = new Common::MacResManager();
@@ -116,7 +116,6 @@ Common::Error WageEngine::run() {
_world->_player->_currentScene = _world->_orderedScenes[1];
_world->_globalScript->execute(_world, 1, &input, NULL, this);
- _gui->setScene(_world->_orderedScenes[1]);
_gui->draw();
while (true) {
Commit: 31e4f810c6b9a3d8ab7b202f4ceb73f699e38d08
https://github.com/scummvm/scummvm/commit/31e4f810c6b9a3d8ab7b202f4ceb73f699e38d08
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-02T02:42:15+01:00
Commit Message:
WAGE: Fixed game loop
Changed paths:
engines/wage/wage.cpp
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 1f4c372..07fe30e 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -112,14 +112,12 @@ Common::Error WageEngine::run() {
_temporarilyHidden = false;
Common::String input("look");
-
- _world->_player->_currentScene = _world->_orderedScenes[1];
_world->_globalScript->execute(_world, 1, &input, NULL, this);
- _gui->draw();
-
while (true) {
processEvents();
+
+ _gui->draw();
g_system->updateScreen();
g_system->delayMillis(50);
}
Commit: 8d6e8118423088ba5c126e2cedf79bb3f41492f6
https://github.com/scummvm/scummvm/commit/8d6e8118423088ba5c126e2cedf79bb3f41492f6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-02T02:53:30+01:00
Commit Message:
WAGE: Redraw Gui parts on demand
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index c2b0223..92f05f0 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -121,7 +121,9 @@ Gui::Gui(WageEngine *engine) {
_engine = engine;
_scene = NULL;
_sceneDirty = true;
+ _consoleDirty = true;
_bordersDirty = true;
+ _menuDirty = true;
_screen.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8());
Patterns p;
@@ -153,6 +155,8 @@ void Gui::clearOutput() {
}
void Gui::appendText(String &str) {
+ _consoleDirty = true;
+
if (!str.contains('\n')) {
_out.push_back(str);
return;
@@ -178,6 +182,7 @@ void Gui::appendText(String &str) {
void Gui::draw() {
if (_scene != _engine->_world->_player->_currentScene || _sceneDirty) {
_scene = _engine->_world->_player->_currentScene;
+ _sceneDirty = true;
_scene->paint(&_screen, 0 + kComponentsPadding, kMenuHeight + kComponentsPadding);
@@ -185,10 +190,13 @@ void Gui::draw() {
_sceneArea.top = kMenuHeight + kComponentsPadding + kBorderWidth;
_sceneArea.setWidth(_scene->_design->getBounds()->width() - 2 * kBorderWidth);
_sceneArea.setHeight(_scene->_design->getBounds()->height() - 2 * kBorderWidth);
-
- _sceneDirty = false;
}
+ if (_scene && (_bordersDirty || _sceneDirty))
+ paintBorder(&_screen, 0 + kComponentsPadding, kMenuHeight + kComponentsPadding, _scene->_design->getBounds()->width(), _scene->_design->getBounds()->height(),
+ kWindowScene);
+
+
// Render console
int sceneW = _scene->_design->getBounds()->width();
int consoleW = _screen.w - sceneW - 2 * kComponentsPadding;
@@ -196,18 +204,19 @@ void Gui::draw() {
int consoleX = sceneW + kComponentsPadding;
int consoleY = kMenuHeight + kComponentsPadding;
- renderConsole(&_screen, consoleX + kBorderWidth , consoleY + kBorderWidth, consoleW - 2 * kBorderWidth, consoleH - 2 * kBorderWidth);
+ if (_consoleDirty)
+ renderConsole(&_screen, consoleX + kBorderWidth , consoleY + kBorderWidth, consoleW - 2 * kBorderWidth, consoleH - 2 * kBorderWidth);
- if (_bordersDirty) {
- if (_scene)
- paintBorder(&_screen, 0 + kComponentsPadding, kMenuHeight + kComponentsPadding, _scene->_design->getBounds()->width(), _scene->_design->getBounds()->height(),
- kWindowScene);
+ if (_bordersDirty || _consoleDirty)
paintBorder(&_screen, consoleX, consoleY, consoleW, consoleH, kWindowConsole);
- _bordersDirty = false;
- }
+ if (_menuDirty)
+ renderMenu();
- renderMenu();
+ _sceneDirty = false;
+ _consoleDirty = false;
+ _bordersDirty = false;
+ _menuDirty = false;
// Blit to screen
g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, _screen.h);
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index dc04e90..2fa9e7a 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -84,7 +84,9 @@ private:
Graphics::Surface _console;
Scene *_scene;
bool _sceneDirty;
+ bool _consoleDirty;
bool _bordersDirty;
+ bool _menuDirty;
Common::StringArray _out;
Common::StringArray _lines;
Commit: 0870ac88b8ce03753bf6114d2c0a76f5a638b61d
https://github.com/scummvm/scummvm/commit/0870ac88b8ce03753bf6114d2c0a76f5a638b61d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-02T12:55:22+01:00
Commit Message:
WAGE: Implement evalClickCondition
Changed paths:
engines/wage/script.cpp
engines/wage/script.h
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 778c0c8..13b2617 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -749,10 +749,51 @@ Script::Operand *Script::convertOperand(Operand *operand, int type) {
return NULL;
}
+bool Script::evalClickEquality(Operand *lhs, Operand *rhs, bool partialMatch) {
+ bool result = false;
+ if (lhs->_value.obj == NULL || rhs->_value.obj == NULL) {
+ result = false;
+ } else if (lhs->_value.obj == rhs->_value.obj) {
+ result = true;
+ } else if (rhs->_type == STRING) {
+ Common::String str = rhs->toString();
+ str.toLowercase();
+
+ if (lhs->_type == CHR || lhs->_type == OBJ) {
+ Common::String name = lhs->_value.designed->_name;
+ name.toLowercase();
+
+ if (partialMatch)
+ result = name.contains(str);
+ else
+ result = name.equals(str);
+ }
+ }
+ return result;
+}
+
bool Script::evalClickCondition(Operand *lhs, const char *op, Operand *rhs) {
- warning("STUB: evalClickCondition");
+ // TODO: check if >> can be used for click inputs
+ if (strcmp(op, "==") && strcmp(op, "=") && strcmp(op, "<") && strcmp(op, ">")) {
+ error("Unknown operation '%s' for Script::evalClickCondition", op);
+ }
- return false;
+ bool partialMatch = strcmp(op, "==");
+ bool result;
+ if (lhs->_type == CLICK_INPUT) {
+ result = evalClickEquality(lhs, rhs, partialMatch);
+ } else {
+ result = evalClickEquality(rhs, lhs, partialMatch);
+ }
+ if (!strcmp(op, "<") || !strcmp(op, ">")) {
+ // CLICK$<FOO only matches if there was a click
+ if (_inputClick == NULL) {
+ result = false;
+ } else {
+ result = !result;
+ }
+ }
+ return result;
}
void Script::takeObj(Obj *obj) {
diff --git a/engines/wage/script.h b/engines/wage/script.h
index 0cf6785..876ec07 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -70,6 +70,7 @@ private:
union {
Obj *obj;
Chr *chr;
+ Designed *designed;
Scene *scene;
int16 number;
String *string;
@@ -156,6 +157,7 @@ private:
bool eval(Operand *lhs, const char *op, Operand *rhs);
Operand *convertOperand(Operand *operand, int type);
bool evalClickCondition(Operand *lhs, const char *op, Operand *rhs);
+ bool evalClickEquality(Operand *lhs, Operand *rhs, bool partialMatch);
void takeObj(Obj *obj);
void processMove();
void processLet();
Commit: c6a83d1e06fd96e49c8500306fd7d45de2c45e72
https://github.com/scummvm/scummvm/commit/c6a83d1e06fd96e49c8500306fd7d45de2c45e72
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-03T00:28:37+01:00
Commit Message:
WAGE: Proper game start
Changed paths:
engines/wage/wage.cpp
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 07fe30e..5ab49ea 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -112,7 +112,7 @@ Common::Error WageEngine::run() {
_temporarilyHidden = false;
Common::String input("look");
- _world->_globalScript->execute(_world, 1, &input, NULL, this);
+ processTurn(&input, NULL);
while (true) {
processEvents();
Commit: a210ff65a369b3463457470935d4eaf4679b0535
https://github.com/scummvm/scummvm/commit/a210ff65a369b3463457470935d4eaf4679b0535
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-03T00:29:18+01:00
Commit Message:
WAGE; Fix stringOp reading
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 13b2617..0a55360 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -379,12 +379,14 @@ Script::Operand *Script::readStringOperand() {
sb = new String();
- byte c = 0x20;
- while (c >= 0x20 && c < 0x80) {
- c = _data->readByte();
+ while (true) {
+ byte c = _data->readByte();
if (c < '0' || c > '9')
allDigits = false;
- *sb += c;
+ if (c >= 0x20 && c < 0x80)
+ *sb += c;
+ else
+ break;
}
_data->seek(-1, SEEK_CUR);
Commit: 8ce82bd8b8242a9bacbab450322b0d0a2072f284
https://github.com/scummvm/scummvm/commit/8ce82bd8b8242a9bacbab450322b0d0a2072f284
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-03T00:30:57+01:00
Commit Message:
WAGE: Fix ifClick conditional
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 0a55360..d9d9252 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -761,7 +761,7 @@ bool Script::evalClickEquality(Operand *lhs, Operand *rhs, bool partialMatch) {
Common::String str = rhs->toString();
str.toLowercase();
- if (lhs->_type == CHR || lhs->_type == OBJ) {
+ if (lhs->_value.inputClick->_classType == CHR || lhs->_value.inputClick->_classType == OBJ) {
Common::String name = lhs->_value.designed->_name;
name.toLowercase();
Commit: b1a558f53cc9125cce4c3621e3020753a1bc5d24
https://github.com/scummvm/scummvm/commit/b1a558f53cc9125cce4c3621e3020753a1bc5d24
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-03T00:52:07+01:00
Commit Message:
WAGE: Fix number parsing
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index d9d9252..1a772df 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -381,12 +381,12 @@ Script::Operand *Script::readStringOperand() {
while (true) {
byte c = _data->readByte();
- if (c < '0' || c > '9')
- allDigits = false;
if (c >= 0x20 && c < 0x80)
*sb += c;
else
break;
+ if (c < '0' || c > '9')
+ allDigits = false;
}
_data->seek(-1, SEEK_CUR);
Commit: c3f20695ee85d491688c8173b9f54490527d504c
https://github.com/scummvm/scummvm/commit/c3f20695ee85d491688c8173b9f54490527d504c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-03T00:52:33+01:00
Commit Message:
WAGE: Less intrusive stub
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 1a772df..a11cc48 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -574,7 +574,8 @@ bool Script::compare(Operand *o1, Operand *o2, int comparator) {
error("FIXME kCompEqChrScene");
//return o2->_value.scene->_chrs.contains(*o1->_value.chr);
case kCompEqObjChr:
- error("FIXME kCompEqObjChr");
+ warning("FIXME kCompEqObjChr");
+ return false;
//return o2->_value.chr->_inventory.contains(*o1->_value.obj);
case kCompEqChrChr:
return o1->_value.chr == o2->_value.chr;
Commit: 330f4417e56fea4f004b756d20e43f08221566a5
https://github.com/scummvm/scummvm/commit/330f4417e56fea4f004b756d20e43f08221566a5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-03T00:52:52+01:00
Commit Message:
WAGE: More debug output
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index a11cc48..1e29f56 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -762,15 +762,22 @@ bool Script::evalClickEquality(Operand *lhs, Operand *rhs, bool partialMatch) {
Common::String str = rhs->toString();
str.toLowercase();
+ debug(9, "evalClickEquality(%s, %s, %d)", lhs->_value.designed->_name.c_str(), rhs->_value.designed->_name.c_str(), partialMatch);
+ debug(9, "l: %d r: %d (ch: %d ob: %d)", lhs->_type, rhs->_type, CHR, OBJ);
+ debug(9, "class: %d", lhs->_value.inputClick->_classType);
+
if (lhs->_value.inputClick->_classType == CHR || lhs->_value.inputClick->_classType == OBJ) {
Common::String name = lhs->_value.designed->_name;
name.toLowercase();
+ warning("%s <> %s", name.c_str(), str.c_str());
if (partialMatch)
result = name.contains(str);
else
result = name.equals(str);
}
+
+ debug(9, "result: %d", result);
}
return result;
}
Commit: 077048032b493c5ee81c0ccefaea9acac1a964ba
https://github.com/scummvm/scummvm/commit/077048032b493c5ee81c0ccefaea9acac1a964ba
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-03T12:23:17+01:00
Commit Message:
WAGE: Refactored coordinate manipulation
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 92f05f0..bfafe0b 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -159,6 +159,7 @@ void Gui::appendText(String &str) {
if (!str.contains('\n')) {
_out.push_back(str);
+ flowText(str);
return;
}
@@ -169,6 +170,7 @@ void Gui::appendText(String &str) {
for (int i = 0; i < str.size(); i++) {
if (str[i] == '\n') {
_out.push_back(tmp);
+ flowText(tmp);
tmp = "";
continue;
}
@@ -177,6 +179,7 @@ void Gui::appendText(String &str) {
}
_out.push_back(tmp);
+ flowText(tmp);
}
void Gui::draw() {
@@ -190,25 +193,29 @@ void Gui::draw() {
_sceneArea.top = kMenuHeight + kComponentsPadding + kBorderWidth;
_sceneArea.setWidth(_scene->_design->getBounds()->width() - 2 * kBorderWidth);
_sceneArea.setHeight(_scene->_design->getBounds()->height() - 2 * kBorderWidth);
+
+ int sceneW = _scene->_design->getBounds()->width();
+ int consoleW = _screen.w - sceneW - 2 * kComponentsPadding - 2 * kBorderWidth;
+ int consoleH = _scene->_design->getBounds()->height() - 2 * kBorderWidth;
+ int consoleX = sceneW + kComponentsPadding + kBorderWidth;
+ int consoleY = kMenuHeight + kComponentsPadding + kBorderWidth;
+
+ _consoleTextArea.left = consoleX;
+ _consoleTextArea.top = consoleY;
+ _consoleTextArea.right = consoleX + consoleW;
+ _consoleTextArea.bottom = consoleY + consoleH;
}
if (_scene && (_bordersDirty || _sceneDirty))
- paintBorder(&_screen, 0 + kComponentsPadding, kMenuHeight + kComponentsPadding, _scene->_design->getBounds()->width(), _scene->_design->getBounds()->height(),
- kWindowScene);
+ paintBorder(&_screen, _sceneArea, kWindowScene);
// Render console
- int sceneW = _scene->_design->getBounds()->width();
- int consoleW = _screen.w - sceneW - 2 * kComponentsPadding;
- int consoleH = _scene->_design->getBounds()->height();
- int consoleX = sceneW + kComponentsPadding;
- int consoleY = kMenuHeight + kComponentsPadding;
-
if (_consoleDirty)
- renderConsole(&_screen, consoleX + kBorderWidth , consoleY + kBorderWidth, consoleW - 2 * kBorderWidth, consoleH - 2 * kBorderWidth);
+ renderConsole(&_screen, _consoleTextArea);
if (_bordersDirty || _consoleDirty)
- paintBorder(&_screen, consoleX, consoleY, consoleW, consoleH, kWindowConsole);
+ paintBorder(&_screen, _consoleTextArea, kWindowConsole);
if (_menuDirty)
renderMenu();
@@ -245,8 +252,13 @@ const int arrowPixels[ARROW_H][ARROW_W] = {
{0,1,1,1,1,1,1,1,1,1,1,0},
{1,1,1,1,1,1,1,1,1,1,1,1}};
-void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height, WindowType windowType) {
+void Gui::paintBorder(Graphics::Surface *g, Common::Rect &r, WindowType windowType) {
bool active, scrollable, closeable, closeBoxPressed, drawTitle;
+ const int size = kBorderWidth;
+ int x = r.left - size;
+ int y = r.top - size;
+ int width = r.width() + 2 * size;
+ int height = r.height() + 2 * size;
switch (windowType) {
case kWindowScene:
@@ -265,7 +277,6 @@ void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height,
break;
}
- const int size = kBorderWidth;
drawBox(g, x, y, size, size);
drawBox(g, x+width-size-1, y, size, size);
drawBox(g, x+width-size-1, y+height-size-1, size, size);
@@ -348,14 +359,43 @@ enum {
kLineSpacing = 0
};
-void Gui::renderConsole(Graphics::Surface *g, int x, int y, int width, int height) {
+void Gui::flowText(String &str) {
+ Common::StringArray wrappedLines;
+ int textW = _consoleTextArea.width() - kConWPadding * 2;
+
+ const Graphics::Font *font;
+
+ if (!_builtInFonts) {
+ char fontName[128];
+ Scene *scene = _engine->_world->_player->_currentScene;
+
+ snprintf(fontName, 128, "%s-%d", scene->getFontName(), scene->_fontSize);
+ font = FontMan.getFontByName(fontName);
+
+ if (!font)
+ warning("Cannot load font %s", fontName);
+ }
+
+ if (_builtInFonts || !font)
+ font = FontMan.getFontByUsage(Graphics::FontManager::kConsoleFont);
+
+ font->wordWrapText(str, textW, wrappedLines);
+
+ if (wrappedLines.size() == 0) // Sometimes we have empty lines
+ _lines.push_back("");
+
+ for (Common::StringArray::const_iterator j = wrappedLines.begin(); j != wrappedLines.end(); ++j)
+ _lines.push_back(*j);
+}
+
+void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) {
bool fullRedraw = false;
bool textReflow = false;
- int surfW = width + kConWOverlap * 2;
- int surfH = height + kConHOverlap * 2;
+ int surfW = r.width() + kConWOverlap * 2;
+ int surfH = r.height() + kConHOverlap * 2;
Common::Rect boundsR(kConWOverlap - kConOverscan, kConHOverlap - kConOverscan,
- width + kConWOverlap + kConOverscan, height + kConHOverlap + kConOverscan);
+ r.width() + kConWOverlap + kConOverscan, r.height() + kConHOverlap + kConOverscan);
Common::Rect fullR(0, 0, surfW, surfH);
if (_console.w != surfW || _console.h != surfH) {
@@ -387,23 +427,14 @@ void Gui::renderConsole(Graphics::Surface *g, int x, int y, int width, int heigh
font = FontMan.getFontByUsage(Graphics::FontManager::kConsoleFont);
int lineHeight = font->getFontHeight() + kLineSpacing;
- int textW = width - kConWPadding * 2;
- int textH = height - kConHPadding * 2;
+ int textW = r.width() - kConWPadding * 2;
+ int textH = r.height() - kConHPadding * 2;
if (textReflow) {
_lines.clear();
- for (int i = 0; i < _out.size(); i++) {
- Common::StringArray wrappedLines;
-
- font->wordWrapText(_out[i], textW, wrappedLines);
-
- if (wrappedLines.size() == 0) // Sometimes we have empty lines
- _lines.push_back("");
-
- for (Common::StringArray::const_iterator j = wrappedLines.begin(); j != wrappedLines.end(); ++j)
- _lines.push_back(*j);
- }
+ for (int i = 0; i < _out.size(); i++)
+ flowText(_out[i]);
}
const int firstLine = _scrollPos / lineHeight;
@@ -422,12 +453,7 @@ void Gui::renderConsole(Graphics::Surface *g, int x, int y, int width, int heigh
y1 += lineHeight;
}
- _consoleTextArea.left = x;
- _consoleTextArea.top = y;
- _consoleTextArea.right = x + width;
- _consoleTextArea.bottom = y + height;
-
- g->copyRectToSurface(_console, x - kConOverscan, y - kConOverscan, boundsR);
+ g->copyRectToSurface(_console, r.left - kConOverscan, r.top - kConOverscan, boundsR);
}
void Gui::loadFonts() {
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 2fa9e7a..28e1934 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -71,12 +71,13 @@ public:
Designed *getClickTarget(int x, int y);
private:
- void paintBorder(Graphics::Surface *g, int x, int y, int width, int height, WindowType windowType);
- void renderConsole(Graphics::Surface *g, int x, int y, int width, int height);
+ void paintBorder(Graphics::Surface *g, Common::Rect &r, WindowType windowType);
+ void renderConsole(Graphics::Surface *g, Common::Rect &r);
void drawBox(Graphics::Surface *g, int x, int y, int w, int h);
void fillRect(Graphics::Surface *g, int x, int y, int w, int h);
void loadFonts();
void renderMenu();
+ void flowText(Common::String &str);
private:
WageEngine *_engine;
Commit: 2aef67c0acdffea281daf5cea3aac055bee17d05
https://github.com/scummvm/scummvm/commit/2aef67c0acdffea281daf5cea3aac055bee17d05
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-03T12:39:29+01:00
Commit Message:
WAGE: Refactored font querying
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index bfafe0b..6a67984 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -150,6 +150,39 @@ Gui::Gui(WageEngine *engine) {
Gui::~Gui() {
}
+const Graphics::Font *Gui::getFont(const char *name, Graphics::FontManager::FontUsage fallback) {
+ const Graphics::Font *font;
+
+ if (!_builtInFonts) {
+ font = FontMan.getFontByName(name);
+
+ if (!font)
+ warning("Cannot load font %s", name);
+ }
+
+ if (_builtInFonts || !font)
+ font = FontMan.getFontByUsage(fallback);
+
+ return font;
+}
+
+const Graphics::Font *Gui::getConsoleFont() {
+ char fontName[128];
+ Scene *scene = _engine->_world->_player->_currentScene;
+
+ snprintf(fontName, 128, "%s-%d", scene->getFontName(), scene->_fontSize);
+
+ return getFont(fontName, Graphics::FontManager::kConsoleFont);
+}
+
+const Graphics::Font *Gui::getMenuFont() {
+ return getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
+}
+
+const Graphics::Font *Gui::getTitleFont() {
+ return getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
+}
+
void Gui::clearOutput() {
_out.clear();
}
@@ -326,20 +359,8 @@ void Gui::paintBorder(Graphics::Surface *g, Common::Rect &r, WindowType windowTy
}
if (drawTitle) {
- const Graphics::Font *font;
- int yOff = 1;
-
- if (!_builtInFonts) {
- font = FontMan.getFontByName("Chicago-12");
-
- if (!font)
- warning("Cannot load font Chicago-12");
- }
-
- if (_builtInFonts || !font) {
- font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
- yOff = 3;
- }
+ const Graphics::Font *font = getTitleFont();
+ int yOff = _builtInFonts ? 3 : 1;
int w = font->getStringWidth(_scene->_name) + 6;
int maxWidth = width - size*2 - 7;
@@ -362,22 +383,7 @@ enum {
void Gui::flowText(String &str) {
Common::StringArray wrappedLines;
int textW = _consoleTextArea.width() - kConWPadding * 2;
-
- const Graphics::Font *font;
-
- if (!_builtInFonts) {
- char fontName[128];
- Scene *scene = _engine->_world->_player->_currentScene;
-
- snprintf(fontName, 128, "%s-%d", scene->getFontName(), scene->_fontSize);
- font = FontMan.getFontByName(fontName);
-
- if (!font)
- warning("Cannot load font %s", fontName);
- }
-
- if (_builtInFonts || !font)
- font = FontMan.getFontByUsage(Graphics::FontManager::kConsoleFont);
+ const Graphics::Font *font = getConsoleFont();
font->wordWrapText(str, textW, wrappedLines);
@@ -411,20 +417,7 @@ void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) {
if (fullRedraw)
_console.fillRect(fullR, kColorWhite);
- const Graphics::Font *font;
-
- if (!_builtInFonts) {
- char fontName[128];
-
- snprintf(fontName, 128, "%s-%d", _scene->getFontName(), _scene->_fontSize);
- font = FontMan.getFontByName(fontName);
-
- if (!font)
- warning("Cannot load font %s", fontName);
- }
-
- if (_builtInFonts || !font)
- font = FontMan.getFontByUsage(Graphics::FontManager::kConsoleFont);
+ const Graphics::Font *font = getConsoleFont();
int lineHeight = font->getFontHeight() + kLineSpacing;
int textW = r.width() - kConWPadding * 2;
@@ -525,21 +518,8 @@ void Gui::renderMenu() {
r.top = kMenuHeight - 1;
Design::drawFilledRect(&_screen, r, kColorBlack, p, 1);
- const Graphics::Font *font = NULL;
- int y = 1;
-
- if (!_builtInFonts) {
- font = FontMan.getFontByName("Chicago-12");
-
- if (!font)
- warning("Cannot load font Chicago-12");
- }
-
- if (_builtInFonts || !font) {
- font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
- y = 3;
- }
-
+ const Graphics::Font *font = getMenuFont();
+ int y = _builtInFonts ? 3 : 1;
int x = 18;
for (int i = 0; menuItems[i]; i++) {
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 28e1934..aafc9b3 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -49,6 +49,8 @@
#define WAGE_GUI_H
#include "common/str-array.h"
+#include "graphics/font.h"
+#include "graphics/fontman.h"
#include "graphics/surface.h"
#include "common/rect.h"
@@ -78,6 +80,10 @@ private:
void loadFonts();
void renderMenu();
void flowText(Common::String &str);
+ const Graphics::Font *getConsoleFont();
+ const Graphics::Font *getMenuFont();
+ const Graphics::Font *getTitleFont();
+ const Graphics::Font *getFont(const char *name, Graphics::FontManager::FontUsage fallback);
private:
WageEngine *_engine;
Commit: e684c1148e43b757625e4531a8d51e76c5e438bd
https://github.com/scummvm/scummvm/commit/e684c1148e43b757625e4531a8d51e76c5e438bd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-03T12:40:29+01:00
Commit Message:
WAGE: Remove redundant headers
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 6a67984..a0d1ecd 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -48,8 +48,6 @@
#include "common/system.h"
#include "common/unzip.h"
#include "graphics/cursorman.h"
-#include "graphics/fontman.h"
-#include "graphics/font.h"
#include "graphics/fonts/bdf.h"
#include "graphics/palette.h"
#include "wage/wage.h"
Commit: a4251c58b54ff70bb9faefb1c07dbcebd1816acd
https://github.com/scummvm/scummvm/commit/a4251c58b54ff70bb9faefb1c07dbcebd1816acd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-03T13:01:09+01:00
Commit Message:
WAGE: Implement processMove()
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 1e29f56..1473029 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -523,7 +523,10 @@ enum {
kCompLtObjScene,
kCompGtNumNum,
kCompGtStringString,
- kCompGtChrScene
+ kCompGtChrScene,
+ kMoveObjChr,
+ kMoveObjScene,
+ kMoveChrScene
};
struct Comparator {
@@ -560,6 +563,10 @@ struct Comparator {
{ '>', OBJ, CHR, kCompLtObjChr }, // Same logic as <
{ '>', OBJ, SCENE, kCompLtObjScene }, // Same logic as <
{ '>', CHR, SCENE, kCompGtChrScene },
+
+ { 'M', OBJ, CHR, kMoveObjChr },
+ { 'M', OBJ, SCENE, kMoveObjScene },
+ { 'M', CHR, SCENE, kMoveChrScene },
{ 0, OBJ, OBJ, 0 }
};
@@ -631,6 +638,23 @@ bool Script::compare(Operand *o1, Operand *o2, int comparator) {
return o1->_value.string == o2->_value.string;
case kCompGtChrScene:
return (o1->_value.chr != NULL && o1->_value.chr->_currentScene != o2->_value.scene);
+ case kMoveObjChr:
+ if (o1->_value.obj->_currentOwner != o2->_value.chr) {
+ _world->move(o1->_value.obj, o2->_value.chr);
+ _handled = true; // TODO: Is this correct?
+ }
+ break;
+ case kMoveObjScene:
+ if (o1->_value.obj->_currentScene != o2->_value.scene) {
+ _world->move(o1->_value.obj, o2->_value.scene);
+ // Note: This shouldn't call setHandled() - see
+ // Sultan's Palace 'Food and Drink' scene.
+ }
+ break;
+ case kMoveChrScene:
+ _world->move(o1->_value.chr, o2->_value.scene);
+ _handled = true; // TODO: Is this correct?
+ break;
}
return false;
@@ -828,7 +852,21 @@ void Script::takeObj(Obj *obj) {
}
void Script::processMove() {
- warning("STUB: processMove");
+ Operand *what = readOperand();
+ // TODO check data[index] == 0x8A
+ Operand *to = readOperand();
+ // TODO check data[index] == 0xFD
+
+ for (int cmp = 0; comparators[cmp].op != 0; cmp++) {
+ if (comparators[cmp].op != 'M')
+ continue;
+
+ if (comparators[cmp].o1 == what->_type && comparators[cmp].o2 == to->_type) {
+ compare(what, to, comparators[cmp].cmp);
+
+ break;
+ }
+ }
}
void Script::processLet() {
Commit: 4e14c952d81a1fdbe6c83bed4448cb0235f5d0cd
https://github.com/scummvm/scummvm/commit/4e14c952d81a1fdbe6c83bed4448cb0235f5d0cd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-03T14:05:23+01:00
Commit Message:
WAGE: Fixed processMove operands
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 1473029..9bd9397 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -853,9 +853,15 @@ void Script::takeObj(Obj *obj) {
void Script::processMove() {
Operand *what = readOperand();
- // TODO check data[index] == 0x8A
+ byte skip = _data->readByte();
+ if (skip != 0x8a)
+ error("Incorrect operator for MOVE: %02x", skip);
+
Operand *to = readOperand();
- // TODO check data[index] == 0xFD
+
+ skip = _data->readByte();
+ if (skip != 0xfd)
+ error("No end for MOVE: %02x", skip);
for (int cmp = 0; comparators[cmp].op != 0; cmp++) {
if (comparators[cmp].op != 'M')
Commit: 74cbf5477da7418e94b5ba8a5222a2cae0c16a99
https://github.com/scummvm/scummvm/commit/74cbf5477da7418e94b5ba8a5222a2cae0c16a99
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-03T15:31:24+01:00
Commit Message:
WAGE: Implement console scrolling
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index a0d1ecd..f9df59f 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -122,12 +122,15 @@ Gui::Gui(WageEngine *engine) {
_consoleDirty = true;
_bordersDirty = true;
_menuDirty = true;
+ _consoleFullRedraw = true;
_screen.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8());
Patterns p;
p.push_back(checkersPattern);
_scrollPos = 0;
+ _consoleLineHeight = 8; // Dummy value which makes sense
+ _consoleNumLines = 24; // Dummy value
_builtInFonts = false;
_sceneIsActive = false;
@@ -255,6 +258,7 @@ void Gui::draw() {
_consoleDirty = false;
_bordersDirty = false;
_menuDirty = false;
+ _consoleFullRedraw = false;
// Blit to screen
g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, _screen.h);
@@ -374,8 +378,7 @@ enum {
kConHOverlap = 20,
kConWPadding = 3,
kConHPadding = 4,
- kConOverscan = 3,
- kLineSpacing = 0
+ kConOverscan = 3
};
void Gui::flowText(String &str) {
@@ -390,10 +393,16 @@ void Gui::flowText(String &str) {
for (Common::StringArray::const_iterator j = wrappedLines.begin(); j != wrappedLines.end(); ++j)
_lines.push_back(*j);
+
+ int pos = _scrollPos;
+ _scrollPos = MAX<int>(0, (_lines.size() - _consoleNumLines) * _consoleLineHeight);
+
+ if (pos != _scrollPos)
+ _consoleFullRedraw = true;
}
void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) {
- bool fullRedraw = false;
+ bool fullRedraw = _consoleFullRedraw;
bool textReflow = false;
int surfW = r.width() + kConWOverlap * 2;
int surfH = r.height() + kConHOverlap * 2;
@@ -417,7 +426,7 @@ void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) {
const Graphics::Font *font = getConsoleFont();
- int lineHeight = font->getFontHeight() + kLineSpacing;
+ _consoleLineHeight = font->getFontHeight();
int textW = r.width() - kConWPadding * 2;
int textH = r.height() - kConHPadding * 2;
@@ -428,12 +437,15 @@ void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) {
flowText(_out[i]);
}
- const int firstLine = _scrollPos / lineHeight;
- const int lastLine = MIN((_scrollPos + textH) / lineHeight + 1, _lines.size());
+ const int firstLine = _scrollPos / _consoleLineHeight;
+ const int lastLine = MIN((_scrollPos + textH) / _consoleLineHeight + 1, _lines.size());
const int xOff = kConWOverlap;
const int yOff = kConHOverlap;
int x1 = xOff + kConWPadding;
- int y1 = yOff - (_scrollPos % lineHeight) + kConHPadding;
+ int y1 = yOff - (_scrollPos % _consoleLineHeight) + kConHPadding;
+
+ if (fullRedraw)
+ _consoleNumLines = r.height() / _consoleLineHeight - 1;
for (int line = firstLine; line < lastLine; line++) {
const char *str = _lines[line].c_str();
@@ -441,7 +453,7 @@ void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) {
if (*str)
font->drawString(&_console, _lines[line], x1, y1, textW, kColorBlack);
- y1 += lineHeight;
+ y1 += _consoleLineHeight;
}
g->copyRectToSurface(_console, r.left - kConOverscan, r.top - kConOverscan, boundsR);
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index aafc9b3..4f2815b 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -98,6 +98,9 @@ private:
Common::StringArray _out;
Common::StringArray _lines;
uint _scrollPos;
+ int _consoleLineHeight;
+ uint _consoleNumLines;
+ bool _consoleFullRedraw;
bool _builtInFonts;
Commit: b25b2ec8ad98a3c19919095dd2dcc9ca80cccdd5
https://github.com/scummvm/scummvm/commit/b25b2ec8ad98a3c19919095dd2dcc9ca80cccdd5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-03T15:34:26+01:00
Commit Message:
WAGE: Implement immediate text rendering to match original
Changed paths:
engines/wage/gui.cpp
engines/wage/wage.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index f9df59f..650a037 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -262,6 +262,7 @@ void Gui::draw() {
// Blit to screen
g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, _screen.h);
+ g_system->updateScreen();
}
void Gui::drawBox(Graphics::Surface *g, int x, int y, int w, int h) {
@@ -399,6 +400,9 @@ void Gui::flowText(String &str) {
if (pos != _scrollPos)
_consoleFullRedraw = true;
+
+ if (!_engine->_temporarilyHidden)
+ draw();
}
void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) {
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 5ab49ea..3269039 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -109,10 +109,9 @@ Common::Error WageEngine::run() {
_temporarilyHidden = true;
performInitialSetup();
- _temporarilyHidden = false;
-
Common::String input("look");
processTurn(&input, NULL);
+ _temporarilyHidden = false;
while (true) {
processEvents();
Commit: 6233e429f33822758f2316f29fb4158797683cf2
https://github.com/scummvm/scummvm/commit/6233e429f33822758f2316f29fb4158797683cf2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-03T19:05:43+01:00
Commit Message:
WAGE: Leave room for input text in console
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 650a037..dd398b5 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -449,7 +449,7 @@ void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) {
int y1 = yOff - (_scrollPos % _consoleLineHeight) + kConHPadding;
if (fullRedraw)
- _consoleNumLines = r.height() / _consoleLineHeight - 1;
+ _consoleNumLines = r.height() / _consoleLineHeight - 2;
for (int line = firstLine; line < lastLine; line++) {
const char *str = _lines[line].c_str();
Commit: 07d11b4af695e7fdc2d3d686f3d24e60387bb749
https://github.com/scummvm/scummvm/commit/07d11b4af695e7fdc2d3d686f3d24e60387bb749
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-03T19:06:15+01:00
Commit Message:
WAGE: Complete Script::compare()
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 9bd9397..8dde95e 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -575,15 +575,20 @@ bool Script::compare(Operand *o1, Operand *o2, int comparator) {
case kCompEqNumNum:
return o1->_value.number == o2->_value.number;
case kCompEqObjScene:
- error("FIXME kCompEqObjScene");
- //return o2->_value.scene->_objs.contains(*o1->_value.obj);
+ for (Common::List<Obj *>::const_iterator it = o2->_value.scene->_objs.begin(); it != o2->_value.scene->_objs.end(); ++it)
+ if (*it == o1->_value.obj)
+ return true;
+ return false;
case kCompEqChrScene:
- error("FIXME kCompEqChrScene");
- //return o2->_value.scene->_chrs.contains(*o1->_value.chr);
+ for (Common::List<Chr *>::const_iterator it = o2->_value.scene->_chrs.begin(); it != o2->_value.scene->_chrs.end(); ++it)
+ if (*it == o1->_value.chr)
+ return true;
+ return false;
case kCompEqObjChr:
- warning("FIXME kCompEqObjChr");
+ for (Common::Array<Obj *>::const_iterator it = o2->_value.chr->_inventory.begin(); it != o2->_value.chr->_inventory.end(); ++it)
+ if (*it == o1->_value.obj)
+ return true;
return false;
- //return o2->_value.chr->_inventory.contains(*o1->_value.obj);
case kCompEqChrChr:
return o1->_value.chr == o2->_value.chr;
case kCompEqSceneScene:
Commit: d66c3a21f1b2305fe30640213ff8dba0a20595c5
https://github.com/scummvm/scummvm/commit/d66c3a21f1b2305fe30640213ff8dba0a20595c5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-03T20:23:39+01:00
Commit Message:
WAGE: Implement getGroundItemsList()
Changed paths:
engines/wage/script.cpp
engines/wage/script.h
engines/wage/util.cpp
engines/wage/wage.h
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 8dde95e..740d8ec 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -941,10 +941,42 @@ void Script::handleLookCommand() {
}
Common::String *Script::getGroundItemsList(Scene *scene) {
- warning("STUB: getGroundItemsList");
+ Common::Array<Obj *> objs;
+
+ for (Common::List<Obj *>::const_iterator it = scene->_objs.begin(); it != scene->_objs.end(); ++it)
+ if ((*it)->_type != Obj::IMMOBILE_OBJECT)
+ objs.push_back(*it);
+
+ if (objs.size()) {
+ Common::String *res = new Common::String("On the ground you see ");
+ appendObjNames(*res, objs);
+ return res;
+ }
return NULL;
}
+void Script::appendObjNames(Common::String &str, Common::Array<Obj *> &objs) {
+ for (int i = 0; i < objs.size(); i++) {
+ Obj *obj = objs[i];
+
+ if (!obj->_namePlural)
+ str += getIndefiniteArticle(obj->_name);
+ else
+ str += "some ";
+
+ str += obj->_name;
+
+ if (i == objs.size() - 1) {
+ str += ".";
+ } else if (i == objs.size() - 2) {
+ if (objs.size() > 2)
+ str += ",";
+ str += " and ";
+ } else {
+ str += ", ";
+ }
+ }
+}
void Script::handleInventoryCommand() {
warning("STUB: handleInventoryCommand");
diff --git a/engines/wage/script.h b/engines/wage/script.h
index 876ec07..bff6917 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -168,6 +168,7 @@ private:
void handleMoveCommand(Scene::Directions dir, const char *dirName);
void handleLookCommand();
Common::String *getGroundItemsList(Scene *scene);
+ void appendObjNames(Common::String &str, Common::Array<Obj *> &objs);
void handleInventoryCommand();
void handleStatusCommand();
void handleRestCommand();
diff --git a/engines/wage/util.cpp b/engines/wage/util.cpp
index 0bed88e..8dac0d2 100644
--- a/engines/wage/util.cpp
+++ b/engines/wage/util.cpp
@@ -87,4 +87,16 @@ Common::Rect *readRect(Common::SeekableReadStream *in) {
return new Common::Rect(x1, y1, x2, y2);
}
+const char *getIndefiniteArticle(String &word) {
+ switch (word[0]) {
+ case 'a': case 'A':
+ case 'e': case 'E':
+ case 'i': case 'I':
+ case 'o': case 'O':
+ case 'u': case 'U':
+ return "an ";
+ }
+ return "a ";
+}
+
} // End of namespace Wage
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index e96e298..724f39a 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -98,6 +98,7 @@ enum {
Common::String readPascalString(Common::SeekableReadStream *in);
Common::Rect *readRect(Common::SeekableReadStream *in);
+const char *getIndefiniteArticle(String &word);
typedef Common::Array<byte *> Patterns;
Commit: 562355e62dddedaddb40555b0e5dff5468322bb4
https://github.com/scummvm/scummvm/commit/562355e62dddedaddb40555b0e5dff5468322bb4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-03T21:44:04+01:00
Commit Message:
WAGE: Graceful engine quitting
Changed paths:
engines/wage/wage.cpp
engines/wage/wage.h
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 3269039..e865810 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -78,6 +78,8 @@ WageEngine::WageEngine(OSystem *syst, const ADGameDescription *desc) : Engine(sy
_commandWasQuick = false;
+ _shouldQuit = false;
+
debug("WageEngine::WageEngine()");
}
@@ -85,6 +87,9 @@ WageEngine::~WageEngine() {
debug("WageEngine::~WageEngine()");
DebugMan.clearAllDebugChannels();
+ delete _world;
+ delete _resManager;
+ delete _gui;
delete _rnd;
}
@@ -113,7 +118,9 @@ Common::Error WageEngine::run() {
processTurn(&input, NULL);
_temporarilyHidden = false;
- while (true) {
+ _shouldQuit = false;
+
+ while (!_shouldQuit) {
processEvents();
_gui->draw();
@@ -138,7 +145,7 @@ void WageEngine::processEvents() {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_QUIT:
- error("Exiting");
+ _shouldQuit = true;
break;
case Common::EVENT_MOUSEMOVE:
_gui->mouseMove(event.mouse.x, event.mouse.y);
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 724f39a..0c6f2e0 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -163,6 +163,7 @@ private:
bool _commandWasQuick;
+ bool _shouldQuit;
};
// Example console class
Commit: 0b361b94dc303f95a636e8d183aca7f3854f00e4
https://github.com/scummvm/scummvm/commit/0b361b94dc303f95a636e8d183aca7f3854f00e4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-03T21:59:57+01:00
Commit Message:
WAGE: Initial cursor drawing code
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index dd398b5..e3c98de 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -46,6 +46,7 @@
*/
#include "common/system.h"
+#include "common/timer.h"
#include "common/unzip.h"
#include "graphics/cursorman.h"
#include "graphics/fonts/bdf.h"
@@ -115,6 +116,28 @@ static const byte macCursorBeam[] = {
0, 0, 3, 3, 3, 0, 0, 3, 3, 3, 3,
};
+static void cursor_timer_handler(void *refCon) {
+ Gui *gui = (Gui *)refCon;
+
+ int x = gui->_cursorX;
+ int y = gui->_cursorY;
+
+ if (x == 0 && y == 0)
+ return;
+
+ if (!gui->_screen.getPixels())
+ return;
+
+ x += gui->_consoleTextArea.left;
+ y += gui->_consoleTextArea.top;
+
+ gui->_screen.vLine(x, y, y + 8, gui->_cursorState ? kColorBlack : kColorWhite);
+ gui->_cursorState = !gui->_cursorState;
+
+ g_system->copyRectToScreen(gui->_screen.getPixels(), gui->_screen.pitch, x, y, 1, 8);
+ g_system->updateScreen();
+}
+
Gui::Gui(WageEngine *engine) {
_engine = engine;
_scene = NULL;
@@ -134,6 +157,10 @@ Gui::Gui(WageEngine *engine) {
_builtInFonts = false;
_sceneIsActive = false;
+ _cursorX = 0;
+ _cursorY = 0;
+ _cursorState = false;
+
g_system->getPaletteManager()->setPalette(palette, 0, 4);
CursorMan.replaceCursorPalette(palette, 0, 4);
@@ -146,9 +173,12 @@ Gui::Gui(WageEngine *engine) {
Design::drawFilledRoundRect(&_screen, r, kDesktopArc, kColorBlack, p, 1);
loadFonts();
+
+ g_system->getTimerManager()->installTimerProc(&cursor_timer_handler, 500000, this, "wageCursor");
}
Gui::~Gui() {
+ g_system->getTimerManager()->removeTimerProc(&cursor_timer_handler);
}
const Graphics::Font *Gui::getFont(const char *name, Graphics::FontManager::FontUsage fallback) {
@@ -243,7 +273,6 @@ void Gui::draw() {
if (_scene && (_bordersDirty || _sceneDirty))
paintBorder(&_screen, _sceneArea, kWindowScene);
-
// Render console
if (_consoleDirty)
renderConsole(&_screen, _consoleTextArea);
@@ -398,6 +427,13 @@ void Gui::flowText(String &str) {
int pos = _scrollPos;
_scrollPos = MAX<int>(0, (_lines.size() - _consoleNumLines) * _consoleLineHeight);
+ _cursorX = 0;
+
+ if (_scrollPos)
+ _cursorY = (_consoleNumLines + 1) * _consoleLineHeight;
+ else
+ _cursorY = (_lines.size() + 1) * _consoleLineHeight;
+
if (pos != _scrollPos)
_consoleFullRedraw = true;
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 4f2815b..1a82c8f 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -85,9 +85,14 @@ private:
const Graphics::Font *getTitleFont();
const Graphics::Font *getFont(const char *name, Graphics::FontManager::FontUsage fallback);
+public:
+ Graphics::Surface _screen;
+ int _cursorX, _cursorY;
+ bool _cursorState;
+ Common::Rect _consoleTextArea;
+
private:
WageEngine *_engine;
- Graphics::Surface _screen;
Graphics::Surface _console;
Scene *_scene;
bool _sceneDirty;
@@ -104,7 +109,6 @@ private:
bool _builtInFonts;
- Common::Rect _consoleTextArea;
Common::Rect _sceneArea;
bool _sceneIsActive;
bool _cursorIsArrow;
Commit: aec3bc19ece9c09754da1c026b56fa7213918126
https://github.com/scummvm/scummvm/commit/aec3bc19ece9c09754da1c026b56fa7213918126
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-03T22:11:41+01:00
Commit Message:
WAGE: Fixed cursor position
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index e3c98de..141cca9 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -427,7 +427,7 @@ void Gui::flowText(String &str) {
int pos = _scrollPos;
_scrollPos = MAX<int>(0, (_lines.size() - _consoleNumLines) * _consoleLineHeight);
- _cursorX = 0;
+ _cursorX = kConHPadding;
if (_scrollPos)
_cursorY = (_consoleNumLines + 1) * _consoleLineHeight;
Commit: e95122be6cce38c63d92585adf18084fba59b156
https://github.com/scummvm/scummvm/commit/e95122be6cce38c63d92585adf18084fba59b156
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-03T22:11:58+01:00
Commit Message:
WAGE: Optimized screen blitting
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 141cca9..baf9445 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -65,7 +65,8 @@ enum {
kMenuItemHeight = 19,
kBorderWidth = 17,
kDesktopArc = 7,
- kComponentsPadding = 10
+ kComponentsPadding = 10,
+ kCursorHeight = 12
};
static const byte palette[] = {
@@ -131,10 +132,10 @@ static void cursor_timer_handler(void *refCon) {
x += gui->_consoleTextArea.left;
y += gui->_consoleTextArea.top;
- gui->_screen.vLine(x, y, y + 8, gui->_cursorState ? kColorBlack : kColorWhite);
+ gui->_screen.vLine(x, y - kCursorHeight, y, gui->_cursorState ? kColorBlack : kColorWhite);
gui->_cursorState = !gui->_cursorState;
- g_system->copyRectToScreen(gui->_screen.getPixels(), gui->_screen.pitch, x, y, 1, 8);
+ g_system->copyRectToScreen(gui->_screen.getBasePtr(x, y - kCursorHeight), gui->_screen.pitch, x, y - kCursorHeight, 1, kCursorHeight);
g_system->updateScreen();
}
@@ -171,10 +172,11 @@ Gui::Gui(WageEngine *engine) {
// Draw desktop
Common::Rect r(0, 0, _screen.w - 1, _screen.h - 1);
Design::drawFilledRoundRect(&_screen, r, kDesktopArc, kColorBlack, p, 1);
+ g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, _screen.h);
loadFonts();
- g_system->getTimerManager()->installTimerProc(&cursor_timer_handler, 500000, this, "wageCursor");
+ g_system->getTimerManager()->installTimerProc(&cursor_timer_handler, 200000, this, "wageCursor");
}
Gui::~Gui() {
@@ -288,10 +290,6 @@ void Gui::draw() {
_bordersDirty = false;
_menuDirty = false;
_consoleFullRedraw = false;
-
- // Blit to screen
- g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, _screen.h);
- g_system->updateScreen();
}
void Gui::drawBox(Graphics::Surface *g, int x, int y, int w, int h) {
@@ -401,6 +399,8 @@ void Gui::paintBorder(Graphics::Surface *g, Common::Rect &r, WindowType windowTy
drawBox(g, x + (width - w) / 2, y, w, size);
font->drawString(g, _scene->_name, x + (width - w) / 2 + 3, y + yOff, w, kColorBlack);
}
+
+ g_system->copyRectToScreen(g->getBasePtr(x, y), g->pitch, x, y, width, height);
}
enum {
@@ -497,6 +497,7 @@ void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) {
}
g->copyRectToSurface(_console, r.left - kConOverscan, r.top - kConOverscan, boundsR);
+ g_system->copyRectToScreen(g->getBasePtr(r.left, r.top), g->pitch, r.left, r.top, r.width(), r.height());
}
void Gui::loadFonts() {
@@ -583,6 +584,8 @@ void Gui::renderMenu() {
x += w + 13;
}
+
+ g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, kMenuHeight);
}
Designed *Gui::getClickTarget(int x, int y) {
Commit: f97c915c7b0f3ef3c34dfea78619d8c17446638b
https://github.com/scummvm/scummvm/commit/f97c915c7b0f3ef3c34dfea78619d8c17446638b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T00:09:10+01:00
Commit Message:
WAGE: Display text input
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/wage.cpp
engines/wage/wage.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index baf9445..2f36270 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -133,7 +133,9 @@ static void cursor_timer_handler(void *refCon) {
y += gui->_consoleTextArea.top;
gui->_screen.vLine(x, y - kCursorHeight, y, gui->_cursorState ? kColorBlack : kColorWhite);
- gui->_cursorState = !gui->_cursorState;
+
+ if (!gui->_cursorOff)
+ gui->_cursorState = !gui->_cursorState;
g_system->copyRectToScreen(gui->_screen.getBasePtr(x, y - kCursorHeight), gui->_screen.pitch, x, y - kCursorHeight, 1, kCursorHeight);
g_system->updateScreen();
@@ -161,6 +163,7 @@ Gui::Gui(WageEngine *engine) {
_cursorX = 0;
_cursorY = 0;
_cursorState = false;
+ _cursorOff = false;
g_system->getPaletteManager()->setPalette(palette, 0, 4);
@@ -500,6 +503,34 @@ void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) {
g_system->copyRectToScreen(g->getBasePtr(r.left, r.top), g->pitch, r.left, r.top, r.width(), r.height());
}
+void Gui::drawInput() {
+ if (!_screen.getPixels())
+ return;
+
+ const Graphics::Font *font = getConsoleFont();
+
+ int x = kConHPadding + _consoleTextArea.left;
+ int y = _cursorY + _consoleTextArea.top;
+ Common::String text(_engine->_inputText);
+ int textW = font->getStringWidth(text);
+
+ // undraw cursor
+ _cursorOff = true;
+ _cursorState = false;
+ cursor_timer_handler(this);
+ _cursorOff = false;
+
+ Common::Rect r(x, y, x + textW + 10, y + font->getFontHeight());
+
+ _screen.fillRect(r, kColorWhite);
+
+ font->drawString(&_screen, text, x, y, _screen.w, kColorBlack);
+
+ g_system->copyRectToScreen(_screen.getBasePtr(x, y), _screen.pitch, x, y, textW + 10, font->getFontHeight());
+
+ _cursorX = font->getStringWidth(_engine->_inputText) + 1;
+}
+
void Gui::loadFonts() {
Common::Archive *dat;
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 1a82c8f..cd918f7 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -71,6 +71,7 @@ public:
void clearOutput();
void mouseMove(int x, int y);
Designed *getClickTarget(int x, int y);
+ void drawInput();
private:
void paintBorder(Graphics::Surface *g, Common::Rect &r, WindowType windowType);
@@ -90,6 +91,7 @@ public:
int _cursorX, _cursorY;
bool _cursorState;
Common::Rect _consoleTextArea;
+ bool _cursorOff;
private:
WageEngine *_engine;
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index e865810..e3addd1 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -158,6 +158,29 @@ void WageEngine::processEvents() {
if (obj != NULL)
processTurn(NULL, obj);
}
+ break;
+ case Common::EVENT_KEYDOWN:
+ switch (event.kbd.keycode) {
+ case Common::KEYCODE_BACKSPACE:
+ if (_inputText.size()) {
+ _inputText.deleteLastChar();
+ _gui->drawInput();
+ }
+ break;
+
+ default:
+ if (event.kbd.flags)
+ break;
+
+ if (Common::isAlpha(event.kbd.ascii)) {
+ _inputText += (char)event.kbd.ascii;
+ _gui->drawInput();
+ }
+
+ break;
+ }
+ break;
+
default:
break;
}
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 0c6f2e0..91d9404 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -132,7 +132,6 @@ public:
World *_world;
Scene *_lastScene;
- //PrintStream out;
int _loopCount;
int _turn;
Chr *_monster;
@@ -142,6 +141,8 @@ public:
bool _temporarilyHidden;
bool _isGameOver;
+ Common::String _inputText;
+
void playSound(String soundName);
void setMenu(String soundName);
void appendText(String &str);
Commit: c8b20bc8ab83e24dd7e4f6ac06fb2a80f97f6ba2
https://github.com/scummvm/scummvm/commit/c8b20bc8ab83e24dd7e4f6ac06fb2a80f97f6ba2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T00:13:28+01:00
Commit Message:
WAGE: Fix cursor position
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 2f36270..4f451bb 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -132,12 +132,12 @@ static void cursor_timer_handler(void *refCon) {
x += gui->_consoleTextArea.left;
y += gui->_consoleTextArea.top;
- gui->_screen.vLine(x, y - kCursorHeight, y, gui->_cursorState ? kColorBlack : kColorWhite);
+ gui->_screen.vLine(x, y, y + kCursorHeight, gui->_cursorState ? kColorBlack : kColorWhite);
if (!gui->_cursorOff)
gui->_cursorState = !gui->_cursorState;
- g_system->copyRectToScreen(gui->_screen.getBasePtr(x, y - kCursorHeight), gui->_screen.pitch, x, y - kCursorHeight, 1, kCursorHeight);
+ g_system->copyRectToScreen(gui->_screen.getBasePtr(x, y), gui->_screen.pitch, x, y, 1, kCursorHeight);
g_system->updateScreen();
}
@@ -433,9 +433,9 @@ void Gui::flowText(String &str) {
_cursorX = kConHPadding;
if (_scrollPos)
- _cursorY = (_consoleNumLines + 1) * _consoleLineHeight;
+ _cursorY = (_consoleNumLines) * _consoleLineHeight;
else
- _cursorY = (_lines.size() + 1) * _consoleLineHeight;
+ _cursorY = (_lines.size()) * _consoleLineHeight;
if (pos != _scrollPos)
_consoleFullRedraw = true;
@@ -528,7 +528,7 @@ void Gui::drawInput() {
g_system->copyRectToScreen(_screen.getBasePtr(x, y), _screen.pitch, x, y, textW + 10, font->getFontHeight());
- _cursorX = font->getStringWidth(_engine->_inputText) + 1;
+ _cursorX = font->getStringWidth(_engine->_inputText) + kConHPadding;
}
void Gui::loadFonts() {
Commit: 44582b503abb4ebcf7d50badada0d10123483a87
https://github.com/scummvm/scummvm/commit/44582b503abb4ebcf7d50badada0d10123483a87
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T00:17:31+01:00
Commit Message:
WAGE: Support full range of ASCII in input
Changed paths:
engines/wage/wage.cpp
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index e3addd1..9a320a2 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -169,10 +169,12 @@ void WageEngine::processEvents() {
break;
default:
- if (event.kbd.flags)
+ if (event.kbd.flags & Common::KBD_ALT || event.kbd.flags & Common::KBD_CTRL) {
+ warning("STUB: Shortcuts");
break;
+ }
- if (Common::isAlpha(event.kbd.ascii)) {
+ if (event.kbd.ascii >= 0x20 && event.kbd.ascii <= 0x7f) {
_inputText += (char)event.kbd.ascii;
_gui->drawInput();
}
Commit: 1b0d6a43048d7497bb6200b35974053693616890
https://github.com/scummvm/scummvm/commit/1b0d6a43048d7497bb6200b35974053693616890
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T00:21:31+01:00
Commit Message:
WAGE: Implement command execution
Changed paths:
engines/wage/wage.cpp
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 9a320a2..26785b5 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -168,6 +168,13 @@ void WageEngine::processEvents() {
}
break;
+ case Common::KEYCODE_RETURN:
+ _gui->appendText(_inputText);
+ processTurn(&_inputText, NULL);
+ _inputText = "";
+ _gui->drawInput();
+ break;
+
default:
if (event.kbd.flags & Common::KBD_ALT || event.kbd.flags & Common::KBD_CTRL) {
warning("STUB: Shortcuts");
Commit: 2c8922ed3094e20afa53861e95a0b5d97460feee
https://github.com/scummvm/scummvm/commit/2c8922ed3094e20afa53861e95a0b5d97460feee
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T00:23:05+01:00
Commit Message:
WAGE: Fix cursor position at the scroll end
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 4f451bb..3d3a502 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -433,7 +433,7 @@ void Gui::flowText(String &str) {
_cursorX = kConHPadding;
if (_scrollPos)
- _cursorY = (_consoleNumLines) * _consoleLineHeight;
+ _cursorY = (_consoleNumLines + 1) * _consoleLineHeight;
else
_cursorY = (_lines.size()) * _consoleLineHeight;
Commit: cc14b5f96fc6457e240d8c7c9a9c16422dc3586d
https://github.com/scummvm/scummvm/commit/cc14b5f96fc6457e240d8c7c9a9c16422dc3586d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T00:42:10+01:00
Commit Message:
WAGE: Implement handleMoveCommand()
Changed paths:
engines/wage/script.cpp
engines/wage/world.cpp
engines/wage/world.h
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 740d8ec..c08b06b 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -925,8 +925,37 @@ void Script::appendText(String str) {
_callbacks->appendText(str);
}
+static const int directionsX[] = { 0, 0, 1, -1 };
+static const int directionsY[] = { -1, 1, 0, 0 };
+
void Script::handleMoveCommand(Scene::Directions dir, const char *dirName) {
- warning("STUB: handleMoveCommand");
+ Scene *playerScene = _world->_player->_currentScene;
+ Common::String msg(playerScene->_messages[dir]);
+
+ warning("Dir: %s msg: %s", dirName, msg.c_str());
+
+ if (!playerScene->_blocked[dir]) {
+ int destX = playerScene->_worldX + directionsX[dir];
+ int destY = playerScene->_worldY + directionsY[dir];
+
+ Scene *scene = _world->getSceneAt(destX, destY);
+
+ if (scene != NULL) {
+ if (msg.size() > 0) {
+ appendText(msg);
+ }
+ _world->move(_world->_player, scene);
+ return;
+ }
+ }
+ if (msg != NULL && msg.size() > 0) {
+ appendText(msg);
+ } else {
+ Common::String txt("You can't go ");
+ txt += dirName;
+ txt += ".";
+ appendText(txt);
+ }
}
void Script::handleLookCommand() {
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index e7c37c1..f0d7c97 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -434,4 +434,15 @@ Scene *World::getRandomScene() {
return _orderedScenes[1 + _engine->_rnd->getRandomNumber(_orderedScenes.size() - 1)];
}
+Scene *World::getSceneAt(int x, int y) {
+ for (int i = 0; i < _orderedScenes.size(); i++) {
+ Scene *scene = _orderedScenes[i];
+
+ if (scene != _storageScene && scene->_worldX == x && scene->_worldY == y) {
+ return scene;
+ }
+ }
+ return NULL;
+}
+
} // End of namespace Wage
diff --git a/engines/wage/world.h b/engines/wage/world.h
index ea00322..a4ca2fd 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -64,6 +64,7 @@ public:
void move(Obj *obj, Scene *scene, bool skipSort = false);
void move(Chr *chr, Scene *scene, bool skipSort = false);
Scene *getRandomScene();
+ Scene *getSceneAt(int x, int y);
WageEngine *_engine;
Commit: b38646790386fcc107431c286a907d1ccd0e525a
https://github.com/scummvm/scummvm/commit/b38646790386fcc107431c286a907d1ccd0e525a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T00:47:16+01:00
Commit Message:
WAGE: Fix crash when wage.dat is not present
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 3d3a502..6ecc4c8 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -539,6 +539,8 @@ void Gui::loadFonts() {
if (!dat) {
warning("Could not find wage.dat. Falling back to built-in fonts");
_builtInFonts = true;
+
+ return;
}
Common::ArchiveMemberList list;
Commit: 21dae458ea4f9629da371fd554e4018c58e73ddb
https://github.com/scummvm/scummvm/commit/21dae458ea4f9629da371fd554e4018c58e73ddb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T11:11:04+01:00
Commit Message:
WAGE: Properly print out input text on game events
Changed paths:
engines/wage/wage.cpp
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 26785b5..fa00618 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -169,7 +169,6 @@ void WageEngine::processEvents() {
break;
case Common::KEYCODE_RETURN:
- _gui->appendText(_inputText);
processTurn(&_inputText, NULL);
_inputText = "";
_gui->drawInput();
@@ -205,6 +204,11 @@ void WageEngine::setMenu(String soundName) {
}
void WageEngine::appendText(String &str) {
+ if (_inputText.size())
+ _gui->appendText(_inputText);
+
+ _inputText = "";
+
_gui->appendText(str);
}
Commit: 5cffbed146eaf21be4cb1bb1bf3939e2da7e2c1c
https://github.com/scummvm/scummvm/commit/5cffbed146eaf21be4cb1bb1bf3939e2da7e2c1c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T11:11:27+01:00
Commit Message:
WAGE: Fix cursor position for built-in fonts
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 6ecc4c8..837632a 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -433,9 +433,9 @@ void Gui::flowText(String &str) {
_cursorX = kConHPadding;
if (_scrollPos)
- _cursorY = (_consoleNumLines + 1) * _consoleLineHeight;
+ _cursorY = (_consoleNumLines + 1) * _consoleLineHeight + kConHPadding;
else
- _cursorY = (_lines.size()) * _consoleLineHeight;
+ _cursorY = (_lines.size()) * _consoleLineHeight + kConHPadding;
if (pos != _scrollPos)
_consoleFullRedraw = true;
@@ -488,7 +488,7 @@ void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) {
int y1 = yOff - (_scrollPos % _consoleLineHeight) + kConHPadding;
if (fullRedraw)
- _consoleNumLines = r.height() / _consoleLineHeight - 2;
+ _consoleNumLines = (r.height() - 2 * kConWPadding) / _consoleLineHeight - 2;
for (int line = firstLine; line < lastLine; line++) {
const char *str = _lines[line].c_str();
@@ -509,7 +509,7 @@ void Gui::drawInput() {
const Graphics::Font *font = getConsoleFont();
- int x = kConHPadding + _consoleTextArea.left;
+ int x = kConWPadding + _consoleTextArea.left;
int y = _cursorY + _consoleTextArea.top;
Common::String text(_engine->_inputText);
int textW = font->getStringWidth(text);
Commit: e7eb7ffc810aed64ad3837484f3a5c0bfa001d65
https://github.com/scummvm/scummvm/commit/e7eb7ffc810aed64ad3837484f3a5c0bfa001d65
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T11:17:51+01:00
Commit Message:
WAGE: Further fixes to cursor position
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 837632a..01ae5b6 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -430,10 +430,10 @@ void Gui::flowText(String &str) {
int pos = _scrollPos;
_scrollPos = MAX<int>(0, (_lines.size() - _consoleNumLines) * _consoleLineHeight);
- _cursorX = kConHPadding;
+ _cursorX = kConWPadding;
if (_scrollPos)
- _cursorY = (_consoleNumLines + 1) * _consoleLineHeight + kConHPadding;
+ _cursorY = (_consoleNumLines) * _consoleLineHeight + kConHPadding;
else
_cursorY = (_lines.size()) * _consoleLineHeight + kConHPadding;
Commit: 3b48d90f13159afc3b877929b63bea6a8467694c
https://github.com/scummvm/scummvm/commit/3b48d90f13159afc3b877929b63bea6a8467694c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T12:06:47+01:00
Commit Message:
WAGE: Mark scene as dirty of some object was moved to/from it
Changed paths:
engines/wage/gui.h
engines/wage/wage.cpp
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index cd918f7..3c5660b 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -72,6 +72,7 @@ public:
void mouseMove(int x, int y);
Designed *getClickTarget(int x, int y);
void drawInput();
+ void setSceneDirty() { _sceneDirty = true; }
private:
void paintBorder(Graphics::Surface *g, Common::Rect &r, WindowType windowType);
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index fa00618..6cf9e39 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -308,6 +308,18 @@ void WageEngine::onMove(Designed *what, Designed *from, Designed *to) {
return;
}
+ if (!_temporarilyHidden) {
+ assert(what);
+ assert(from);
+ assert(to);
+ debug(6, "move: %s, %s -> %s", what->_name.c_str(), from->_name.c_str(), to->_name.c_str());
+ }
+
+ if (from == currentScene || to == currentScene ||
+ (what->_classType == CHR && ((Chr *)what)->_currentScene == currentScene) ||
+ (what->_classType == OBJ && ((Obj *)what)->_currentScene == currentScene))
+ _gui->setSceneDirty();
+
if (what != player && what->_classType == CHR) {
Chr *chr = (Chr *)what;
if (to == _world->_storageScene) {
Commit: 5843a180539c55756ec2644223120f7bc6238f57
https://github.com/scummvm/scummvm/commit/5843a180539c55756ec2644223120f7bc6238f57
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T12:07:22+01:00
Commit Message:
WAGE: Fix Script::processMove(), so it works with double conversion too
Changed paths:
engines/wage/script.cpp
engines/wage/script.h
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index c08b06b..951a5d3 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -665,6 +665,60 @@ bool Script::compare(Operand *o1, Operand *o2, int comparator) {
return false;
}
+bool Script::evaluatePair(Operand *lhs, const char *op, Operand *rhs) {
+ for (int cmp = 0; comparators[cmp].op != 0; cmp++) {
+ if (comparators[cmp].op != op[0])
+ continue;
+
+ if (comparators[cmp].o1 == lhs->_type && comparators[cmp].o2 == rhs->_type)
+ return compare(lhs, rhs, comparators[cmp].cmp);
+ }
+
+ // Now, try partial matches.
+ Operand *c1, *c2;
+ for (int cmp = 0; comparators[cmp].op != 0; cmp++) {
+ if (comparators[cmp].op != op[0])
+ continue;
+
+ if (comparators[cmp].o1 == lhs->_type &&
+ (c2 = convertOperand(rhs, comparators[cmp].o2)) != NULL) {
+ bool res = compare(lhs, c2, comparators[cmp].cmp);
+ delete c2;
+ return res;
+ } else if (comparators[cmp].o2 == rhs->_type &&
+ (c1 = convertOperand(lhs, comparators[cmp].o1)) != NULL) {
+ bool res = compare(c1, rhs, comparators[cmp].cmp);
+ delete c1;
+ return res;
+ }
+ }
+
+ // Now, try double conversion.
+ for (int cmp = 0; comparators[cmp].op != 0; cmp++) {
+ if (comparators[cmp].op != op[0])
+ continue;
+
+ if (comparators[cmp].o1 == lhs->_type || comparators[cmp].o2 == rhs->_type)
+ continue;
+
+ if ((c1 = convertOperand(lhs, comparators[cmp].o1)) != NULL) {
+ if ((c2 = convertOperand(rhs, comparators[cmp].o2)) != NULL) {
+ bool res = compare(c1, c2, comparators[cmp].cmp);
+ delete c1;
+ delete c2;
+ return res;
+ }
+ delete c1;
+ }
+ }
+
+ warning("UNHANDLED CASE: [lhs=%d/%s, op=%s rhs=%d/%s]",
+ lhs->_type, lhs->toString().c_str(), op, rhs->_type, rhs->toString().c_str());
+
+
+ return false;
+}
+
bool Script::eval(Operand *lhs, const char *op, Operand *rhs) {
bool result = false;
@@ -695,51 +749,7 @@ bool Script::eval(Operand *lhs, const char *op, Operand *rhs) {
return result;
} else {
- for (int cmp = 0; comparators[cmp].op != 0; cmp++) {
- if (comparators[cmp].op != op[0])
- continue;
-
- if (comparators[cmp].o1 == lhs->_type && comparators[cmp].o2 == rhs->_type)
- return compare(lhs, rhs, comparators[cmp].cmp);
- }
-
- // Now, try partial matches.
- Operand *c1, *c2;
- for (int cmp = 0; comparators[cmp].op != 0; cmp++) {
- if (comparators[cmp].op != op[0])
- continue;
-
- if (comparators[cmp].o1 == lhs->_type &&
- (c2 = convertOperand(rhs, comparators[cmp].o2)) != NULL) {
- bool res = compare(lhs, c2, comparators[cmp].cmp);
- delete c2;
- return res;
- } else if (comparators[cmp].o2 == rhs->_type &&
- (c1 = convertOperand(lhs, comparators[cmp].o1)) != NULL) {
- bool res = compare(c1, rhs, comparators[cmp].cmp);
- delete c1;
- return res;
- }
- }
-
- // Now, try double conversion.
- for (int cmp = 0; comparators[cmp].op != 0; cmp++) {
- if (comparators[cmp].op != op[0])
- continue;
-
- if (comparators[cmp].o1 == lhs->_type || comparators[cmp].o2 == rhs->_type)
- continue;
-
- if ((c1 = convertOperand(lhs, comparators[cmp].o1)) != NULL) {
- if ((c2 = convertOperand(rhs, comparators[cmp].o2)) != NULL) {
- bool res = compare(c1, c2, comparators[cmp].cmp);
- delete c1;
- delete c2;
- return res;
- }
- delete c1;
- }
- }
+ return evaluatePair(lhs, op, rhs);
}
return false;
@@ -868,16 +878,10 @@ void Script::processMove() {
if (skip != 0xfd)
error("No end for MOVE: %02x", skip);
- for (int cmp = 0; comparators[cmp].op != 0; cmp++) {
- if (comparators[cmp].op != 'M')
- continue;
-
- if (comparators[cmp].o1 == what->_type && comparators[cmp].o2 == to->_type) {
- compare(what, to, comparators[cmp].cmp);
+ debug(6, "MOVE: [what=%d/%s, to=%d/%s]",
+ what->_type, what->toString().c_str(), to->_type, to->toString().c_str());
- break;
- }
- }
+ evaluatePair(what, "M", to);
}
void Script::processLet() {
diff --git a/engines/wage/script.h b/engines/wage/script.h
index bff6917..5bd26ad 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -155,6 +155,7 @@ private:
void skipIf();
bool compare(Operand *o1, Operand *o2, int comparator);
bool eval(Operand *lhs, const char *op, Operand *rhs);
+ bool evaluatePair(Operand *lhs, const char *op, Operand *rhs);
Operand *convertOperand(Operand *operand, int type);
bool evalClickCondition(Operand *lhs, const char *op, Operand *rhs);
bool evalClickEquality(Operand *lhs, Operand *rhs, bool partialMatch);
Commit: b5ffcac009974453efc2b1811600f56f4f1723d1
https://github.com/scummvm/scummvm/commit/b5ffcac009974453efc2b1811600f56f4f1723d1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T19:29:07+01:00
Commit Message:
WAGE: Switched most primitives to proper thick brush drawing.
It matches original QuickDraw code.
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 3b44566..13ac3a0 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -46,6 +46,7 @@
*/
#include "common/system.h"
+#include "graphics/primitives.h"
#include "wage/wage.h"
#include "wage/design.h"
@@ -55,9 +56,10 @@ struct plotData {
Graphics::Surface *surface;
Patterns *patterns;
int fillType;
+ int thickness;
- plotData(Graphics::Surface *s, Patterns *p, int f) :
- surface(s), patterns(p), fillType(f) {}
+ plotData(Graphics::Surface *s, Patterns *p, int f, int t) :
+ surface(s), patterns(p), fillType(f), thickness(t) {}
};
void drawPixel(int x, int y, int color, void *data);
@@ -186,10 +188,24 @@ void drawPixel(int x, int y, int color, void *data) {
byte *pat = p->patterns->operator[](p->fillType - 1);
- if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h) {
- *((byte *)p->surface->getBasePtr(x, y)) =
- (pat[y % 8] & (1 << (7 - x % 8))) ?
- color : kColorWhite;
+ if (p->thickness == 1) {
+ if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h) {
+ *((byte *)p->surface->getBasePtr(x, y)) =
+ (pat[y % 8] & (1 << (7 - x % 8))) ?
+ color : kColorWhite;
+ }
+ } else {
+ int x1 = x - p->thickness / 2;
+ int x2 = x1 + p->thickness;
+ int y1 = y - p->thickness / 2;
+ int y2 = y1 + p->thickness;
+
+ for (y = y1; y < y2; y++)
+ for (x = x1; x < x2; x++)
+ if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h)
+ *((byte *)p->surface->getBasePtr(x, y)) =
+ (pat[y % 8] & (1 << (7 - x % 8))) ?
+ color : kColorWhite;
}
}
@@ -214,7 +230,7 @@ void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool m
Common::Rect outer(x1, y1, x2, y2);
- plotData pd(surface, &patterns, borderFillType);
+ plotData pd(surface, &patterns, fillType, 1);
if (mask) {
drawFilledRect(outer, kColorBlack, drawPixelPlain, &pd);
@@ -223,16 +239,19 @@ void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool m
Common::Rect inner(x1 + borderThickness, y1 + borderThickness, x2 - borderThickness, y2 - borderThickness);
if (fillType <= patterns.size()) {
+ pd.fillType = fillType;
+ pd.thickness = 1;
drawFilledRect(outer, kColorBlack, drawPixel, &pd);
+ }
- pd.fillType = fillType;
+ pd.fillType = borderFillType;
+ pd.thickness = borderThickness;
- drawFilledRect(inner, kColorBlack, drawPixel, &pd);
- } else {
- drawThickLine(x1, y1, x2-borderThickness, y1, borderThickness, kColorBlack, drawPixel, &pd);
- drawThickLine(x2-borderThickness, y1, x2-borderThickness, y2, borderThickness, kColorBlack, drawPixel, &pd);
- drawThickLine(x2-borderThickness, y2-borderThickness, x1, y2-borderThickness, borderThickness, kColorBlack, drawPixel, &pd);
- drawThickLine(x1, y2-borderThickness, x1, y1, borderThickness, kColorBlack, drawPixel, &pd);
+ if (borderThickness > 0 && borderFillType <= patterns.size()) {
+ Graphics::drawLine(x1, y1, x2, y1, kColorBlack, drawPixel, &pd);
+ Graphics::drawLine(x2, y1, x2, y2, kColorBlack, drawPixel, &pd);
+ Graphics::drawLine(x2, y2, x1, y2, kColorBlack, drawPixel, &pd);
+ Graphics::drawLine(x1, y2, x1, y1, kColorBlack, drawPixel, &pd);
}
}
@@ -251,7 +270,7 @@ void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, b
Common::Rect outer(x1, y1, x2, y2);
- plotData pd(surface, &patterns, borderFillType);
+ plotData pd(surface, &patterns, borderFillType, 1);
if (mask) {
drawFilledRoundRect(outer, arc, kColorBlack, drawPixelPlain, &pd);
@@ -328,7 +347,7 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
ypoints[i] = ycoords[i];
}
- plotData pd(surface, &patterns, fillType);
+ plotData pd(surface, &patterns, fillType, 1);
if (mask) {
drawPolygonScan(xpoints, ypoints, npoints, bbox, kColorBlack, drawPixelPlain, &pd);
@@ -340,9 +359,10 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
}
pd.fillType = borderFillType;
+ pd.thickness = borderThickness;
if (borderThickness > 0 && borderFillType <= patterns.size()) {
for (int i = 1; i < npoints; i++)
- drawThickLine(xpoints[i-1], ypoints[i-1], xpoints[i], ypoints[i], borderThickness, kColorBlack, drawPixel, &pd);
+ Graphics::drawLine(xpoints[i-1], ypoints[i-1], xpoints[i], ypoints[i], kColorBlack, drawPixel, &pd);
}
free(xpoints);
@@ -356,26 +376,21 @@ void Design::drawOval(Graphics::Surface *surface, Common::ReadStream &in, bool m
int16 y2 = in.readSint16BE();
int16 x2 = in.readSint16BE();
- plotData pd(surface, &patterns, borderFillType);
+ plotData pd(surface, &patterns, fillType, 1);
if (mask) {
drawEllipse(x1, y1, x2, y2, true, drawPixelPlain, &pd);
return;
}
- if (borderThickness > 0 && borderFillType <= patterns.size()) {
- if (borderThickness == 1) {
- drawEllipse(x1, y1, x2-1, y2-1, false, drawPixel, &pd);
- } else {
- drawEllipse(x1, y1, x2-1, y2-1, true, drawPixel, &pd);
- warning("Ellipse thickness >1: borderThickness");
- }
- }
+ if (fillType <= patterns.size())
+ drawEllipse(x1, y1, x2-1, y2-1, true, drawPixel, &pd);
- if (fillType <= patterns.size()) {
- pd.fillType = fillType;
- drawEllipse(x1+borderThickness, y1+borderThickness, x2-1-2*borderThickness, y2-2*borderThickness, true, drawPixel, &pd);
- }
+ pd.fillType = borderFillType;
+ pd.thickness = borderThickness;
+
+ if (borderThickness > 0 && borderFillType <= patterns.size())
+ drawEllipse(x1, y1, x2-1, y2-1, true, drawPixel, &pd);
}
void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool mask) {
@@ -439,7 +454,7 @@ void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool
}
void Design::drawFilledRect(Graphics::Surface *surface, Common::Rect &rect, int color, Patterns &patterns, byte fillType) {
- plotData pd(surface, &patterns, fillType);
+ plotData pd(surface, &patterns, fillType, 1);
for (int y = rect.top; y <= rect.bottom; y++)
drawHLine(rect.left, rect.right, y, color, drawPixel, &pd);
@@ -451,7 +466,7 @@ void Design::drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int,
}
void Design::drawFilledRoundRect(Graphics::Surface *surface, Common::Rect &rect, int arc, int color, Patterns &patterns, byte fillType) {
- plotData pd(surface, &patterns, fillType);
+ plotData pd(surface, &patterns, fillType, 1);
drawFilledRoundRect(rect, arc, color, drawPixel, &pd);
}
Commit: 2db59e9c45d19d4c012a43d200d9ba4ec32b83a8
https://github.com/scummvm/scummvm/commit/2db59e9c45d19d4c012a43d200d9ba4ec32b83a8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T19:47:16+01:00
Commit Message:
WAGE: Switched round rectangles to think brush drawing
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 13ac3a0..9f78560 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -273,20 +273,17 @@ void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, b
plotData pd(surface, &patterns, borderFillType, 1);
if (mask) {
- drawFilledRoundRect(outer, arc, kColorBlack, drawPixelPlain, &pd);
+ drawRoundRect(outer, arc, kColorBlack, true, drawPixelPlain, &pd);
return;
}
Common::Rect inner(x1 + borderThickness, y1 + borderThickness, x2 - borderThickness, y2 - borderThickness);
- drawFilledRoundRect(outer, arc/2, kColorBlack, drawPixel, &pd);
+ drawRoundRect(outer, arc/2, kColorBlack, true, drawPixel, &pd);
pd.fillType = fillType;
+ pd.thickness = borderThickness;
- if (fillType > patterns.size()) {
- warning("Transparent roundrect, border: %d", borderThickness);
- }
-
- drawFilledRoundRect(inner, arc/2, kColorBlack, drawPixel, &pd);
+ drawRoundRect(inner, arc/2, kColorBlack, false, drawPixel, &pd);
}
void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
@@ -468,11 +465,11 @@ void Design::drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int,
void Design::drawFilledRoundRect(Graphics::Surface *surface, Common::Rect &rect, int arc, int color, Patterns &patterns, byte fillType) {
plotData pd(surface, &patterns, fillType, 1);
- drawFilledRoundRect(rect, arc, color, drawPixel, &pd);
+ drawRoundRect(rect, arc, color, true, drawPixel, &pd);
}
// http://members.chello.at/easyfilter/bresenham.html
-void Design::drawFilledRoundRect(Common::Rect &rect, int arc, int color, void (*plotProc)(int, int, int, void *), void *data) {
+void Design::drawRoundRect(Common::Rect &rect, int arc, int color, bool filled, void (*plotProc)(int, int, int, void *), void *data) {
if (rect.height() < rect.width()) {
int x = -arc, y = 0, err = 2-2*arc; /* II. Quadrant */
int dy = rect.height() - arc * 2;
@@ -482,8 +479,15 @@ void Design::drawFilledRoundRect(Common::Rect &rect, int arc, int color, void (*
stop = -dy / 2;
do {
- drawHLine(rect.left+x+r, rect.right-x-r, rect.top-y+r-stop, color, plotProc, data);
- drawHLine(rect.left+x+r, rect.right-x-r, rect.bottom+y-r+stop, color, plotProc, data);
+ if (filled) {
+ drawHLine(rect.left+x+r, rect.right-x-r, rect.top-y+r-stop, color, plotProc, data);
+ drawHLine(rect.left+x+r, rect.right-x-r, rect.bottom+y-r+stop, color, plotProc, data);
+ } else {
+ (*plotProc)(rect.left+x+r, rect.top-y+r-stop, color, data);
+ (*plotProc)(rect.right-x-r, rect.top-y+r-stop, color, data);
+ (*plotProc)(rect.left+x+r, rect.bottom+y-r+stop, color, data);
+ (*plotProc)(rect.right-x-r, rect.bottom+y-r+stop, color, data);
+ }
arc = err;
if (arc <= y) err += ++y*2+1; /* e_xy+e_y < 0 */
if (arc > x || err > y) err += ++x*2+1; /* e_xy+e_x > 0 or no 2nd y-step */
@@ -491,8 +495,14 @@ void Design::drawFilledRoundRect(Common::Rect &rect, int arc, int color, void (*
break;
} while (x < 0);
- for (int i = 0; i < dy; i++)
- drawHLine(rect.left, rect.right, rect.top + r + i, color, plotProc, data);
+ for (int i = 0; i < dy; i++) {
+ if (filled) {
+ drawHLine(rect.left, rect.right, rect.top + r + i, color, plotProc, data);
+ } else {
+ (*plotProc)(rect.left, rect.top + r + i, color, data);
+ (*plotProc)(rect.right, rect.top + r + i, color, data);
+ }
+ }
} else {
int y = -arc, x = 0, err = 2-2*arc; /* II. Quadrant */
int dx = rect.width() - arc * 2;
@@ -502,8 +512,15 @@ void Design::drawFilledRoundRect(Common::Rect &rect, int arc, int color, void (*
stop = -dx / 2;
do {
- drawVLine(rect.left-x+r-stop, rect.top+y+r, rect.bottom-y-r, color, plotProc, data);
- drawVLine(rect.right+x-r+stop, rect.top+y+r, rect.bottom-y-r, color, plotProc, data);
+ if (filled) {
+ drawVLine(rect.left-x+r-stop, rect.top+y+r, rect.bottom-y-r, color, plotProc, data);
+ drawVLine(rect.right+x-r+stop, rect.top+y+r, rect.bottom-y-r, color, plotProc, data);
+ } else {
+ (*plotProc)(rect.left-x+r-stop, rect.top+y+r, color, data);
+ (*plotProc)(rect.left-x+r-stop, rect.bottom-y-r, color, data);
+ (*plotProc)(rect.right+x-r+stop, rect.top+y+r, color, data);
+ (*plotProc)(rect.right+x-r+stop, rect.bottom-y-r, color, data);
+ }
arc = err;
if (arc <= x) err += ++x*2+1; /* e_xy+e_y < 0 */
@@ -512,8 +529,14 @@ void Design::drawFilledRoundRect(Common::Rect &rect, int arc, int color, void (*
break;
} while (y < 0);
- for (int i = 0; i < dx; i++)
- drawVLine(rect.left + r + i, rect.top, rect.bottom, color, plotProc, data);
+ for (int i = 0; i < dx; i++) {
+ if (filled) {
+ drawVLine(rect.left + r + i, rect.top, rect.bottom, color, plotProc, data);
+ } else {
+ (*plotProc)(rect.left + r + i, rect.top, color, data);
+ (*plotProc)(rect.left + r + i, rect.bottom, color, data);
+ }
+ }
}
}
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 2a051f1..9581945 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -90,7 +90,7 @@ private:
void drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool mask);
void drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data);
- static void drawFilledRoundRect(Common::Rect &rect, int arc, int color, void (*plotProc)(int, int, int, void *), void *data);
+ static void drawRoundRect(Common::Rect &rect, int arc, int color, bool filled, void (*plotProc)(int, int, int, void *), void *data);
void drawPolygonScan(int *polyX, int *polyY, int npoints, Common::Rect &bbox, int color,
void (*plotProc)(int, int, int, void *), void *data);
void drawEllipse(int x0, int y0, int x1, int y1, bool filled, void (*plotProc)(int, int, int, void *), void *data);
Commit: 79dfc2bda545be7f6275b9525ddf9df10b5b68f5
https://github.com/scummvm/scummvm/commit/79dfc2bda545be7f6275b9525ddf9df10b5b68f5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T19:52:40+01:00
Commit Message:
WAGE: Fixes to think round rectangle drawing
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 9f78560..7b7365b 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -270,20 +270,19 @@ void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, b
Common::Rect outer(x1, y1, x2, y2);
- plotData pd(surface, &patterns, borderFillType, 1);
+ plotData pd(surface, &patterns, fillType, 1);
if (mask) {
drawRoundRect(outer, arc, kColorBlack, true, drawPixelPlain, &pd);
return;
}
- Common::Rect inner(x1 + borderThickness, y1 + borderThickness, x2 - borderThickness, y2 - borderThickness);
drawRoundRect(outer, arc/2, kColorBlack, true, drawPixel, &pd);
- pd.fillType = fillType;
+ pd.fillType = borderFillType;
pd.thickness = borderThickness;
- drawRoundRect(inner, arc/2, kColorBlack, false, drawPixel, &pd);
+ drawRoundRect(outer, arc/2, kColorBlack, false, drawPixel, &pd);
}
void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
Commit: e2fa8c1de7e252bc8ca1f869e800fa82762decf2
https://github.com/scummvm/scummvm/commit/e2fa8c1de7e252bc8ca1f869e800fa82762decf2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T20:10:31+01:00
Commit Message:
WAGE: Fix menu height
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 01ae5b6..1b5efbf 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -60,9 +60,9 @@
namespace Wage {
enum {
- kMenuHeight = 19,
+ kMenuHeight = 20,
kMenuPadding = 6,
- kMenuItemHeight = 19,
+ kMenuItemHeight = 20,
kBorderWidth = 17,
kDesktopArc = 7,
kComponentsPadding = 10,
@@ -603,7 +603,7 @@ void Gui::renderMenu() {
Design::drawFilledRect(&_screen, r, kColorBlack, p, 1);
const Graphics::Font *font = getMenuFont();
- int y = _builtInFonts ? 3 : 1;
+ int y = _builtInFonts ? 3 : 2;
int x = 18;
for (int i = 0; menuItems[i]; i++) {
Commit: 5c129d65da74be32b8c630a893352b96e06a8e86
https://github.com/scummvm/scummvm/commit/5c129d65da74be32b8c630a893352b96e06a8e86
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T20:19:40+01:00
Commit Message:
WAGE: Fixed ellipse rendering
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 7b7365b..19887a0 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -386,7 +386,7 @@ void Design::drawOval(Graphics::Surface *surface, Common::ReadStream &in, bool m
pd.thickness = borderThickness;
if (borderThickness > 0 && borderFillType <= patterns.size())
- drawEllipse(x1, y1, x2-1, y2-1, true, drawPixel, &pd);
+ drawEllipse(x1, y1, x2-1, y2-1, false, drawPixel, &pd);
}
void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool mask) {
Commit: 4cbabd89a2042ad2d90157a7f12496c2eccf81f4
https://github.com/scummvm/scummvm/commit/4cbabd89a2042ad2d90157a7f12496c2eccf81f4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T20:20:26+01:00
Commit Message:
WAGE: Simplified code
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 19887a0..c2ee09f 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -238,11 +238,8 @@ void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool m
}
Common::Rect inner(x1 + borderThickness, y1 + borderThickness, x2 - borderThickness, y2 - borderThickness);
- if (fillType <= patterns.size()) {
- pd.fillType = fillType;
- pd.thickness = 1;
+ if (fillType <= patterns.size())
drawFilledRect(outer, kColorBlack, drawPixel, &pd);
- }
pd.fillType = borderFillType;
pd.thickness = borderThickness;
Commit: 3eeb240f95a18b0371b5c9c35bdcee56d23e54de
https://github.com/scummvm/scummvm/commit/3eeb240f95a18b0371b5c9c35bdcee56d23e54de
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T21:24:29+01:00
Commit Message:
WAGE: Fixed round rect drawing
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index c2ee09f..82d8ba7 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -95,11 +95,11 @@ void Design::paint(Graphics::Surface *surface, Patterns &patterns, bool mask, in
_surface->fillRect(r, kColorWhite);
}
-/*
- plotData pd(canvas, &patterns, 8);
+#if 0
+ plotData pd(_surface, &patterns, 8, 1);
int x1 = 50, y1 = 50, x2 = 200, y2 = 200, borderThickness = 30;
Common::Rect inn(x1-5, y1-5, x2+5, y2+5);
- drawFilledRect(inn, kColorGray, drawPixelPlain, &pd);
+ drawRoundRect(inn, 6, kColorGray, false, drawPixelPlain, &pd);
drawThickLine(x1, y1, x2-borderThickness, y1, borderThickness, kColorBlack, drawPixel, &pd);
drawThickLine(x2-borderThickness, y1, x2-borderThickness, y2, borderThickness, kColorBlack, drawPixel, &pd);
@@ -107,7 +107,7 @@ void Design::paint(Graphics::Surface *surface, Patterns &patterns, bool mask, in
drawThickLine(x1, y2-borderThickness, x1, y1, borderThickness, kColorBlack, drawPixel, &pd);
drawThickLine(x2+10, y2+10, x2+100, y2+100, borderThickness, kColorBlack, drawPixel, &pd);
- g_system->copyRectToScreen(canvas->getPixels(), canvas->pitch, 0, 0, canvas->w, canvas->h);
+ g_system->copyRectToScreen(_surface->getPixels(), _surface->pitch, 0, 0, _surface->w, _surface->h);
while (true) {
((WageEngine *)g_engine)->processEvents();
@@ -115,9 +115,9 @@ void Design::paint(Graphics::Surface *surface, Patterns &patterns, bool mask, in
g_system->delayMillis(50);
}
return;
-*/
+#endif
- while (true && needRender) {
+ while (needRender) {
byte fillType = in.readByte();
byte borderThickness = in.readByte();
byte borderFillType = in.readByte();
@@ -146,11 +146,6 @@ void Design::paint(Graphics::Surface *surface, Patterns &patterns, bool mask, in
break;
default:
warning("Unknown type => %d", type);
- while (true) {
- ((WageEngine *)g_engine)->processEvents();
- g_system->updateScreen();
- g_system->delayMillis(50);
- }
break;
}
@@ -274,12 +269,14 @@ void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, b
return;
}
- drawRoundRect(outer, arc/2, kColorBlack, true, drawPixel, &pd);
+ if (fillType <= patterns.size())
+ drawRoundRect(outer, arc/2, kColorBlack, true, drawPixel, &pd);
pd.fillType = borderFillType;
pd.thickness = borderThickness;
- drawRoundRect(outer, arc/2, kColorBlack, false, drawPixel, &pd);
+ if (borderThickness > 0 && borderFillType <= patterns.size())
+ drawRoundRect(outer, arc/2, kColorBlack, false, drawPixel, &pd);
}
void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
@@ -471,6 +468,7 @@ void Design::drawRoundRect(Common::Rect &rect, int arc, int color, bool filled,
int dy = rect.height() - arc * 2;
int r = arc;
int stop = 0;
+ int lastx, lasty;
if (dy < 0)
stop = -dy / 2;
@@ -483,6 +481,9 @@ void Design::drawRoundRect(Common::Rect &rect, int arc, int color, bool filled,
(*plotProc)(rect.right-x-r, rect.top-y+r-stop, color, data);
(*plotProc)(rect.left+x+r, rect.bottom+y-r+stop, color, data);
(*plotProc)(rect.right-x-r, rect.bottom+y-r+stop, color, data);
+
+ lastx = x;
+ lasty = y;
}
arc = err;
if (arc <= y) err += ++y*2+1; /* e_xy+e_y < 0 */
@@ -491,6 +492,14 @@ void Design::drawRoundRect(Common::Rect &rect, int arc, int color, bool filled,
break;
} while (x < 0);
+ if (!filled) {
+ x = lastx;
+ y = lasty;
+
+ drawHLine(rect.left+x+r, rect.right-x-r, rect.top-y+r-stop, color, plotProc, data);
+ drawHLine(rect.left+x+r, rect.right-x-r, rect.bottom+y-r+stop, color, plotProc, data);
+ }
+
for (int i = 0; i < dy; i++) {
if (filled) {
drawHLine(rect.left, rect.right, rect.top + r + i, color, plotProc, data);
@@ -504,6 +513,7 @@ void Design::drawRoundRect(Common::Rect &rect, int arc, int color, bool filled,
int dx = rect.width() - arc * 2;
int r = arc;
int stop = 0;
+ int lastx, lasty;
if (dx < 0)
stop = -dx / 2;
@@ -516,6 +526,9 @@ void Design::drawRoundRect(Common::Rect &rect, int arc, int color, bool filled,
(*plotProc)(rect.left-x+r-stop, rect.bottom-y-r, color, data);
(*plotProc)(rect.right+x-r+stop, rect.top+y+r, color, data);
(*plotProc)(rect.right+x-r+stop, rect.bottom-y-r, color, data);
+
+ lastx = x;
+ lasty = y;
}
arc = err;
@@ -525,6 +538,13 @@ void Design::drawRoundRect(Common::Rect &rect, int arc, int color, bool filled,
break;
} while (y < 0);
+ if (!filled) {
+ x = lastx;
+ y = lasty;
+ drawVLine(rect.left-x+r-stop, rect.top+y+r, rect.bottom-y-r, color, plotProc, data);
+ drawVLine(rect.right+x-r+stop, rect.top+y+r, rect.bottom-y-r, color, plotProc, data);
+ }
+
for (int i = 0; i < dx; i++) {
if (filled) {
drawVLine(rect.left + r + i, rect.top, rect.bottom, color, plotProc, data);
Commit: e4002d3fee0ce59adc93983a6232cc51b606a7e7
https://github.com/scummvm/scummvm/commit/e4002d3fee0ce59adc93983a6232cc51b606a7e7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T22:59:11+01:00
Commit Message:
WAGE: Fixed bitmap rendering
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 82d8ba7..6c8fa7f 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -395,11 +395,11 @@ void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool
numBytes -= 10;
int x = 0, y = 0;
- while (numBytes) {
+ while (numBytes > 0) {
int n = in.readSByte();
int count;
int b;
- int state;
+ int state = 0;
numBytes--;
@@ -433,14 +433,23 @@ void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool
y++;
if (y == h)
- return;
+ break;
x = 0;
break;
}
}
+
+ if (y == h)
+ break;
}
+
+ if (y == h)
+ break;
}
+
+ while (numBytes--)
+ in.readByte();
}
void Design::drawFilledRect(Graphics::Surface *surface, Common::Rect &rect, int color, Patterns &patterns, byte fillType) {
Commit: 9d09466f505c95e23b2e7e508a2320e33fc596ea
https://github.com/scummvm/scummvm/commit/9d09466f505c95e23b2e7e508a2320e33fc596ea
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T23:00:40+01:00
Commit Message:
WAGE: Simplified bitmap code
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 6c8fa7f..a5d217b 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -395,7 +395,7 @@ void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool
numBytes -= 10;
int x = 0, y = 0;
- while (numBytes > 0) {
+ while (numBytes > 0 && y < h) {
int n = in.readSByte();
int count;
int b;
@@ -415,7 +415,7 @@ void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool
count = 0;
}
- for (int i = 0; i < count; i++) {
+ for (int i = 0; i < count && y < h; i++) {
byte color;
if (state == 1) {
color = in.readByte();
@@ -439,13 +439,7 @@ void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool
break;
}
}
-
- if (y == h)
- break;
}
-
- if (y == h)
- break;
}
while (numBytes--)
Commit: 0aaab27025aa12382e76db1ec6b43016340b6b1d
https://github.com/scummvm/scummvm/commit/0aaab27025aa12382e76db1ec6b43016340b6b1d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T23:12:55+01:00
Commit Message:
WAGE: Remove redundant code
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
engines/wage/entities.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index a5d217b..18ba83c 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -78,7 +78,7 @@ Design::~Design() {
delete _surface;
}
-void Design::paint(Graphics::Surface *surface, Patterns &patterns, bool mask, int x, int y) {
+void Design::paint(Graphics::Surface *surface, Patterns &patterns, int x, int y) {
Common::MemoryReadStream in(_data, _len);
Common::Rect r(0, 0, _bounds->width(), _bounds->height());
bool needRender = false;
@@ -91,10 +91,6 @@ void Design::paint(Graphics::Surface *surface, Patterns &patterns, bool mask, in
needRender = true;
}
- if (mask) {
- _surface->fillRect(r, kColorWhite);
- }
-
#if 0
plotData pd(_surface, &patterns, 8, 1);
int x1 = 50, y1 = 50, x2 = 200, y2 = 200, borderThickness = 30;
@@ -129,20 +125,20 @@ void Design::paint(Graphics::Surface *surface, Patterns &patterns, bool mask, in
debug(8, "fill: %d borderFill: %d border: %d type: %d", fillType, borderFillType, borderThickness, type);
switch (type) {
case 4:
- drawRect(_surface, in, mask, patterns, fillType, borderThickness, borderFillType);
+ drawRect(_surface, in, patterns, fillType, borderThickness, borderFillType);
break;
case 8:
- drawRoundRect(_surface, in, mask, patterns, fillType, borderThickness, borderFillType);
+ drawRoundRect(_surface, in, patterns, fillType, borderThickness, borderFillType);
break;
case 12:
- drawOval(_surface, in, mask, patterns, fillType, borderThickness, borderFillType);
+ drawOval(_surface, in, patterns, fillType, borderThickness, borderFillType);
break;
case 16:
case 20:
- drawPolygon(_surface, in, mask, patterns, fillType, borderThickness, borderFillType);
+ drawPolygon(_surface, in, patterns, fillType, borderThickness, borderFillType);
break;
case 24:
- drawBitmap(_surface, in, mask);
+ drawBitmap(_surface, in);
break;
default:
warning("Unknown type => %d", type);
@@ -211,7 +207,7 @@ void drawPixelPlain(int x, int y, int color, void *data) {
*((byte *)p->surface->getBasePtr(x, y)) = (byte)color;
}
-void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
+void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
int16 y1 = in.readSint16BE();
int16 x1 = in.readSint16BE();
@@ -223,18 +219,11 @@ void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool m
if (y1 > y2)
SWAP(y1, y2);
- Common::Rect outer(x1, y1, x2, y2);
-
+ Common::Rect r(x1, y1, x2, y2);
plotData pd(surface, &patterns, fillType, 1);
- if (mask) {
- drawFilledRect(outer, kColorBlack, drawPixelPlain, &pd);
- return;
- }
- Common::Rect inner(x1 + borderThickness, y1 + borderThickness, x2 - borderThickness, y2 - borderThickness);
-
if (fillType <= patterns.size())
- drawFilledRect(outer, kColorBlack, drawPixel, &pd);
+ drawFilledRect(r, kColorBlack, drawPixel, &pd);
pd.fillType = borderFillType;
pd.thickness = borderThickness;
@@ -247,7 +236,7 @@ void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool m
}
}
-void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
+void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
int16 y1 = in.readSint16BE();
int16 x1 = in.readSint16BE();
@@ -260,26 +249,20 @@ void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, b
if (y1 > y2)
SWAP(y1, y2);
- Common::Rect outer(x1, y1, x2, y2);
-
+ Common::Rect r(x1, y1, x2, y2);
plotData pd(surface, &patterns, fillType, 1);
- if (mask) {
- drawRoundRect(outer, arc, kColorBlack, true, drawPixelPlain, &pd);
- return;
- }
-
if (fillType <= patterns.size())
- drawRoundRect(outer, arc/2, kColorBlack, true, drawPixel, &pd);
+ drawRoundRect(r, arc/2, kColorBlack, true, drawPixel, &pd);
pd.fillType = borderFillType;
pd.thickness = borderThickness;
if (borderThickness > 0 && borderFillType <= patterns.size())
- drawRoundRect(outer, arc/2, kColorBlack, false, drawPixel, &pd);
+ drawRoundRect(r, arc/2, kColorBlack, false, drawPixel, &pd);
}
-void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
+void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
byte ignored = in.readSint16BE(); // ignored
@@ -339,11 +322,6 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
plotData pd(surface, &patterns, fillType, 1);
- if (mask) {
- drawPolygonScan(xpoints, ypoints, npoints, bbox, kColorBlack, drawPixelPlain, &pd);
- return;
- }
-
if (fillType <= patterns.size()) {
drawPolygonScan(xpoints, ypoints, npoints, bbox, kColorBlack, drawPixel, &pd);
}
@@ -359,20 +337,14 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
free(ypoints);
}
-void Design::drawOval(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
+void Design::drawOval(Graphics::Surface *surface, Common::ReadStream &in,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
int16 y1 = in.readSint16BE();
int16 x1 = in.readSint16BE();
int16 y2 = in.readSint16BE();
int16 x2 = in.readSint16BE();
-
plotData pd(surface, &patterns, fillType, 1);
- if (mask) {
- drawEllipse(x1, y1, x2, y2, true, drawPixelPlain, &pd);
- return;
- }
-
if (fillType <= patterns.size())
drawEllipse(x1, y1, x2-1, y2-1, true, drawPixel, &pd);
@@ -383,7 +355,7 @@ void Design::drawOval(Graphics::Surface *surface, Common::ReadStream &in, bool m
drawEllipse(x1, y1, x2-1, y2-1, false, drawPixel, &pd);
}
-void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool mask) {
+void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in) {
int numBytes = in.readSint16BE();
int y1 = in.readSint16BE();
int x1 = in.readSint16BE();
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 9581945..214e6e4 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -67,7 +67,7 @@ public:
return _bounds;
}
- void paint(Graphics::Surface *canvas, Patterns &patterns, bool mask, int x, int y);
+ void paint(Graphics::Surface *canvas, Patterns &patterns, int x, int y);
bool isPointOpaque(int x, int y);
static void drawFilledRect(Graphics::Surface *surface, Common::Rect &rect, int color, Patterns &patterns, byte fillType);
static void drawFilledRoundRect(Graphics::Surface *surface, Common::Rect &rect, int arc, int color, Patterns &patterns, byte fillType);
@@ -79,15 +79,15 @@ private:
Graphics::Surface *_surface;
private:
- void drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
+ void drawRect(Graphics::Surface *surface, Common::ReadStream &in,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
- void drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
+ void drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
- void drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
+ void drawPolygon(Graphics::Surface *surface, Common::ReadStream &in,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
- void drawOval(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
+ void drawOval(Graphics::Surface *surface, Common::ReadStream &in,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
- void drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool mask);
+ void drawBitmap(Graphics::Surface *surface, Common::ReadStream &in);
void drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data);
static void drawRoundRect(Common::Rect &rect, int arc, int color, bool filled, void (*plotProc)(int, int, int, void *), void *data);
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 614b831..c93a47f 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -126,16 +126,16 @@ void Scene::paint(Graphics::Surface *surface, int x, int y) {
Common::Rect r(x + 5, y + 5, _design->getBounds()->width() + x - 10, _design->getBounds()->height() + y - 10);
surface->fillRect(r, kColorWhite);
- _design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, false, x, y);
+ _design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, x, y);
for (Common::List<Obj *>::const_iterator it = _objs.begin(); it != _objs.end(); ++it) {
debug(2, "paining Obj: %s", (*it)->_name.c_str());
- (*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, false, x, y);
+ (*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, x, y);
}
for (Common::List<Chr *>::const_iterator it = _chrs.begin(); it != _chrs.end(); ++it) {
debug(2, "paining Chr: %s", (*it)->_name.c_str());
- (*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, false, x, y);
+ (*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, x, y);
}
}
Commit: 41bad49b4a521c35266a3fd3829013a8e9ca2387
https://github.com/scummvm/scummvm/commit/41bad49b4a521c35266a3fd3829013a8e9ca2387
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T23:13:05+01:00
Commit Message:
WAGE: Do not copy scene under border. Removes gfx glitch
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 18ba83c..0e94db3 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -150,10 +150,11 @@ void Design::paint(Graphics::Surface *surface, Patterns &patterns, int x, int y)
//g_system->updateScreen();
}
- for (int i = 0; i < _bounds->height(); i++) {
- const byte *src = (const byte *)_surface->getBasePtr(0, i);
- byte *dst = (byte *)surface->getBasePtr(x, y+i);
- for (int j = 0; j < _bounds->width(); j++) {
+ const int padding = 3;
+ for (int i = padding; i < _bounds->height() - 2 * padding; i++) {
+ const byte *src = (const byte *)_surface->getBasePtr(padding, i);
+ byte *dst = (byte *)surface->getBasePtr(x + padding, y+i);
+ for (int j = padding; j < _bounds->width() - 2 * padding; j++) {
if (*src != kColorGreen)
*dst = *src;
src++;
Commit: ba34243d5bbe7918bd43950cd84d775e946beb49
https://github.com/scummvm/scummvm/commit/ba34243d5bbe7918bd43950cd84d775e946beb49
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T23:17:27+01:00
Commit Message:
WAGE: Make console window active when text is entered. Matches original
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 1b5efbf..d8bb220 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -507,6 +507,11 @@ void Gui::drawInput() {
if (!_screen.getPixels())
return;
+ if (_sceneIsActive) {
+ _sceneIsActive = false;
+ _bordersDirty = true;
+ }
+
const Graphics::Font *font = getConsoleFont();
int x = kConWPadding + _consoleTextArea.left;
Commit: 2ec86f1381dad48b25038bd02303f2bc380fb8d6
https://github.com/scummvm/scummvm/commit/2ec86f1381dad48b25038bd02303f2bc380fb8d6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T23:40:18+01:00
Commit Message:
WAGE: Fix command processing
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 951a5d3..de4b935 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -85,6 +85,10 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
_inputClick = inputClick;
_callbacks = callbacks;
_handled = false;
+ Common::String input;
+
+ if (inputText)
+ input = *inputText;
_data->seek(12);
while (_data->pos() < _data->size()) {
@@ -150,11 +154,10 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
if (_world->_globalScript != this) {
debug(1, "Executing global script...");
- bool globalHandled = _world->_globalScript->execute(_world, _loopCount, _inputText, _inputClick, _callbacks);
+ bool globalHandled = _world->_globalScript->execute(_world, _loopCount, &input, _inputClick, _callbacks);
if (globalHandled)
_handled = true;
- } else if (inputText != NULL) {
- Common::String input(*inputText);
+ } else if (!input.empty()) {
input.toLowercase();
if (input.equals("n") || input.contains("north")) {
handleMoveCommand(Scene::NORTH, "north");
Commit: bc8b63cfb4162ceed617792ad35777504b12b37b
https://github.com/scummvm/scummvm/commit/bc8b63cfb4162ceed617792ad35777504b12b37b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-04T23:46:31+01:00
Commit Message:
WAGE: Full redraw on scene change
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index d8bb220..7afcf22 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -151,9 +151,6 @@ Gui::Gui(WageEngine *engine) {
_consoleFullRedraw = true;
_screen.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8());
- Patterns p;
- p.push_back(checkersPattern);
-
_scrollPos = 0;
_consoleLineHeight = 8; // Dummy value which makes sense
_consoleNumLines = 24; // Dummy value
@@ -172,11 +169,6 @@ Gui::Gui(WageEngine *engine) {
_cursorIsArrow = true;
CursorMan.showMouse(true);
- // Draw desktop
- Common::Rect r(0, 0, _screen.w - 1, _screen.h - 1);
- Design::drawFilledRoundRect(&_screen, r, kDesktopArc, kColorBlack, p, 1);
- g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, _screen.h);
-
loadFonts();
g_system->getTimerManager()->installTimerProc(&cursor_timer_handler, 200000, this, "wageCursor");
@@ -254,7 +246,18 @@ void Gui::appendText(String &str) {
void Gui::draw() {
if (_scene != _engine->_world->_player->_currentScene || _sceneDirty) {
_scene = _engine->_world->_player->_currentScene;
+
+ // Draw desktop
+ Patterns p;
+ p.push_back(checkersPattern);
+ Common::Rect r(0, 0, _screen.w - 1, _screen.h - 1);
+ Design::drawFilledRoundRect(&_screen, r, kDesktopArc, kColorBlack, p, 1);
+ g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, _screen.h);
+
_sceneDirty = true;
+ _consoleDirty = true;
+ _menuDirty = true;
+ _consoleFullRedraw = true;
_scene->paint(&_screen, 0 + kComponentsPadding, kMenuHeight + kComponentsPadding);
@@ -279,10 +282,10 @@ void Gui::draw() {
paintBorder(&_screen, _sceneArea, kWindowScene);
// Render console
- if (_consoleDirty)
+ if (_consoleDirty || _consoleFullRedraw)
renderConsole(&_screen, _consoleTextArea);
- if (_bordersDirty || _consoleDirty)
+ if (_bordersDirty || _consoleDirty || _consoleFullRedraw)
paintBorder(&_screen, _consoleTextArea, kWindowConsole);
if (_menuDirty)
Commit: ca7470b697edf06150dcf49056d47a0789fe8350
https://github.com/scummvm/scummvm/commit/ca7470b697edf06150dcf49056d47a0789fe8350
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-05T19:02:33+01:00
Commit Message:
WAGE: Fix bitmap drawing by implementing flood fill algorithm
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 0e94db3..71a55be 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -148,6 +148,7 @@ void Design::paint(Graphics::Surface *surface, Patterns &patterns, int x, int y)
//g_system->copyRectToScreen(_surface->getPixels(), _surface->pitch, 0, 0, _surface->w, _surface->h);
//((WageEngine *)g_engine)->processEvents();
//g_system->updateScreen();
+ //g_system->delayMillis(500);
}
const int padding = 3;
@@ -364,6 +365,9 @@ void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in) {
int x2 = in.readSint16BE();
int w = x2 - x1;
int h = y2 - y1;
+ Graphics::Surface tmp;
+
+ tmp.create(w, h, Graphics::PixelFormat::createFormatCLUT8());
numBytes -= 10;
@@ -398,16 +402,10 @@ void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in) {
for (int c = 0; c < 8; c++) {
if (x1 + x >= 0 && x1 + x < surface->w && y1 + y >= 0 && y1 + y < surface->h)
- *((byte *)surface->getBasePtr(x1 + x, y1 + y)) =
- (color & (1 << (7 - c % 8))) ?
- kColorBlack : kColorWhite;
+ *((byte *)tmp.getBasePtr(x, y)) = (color & (1 << (7 - c % 8))) ? kColorBlack : kColorWhite;
x++;
if (x == w) {
y++;
-
- if (y == h)
- break;
-
x = 0;
break;
}
@@ -417,6 +415,28 @@ void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in) {
while (numBytes--)
in.readByte();
+
+ FloodFill ff(&tmp, kColorWhite, kColorGreen);
+ for (int yy = 0; yy < h; yy++) {
+ ff.addSeed(0, yy);
+ ff.addSeed(w - 1, yy);
+ }
+ for (int xx = 0; xx < w; xx++) {
+ ff.addSeed(xx, 0);
+ ff.addSeed(xx, h - 1);
+ }
+ ff.fill();
+
+ for (y = 0; y < h; y++) {
+ byte *src = (byte *)tmp.getBasePtr(0, y);
+ byte *dst = (byte *)surface->getBasePtr(x1, y1 + y);
+ for (x = 0; x < w; x++) {
+ if (*src != kColorGreen)
+ *dst = *src;
+ src++;
+ dst++;
+ }
+ }
}
void Design::drawFilledRect(Graphics::Surface *surface, Common::Rect &rect, int color, Patterns &patterns, byte fillType) {
@@ -790,5 +810,54 @@ void Design::drawThickLine (int x1, int y1, int x2, int y2, int thick, int color
}
}
+FloodFill::FloodFill(Graphics::Surface *surface, byte color1, byte color2) {
+ _surface = surface;
+ _color1 = color1;
+ _color2 = color2;
+ _w = surface->w;
+ _h = surface->h;
+
+ _visited = (byte *)calloc(_w * _h, 1);
+}
+
+FloodFill::~FloodFill() {
+ while(_queue.size()) {
+ Common::Point *p = _queue.front();
+
+ delete p;
+ _queue.pop_front();
+ }
+
+ free(_visited);
+}
+
+void FloodFill::addSeed(int x, int y) {
+ byte *p;
+
+ if (x >= 0 && x < _w && y >= 0 && y < _h) {
+ if (!_visited[y * _w + x] && *(p = (byte *)_surface->getBasePtr(x, y)) == _color1) {
+ _visited[y * _w + x] = 1;
+ *p = _color2;
+
+ Common::Point *pt = new Common::Point(x, y);
+
+ _queue.push_back(pt);
+ }
+ }
+}
+
+void FloodFill::fill() {
+ while (_queue.size()) {
+ Common::Point *p = _queue.front();
+ _queue.pop_front();
+ addSeed(p->x , p->y - 1);
+ addSeed(p->x - 1, p->y );
+ addSeed(p->x , p->y + 1);
+ addSeed(p->x + 1, p->y );
+
+ delete p;
+ }
+}
+
} // End of namespace Wage
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 214e6e4..74ee5b3 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -100,6 +100,21 @@ private:
void (*plotProc)(int, int, int, void *), void *data);
};
+class FloodFill {
+public:
+ FloodFill(Graphics::Surface *surface, byte color1, byte color2);
+ ~FloodFill();
+ void addSeed(int x, int y);
+ void fill();
+
+private:
+ Common::List<Common::Point *> _queue;
+ Graphics::Surface *_surface;
+ byte _color1, _color2;
+ byte *_visited;
+ int _w, _h;
+};
+
} // End of namespace Wage
#endif
Commit: 05ffd45360eb01b746377f5e62db1f2fe072da74
https://github.com/scummvm/scummvm/commit/05ffd45360eb01b746377f5e62db1f2fe072da74
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-05T19:04:09+01:00
Commit Message:
WAGE: Remove debug output
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index de4b935..8fe08f3 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -881,9 +881,6 @@ void Script::processMove() {
if (skip != 0xfd)
error("No end for MOVE: %02x", skip);
- debug(6, "MOVE: [what=%d/%s, to=%d/%s]",
- what->_type, what->toString().c_str(), to->_type, to->toString().c_str());
-
evaluatePair(what, "M", to);
}
Commit: 8763ca48416287eb61863f90d856aa65e79abc71
https://github.com/scummvm/scummvm/commit/8763ca48416287eb61863f90d856aa65e79abc71
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-05T19:31:08+01:00
Commit Message:
WAGE: Fix scene transitions
Changed paths:
engines/wage/wage.cpp
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 6cf9e39..4d66f82 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -367,7 +367,6 @@ void WageEngine::redrawScene() {
Scene *currentScene = _world->_player->_currentScene;
if (currentScene != NULL) {
//bool firstTime = (_lastScene != currentScene);
- _lastScene = currentScene;
warning("STUB: WageEngine::redrawScene()");
Commit: 57372c7375b992cd03666b638626a52af5b0aa34
https://github.com/scummvm/scummvm/commit/57372c7375b992cd03666b638626a52af5b0aa34
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-05T19:31:25+01:00
Commit Message:
WAGE: Fix console clearing
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 7afcf22..d4eb2b0 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -213,6 +213,8 @@ const Graphics::Font *Gui::getTitleFont() {
void Gui::clearOutput() {
_out.clear();
+ _lines.clear();
+ _consoleFullRedraw = true;
}
void Gui::appendText(String &str) {
Commit: 5d715e178aa3b8bb4db4d20931712b1c0e4af6ff
https://github.com/scummvm/scummvm/commit/5d715e178aa3b8bb4db4d20931712b1c0e4af6ff
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-06T00:41:02+01:00
Commit Message:
WAGE: Added detection for "Escape from School!"
Changed paths:
engines/wage/detection.cpp
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
index cd6fe2b..6db0645 100644
--- a/engines/wage/detection.cpp
+++ b/engines/wage/detection.cpp
@@ -41,6 +41,7 @@ static const PlainGameDescriptor wageGames[] = {
{"afm", "Another Fine Mess"},
{"amot", "A Mess O' Trouble"},
{"cantitoe", "Camp Cantitoe"},
+ {"escapefromschool", "Escape from School!"},
{"wage", "World Adventure Game Engine game"},
{0, 0}
};
@@ -75,6 +76,15 @@ static const ADGameDescription gameDescriptions[] = {
ADGF_NO_FLAGS,
GUIO0()
},
+ {
+ "escapefromschool",
+ "",
+ AD_ENTRY1s("Escape from School!", "a854be48d4af20126d18a9cad93a969b", 51840),
+ Common::EN_ANY,
+ Common::kPlatformMacintosh,
+ ADGF_NO_FLAGS,
+ GUIO0()
+ },
AD_TABLE_END_MARKER
};
Commit: 1f9e724a53a0f3a0bd16bb4ecf3994f14cb51ddf
https://github.com/scummvm/scummvm/commit/1f9e724a53a0f3a0bd16bb4ecf3994f14cb51ddf
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-06T00:53:55+01:00
Commit Message:
WAGE: Added detection for "Queen Quest"
Changed paths:
engines/wage/detection.cpp
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
index 6db0645..bdc59e9 100644
--- a/engines/wage/detection.cpp
+++ b/engines/wage/detection.cpp
@@ -42,6 +42,7 @@ static const PlainGameDescriptor wageGames[] = {
{"amot", "A Mess O' Trouble"},
{"cantitoe", "Camp Cantitoe"},
{"escapefromschool", "Escape from School!"},
+ {"queenquest", "Queen Quest"},
{"wage", "World Adventure Game Engine game"},
{0, 0}
};
@@ -85,6 +86,15 @@ static const ADGameDescription gameDescriptions[] = {
ADGF_NO_FLAGS,
GUIO0()
},
+ {
+ "queenquest",
+ "",
+ AD_ENTRY1s("Queen Quest", "730605d312efedb5e3ff108522fcac18", 59776),
+ Common::EN_ANY,
+ Common::kPlatformMacintosh,
+ ADGF_NO_FLAGS,
+ GUIO0()
+ },
AD_TABLE_END_MARKER
};
Commit: 550d393341dbf206ffc33e5effa31eb40d427358
https://github.com/scummvm/scummvm/commit/550d393341dbf206ffc33e5effa31eb40d427358
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-06T23:07:04+01:00
Commit Message:
WAGE: Fix crash
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 8fe08f3..a80f0ac 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -952,7 +952,7 @@ void Script::handleMoveCommand(Scene::Directions dir, const char *dirName) {
return;
}
}
- if (msg != NULL && msg.size() > 0) {
+ if (msg.size() > 0) {
appendText(msg);
} else {
Common::String txt("You can't go ");
Commit: af691d995974be826a7b4784cc021b02a812d7fe
https://github.com/scummvm/scummvm/commit/af691d995974be826a7b4784cc021b02a812d7fe
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-06T23:17:21+01:00
Commit Message:
WAGE: Fix crash with empty input
Changed paths:
engines/wage/wage.cpp
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 4d66f82..5fa5626 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -169,6 +169,9 @@ void WageEngine::processEvents() {
break;
case Common::KEYCODE_RETURN:
+ if (_inputText.empty())
+ break;
+
processTurn(&_inputText, NULL);
_inputText = "";
_gui->drawInput();
Commit: b28dc762df03662bee8c43e7fbd7472132dcd333
https://github.com/scummvm/scummvm/commit/b28dc762df03662bee8c43e7fbd7472132dcd333
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-06T23:19:51+01:00
Commit Message:
WAGE: Fix warnings
Changed paths:
engines/wage/wage.cpp
engines/wage/world.cpp
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 5fa5626..7ea5bc1 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -234,19 +234,19 @@ void WageEngine::gameOver() {
void WageEngine::performInitialSetup() {
debug(5, "Resetting Objs: %d", _world->_orderedObjs.size());
- for (int i = 0; i < _world->_orderedObjs.size() - 1; i++)
+ for (uint i = 0; i < _world->_orderedObjs.size() - 1; i++)
_world->move(_world->_orderedObjs[i], _world->_storageScene, true);
_world->move(_world->_orderedObjs[_world->_orderedObjs.size() - 1], _world->_storageScene);
debug(5, "Resetting Chrs: %d", _world->_orderedChrs.size());
- for (int i = 0; i < _world->_orderedChrs.size() - 1; i++)
+ for (uint i = 0; i < _world->_orderedChrs.size() - 1; i++)
_world->move(_world->_orderedChrs[i], _world->_storageScene, true);
_world->move(_world->_orderedChrs[_world->_orderedChrs.size() - 1], _world->_storageScene);
debug(5, "Resetting Owners: %d", _world->_orderedObjs.size());
- for (int i = 0; i < _world->_orderedObjs.size(); i++) {
+ for (uint i = 0; i < _world->_orderedObjs.size(); i++) {
Obj *obj = _world->_orderedObjs[i];
if (!obj->_sceneOrOwner.equalsIgnoreCase(STORAGESCENE)) {
String location = obj->_sceneOrOwner;
@@ -266,7 +266,7 @@ void WageEngine::performInitialSetup() {
}
bool playerPlaced = false;
- for (int i = 0; i < _world->_orderedChrs.size(); i++) {
+ for (uint i = 0; i < _world->_orderedChrs.size(); i++) {
Chr *chr = _world->_orderedChrs[i];
if (!chr->_initialScene.equalsIgnoreCase(STORAGESCENE)) {
String key = chr->_initialScene;
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index f0d7c97..ab7b727 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -435,7 +435,7 @@ Scene *World::getRandomScene() {
}
Scene *World::getSceneAt(int x, int y) {
- for (int i = 0; i < _orderedScenes.size(); i++) {
+ for (uint i = 0; i < _orderedScenes.size(); i++) {
Scene *scene = _orderedScenes[i];
if (scene != _storageScene && scene->_worldX == x && scene->_worldY == y) {
Commit: fdfb4eedcd438096d0ec45ea055be2da465dd437
https://github.com/scummvm/scummvm/commit/fdfb4eedcd438096d0ec45ea055be2da465dd437
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-06T23:39:35+01:00
Commit Message:
WAGE: More warning fixes
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index d4eb2b0..a50c485 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -230,7 +230,7 @@ void Gui::appendText(String &str) {
// and push substrings individually
Common::String tmp = "";
- for (int i = 0; i < str.size(); i++) {
+ for (uint i = 0; i < str.size(); i++) {
if (str[i] == '\n') {
_out.push_back(tmp);
flowText(tmp);
@@ -432,7 +432,7 @@ void Gui::flowText(String &str) {
for (Common::StringArray::const_iterator j = wrappedLines.begin(); j != wrappedLines.end(); ++j)
_lines.push_back(*j);
- int pos = _scrollPos;
+ uint pos = _scrollPos;
_scrollPos = MAX<int>(0, (_lines.size() - _consoleNumLines) * _consoleLineHeight);
_cursorX = kConWPadding;
@@ -481,7 +481,7 @@ void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) {
if (textReflow) {
_lines.clear();
- for (int i = 0; i < _out.size(); i++)
+ for (uint i = 0; i < _out.size(); i++)
flowText(_out[i]);
}
Commit: ac0be3401c7fc68da523d52e3757cbfede18c716
https://github.com/scummvm/scummvm/commit/ac0be3401c7fc68da523d52e3757cbfede18c716
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-06T23:40:59+01:00
Commit Message:
WAGE: Clean up world on exit
Changed paths:
engines/wage/world.cpp
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index ab7b727..0b8529e 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -73,7 +73,17 @@ World::World(WageEngine *engine) {
}
World::~World() {
- delete _storageScene;
+ for (uint i = 0; i < _orderedObjs.size(); i++)
+ delete _orderedObjs[i];
+
+ for (uint i = 0; i < _orderedChrs.size(); i++)
+ delete _orderedChrs[i];
+
+ for (uint i = 0; i < _orderedSounds.size(); i++)
+ delete _orderedSounds[i];
+
+ for (uint i = 0; i < _orderedScenes.size(); i++)
+ delete _orderedScenes[i];
}
bool World::loadWorld(Common::MacResManager *resMan) {
Commit: 4ba3da8b9b495d27bd486c78e469782fa9f75344
https://github.com/scummvm/scummvm/commit/4ba3da8b9b495d27bd486c78e469782fa9f75344
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-06T23:40:59+01:00
Commit Message:
WAGE: Plug memory leak
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index a50c485..668a20f 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -175,6 +175,7 @@ Gui::Gui(WageEngine *engine) {
}
Gui::~Gui() {
+ _screen.free();
g_system->getTimerManager()->removeTimerProc(&cursor_timer_handler);
}
Commit: 4a9bb72cd83750f81407ae541e79a8a8a5659eb3
https://github.com/scummvm/scummvm/commit/4a9bb72cd83750f81407ae541e79a8a8a5659eb3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-06T23:48:04+01:00
Commit Message:
WAGE: Plug memory leak
Changed paths:
engines/wage/entities.cpp
engines/wage/entities.h
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index c93a47f..3094d21 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -59,6 +59,11 @@ void Designed::setDesignBounds(Common::Rect *bounds) {
_design->setBounds(bounds);
}
+Designed::~Designed() {
+ delete _design;
+ delete _designBounds;
+}
+
Context::Context() {
_visits = 0;
_kills = 0;
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index f6cb525..7cfe35f 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -116,6 +116,7 @@ public:
class Designed {
public:
Designed() : _design(NULL), _designBounds(NULL), _classType(UNKNOWN) {}
+ ~Designed();
String _name;
Design *_design;
Commit: f67b43eec871cc0726478f0228c16604aebd9487
https://github.com/scummvm/scummvm/commit/f67b43eec871cc0726478f0228c16604aebd9487
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-06T23:49:57+01:00
Commit Message:
WAGE: Fix unsigned/signed comparison
Changed paths:
engines/wage/entities.cpp
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 3094d21..d99ad74 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -229,7 +229,7 @@ Obj::Obj(String name, Common::SeekableReadStream *data) {
Chr *Obj::removeFromChr() {
if (_currentOwner != NULL) {
- for (int i = _currentOwner->_inventory.size() - 1; i >= 0; i--)
+ for (int i = (int)_currentOwner->_inventory.size() - 1; i >= 0; i--)
if (_currentOwner->_inventory[i] == this)
_currentOwner->_inventory.remove_at(i);
@@ -358,7 +358,7 @@ WeaponArray *Chr::getWeapons() {
}
void Chr::wearObjs() {
- for (int i = 0; i < _inventory.size(); i++)
+ for (uint i = 0; i < _inventory.size(); i++)
wearObjIfPossible(_inventory[i]);
}
Commit: 71f41f9ff88b3096352199a09660aa9a96d42926
https://github.com/scummvm/scummvm/commit/71f41f9ff88b3096352199a09660aa9a96d42926
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-06T23:52:16+01:00
Commit Message:
WAGE: Plug another leak
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 71a55be..74a97ed 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -75,6 +75,7 @@ Design::Design(Common::SeekableReadStream *data) {
Design::~Design() {
free(_data);
+ _surface->free();
delete _surface;
}
Commit: ac6e5cc48a63940954d23e9fe3d59e8e2779b860
https://github.com/scummvm/scummvm/commit/ac6e5cc48a63940954d23e9fe3d59e8e2779b860
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-06T23:52:39+01:00
Commit Message:
WAGE: Fix warning
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 74a97ed..8714d41 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -55,7 +55,7 @@ namespace Wage {
struct plotData {
Graphics::Surface *surface;
Patterns *patterns;
- int fillType;
+ uint fillType;
int thickness;
plotData(Graphics::Surface *s, Patterns *p, int f, int t) :
Commit: f9ea23f6a5e0359aa5bad1be7a38d25922e35791
https://github.com/scummvm/scummvm/commit/f9ea23f6a5e0359aa5bad1be7a38d25922e35791
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-06T23:58:37+01:00
Commit Message:
WAGE: More leak plugging
Changed paths:
engines/wage/entities.cpp
engines/wage/script.cpp
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index d99ad74..606e309 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -122,6 +122,8 @@ Scene::Scene(String name, Common::SeekableReadStream *data) {
_soundName = readPascalString(data);
_visited = false;
+
+ delete data;
}
Scene::~Scene() {
@@ -225,6 +227,8 @@ Obj::Obj(String name, Common::SeekableReadStream *data) {
_failureMessage = readPascalString(data);
_useMessage = readPascalString(data);
_sound = readPascalString(data);
+
+ delete data;
}
Chr *Obj::removeFromChr() {
@@ -333,6 +337,8 @@ Chr::Chr(String name, Common::SeekableReadStream *data) {
for (int i = 0; i < NUMBER_OF_ARMOR_TYPES; i++)
_armor[i] = NULL;
+
+ delete data;
}
void Chr::resetState() {
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index a80f0ac..b8b71ea 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -62,6 +62,8 @@ Script::~Script() {
for (int i = 0; i < _scriptText.size(); i++) {
delete _scriptText[i];
}
+
+ delete _data;
}
void Script::print() {
Commit: b9c256587b93edd791ae3425946a5e34a5890c1c
https://github.com/scummvm/scummvm/commit/b9c256587b93edd791ae3425946a5e34a5890c1c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-07T00:02:00+01:00
Commit Message:
WAGE: Warning fixws
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index b8b71ea..c9b456b 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -59,7 +59,7 @@ Script::Script(Common::SeekableReadStream *data) : _data(data) {
}
Script::~Script() {
- for (int i = 0; i < _scriptText.size(); i++) {
+ for (uint i = 0; i < _scriptText.size(); i++) {
delete _scriptText[i];
}
@@ -67,13 +67,13 @@ Script::~Script() {
}
void Script::print() {
- for (int i = 0; i < _scriptText.size(); i++) {
+ for (uint i = 0; i < _scriptText.size(); i++) {
debug(4, "%d [%04x]: %s", i, _scriptText[i]->offset, _scriptText[i]->line.c_str());
}
}
void Script::printLine(int offset) {
- for (int i = 0; i < _scriptText.size(); i++)
+ for (uint i = 0; i < _scriptText.size(); i++)
if (_scriptText[i]->offset >= offset) {
debug(4, "%d [%04x]: %s", i, _scriptText[i]->offset, _scriptText[i]->line.c_str());
break;
@@ -851,7 +851,7 @@ bool Script::evalClickCondition(Operand *lhs, const char *op, Operand *rhs) {
}
void Script::takeObj(Obj *obj) {
- if (_world->_player->_inventory.size() >= _world->_player->_maximumCarriedObjects) {
+ if ((int)_world->_player->_inventory.size() >= _world->_player->_maximumCarriedObjects) {
appendText("Your pack is full, you must drop something.");
} else {
_world->move(obj, _world->_player);
@@ -991,7 +991,7 @@ Common::String *Script::getGroundItemsList(Scene *scene) {
}
void Script::appendObjNames(Common::String &str, Common::Array<Obj *> &objs) {
- for (int i = 0; i < objs.size(); i++) {
+ for (uint i = 0; i < objs.size(); i++) {
Obj *obj = objs[i];
if (!obj->_namePlural)
@@ -1067,7 +1067,7 @@ enum {
OPCODE
};
-struct {
+struct Mapping {
const char *cmd;
int type;
} mapping[] = {
Commit: 777536d203943484cdbdd15539e5002896628a9a
https://github.com/scummvm/scummvm/commit/777536d203943484cdbdd15539e5002896628a9a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-07T00:12:43+01:00
Commit Message:
WAGE: Add last line from scene description
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index c9b456b..ec3f7b2 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -1257,6 +1257,9 @@ void Script::convertToText() {
}
}
}
+
+ if (scr->line.size())
+ _scriptText.push_back(scr);
}
} // End of namespace Wage
Commit: 28a02b820061bd2d344f273dce54e562cf5b1fa1
https://github.com/scummvm/scummvm/commit/28a02b820061bd2d344f273dce54e562cf5b1fa1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-07T00:13:21+01:00
Commit Message:
WAGE: Fixed couple of memory leaks
Changed paths:
engines/wage/design.cpp
engines/wage/entities.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 8714d41..9515137 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -438,6 +438,8 @@ void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in) {
dst++;
}
}
+
+ tmp.free();
}
void Design::drawFilledRect(Graphics::Surface *surface, Common::Rect &rect, int color, Patterns &patterns, byte fillType) {
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 606e309..61f579e 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -48,6 +48,7 @@
#include "wage/wage.h"
#include "wage/entities.h"
#include "wage/design.h"
+#include "wage/script.h"
#include "wage/world.h"
#include "common/memstream.h"
@@ -127,6 +128,8 @@ Scene::Scene(String name, Common::SeekableReadStream *data) {
}
Scene::~Scene() {
+ delete _script;
+ delete _textBounds;
}
void Scene::paint(Graphics::Surface *surface, int x, int y) {
Commit: 6b428f211c45bbc3ef829b0032cb18d335408bce
https://github.com/scummvm/scummvm/commit/6b428f211c45bbc3ef829b0032cb18d335408bce
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-07T00:26:12+01:00
Commit Message:
WAGE: Fix numerpous memory leaks
Changed paths:
engines/wage/script.cpp
engines/wage/script.h
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index ec3f7b2..5bc1bb7 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -119,6 +119,7 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
Operand *op = readOperand();
// TODO check op type is string or number, or something good...
appendText(op->toString());
+ delete op;
byte d = _data->readByte();
if (d != 0xFD)
warning("Operand 0x8B (PRINT) End Byte != 0xFD");
@@ -130,6 +131,7 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
// TODO check op type is string.
_handled = true;
callbacks->playSound(op->toString());
+ delete op;
byte d = _data->readByte();
if (d != 0xFD)
warning("Operand 0x8B (PRINT) End Byte != 0xFD");
@@ -449,6 +451,9 @@ void Script::processIf() {
bool condResult = eval(lhs, op, rhs);
+ delete lhs;
+ delete rhs;
+
if (logicalOp == 1) {
result = (result && condResult);
} else if (logicalOp == 2) {
@@ -475,9 +480,12 @@ void Script::processIf() {
void Script::skipIf() {
do {
- readOperand();
+ Operand *lhs = readOperand();
readOperator();
- readOperand();
+ Operand *rhs = readOperand();
+
+ delete lhs;
+ delete rhs;
} while (_data->readByte() != 0xFE);
}
@@ -884,6 +892,9 @@ void Script::processMove() {
error("No end for MOVE: %02x", skip);
evaluatePair(what, "M", to);
+
+ delete what;
+ delete to;
}
void Script::processLet() {
@@ -904,6 +915,7 @@ void Script::processLet() {
Operand *operand = readOperand();
// TODO assert that value is NUMBER
int16 value = operand->_value.number;
+ delete operand;
if (lastOp != NULL) {
if (lastOp[0] == '+')
result += value;
diff --git a/engines/wage/script.h b/engines/wage/script.h
index 5bd26ad..adb1813 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -109,6 +109,11 @@ private:
_type = type;
}
+ ~Operand() {
+ if (_type == STRING)
+ delete _value.string;
+ }
+
Common::String toString() {
char buf[128];
Commit: 07642d291e7ced77a367ec9a91fa390e7c86e6e4
https://github.com/scummvm/scummvm/commit/07642d291e7ced77a367ec9a91fa390e7c86e6e4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-07T00:42:57+01:00
Commit Message:
WAGE: Fix scene randomization
Changed paths:
engines/wage/world.cpp
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 0b8529e..7a15b93 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -441,7 +441,7 @@ void World::move(Chr *chr, Scene *scene, bool skipSort) {
Scene *World::getRandomScene() {
// Not including storage:
- return _orderedScenes[1 + _engine->_rnd->getRandomNumber(_orderedScenes.size() - 1)];
+ return _orderedScenes[1 + _engine->_rnd->getRandomNumber(_orderedScenes.size() - 2)];
}
Scene *World::getSceneAt(int x, int y) {
Commit: 4d3707d7956352acb69f05e45084ee1964a2577f
https://github.com/scummvm/scummvm/commit/4d3707d7956352acb69f05e45084ee1964a2577f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-07T00:51:14+01:00
Commit Message:
WAGE: Plugged even more memory leaks
Changed paths:
engines/wage/design.cpp
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/world.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 9515137..5ce1ff3 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -75,7 +75,8 @@ Design::Design(Common::SeekableReadStream *data) {
Design::~Design() {
free(_data);
- _surface->free();
+ if (_surface && _surface->getPixels())
+ _surface->free();
delete _surface;
}
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 61f579e..1a9e936 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -234,6 +234,9 @@ Obj::Obj(String name, Common::SeekableReadStream *data) {
delete data;
}
+Obj::~Obj() {
+}
+
Chr *Obj::removeFromChr() {
if (_currentOwner != NULL) {
for (int i = (int)_currentOwner->_inventory.size() - 1; i >= 0; i--)
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 7cfe35f..ba19086 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -315,6 +315,7 @@ class Obj : public Weapon, public Designed {
public:
Obj() : _currentOwner(NULL), _currentScene(NULL) {}
Obj(String name, Common::SeekableReadStream *data);
+ ~Obj();
enum ObjectType {
REGULAR_WEAPON = 1,
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 7a15b93..c525bd3 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -363,9 +363,12 @@ Common::String *World::loadStringFromDITL(Common::MacResManager *resMan, int res
Common::String message = readPascalString(res);
if (i == itemIndex) {
Common::String *msg = new Common::String(message);
+ delete res;
return msg;
}
}
+
+ delete res;
}
return NULL;
Commit: 46076a0e6c6a6f35f979dc26c70fd023a3282626
https://github.com/scummvm/scummvm/commit/46076a0e6c6a6f35f979dc26c70fd023a3282626
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-07T01:24:42+01:00
Commit Message:
WAGE: Plugged great deal of leaks
Changed paths:
engines/wage/design.h
engines/wage/entities.cpp
engines/wage/gui.cpp
engines/wage/script.cpp
engines/wage/wage.cpp
engines/wage/world.cpp
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 74ee5b3..300d6fa 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -60,7 +60,7 @@ public:
~Design();
void setBounds(Common::Rect *bounds) {
- _bounds = new Common::Rect(*bounds);
+ _bounds = bounds;
}
Common::Rect *getBounds() {
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 1a9e936..dbf156f 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -56,7 +56,7 @@
namespace Wage {
void Designed::setDesignBounds(Common::Rect *bounds) {
- _designBounds = new Common::Rect(*bounds);
+ _designBounds = bounds;
_design->setBounds(bounds);
}
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 668a20f..7f76daf 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -176,6 +176,7 @@ Gui::Gui(WageEngine *engine) {
Gui::~Gui() {
_screen.free();
+ _console.free();
g_system->getTimerManager()->removeTimerProc(&cursor_timer_handler);
}
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 5bc1bb7..4fdbddb 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -1271,7 +1271,9 @@ void Script::convertToText() {
}
if (scr->line.size())
- _scriptText.push_back(scr);
+ _scriptText.push_back(scr);
+ else
+ delete scr;
}
} // End of namespace Wage
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 7ea5bc1..0cac983 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -91,6 +91,7 @@ WageEngine::~WageEngine() {
delete _resManager;
delete _gui;
delete _rnd;
+ delete _console;
}
Common::Error WageEngine::run() {
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index c525bd3..1887545 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -84,6 +84,17 @@ World::~World() {
for (uint i = 0; i < _orderedScenes.size(); i++)
delete _orderedScenes[i];
+
+ for (uint i = 0; i < _patterns.size(); i++)
+ free(_patterns[i]);
+
+ delete _globalScript;
+
+ delete _gameOverMessage;
+ delete _saveBeforeQuitMessage;
+ delete _saveBeforeCloseMessage;
+ delete _revertMessage;
+
}
bool World::loadWorld(Common::MacResManager *resMan) {
Commit: f2584488aab4073642ddbf35c50ea8e46bd43a55
https://github.com/scummvm/scummvm/commit/f2584488aab4073642ddbf35c50ea8e46bd43a55
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-07T12:14:07+01:00
Commit Message:
WAGE: Fixed font mapping
Changed paths:
engines/wage/entities.cpp
engines/wage/world.cpp
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index dbf156f..f24eea2 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -164,16 +164,33 @@ const char *fontNames[] = {
"San Francisco",
"Toronto",
+ NULL,
"Cairo",
"Los Angeles", // 12
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, // not in Inside Macintosh
+ "Zapf Dingbats",
+ "Bookman",
+ "Helvetica Narrow",
+ "Palatino",
+ NULL,
+ "Zapf Chancery",
+ NULL,
"Times", // 20
"Helvetica",
"Courier",
"Symbol",
- "Taliesin" // mobile?
+ "Taliesin", // mobile?
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL, // 30
+ NULL,
+ NULL,
+ "Avant Garde",
+ "New Century Schoolbook"
};
const char *Scene::getFontName() {
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 1887545..22a7bc9 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -182,7 +182,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
scene->_fontSize = res->readUint16BE();
if (scene->_fontType != 3 || scene->_fontSize != 9)
- warning("scene: %s font: %s size: %d", scene->_name.c_str(), scene->getFontName(), scene->_fontSize);
+ warning("scene: %s font: '%s' (%d) size: %d", scene->_name.c_str(), scene->getFontName(), scene->_fontType, scene->_fontSize);
String text;
while (res->pos() < res->size()) {
Commit: 9bd51254c6556a6e560af421c29584158bf1ca6a
https://github.com/scummvm/scummvm/commit/9bd51254c6556a6e560af421c29584158bf1ca6a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-07T12:35:05+01:00
Commit Message:
WAGE: Process scenes without scripts
Changed paths:
engines/wage/wage.cpp
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 0cac983..31df424 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -412,7 +412,8 @@ void WageEngine::processTurnInternal(Common::String *textInput, Designed *clickI
}
bool monsterWasNull = (_monster == NULL);
- bool handled = playerScene->_script->execute(_world, _loopCount++, textInput, clickInput, this);
+ Script *script = playerScene->_script != NULL ? playerScene->_script : _world->_globalScript;
+ bool handled = script->execute(_world, _loopCount++, textInput, clickInput, this);
playerScene = _world->_player->_currentScene;
Commit: 83dcdf9c63e8936b2f9a679dacd36fa418ae7ee0
https://github.com/scummvm/scummvm/commit/83dcdf9c63e8936b2f9a679dacd36fa418ae7ee0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-07T14:17:50+01:00
Commit Message:
WAGE: Fix race condition which led to random crashes
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 7f76daf..f5c24d0 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -138,7 +138,6 @@ static void cursor_timer_handler(void *refCon) {
gui->_cursorState = !gui->_cursorState;
g_system->copyRectToScreen(gui->_screen.getBasePtr(x, y), gui->_screen.pitch, x, y, 1, kCursorHeight);
- g_system->updateScreen();
}
Gui::Gui(WageEngine *engine) {
Commit: 7bdb942cacea2d950c2b7fadd96e9bcdca06f8b4
https://github.com/scummvm/scummvm/commit/7bdb942cacea2d950c2b7fadd96e9bcdca06f8b4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-07T18:30:44+01:00
Commit Message:
WAGE: Implement WageEngine::regen()
Changed paths:
engines/wage/wage.cpp
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 31df424..1f0769c 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -385,7 +385,15 @@ void WageEngine::redrawScene() {
}
void WageEngine::regen() {
- warning("STUB WageEngine::regen()");
+ Chr *player = _world->_player;
+ int curHp = player->_context._statVariables[PHYS_HIT_CUR];
+ int maxHp = player->_context._statVariables[PHYS_HIT_BAS];
+ int delta = maxHp - curHp;
+
+ if (delta > 0) {
+ int bonus = (int)(delta / (8 + _rnd->getRandomNumber(2)));
+ player->_context._statVariables[PHYS_HIT_CUR] += bonus;
+ }
}
void WageEngine::processTurnInternal(Common::String *textInput, Designed *clickInput) {
Commit: 87766f675351a5c1d2cf7affe40322fd845633ed
https://github.com/scummvm/scummvm/commit/87766f675351a5c1d2cf7affe40322fd845633ed
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-08T00:27:40+01:00
Commit Message:
WAGE: Implement monster following
Changed paths:
engines/wage/wage.cpp
engines/wage/world.cpp
engines/wage/world.h
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 1f0769c..5841b47 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -463,13 +463,11 @@ void WageEngine::processTurn(Common::String *textInput, Designed *clickInput) {
if (prevMonster != NULL) {
bool followed = false;
if (_monster == NULL) {
- warning("STUB: processTurn(), monster");
- //Set<Scene> scenes = world.getAdjacentScenes(prevMonster.getState().getCurrentScene());
// TODO: adjacent scenes doesn't contain up/down etc... verify that monsters can't follow these...
- //if (scenes.contains(playerScene)) {
- // int chance = (int) (Math.random() * 255);
- // followed = (chance < prevMonster.getFollowsOpponent());
- //}
+ if (_world->scenesAreConnected(playerScene, prevMonster->_currentScene)) {
+ int chance = _rnd->getRandomNumber(255);
+ followed = (chance < prevMonster->_followsOpponent);
+ }
}
Common::String msg;
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 22a7bc9..d44267a 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -469,4 +469,22 @@ Scene *World::getSceneAt(int x, int y) {
return NULL;
}
+static const int directionsX[] = { 0, 0, 1, -1 };
+static const int directionsY[] = { -1, 1, 0, 0 };
+
+bool World::scenesAreConnected(Scene *scene1, Scene *scene2) {
+ if (!scene1 || !scene2)
+ return false;
+
+ int x = scene2->_worldX;
+ int y = scene2->_worldY;
+
+ for (int dir = 0; dir < 4; dir++)
+ if (!scene2->_blocked[dir])
+ if (getSceneAt(x + directionsX[dir], y + directionsY[dir]) == scene1)
+ return true;
+
+ return false;
+}
+
} // End of namespace Wage
diff --git a/engines/wage/world.h b/engines/wage/world.h
index a4ca2fd..6afd1af 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -65,6 +65,7 @@ public:
void move(Chr *chr, Scene *scene, bool skipSort = false);
Scene *getRandomScene();
Scene *getSceneAt(int x, int y);
+ bool scenesAreConnected(Scene *scene1, Scene *scene2);
WageEngine *_engine;
Commit: 51af66371dc71e908dade3563b9792e26f0d9661
https://github.com/scummvm/scummvm/commit/51af66371dc71e908dade3563b9792e26f0d9661
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-08T00:55:16+01:00
Commit Message:
WAGE: Implement WageEngine::encounter()
Changed paths:
engines/wage/util.cpp
engines/wage/wage.cpp
engines/wage/wage.h
diff --git a/engines/wage/util.cpp b/engines/wage/util.cpp
index 8dac0d2..1390c49 100644
--- a/engines/wage/util.cpp
+++ b/engines/wage/util.cpp
@@ -99,4 +99,28 @@ const char *getIndefiniteArticle(String &word) {
return "a ";
}
+enum {
+ GENDER_HE = 0,
+ GENDER_SHE = 1,
+ GENDER_IT = 2
+};
+
+const char *prependGenderSpecificPronoun(int gender) {
+ if (gender == GENDER_HE)
+ return "his ";
+ else if (gender == GENDER_SHE)
+ return "her ";
+ else
+ return "its ";
+}
+
+const char *getGenderSpecificPronoun(int gender, bool capitalize) {
+ if (gender == GENDER_HE)
+ return capitalize ? "He" : "he";
+ else if (gender == GENDER_SHE)
+ return capitalize ? "She" : "she";
+ else
+ return capitalize ? "It" : "it";
+}
+
} // End of namespace Wage
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 5841b47..d87a7c1 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -360,7 +360,41 @@ void WageEngine::onMove(Designed *what, Designed *from, Designed *to) {
}
void WageEngine::encounter(Chr *player, Chr *chr) {
- warning("STUB WageEngine::encounter()");
+ Common::String msg("You encounter ");
+ if (!chr->_nameProperNoun)
+ msg += getIndefiniteArticle(chr->_name);
+ msg += chr->_name;
+ msg += ".";
+ appendText(msg);
+
+ if (!chr->_initialComment.empty())
+ appendText(chr->_initialComment);
+
+ if (chr->_armor[Chr::HEAD_ARMOR] != NULL) {
+ msg = chr->getNameWithDefiniteArticle(true);
+ msg += " is wearing ";
+ msg += getIndefiniteArticle(chr->_armor[Chr::HEAD_ARMOR]->_name);
+ msg += ".";
+ appendText(msg);
+ }
+ if (chr->_armor[Chr::BODY_ARMOR] != NULL) {
+ msg = getGenderSpecificPronoun(chr->_gender, true);
+ msg += " is protected by ";
+ msg += prependGenderSpecificPronoun(chr->_gender);
+ msg += chr->_armor[Chr::BODY_ARMOR]->_name;
+ msg += ".";
+ appendText(msg);
+ }
+ if (chr->_armor[Chr::SHIELD_ARMOR] != NULL) {
+ Obj *obj = chr->_armor[Chr::SHIELD_ARMOR];
+ msg = getGenderSpecificPronoun(chr->_gender, true);
+ msg += " carries ";
+ if (!obj->_namePlural)
+ msg += getIndefiniteArticle(obj->_name);
+ msg += obj->_name;
+ msg += ".";
+ appendText(msg);
+ }
}
void WageEngine::performCombatAction(Chr *npc, Chr *player) {
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 91d9404..bbf3b99 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -99,6 +99,9 @@ enum {
Common::String readPascalString(Common::SeekableReadStream *in);
Common::Rect *readRect(Common::SeekableReadStream *in);
const char *getIndefiniteArticle(String &word);
+const char *prependGenderSpecificPronoun(int gender);
+const char *getGenderSpecificPronoun(int gender, bool capitalize);
+
typedef Common::Array<byte *> Patterns;
Commit: 82d002629841841500506dc22f8a9b83731ba863
https://github.com/scummvm/scummvm/commit/82d002629841841500506dc22f8a9b83731ba863
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-09T00:55:35+01:00
Commit Message:
WAGE: Started implementation of performCombatAction()
Changed paths:
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/module.mk
engines/wage/script.cpp
engines/wage/wage.cpp
engines/wage/wage.h
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index f24eea2..753084e 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -378,7 +378,7 @@ void Chr::resetState() {
_context._statVariables[PHYS_SPE_BAS] = _context._statVariables[PHYS_SPE_CUR] = _runningSpeed;
}
-WeaponArray *Chr::getWeapons() {
+WeaponArray *Chr::getWeapons(bool includeMagic) {
WeaponArray *list = new WeaponArray;
warning("STUB: getWeapons");
@@ -386,6 +386,14 @@ WeaponArray *Chr::getWeapons() {
return list;
}
+ObjArray *Chr::getMagicalObjects() {
+ ObjArray *list = new ObjArray;
+
+ warning("STUB: getMagicalObjects");
+
+ return list;
+}
+
void Chr::wearObjs() {
for (uint i = 0; i < _inventory.size(); i++)
wearObjIfPossible(_inventory[i]);
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index ba19086..4cf756a 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -61,6 +61,9 @@ class Script;
class Weapon;
typedef Common::Array<Weapon *> WeaponArray;
+typedef Common::Array<Obj *> ObjArray;
+typedef Common::Array<Chr *> ChrArray;
+typedef Common::List<Obj *> ObjList;
enum StatVariable {
/** The base physical accuracy of the player. */
@@ -215,71 +218,11 @@ public:
Context _context;
- WeaponArray *getWeapons();
+ WeaponArray *getWeapons(bool includeMagic);
+ ObjArray *getMagicalObjects();
String &getNameWithDefiniteArticle(bool capitalize);
public:
-#if 0
- Weapon[] getWeapons() {
- ArrayList<Weapon> weapons = new ArrayList<Weapon>();
- if (hasNativeWeapon1()) {
- weapons.add(new Weapon() {
- String getName() {
- return _getNativeWeapon1();
- }
- String getOperativeVerb() {
- return _getOperativeVerb1();
- }
- int getType() {
- return _Obj.REGULAR_WEAPON;
- }
- int getAccuracy() {
- return _0;
- }
- int getDamage() {
- return _getWeaponDamage1();
- }
- String getSound() {
- return _getWeaponSound1();
- }
- void decrementNumberOfUses() {}
- });
- }
- if (hasNativeWeapon2()) {
- weapons.add(new Weapon() {
- String getName() {
- return _getNativeWeapon2();
- }
- String getOperativeVerb() {
- return _getOperativeVerb2();
- }
- int getType() {
- return _Obj.REGULAR_WEAPON;
- }
- int getAccuracy() {
- return _0;
- }
- int getDamage() {
- return _getWeaponDamage2();
- }
- String getSound() {
- return _getWeaponSound2();
- }
- void decrementNumberOfUses() {}
- });
- }
- for (Obj o : getInventory()) {
- switch (o.getType()) {
- case Obj.REGULAR_WEAPON:
- case Obj.THROW_WEAPON:
- case Obj.MAGICAL_OBJECT:
- weapons.add(o);
- }
- }
- return _(Weapon[]) weapons.toArray(new Weapon[0]);
- }
-#endif
-
bool hasNativeWeapon1() {
return (_nativeWeapon1.size() > 0 && _operativeVerb1.size() > 0);
}
diff --git a/engines/wage/module.mk b/engines/wage/module.mk
index 5356902..216ac52 100644
--- a/engines/wage/module.mk
+++ b/engines/wage/module.mk
@@ -5,6 +5,7 @@ MODULE_OBJS := \
detection.o \
entities.o \
gui.o \
+ randomhat.o \
script.o \
util.o \
wage.o \
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 4fdbddb..71c75d9 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -199,7 +199,7 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
handleAcceptCommand();
} else {
Chr *player = _world->_player;
- WeaponArray *weapons = player->getWeapons();
+ WeaponArray *weapons = player->getWeapons(true);
for (WeaponArray::const_iterator weapon = weapons->begin(); weapon != weapons->end(); ++weapon) {
if (tryAttack(*weapon, input)) {
handleAttack(*weapon);
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index d87a7c1..8b7f4ff 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -399,6 +399,83 @@ void WageEngine::encounter(Chr *player, Chr *chr) {
void WageEngine::performCombatAction(Chr *npc, Chr *player) {
warning("STUB WageEngine::performCombatAction()");
+#if 0
+ if (npc->_frozen)
+ return;
+
+ RandomHat hat;
+
+ bool winning = (npc->_context._statVariables[PHYS_HIT_CUR] > player->_context._statVariables[PHYS_HIT_CUR]);
+ int validMoves = getValidMoveDirections(npc);
+ WeaponArray *weapons = npc->getWeapons(false);
+ ObjArray *magics = npc->getMagicalObjects();
+ // TODO: Figure out under what circumstances we need to add +1
+ // for the chance (e.g. only when all values were set to 0?).
+ if (winning) {
+ if (!_world->_weaponsMenuDisabled) {
+ if (weapons->size() > 0)
+ hat.addTokens(kTokWeapons, npc->_winningWeapons + 1);
+ if (magics->size() > 0)
+ hat.addTokens(kTokMagic, npc->_winningMagic);
+ }
+ if (validMoves != 0)
+ hat.addTokens(kTokRun, npc->_winningRun + 1);
+ if (npc->_inventory.size())
+ hat.addTokens(kTokOffer, npc->_winningOffer + 1);
+ } else {
+ if (!_world->_weaponsMenuDisabled) {
+ if (npc.getWeapons(false).length > 0)
+ hat.addTokens(kTokWeapons, npc->_losingWeapons + 1);
+ if (magics->size() > 0)
+ hat.addTokens(kTokMagic, npc->_losingMagic);
+ }
+ if (validMoves != 0)
+ hat.addTokens(kTokRun, npc->_losingRun + 1);
+ if (npc->_inventory.size())
+ hat.addTokens(kTokOffer, npc->_losingOffer + 1);
+ }
+
+ ObjArray *objs = npc->_currentScene->_objs;
+ if (npc->_inventory.size() < npc->_maximumCarriedObjects) {
+ int cnt = 0;
+ for (ObjList::const_iterator it = objs.begin(); it != objs.end(); ++it, ++cnt) {
+ if ((*it)->_type != Obj::IMMOBILE_OBJECT) {
+ // TODO: I'm not sure what the chance should be here.
+ hat.addTokens(cnt, 123);
+ }
+ }
+ }
+
+ int token = hat.drawToken();
+ switch (token) {
+ case kTokWeapons:
+ // TODO: I think the monster should choose the "best" weapon.
+ performAttack(npc, player, weapons[_rnd.getRandomNumber(weapons->size() - 1)]);
+ break;
+ case kTokMagic:
+ // TODO: I think the monster should choose the "best" magic.
+ performMagic(npc, player, magics[_rnd.getRandomNumber(magics->size() - 1)]);
+ break;
+ case kTokRun:
+ performMove(npc, validMoves);
+ break;
+ case kTokOffer:
+ performOffer(npc, player);
+ break;
+ default:
+ performTake(npc, objs.get(token));
+ break;
+ }
+
+ delete weapons;
+ delete magics;
+#endif
+}
+
+int WageEngine::getValidMoveDirections(Chr *npc) {
+ warning("STUB: getValidMoveDirections()");
+
+ return 0;
}
void WageEngine::redrawScene() {
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index bbf3b99..6fb287c 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -127,6 +127,7 @@ private:
void processTurnInternal(Common::String *textInput, Designed *clickInput);
void regen();
void performCombatAction(Chr *npc, Chr *player);
+ int getValidMoveDirections(Chr *npc);
public:
Common::RandomSource *_rnd;
Commit: db6fafd58aa7f0523ed601180290cc511d9da3aa
https://github.com/scummvm/scummvm/commit/db6fafd58aa7f0523ed601180290cc511d9da3aa
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-09T01:13:25+01:00
Commit Message:
WAGE: Implemented performCombatAction
Changed paths:
A engines/wage/randomhat.cpp
A engines/wage/randomhat.h
engines/wage/wage.cpp
engines/wage/wage.h
diff --git a/engines/wage/randomhat.cpp b/engines/wage/randomhat.cpp
new file mode 100644
index 0000000..6461abf
--- /dev/null
+++ b/engines/wage/randomhat.cpp
@@ -0,0 +1,62 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "common/hashmap.h"
+#include "wage/randomhat.h"
+
+
+namespace Wage {
+
+void RandomHat::addTokens(int type, int count) {
+ _tokens.setVal(type, _tokens.getVal(type, 0) + count);
+}
+
+int RandomHat::drawToken() {
+ return 0;
+}
+
+} // End of namespace Wage
diff --git a/engines/wage/randomhat.h b/engines/wage/randomhat.h
new file mode 100644
index 0000000..f54b86b
--- /dev/null
+++ b/engines/wage/randomhat.h
@@ -0,0 +1,73 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef WAGE_RANDOMHAT_H
+#define WAGE_RANDOMHAT_H
+
+namespace Wage {
+
+enum {
+ kTokWeapons = -400,
+ kTokMagic = -300,
+ kTokRun = -200,
+ kTokOffer = -100
+};
+
+class RandomHat {
+public:
+ RandomHat() {}
+
+ void addTokens(int type, int count);
+ int drawToken();
+
+private:
+ Common::HashMap<int, int> _tokens;
+};
+
+} // End of namespace Wage
+
+#endif
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 8b7f4ff..f0690f5 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -61,6 +61,7 @@
#include "wage/design.h"
#include "wage/entities.h"
#include "wage/gui.h"
+#include "wage/randomhat.h"
#include "wage/script.h"
#include "wage/world.h"
@@ -398,9 +399,7 @@ void WageEngine::encounter(Chr *player, Chr *chr) {
}
void WageEngine::performCombatAction(Chr *npc, Chr *player) {
- warning("STUB WageEngine::performCombatAction()");
-#if 0
- if (npc->_frozen)
+ if (npc->_context._frozen)
return;
RandomHat hat;
@@ -412,7 +411,7 @@ void WageEngine::performCombatAction(Chr *npc, Chr *player) {
// TODO: Figure out under what circumstances we need to add +1
// for the chance (e.g. only when all values were set to 0?).
if (winning) {
- if (!_world->_weaponsMenuDisabled) {
+ if (!_world->_weaponMenuDisabled) {
if (weapons->size() > 0)
hat.addTokens(kTokWeapons, npc->_winningWeapons + 1);
if (magics->size() > 0)
@@ -423,8 +422,8 @@ void WageEngine::performCombatAction(Chr *npc, Chr *player) {
if (npc->_inventory.size())
hat.addTokens(kTokOffer, npc->_winningOffer + 1);
} else {
- if (!_world->_weaponsMenuDisabled) {
- if (npc.getWeapons(false).length > 0)
+ if (!_world->_weaponMenuDisabled) {
+ if (weapons->size() > 0)
hat.addTokens(kTokWeapons, npc->_losingWeapons + 1);
if (magics->size() > 0)
hat.addTokens(kTokMagic, npc->_losingMagic);
@@ -435,10 +434,10 @@ void WageEngine::performCombatAction(Chr *npc, Chr *player) {
hat.addTokens(kTokOffer, npc->_losingOffer + 1);
}
- ObjArray *objs = npc->_currentScene->_objs;
+ Common::List<Obj *> *objs = &npc->_currentScene->_objs;
if (npc->_inventory.size() < npc->_maximumCarriedObjects) {
int cnt = 0;
- for (ObjList::const_iterator it = objs.begin(); it != objs.end(); ++it, ++cnt) {
+ for (ObjList::const_iterator it = objs->begin(); it != objs->end(); ++it, ++cnt) {
if ((*it)->_type != Obj::IMMOBILE_OBJECT) {
// TODO: I'm not sure what the chance should be here.
hat.addTokens(cnt, 123);
@@ -450,11 +449,11 @@ void WageEngine::performCombatAction(Chr *npc, Chr *player) {
switch (token) {
case kTokWeapons:
// TODO: I think the monster should choose the "best" weapon.
- performAttack(npc, player, weapons[_rnd.getRandomNumber(weapons->size() - 1)]);
+ performAttack(npc, player, weapons->operator[](_rnd->getRandomNumber(weapons->size() - 1)));
break;
case kTokMagic:
// TODO: I think the monster should choose the "best" magic.
- performMagic(npc, player, magics[_rnd.getRandomNumber(magics->size() - 1)]);
+ performMagic(npc, player, magics->operator[](_rnd->getRandomNumber(magics->size() - 1)));
break;
case kTokRun:
performMove(npc, validMoves);
@@ -463,13 +462,37 @@ void WageEngine::performCombatAction(Chr *npc, Chr *player) {
performOffer(npc, player);
break;
default:
- performTake(npc, objs.get(token));
- break;
+ {
+ int cnt = 0;
+ for (ObjList::const_iterator it = objs->begin(); it != objs->end(); ++it, ++cnt)
+ if (cnt == token)
+ performTake(npc, *it);
+ break;
+ }
}
delete weapons;
delete magics;
-#endif
+}
+
+void WageEngine::performAttack(Chr *attacker, Chr *victim, Weapon *weapon) {
+ warning("STUB: performAttack()");
+}
+
+void WageEngine::performMagic(Chr *attacker, Chr *victim, Obj *magicalObject) {
+ warning("STUB: performMagic()");
+}
+
+void WageEngine::performMove(Chr *chr, int validMoves) {
+ warning("STUB: performMove()");
+}
+
+void WageEngine::performOffer(Chr *attacker, Chr *victim) {
+ warning("STUB: performOffer()");
+}
+
+void WageEngine::performTake(Chr *npc, Obj *obj) {
+ warning("STUB: performTake()");
}
int WageEngine::getValidMoveDirections(Chr *npc) {
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 6fb287c..375425b 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -66,6 +66,7 @@ class Designed;
class Gui;
class Obj;
class Scene;
+class Weapon;
class World;
using Common::String;
@@ -128,6 +129,11 @@ private:
void regen();
void performCombatAction(Chr *npc, Chr *player);
int getValidMoveDirections(Chr *npc);
+ void performAttack(Chr *attacker, Chr *victim, Weapon *weapon);
+ void performMagic(Chr *attacker, Chr *victim, Obj *magicalObject);
+ void performMove(Chr *chr, int validMoves);
+ void performOffer(Chr *attacker, Chr *victim);
+ void performTake(Chr *npc, Obj *obj);
public:
Common::RandomSource *_rnd;
Commit: 42ebff811a87051910fce4c75077559dce97e243
https://github.com/scummvm/scummvm/commit/42ebff811a87051910fce4c75077559dce97e243
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-09T01:20:35+01:00
Commit Message:
WAGE: SPlit out combat-related methods into separate file
Changed paths:
A engines/wage/combat.cpp
engines/wage/module.mk
engines/wage/wage.cpp
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
new file mode 100644
index 0000000..102302a
--- /dev/null
+++ b/engines/wage/combat.cpp
@@ -0,0 +1,221 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "wage/wage.h"
+#include "wage/entities.h"
+#include "wage/randomhat.h"
+#include "wage/world.h"
+
+namespace Wage {
+
+Obj *WageEngine::getOffer() {
+ warning("STUB: WageEngine::getOffer");
+
+ return NULL;
+}
+
+Chr *WageEngine::getMonster() {
+ if (_monster != NULL && _monster->_currentScene != _world->_player->_currentScene) {
+ _monster = NULL;
+ }
+ return _monster;
+}
+
+void WageEngine::encounter(Chr *player, Chr *chr) {
+ Common::String msg("You encounter ");
+ if (!chr->_nameProperNoun)
+ msg += getIndefiniteArticle(chr->_name);
+ msg += chr->_name;
+ msg += ".";
+ appendText(msg);
+
+ if (!chr->_initialComment.empty())
+ appendText(chr->_initialComment);
+
+ if (chr->_armor[Chr::HEAD_ARMOR] != NULL) {
+ msg = chr->getNameWithDefiniteArticle(true);
+ msg += " is wearing ";
+ msg += getIndefiniteArticle(chr->_armor[Chr::HEAD_ARMOR]->_name);
+ msg += ".";
+ appendText(msg);
+ }
+ if (chr->_armor[Chr::BODY_ARMOR] != NULL) {
+ msg = getGenderSpecificPronoun(chr->_gender, true);
+ msg += " is protected by ";
+ msg += prependGenderSpecificPronoun(chr->_gender);
+ msg += chr->_armor[Chr::BODY_ARMOR]->_name;
+ msg += ".";
+ appendText(msg);
+ }
+ if (chr->_armor[Chr::SHIELD_ARMOR] != NULL) {
+ Obj *obj = chr->_armor[Chr::SHIELD_ARMOR];
+ msg = getGenderSpecificPronoun(chr->_gender, true);
+ msg += " carries ";
+ if (!obj->_namePlural)
+ msg += getIndefiniteArticle(obj->_name);
+ msg += obj->_name;
+ msg += ".";
+ appendText(msg);
+ }
+}
+
+void WageEngine::performCombatAction(Chr *npc, Chr *player) {
+ if (npc->_context._frozen)
+ return;
+
+ RandomHat hat;
+
+ bool winning = (npc->_context._statVariables[PHYS_HIT_CUR] > player->_context._statVariables[PHYS_HIT_CUR]);
+ int validMoves = getValidMoveDirections(npc);
+ WeaponArray *weapons = npc->getWeapons(false);
+ ObjArray *magics = npc->getMagicalObjects();
+ // TODO: Figure out under what circumstances we need to add +1
+ // for the chance (e.g. only when all values were set to 0?).
+ if (winning) {
+ if (!_world->_weaponMenuDisabled) {
+ if (weapons->size() > 0)
+ hat.addTokens(kTokWeapons, npc->_winningWeapons + 1);
+ if (magics->size() > 0)
+ hat.addTokens(kTokMagic, npc->_winningMagic);
+ }
+ if (validMoves != 0)
+ hat.addTokens(kTokRun, npc->_winningRun + 1);
+ if (npc->_inventory.size())
+ hat.addTokens(kTokOffer, npc->_winningOffer + 1);
+ } else {
+ if (!_world->_weaponMenuDisabled) {
+ if (weapons->size() > 0)
+ hat.addTokens(kTokWeapons, npc->_losingWeapons + 1);
+ if (magics->size() > 0)
+ hat.addTokens(kTokMagic, npc->_losingMagic);
+ }
+ if (validMoves != 0)
+ hat.addTokens(kTokRun, npc->_losingRun + 1);
+ if (npc->_inventory.size())
+ hat.addTokens(kTokOffer, npc->_losingOffer + 1);
+ }
+
+ Common::List<Obj *> *objs = &npc->_currentScene->_objs;
+ if (npc->_inventory.size() < npc->_maximumCarriedObjects) {
+ int cnt = 0;
+ for (ObjList::const_iterator it = objs->begin(); it != objs->end(); ++it, ++cnt) {
+ if ((*it)->_type != Obj::IMMOBILE_OBJECT) {
+ // TODO: I'm not sure what the chance should be here.
+ hat.addTokens(cnt, 123);
+ }
+ }
+ }
+
+ int token = hat.drawToken();
+ switch (token) {
+ case kTokWeapons:
+ // TODO: I think the monster should choose the "best" weapon.
+ performAttack(npc, player, weapons->operator[](_rnd->getRandomNumber(weapons->size() - 1)));
+ break;
+ case kTokMagic:
+ // TODO: I think the monster should choose the "best" magic.
+ performMagic(npc, player, magics->operator[](_rnd->getRandomNumber(magics->size() - 1)));
+ break;
+ case kTokRun:
+ performMove(npc, validMoves);
+ break;
+ case kTokOffer:
+ performOffer(npc, player);
+ break;
+ default:
+ {
+ int cnt = 0;
+ for (ObjList::const_iterator it = objs->begin(); it != objs->end(); ++it, ++cnt)
+ if (cnt == token)
+ performTake(npc, *it);
+ break;
+ }
+ }
+
+ delete weapons;
+ delete magics;
+}
+
+void WageEngine::performAttack(Chr *attacker, Chr *victim, Weapon *weapon) {
+ warning("STUB: performAttack()");
+}
+
+void WageEngine::performMagic(Chr *attacker, Chr *victim, Obj *magicalObject) {
+ warning("STUB: performMagic()");
+}
+
+void WageEngine::performMove(Chr *chr, int validMoves) {
+ warning("STUB: performMove()");
+}
+
+void WageEngine::performOffer(Chr *attacker, Chr *victim) {
+ warning("STUB: performOffer()");
+}
+
+void WageEngine::performTake(Chr *npc, Obj *obj) {
+ warning("STUB: performTake()");
+}
+
+int WageEngine::getValidMoveDirections(Chr *npc) {
+ warning("STUB: getValidMoveDirections()");
+
+ return 0;
+}
+
+void WageEngine::regen() {
+ Chr *player = _world->_player;
+ int curHp = player->_context._statVariables[PHYS_HIT_CUR];
+ int maxHp = player->_context._statVariables[PHYS_HIT_BAS];
+ int delta = maxHp - curHp;
+
+ if (delta > 0) {
+ int bonus = (int)(delta / (8 + _rnd->getRandomNumber(2)));
+ player->_context._statVariables[PHYS_HIT_CUR] += bonus;
+ }
+}
+
+} // End of namespace Wage
diff --git a/engines/wage/module.mk b/engines/wage/module.mk
index 216ac52..8229d17 100644
--- a/engines/wage/module.mk
+++ b/engines/wage/module.mk
@@ -1,6 +1,7 @@
MODULE := engines/wage
MODULE_OBJS := \
+ combat.o \
design.o \
detection.o \
entities.o \
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index f0690f5..da29a20 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -58,10 +58,8 @@
#include "gui/EventRecorder.h"
#include "wage/wage.h"
-#include "wage/design.h"
#include "wage/entities.h"
#include "wage/gui.h"
-#include "wage/randomhat.h"
#include "wage/script.h"
#include "wage/world.h"
@@ -217,19 +215,6 @@ void WageEngine::appendText(String &str) {
_gui->appendText(str);
}
-Obj *WageEngine::getOffer() {
- warning("STUB: WageEngine::getOffer");
-
- return NULL;
-}
-
-Chr *WageEngine::getMonster() {
- if (_monster != NULL && _monster->_currentScene != _world->_player->_currentScene) {
- _monster = NULL;
- }
- return _monster;
-}
-
void WageEngine::gameOver() {
warning("STUB: WageEngine::gameOver()");
}
@@ -360,147 +345,6 @@ void WageEngine::onMove(Designed *what, Designed *from, Designed *to) {
}
}
-void WageEngine::encounter(Chr *player, Chr *chr) {
- Common::String msg("You encounter ");
- if (!chr->_nameProperNoun)
- msg += getIndefiniteArticle(chr->_name);
- msg += chr->_name;
- msg += ".";
- appendText(msg);
-
- if (!chr->_initialComment.empty())
- appendText(chr->_initialComment);
-
- if (chr->_armor[Chr::HEAD_ARMOR] != NULL) {
- msg = chr->getNameWithDefiniteArticle(true);
- msg += " is wearing ";
- msg += getIndefiniteArticle(chr->_armor[Chr::HEAD_ARMOR]->_name);
- msg += ".";
- appendText(msg);
- }
- if (chr->_armor[Chr::BODY_ARMOR] != NULL) {
- msg = getGenderSpecificPronoun(chr->_gender, true);
- msg += " is protected by ";
- msg += prependGenderSpecificPronoun(chr->_gender);
- msg += chr->_armor[Chr::BODY_ARMOR]->_name;
- msg += ".";
- appendText(msg);
- }
- if (chr->_armor[Chr::SHIELD_ARMOR] != NULL) {
- Obj *obj = chr->_armor[Chr::SHIELD_ARMOR];
- msg = getGenderSpecificPronoun(chr->_gender, true);
- msg += " carries ";
- if (!obj->_namePlural)
- msg += getIndefiniteArticle(obj->_name);
- msg += obj->_name;
- msg += ".";
- appendText(msg);
- }
-}
-
-void WageEngine::performCombatAction(Chr *npc, Chr *player) {
- if (npc->_context._frozen)
- return;
-
- RandomHat hat;
-
- bool winning = (npc->_context._statVariables[PHYS_HIT_CUR] > player->_context._statVariables[PHYS_HIT_CUR]);
- int validMoves = getValidMoveDirections(npc);
- WeaponArray *weapons = npc->getWeapons(false);
- ObjArray *magics = npc->getMagicalObjects();
- // TODO: Figure out under what circumstances we need to add +1
- // for the chance (e.g. only when all values were set to 0?).
- if (winning) {
- if (!_world->_weaponMenuDisabled) {
- if (weapons->size() > 0)
- hat.addTokens(kTokWeapons, npc->_winningWeapons + 1);
- if (magics->size() > 0)
- hat.addTokens(kTokMagic, npc->_winningMagic);
- }
- if (validMoves != 0)
- hat.addTokens(kTokRun, npc->_winningRun + 1);
- if (npc->_inventory.size())
- hat.addTokens(kTokOffer, npc->_winningOffer + 1);
- } else {
- if (!_world->_weaponMenuDisabled) {
- if (weapons->size() > 0)
- hat.addTokens(kTokWeapons, npc->_losingWeapons + 1);
- if (magics->size() > 0)
- hat.addTokens(kTokMagic, npc->_losingMagic);
- }
- if (validMoves != 0)
- hat.addTokens(kTokRun, npc->_losingRun + 1);
- if (npc->_inventory.size())
- hat.addTokens(kTokOffer, npc->_losingOffer + 1);
- }
-
- Common::List<Obj *> *objs = &npc->_currentScene->_objs;
- if (npc->_inventory.size() < npc->_maximumCarriedObjects) {
- int cnt = 0;
- for (ObjList::const_iterator it = objs->begin(); it != objs->end(); ++it, ++cnt) {
- if ((*it)->_type != Obj::IMMOBILE_OBJECT) {
- // TODO: I'm not sure what the chance should be here.
- hat.addTokens(cnt, 123);
- }
- }
- }
-
- int token = hat.drawToken();
- switch (token) {
- case kTokWeapons:
- // TODO: I think the monster should choose the "best" weapon.
- performAttack(npc, player, weapons->operator[](_rnd->getRandomNumber(weapons->size() - 1)));
- break;
- case kTokMagic:
- // TODO: I think the monster should choose the "best" magic.
- performMagic(npc, player, magics->operator[](_rnd->getRandomNumber(magics->size() - 1)));
- break;
- case kTokRun:
- performMove(npc, validMoves);
- break;
- case kTokOffer:
- performOffer(npc, player);
- break;
- default:
- {
- int cnt = 0;
- for (ObjList::const_iterator it = objs->begin(); it != objs->end(); ++it, ++cnt)
- if (cnt == token)
- performTake(npc, *it);
- break;
- }
- }
-
- delete weapons;
- delete magics;
-}
-
-void WageEngine::performAttack(Chr *attacker, Chr *victim, Weapon *weapon) {
- warning("STUB: performAttack()");
-}
-
-void WageEngine::performMagic(Chr *attacker, Chr *victim, Obj *magicalObject) {
- warning("STUB: performMagic()");
-}
-
-void WageEngine::performMove(Chr *chr, int validMoves) {
- warning("STUB: performMove()");
-}
-
-void WageEngine::performOffer(Chr *attacker, Chr *victim) {
- warning("STUB: performOffer()");
-}
-
-void WageEngine::performTake(Chr *npc, Obj *obj) {
- warning("STUB: performTake()");
-}
-
-int WageEngine::getValidMoveDirections(Chr *npc) {
- warning("STUB: getValidMoveDirections()");
-
- return 0;
-}
-
void WageEngine::redrawScene() {
Scene *currentScene = _world->_player->_currentScene;
if (currentScene != NULL) {
@@ -518,18 +362,6 @@ void WageEngine::redrawScene() {
}
}
-void WageEngine::regen() {
- Chr *player = _world->_player;
- int curHp = player->_context._statVariables[PHYS_HIT_CUR];
- int maxHp = player->_context._statVariables[PHYS_HIT_BAS];
- int delta = maxHp - curHp;
-
- if (delta > 0) {
- int bonus = (int)(delta / (8 + _rnd->getRandomNumber(2)));
- player->_context._statVariables[PHYS_HIT_CUR] += bonus;
- }
-}
-
void WageEngine::processTurnInternal(Common::String *textInput, Designed *clickInput) {
Scene *playerScene = _world->_player->_currentScene;
if (playerScene == _world->_storageScene)
Commit: 9b8e5020bfae37505cf178aa6604882ee84d12c2
https://github.com/scummvm/scummvm/commit/9b8e5020bfae37505cf178aa6604882ee84d12c2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-09T01:25:23+01:00
Commit Message:
WAGE: Reduced header dependency
Changed paths:
engines/wage/design.cpp
engines/wage/gui.cpp
engines/wage/randomhat.cpp
engines/wage/util.cpp
engines/wage/wage.cpp
engines/wage/world.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 5ce1ff3..abed29b 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -45,7 +45,6 @@
*
*/
-#include "common/system.h"
#include "graphics/primitives.h"
#include "wage/wage.h"
#include "wage/design.h"
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index f5c24d0..3e97f11 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -45,12 +45,12 @@
*
*/
-#include "common/system.h"
#include "common/timer.h"
#include "common/unzip.h"
#include "graphics/cursorman.h"
#include "graphics/fonts/bdf.h"
#include "graphics/palette.h"
+
#include "wage/wage.h"
#include "wage/design.h"
#include "wage/entities.h"
diff --git a/engines/wage/randomhat.cpp b/engines/wage/randomhat.cpp
index 6461abf..f908e0b 100644
--- a/engines/wage/randomhat.cpp
+++ b/engines/wage/randomhat.cpp
@@ -48,7 +48,6 @@
#include "common/hashmap.h"
#include "wage/randomhat.h"
-
namespace Wage {
void RandomHat::addTokens(int type, int count) {
diff --git a/engines/wage/util.cpp b/engines/wage/util.cpp
index 1390c49..1216a27 100644
--- a/engines/wage/util.cpp
+++ b/engines/wage/util.cpp
@@ -45,10 +45,10 @@
*
*/
-#include "wage/wage.h"
-
#include "common/stream.h"
+#include "wage/wage.h"
+
namespace Wage {
Common::String readPascalString(Common::SeekableReadStream *in) {
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index da29a20..920f8fe 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -45,13 +45,7 @@
*
*/
-#include "common/scummsys.h"
-
-#include "common/config-manager.h"
#include "common/debug-channels.h"
-#include "common/error.h"
-#include "common/file.h"
-#include "common/fs.h"
#include "engines/engine.h"
#include "engines/util.h"
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index d44267a..1ef51de 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -46,9 +46,6 @@
*/
#include "common/file.h"
-#include "common/macresman.h"
-#include "common/memstream.h"
-#include "common/str-array.h"
#include "wage/wage.h"
#include "wage/entities.h"
Commit: 3906c368981f19a3f710a4742578ac4d42001e56
https://github.com/scummvm/scummvm/commit/3906c368981f19a3f710a4742578ac4d42001e56
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-09T01:34:06+01:00
Commit Message:
WAGE: Put lists into typedefs
Changed paths:
engines/wage/combat.cpp
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/gui.cpp
engines/wage/script.cpp
engines/wage/script.h
engines/wage/wage.cpp
engines/wage/world.h
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index 102302a..8f3e515 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -139,7 +139,7 @@ void WageEngine::performCombatAction(Chr *npc, Chr *player) {
hat.addTokens(kTokOffer, npc->_losingOffer + 1);
}
- Common::List<Obj *> *objs = &npc->_currentScene->_objs;
+ ObjList *objs = &npc->_currentScene->_objs;
if (npc->_inventory.size() < npc->_maximumCarriedObjects) {
int cnt = 0;
for (ObjList::const_iterator it = objs->begin(); it != objs->end(); ++it, ++cnt) {
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 753084e..64e919b 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -138,12 +138,12 @@ void Scene::paint(Graphics::Surface *surface, int x, int y) {
_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, x, y);
- for (Common::List<Obj *>::const_iterator it = _objs.begin(); it != _objs.end(); ++it) {
+ for (ObjList::const_iterator it = _objs.begin(); it != _objs.end(); ++it) {
debug(2, "paining Obj: %s", (*it)->_name.c_str());
(*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, x, y);
}
- for (Common::List<Chr *>::const_iterator it = _chrs.begin(); it != _chrs.end(); ++it) {
+ for (ChrList::const_iterator it = _chrs.begin(); it != _chrs.end(); ++it) {
debug(2, "paining Chr: %s", (*it)->_name.c_str());
(*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, x, y);
}
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 4cf756a..5f1c968 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -64,6 +64,7 @@ typedef Common::Array<Weapon *> WeaponArray;
typedef Common::Array<Obj *> ObjArray;
typedef Common::Array<Chr *> ChrArray;
typedef Common::List<Obj *> ObjList;
+typedef Common::List<Chr *> ChrList;
enum StatVariable {
/** The base physical accuracy of the player. */
@@ -212,7 +213,7 @@ public:
String _dyingWords;
Scene *_currentScene;
- Common::Array<Obj *> _inventory;
+ ObjArray _inventory;
Obj *_armor[NUMBER_OF_ARMOR_TYPES];
@@ -342,8 +343,8 @@ public:
int _worldY;
bool _visited;
- Common::List<Obj *> _objs;
- Common::List<Chr *> _chrs;
+ ObjList _objs;
+ ChrList _chrs;
Scene();
Scene(String name, Common::SeekableReadStream *data);
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 3e97f11..7cabe6d 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -639,12 +639,12 @@ Designed *Gui::getClickTarget(int x, int y) {
_bordersDirty = true;
}
- for (Common::List<Obj *>::const_iterator it = _scene->_objs.begin(); it != _scene->_objs.end(); ++it) {
+ for (ObjList::const_iterator it = _scene->_objs.begin(); it != _scene->_objs.end(); ++it) {
if ((*it)->_design->isPointOpaque(x - _sceneArea.left + kBorderWidth, y - _sceneArea.top + kBorderWidth))
return *it;
}
- for (Common::List<Chr *>::const_iterator it = _scene->_chrs.begin(); it != _scene->_chrs.end(); ++it) {
+ for (ChrList::const_iterator it = _scene->_chrs.begin(); it != _scene->_chrs.end(); ++it) {
if ((*it)->_design->isPointOpaque(x - _sceneArea.left + kBorderWidth, y - _sceneArea.top + kBorderWidth))
return *it;
}
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 71c75d9..48e01c0 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -588,17 +588,17 @@ bool Script::compare(Operand *o1, Operand *o2, int comparator) {
case kCompEqNumNum:
return o1->_value.number == o2->_value.number;
case kCompEqObjScene:
- for (Common::List<Obj *>::const_iterator it = o2->_value.scene->_objs.begin(); it != o2->_value.scene->_objs.end(); ++it)
+ for (ObjList::const_iterator it = o2->_value.scene->_objs.begin(); it != o2->_value.scene->_objs.end(); ++it)
if (*it == o1->_value.obj)
return true;
return false;
case kCompEqChrScene:
- for (Common::List<Chr *>::const_iterator it = o2->_value.scene->_chrs.begin(); it != o2->_value.scene->_chrs.end(); ++it)
+ for (ChrList::const_iterator it = o2->_value.scene->_chrs.begin(); it != o2->_value.scene->_chrs.end(); ++it)
if (*it == o1->_value.chr)
return true;
return false;
case kCompEqObjChr:
- for (Common::Array<Obj *>::const_iterator it = o2->_value.chr->_inventory.begin(); it != o2->_value.chr->_inventory.end(); ++it)
+ for (ObjArray::const_iterator it = o2->_value.chr->_inventory.begin(); it != o2->_value.chr->_inventory.end(); ++it)
if (*it == o1->_value.obj)
return true;
return false;
@@ -988,9 +988,9 @@ void Script::handleLookCommand() {
}
Common::String *Script::getGroundItemsList(Scene *scene) {
- Common::Array<Obj *> objs;
+ ObjArray objs;
- for (Common::List<Obj *>::const_iterator it = scene->_objs.begin(); it != scene->_objs.end(); ++it)
+ for (ObjList::const_iterator it = scene->_objs.begin(); it != scene->_objs.end(); ++it)
if ((*it)->_type != Obj::IMMOBILE_OBJECT)
objs.push_back(*it);
@@ -1002,7 +1002,7 @@ Common::String *Script::getGroundItemsList(Scene *scene) {
return NULL;
}
-void Script::appendObjNames(Common::String &str, Common::Array<Obj *> &objs) {
+void Script::appendObjNames(Common::String &str, ObjArray &objs) {
for (uint i = 0; i < objs.size(); i++) {
Obj *obj = objs[i];
diff --git a/engines/wage/script.h b/engines/wage/script.h
index adb1813..529efa8 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -174,7 +174,7 @@ private:
void handleMoveCommand(Scene::Directions dir, const char *dirName);
void handleLookCommand();
Common::String *getGroundItemsList(Scene *scene);
- void appendObjNames(Common::String &str, Common::Array<Obj *> &objs);
+ void appendObjNames(Common::String &str, ObjArray &objs);
void handleInventoryCommand();
void handleStatusCommand();
void handleRestCommand();
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 920f8fe..eaadfea 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -370,7 +370,7 @@ void WageEngine::processTurnInternal(Common::String *textInput, Designed *clickI
_running = NULL;
_offer = NULL;
- for (Common::List<Chr *>::const_iterator it = playerScene->_chrs.begin(); it != playerScene->_chrs.end(); ++it) {
+ for (ChrList::const_iterator it = playerScene->_chrs.begin(); it != playerScene->_chrs.end(); ++it) {
if (!(*it)->_playerCharacter) {
_monster = *it;
shouldEncounter = true;
diff --git a/engines/wage/world.h b/engines/wage/world.h
index 6afd1af..f59564f 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -81,8 +81,8 @@ public:
Common::HashMap<String, Chr *> _chrs;
Common::HashMap<String, Sound *> _sounds;
Common::Array<Scene *> _orderedScenes;
- Common::Array<Obj *> _orderedObjs;
- Common::Array<Chr *> _orderedChrs;
+ ObjArray _orderedObjs;
+ ChrArray _orderedChrs;
Common::Array<Sound *> _orderedSounds;
Patterns _patterns;
Scene *_storageScene;
Commit: 4665f23c4a90c30103d2153c8fcfd562e2fc2782
https://github.com/scummvm/scummvm/commit/4665f23c4a90c30103d2153c8fcfd562e2fc2782
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-09T01:48:38+01:00
Commit Message:
WAGE: Implement RandomHat
Changed paths:
engines/wage/combat.cpp
engines/wage/randomhat.cpp
engines/wage/randomhat.h
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index 8f3e515..9bb1a54 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -107,7 +107,7 @@ void WageEngine::performCombatAction(Chr *npc, Chr *player) {
if (npc->_context._frozen)
return;
- RandomHat hat;
+ RandomHat hat(_rnd);
bool winning = (npc->_context._statVariables[PHYS_HIT_CUR] > player->_context._statVariables[PHYS_HIT_CUR]);
int validMoves = getValidMoveDirections(npc);
@@ -166,6 +166,8 @@ void WageEngine::performCombatAction(Chr *npc, Chr *player) {
case kTokOffer:
performOffer(npc, player);
break;
+ case kTokNone:
+ break;
default:
{
int cnt = 0;
diff --git a/engines/wage/randomhat.cpp b/engines/wage/randomhat.cpp
index f908e0b..9371140 100644
--- a/engines/wage/randomhat.cpp
+++ b/engines/wage/randomhat.cpp
@@ -45,6 +45,8 @@
*
*/
+#include "common/random.h"
+
#include "common/hashmap.h"
#include "wage/randomhat.h"
@@ -54,8 +56,28 @@ void RandomHat::addTokens(int type, int count) {
_tokens.setVal(type, _tokens.getVal(type, 0) + count);
}
+int RandomHat::countTokens() {
+ int count = 0;
+ for (Common::HashMap<int, int>::const_iterator it = _tokens.begin(); it != _tokens.end(); ++it)
+ count += it->_value;
+
+ return count;
+}
+
int RandomHat::drawToken() {
- return 0;
+ int total = countTokens();
+ if (total > 0) {
+ int random = _rnd->getRandomNumber(total - 1);
+ int count = 0;
+ for (Common::HashMap<int, int>::iterator it = _tokens.begin(); it != _tokens.end(); ++it) {
+ if (random >= count && random < count + it->_value) {
+ it->_value--;
+ return it->_key;
+ }
+ count += it->_value;
+ }
+ }
+ return kTokNone;
}
} // End of namespace Wage
diff --git a/engines/wage/randomhat.h b/engines/wage/randomhat.h
index f54b86b..254cd2a 100644
--- a/engines/wage/randomhat.h
+++ b/engines/wage/randomhat.h
@@ -54,18 +54,22 @@ enum {
kTokWeapons = -400,
kTokMagic = -300,
kTokRun = -200,
- kTokOffer = -100
+ kTokOffer = -100,
+ kTokNone = -100000
};
class RandomHat {
public:
- RandomHat() {}
+ RandomHat(Common::RandomSource *rnd) : _rnd(rnd) {}
void addTokens(int type, int count);
int drawToken();
private:
+ Common::RandomSource *_rnd;
Common::HashMap<int, int> _tokens;
+
+ int countTokens();
};
} // End of namespace Wage
Commit: 91d70b6df6251145fc6da9d2cc2b8acce5ea100b
https://github.com/scummvm/scummvm/commit/91d70b6df6251145fc6da9d2cc2b8acce5ea100b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-09T01:57:43+01:00
Commit Message:
WAGE: Fix _monster/getMonster() mess
Changed paths:
engines/wage/wage.cpp
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index eaadfea..c1b654f 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -398,11 +398,11 @@ void WageEngine::processTurnInternal(Common::String *textInput, Designed *clickI
_temporarilyHidden = false;
} else if (_loopCount == 1) {
redrawScene();
- if (shouldEncounter && _monster != NULL) {
+ if (shouldEncounter && getMonster() != NULL) {
encounter(_world->_player, _monster);
}
} else if (textInput != NULL && !handled) {
- if (monsterWasNull && _monster != NULL)
+ if (monsterWasNull && getMonster() != NULL)
return;
Common::String rant(_rnd->getRandomNumber(1) ? "What?" : "Huh?");
@@ -415,14 +415,14 @@ void WageEngine::processTurnInternal(Common::String *textInput, Designed *clickI
void WageEngine::processTurn(Common::String *textInput, Designed *clickInput) {
_commandWasQuick = false;
Scene *prevScene = _world->_player->_currentScene;
- Chr *prevMonster = _monster;
+ Chr *prevMonster = getMonster();
processTurnInternal(textInput, clickInput);
Scene *playerScene = _world->_player->_currentScene;
if (prevScene != playerScene && playerScene != _world->_storageScene) {
if (prevMonster != NULL) {
bool followed = false;
- if (_monster == NULL) {
+ if (getMonster() == NULL) {
// TODO: adjacent scenes doesn't contain up/down etc... verify that monsters can't follow these...
if (_world->scenesAreConnected(playerScene, prevMonster->_currentScene)) {
int chance = _rnd->getRandomNumber(255);
@@ -445,8 +445,8 @@ void WageEngine::processTurn(Common::String *textInput, Designed *clickInput) {
}
}
}
- if (!_commandWasQuick && _monster != NULL) {
- performCombatAction(_monster, _world->_player);
+ if (!_commandWasQuick && getMonster() != NULL) {
+ performCombatAction(getMonster(), _world->_player);
}
}
Commit: 047a660dac829cee9f755a31a5f371993f2f9b89
https://github.com/scummvm/scummvm/commit/047a660dac829cee9f755a31a5f371993f2f9b89
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-09T13:19:46+01:00
Commit Message:
WAGE: Implement performTake()
Changed paths:
engines/wage/combat.cpp
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index 9bb1a54..7261a55 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -199,7 +199,12 @@ void WageEngine::performOffer(Chr *attacker, Chr *victim) {
}
void WageEngine::performTake(Chr *npc, Obj *obj) {
- warning("STUB: performTake()");
+ Common::String msg(npc->getNameWithDefiniteArticle(true));
+ msg += " picks up the ";
+ msg += getIndefiniteArticle(obj->_name);
+ msg += obj->_name;
+
+ _world->move(obj, npc);
}
int WageEngine::getValidMoveDirections(Chr *npc) {
Commit: 165066107f9667039a7035b8820fb3f2665c26bf
https://github.com/scummvm/scummvm/commit/165066107f9667039a7035b8820fb3f2665c26bf
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-09T13:40:19+01:00
Commit Message:
WAGE: Implement performOffer()
Changed paths:
engines/wage/combat.cpp
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/wage.cpp
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index 7261a55..cdf336f 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -77,7 +77,8 @@ void WageEngine::encounter(Chr *player, Chr *chr) {
appendText(chr->_initialComment);
if (chr->_armor[Chr::HEAD_ARMOR] != NULL) {
- msg = chr->getNameWithDefiniteArticle(true);
+ msg = chr->getDefiniteArticle(true);
+ msg += chr->_name;
msg += " is wearing ";
msg += getIndefiniteArticle(chr->_armor[Chr::HEAD_ARMOR]->_name);
msg += ".";
@@ -195,14 +196,25 @@ void WageEngine::performMove(Chr *chr, int validMoves) {
}
void WageEngine::performOffer(Chr *attacker, Chr *victim) {
- warning("STUB: performOffer()");
+ /* TODO: choose in a smarter way? */
+ Obj *obj = attacker->_inventory[0];
+ Common::String msg(attacker->getDefiniteArticle(true));
+ msg += attacker->_name;
+ msg += " offers ";
+ msg += obj->_namePlural ? "some " : getIndefiniteArticle(obj->_name);
+ msg += obj->_name;
+ msg += ".";
+
+ _offer = obj;
}
void WageEngine::performTake(Chr *npc, Obj *obj) {
- Common::String msg(npc->getNameWithDefiniteArticle(true));
+ Common::String msg(npc->getDefiniteArticle(true));
+ msg += npc->_name;
msg += " picks up the ";
msg += getIndefiniteArticle(obj->_name);
msg += obj->_name;
+ msg += ".";
_world->move(obj, npc);
}
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 64e919b..8472e78 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -432,14 +432,11 @@ int Chr::wearObjIfPossible(Obj *obj) {
return -1;
}
-String &Chr::getNameWithDefiniteArticle(bool capitalize) {
- Common::String *res = new Common::String;
-
+const char *Chr::getDefiniteArticle(bool capitalize) {
if (!_nameProperNoun)
- *res += capitalize ? "The " : "the ";
- *res += _name;
+ return capitalize ? "The " : "the ";
- return *res;
+ return "";
}
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 5f1c968..362e9b5 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -221,7 +221,7 @@ public:
WeaponArray *getWeapons(bool includeMagic);
ObjArray *getMagicalObjects();
- String &getNameWithDefiniteArticle(bool capitalize);
+ const char *getDefiniteArticle(bool capitalize);
public:
bool hasNativeWeapon1() {
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index c1b654f..37a6031 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -433,13 +433,15 @@ void WageEngine::processTurn(Common::String *textInput, Designed *clickInput) {
Common::String msg;
if (followed) {
- msg = prevMonster->getNameWithDefiniteArticle(true);
+ msg = prevMonster->getDefiniteArticle(true);
+ msg += prevMonster->_name;
msg += " follows you.";
appendText(msg);
_world->move(prevMonster, playerScene);
} else {
msg = "You escape ";
- msg += prevMonster->getNameWithDefiniteArticle(false);
+ msg += prevMonster->getDefiniteArticle(false);
+ msg += prevMonster->_name;
msg += ".";
appendText(msg);
}
Commit: 5b374c6f55885f61215bada85a57feb293ea0c8d
https://github.com/scummvm/scummvm/commit/5b374c6f55885f61215bada85a57feb293ea0c8d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-11T11:16:00+01:00
Commit Message:
WAGE: Moved menu rendering into separate file
Changed paths:
A engines/wage/menu.cpp
A engines/wage/menu.h
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/module.mk
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 7cabe6d..e38d024 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -54,21 +54,12 @@
#include "wage/wage.h"
#include "wage/design.h"
#include "wage/entities.h"
+#include "wage/menu.h"
#include "wage/gui.h"
#include "wage/world.h"
namespace Wage {
-enum {
- kMenuHeight = 20,
- kMenuPadding = 6,
- kMenuItemHeight = 20,
- kBorderWidth = 17,
- kDesktopArc = 7,
- kComponentsPadding = 10,
- kCursorHeight = 12
-};
-
static const byte palette[] = {
0, 0, 0, // Black
0x80, 0x80, 0x80, // Gray
@@ -77,7 +68,6 @@ static const byte palette[] = {
};
static byte checkersPattern[8] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa };
-static byte fillPattern[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
static const byte macCursorArrow[] = {
2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3,
@@ -171,12 +161,15 @@ Gui::Gui(WageEngine *engine) {
loadFonts();
g_system->getTimerManager()->installTimerProc(&cursor_timer_handler, 200000, this, "wageCursor");
+
+ _menu = new Menu(this);
}
Gui::~Gui() {
_screen.free();
_console.free();
g_system->getTimerManager()->removeTimerProc(&cursor_timer_handler);
+ delete _menu;
}
const Graphics::Font *Gui::getFont(const char *name, Graphics::FontManager::FontUsage fallback) {
@@ -204,10 +197,6 @@ const Graphics::Font *Gui::getConsoleFont() {
return getFont(fontName, Graphics::FontManager::kConsoleFont);
}
-const Graphics::Font *Gui::getMenuFont() {
- return getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
-}
-
const Graphics::Font *Gui::getTitleFont() {
return getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
}
@@ -292,7 +281,7 @@ void Gui::draw() {
paintBorder(&_screen, _consoleTextArea, kWindowConsole);
if (_menuDirty)
- renderMenu();
+ _menu->render();
_sceneDirty = false;
_consoleDirty = false;
@@ -598,40 +587,6 @@ void Gui::mouseMove(int x, int y) {
}
}
-static const char *menuItems[] = {
- "\xf0", "File", "Edit", "Commands", "Weapons", 0
-};
-
-void Gui::renderMenu() {
- Common::Rect r(0, 0, _screen.w - 1, kMenuHeight - 1);
- Patterns p;
- p.push_back(fillPattern);
-
- Design::drawFilledRoundRect(&_screen, r, kDesktopArc, kColorWhite, p, 1);
- r.top = 7;
- Design::drawFilledRect(&_screen, r, kColorWhite, p, 1);
- r.top = kMenuHeight - 1;
- Design::drawFilledRect(&_screen, r, kColorBlack, p, 1);
-
- const Graphics::Font *font = getMenuFont();
- int y = _builtInFonts ? 3 : 2;
- int x = 18;
-
- for (int i = 0; menuItems[i]; i++) {
- const char *s = menuItems[i];
-
- if (i == 0 && _builtInFonts)
- s = "\xa9"; // (c) Symbol as the most resembling apple
-
- int w = font->getStringWidth(s);
- font->drawString(&_screen, s, x, y, w, kColorBlack);
-
- x += w + 13;
- }
-
- g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, kMenuHeight);
-}
-
Designed *Gui::getClickTarget(int x, int y) {
if (_sceneArea.contains(x, y)) {
if (!_sceneIsActive) {
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 3c5660b..7e91479 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -56,11 +56,23 @@
namespace Wage {
+class Menu;
+
enum WindowType {
kWindowScene,
kWindowConsole
};
+enum {
+ kMenuHeight = 20,
+ kMenuPadding = 6,
+ kMenuItemHeight = 20,
+ kBorderWidth = 17,
+ kDesktopArc = 7,
+ kComponentsPadding = 10,
+ kCursorHeight = 12
+};
+
class Gui {
public:
Gui(WageEngine *engine);
@@ -73,6 +85,7 @@ public:
Designed *getClickTarget(int x, int y);
void drawInput();
void setSceneDirty() { _sceneDirty = true; }
+ const Graphics::Font *getFont(const char *name, Graphics::FontManager::FontUsage fallback);
private:
void paintBorder(Graphics::Surface *g, Common::Rect &r, WindowType windowType);
@@ -80,12 +93,9 @@ private:
void drawBox(Graphics::Surface *g, int x, int y, int w, int h);
void fillRect(Graphics::Surface *g, int x, int y, int w, int h);
void loadFonts();
- void renderMenu();
void flowText(Common::String &str);
const Graphics::Font *getConsoleFont();
- const Graphics::Font *getMenuFont();
const Graphics::Font *getTitleFont();
- const Graphics::Font *getFont(const char *name, Graphics::FontManager::FontUsage fallback);
public:
Graphics::Surface _screen;
@@ -94,9 +104,12 @@ public:
Common::Rect _consoleTextArea;
bool _cursorOff;
+ bool _builtInFonts;
+
private:
WageEngine *_engine;
Graphics::Surface _console;
+ Menu *_menu;
Scene *_scene;
bool _sceneDirty;
bool _consoleDirty;
@@ -110,8 +123,6 @@ private:
uint _consoleNumLines;
bool _consoleFullRedraw;
- bool _builtInFonts;
-
Common::Rect _sceneArea;
bool _sceneIsActive;
bool _cursorIsArrow;
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
new file mode 100644
index 0000000..c89ec83
--- /dev/null
+++ b/engines/wage/menu.cpp
@@ -0,0 +1,97 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "common/system.h"
+
+#include "wage/wage.h"
+#include "wage/design.h"
+#include "wage/gui.h"
+#include "wage/menu.h"
+
+namespace Wage {
+
+static const char *menuItems[] = {
+ "\xf0", "File", "Edit", "Commands", "Weapons", 0
+};
+
+static byte fillPattern[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+
+const Graphics::Font *Menu::getMenuFont() {
+ return _gui->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
+}
+
+void Menu::render() {
+ Common::Rect r(0, 0, _gui->_screen.w - 1, kMenuHeight - 1);
+ Patterns p;
+ p.push_back(fillPattern);
+
+ Design::drawFilledRoundRect(&_gui->_screen, r, kDesktopArc, kColorWhite, p, 1);
+ r.top = 7;
+ Design::drawFilledRect(&_gui->_screen, r, kColorWhite, p, 1);
+ r.top = kMenuHeight - 1;
+ Design::drawFilledRect(&_gui->_screen, r, kColorBlack, p, 1);
+
+ const Graphics::Font *font = getMenuFont();
+ int y = _gui->_builtInFonts ? 3 : 2;
+ int x = 18;
+
+ for (int i = 0; menuItems[i]; i++) {
+ const char *s = menuItems[i];
+
+ if (i == 0 && _gui->_builtInFonts)
+ s = "\xa9"; // (c) Symbol as the most resembling apple
+
+ int w = font->getStringWidth(s);
+ font->drawString(&_gui->_screen, s, x, y, w, kColorBlack);
+
+ x += w + 13;
+ }
+
+ g_system->copyRectToScreen(_gui->_screen.getPixels(), _gui->_screen.pitch, 0, 0, _gui->_screen.w, kMenuHeight);
+}
+
+} // End of namespace Wage
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
new file mode 100644
index 0000000..9831814
--- /dev/null
+++ b/engines/wage/menu.h
@@ -0,0 +1,68 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef WAGE_MENU_H
+#define WAGE_MENU_H
+
+namespace Wage {
+
+class Menu {
+public:
+ Menu(Gui *gui) : _gui(gui) {}
+
+ void render();
+
+private:
+ Gui *_gui;
+
+private:
+ const Graphics::Font *getMenuFont();
+};
+
+} // End of namespace Wage
+
+#endif
diff --git a/engines/wage/module.mk b/engines/wage/module.mk
index 8229d17..798e5b5 100644
--- a/engines/wage/module.mk
+++ b/engines/wage/module.mk
@@ -6,6 +6,7 @@ MODULE_OBJS := \
detection.o \
entities.o \
gui.o \
+ menu.o \
randomhat.o \
script.o \
util.o \
Commit: faa2588ba4d2074ef7b62ff362c2fce176bfd91e
https://github.com/scummvm/scummvm/commit/faa2588ba4d2074ef7b62ff362c2fce176bfd91e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-11T11:34:12+01:00
Commit Message:
WAGE: Made rendering of 1st menu level generic
Changed paths:
engines/wage/gui.h
engines/wage/menu.cpp
engines/wage/menu.h
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 7e91479..8ba9ce9 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -105,9 +105,9 @@ public:
bool _cursorOff;
bool _builtInFonts;
+ WageEngine *_engine;
private:
- WageEngine *_engine;
Graphics::Surface _console;
Menu *_menu;
Scene *_scene;
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index c89ec83..fab8d04 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -48,18 +48,51 @@
#include "common/system.h"
#include "wage/wage.h"
+#include "wage/entities.h"
#include "wage/design.h"
#include "wage/gui.h"
#include "wage/menu.h"
+#include "wage/world.h"
namespace Wage {
-static const char *menuItems[] = {
- "\xf0", "File", "Edit", "Commands", "Weapons", 0
+struct MenuSubItem {
+ Common::String text;
+ int style;
+ char shortcut;
+ bool enabled;
+
+ MenuSubItem(Common::String &t, int s, char sh) : text(t), style(s), shortcut(sh), enabled(true) {}
+};
+
+struct MenuItem {
+ Common::String name;
+ Common::Array<MenuSubItem *> subitems;
+
+ MenuItem(const char *n) : name(n) {}
};
static byte fillPattern[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+Menu::Menu(Gui *gui) : _gui(gui) {
+ MenuItem *about = new MenuItem(_gui->_builtInFonts ? "\xa9" : "\xf0"); // (c) Symbol as the most resembling apple
+ _items.push_back(about);
+
+ MenuItem *file = new MenuItem("File");
+ _items.push_back(file);
+
+ MenuItem *edit = new MenuItem("Edit");
+ _items.push_back(edit);
+
+ MenuItem *commands = new MenuItem("Commands");
+ _items.push_back(commands);
+
+ if (!_gui->_engine->_world->_weaponMenuDisabled) {
+ MenuItem *weapons = new MenuItem("Weapons");
+ _items.push_back(weapons);
+ }
+}
+
const Graphics::Font *Menu::getMenuFont() {
return _gui->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
}
@@ -79,14 +112,9 @@ void Menu::render() {
int y = _gui->_builtInFonts ? 3 : 2;
int x = 18;
- for (int i = 0; menuItems[i]; i++) {
- const char *s = menuItems[i];
-
- if (i == 0 && _gui->_builtInFonts)
- s = "\xa9"; // (c) Symbol as the most resembling apple
-
- int w = font->getStringWidth(s);
- font->drawString(&_gui->_screen, s, x, y, w, kColorBlack);
+ for (int i = 0; i < _items.size(); i++) {
+ int w = font->getStringWidth(_items[i]->name);
+ font->drawString(&_gui->_screen, _items[i]->name, x, y, w, kColorBlack);
x += w + 13;
}
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index 9831814..aec92cf 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -50,9 +50,11 @@
namespace Wage {
+struct MenuItem;
+
class Menu {
public:
- Menu(Gui *gui) : _gui(gui) {}
+ Menu(Gui *gui);
void render();
@@ -61,6 +63,7 @@ private:
private:
const Graphics::Font *getMenuFont();
+ Common::Array<MenuItem *> _items;
};
} // End of namespace Wage
Commit: 856a4e1eb3a988e40e2cea4845c0b13adf69717a
https://github.com/scummvm/scummvm/commit/856a4e1eb3a988e40e2cea4845c0b13adf69717a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-11T11:38:32+01:00
Commit Message:
WAGE: Fix crash at startup
Changed paths:
engines/wage/wage.cpp
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 37a6031..73499d2 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -95,8 +95,6 @@ Common::Error WageEngine::run() {
debug("WageEngine::init");
- _gui = new Gui(this);
-
// Your main event loop should be (invoked from) here.
_resManager = new Common::MacResManager();
_resManager->open(getGameFile());
@@ -106,6 +104,8 @@ Common::Error WageEngine::run() {
if (!_world->loadWorld(_resManager))
return Common::kNoGameDataFoundError;
+ _gui = new Gui(this);
+
_temporarilyHidden = true;
performInitialSetup();
Common::String input("look");
Commit: c3685046465dacdde6ae8e060b5465a9adf249c2
https://github.com/scummvm/scummvm/commit/c3685046465dacdde6ae8e060b5465a9adf249c2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-11T11:39:25+01:00
Commit Message:
WAGE: Added safeguards to avoid future mistakes
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index fab8d04..ade2b79 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -87,6 +87,9 @@ Menu::Menu(Gui *gui) : _gui(gui) {
MenuItem *commands = new MenuItem("Commands");
_items.push_back(commands);
+ assert(_gui->_engine);
+ assert(_gui->_engine->_world);
+
if (!_gui->_engine->_world->_weaponMenuDisabled) {
MenuItem *weapons = new MenuItem("Weapons");
_items.push_back(weapons);
Commit: 061a00bf09dc80b4e60e2718f0103f59951f1d5c
https://github.com/scummvm/scummvm/commit/061a00bf09dc80b4e60e2718f0103f59951f1d5c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-11T19:21:25+01:00
Commit Message:
WAGE: Started submenu implementation
Changed paths:
engines/wage/menu.cpp
engines/wage/world.cpp
engines/wage/world.h
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index ade2b79..4407ba2 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -58,11 +58,12 @@ namespace Wage {
struct MenuSubItem {
Common::String text;
+ int action;
int style;
char shortcut;
bool enabled;
- MenuSubItem(Common::String &t, int s, char sh) : text(t), style(s), shortcut(sh), enabled(true) {}
+ MenuSubItem(const char *t, int a, int s = 0, char sh = 0, bool e = true) : text(t), action(a), style(s), shortcut(sh), enabled(e) {}
};
struct MenuItem {
@@ -74,9 +75,51 @@ struct MenuItem {
static byte fillPattern[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+enum {
+ kMenuActionAbout,
+ kMenuActionNew,
+ kMenuActionOpen,
+ kMenuActionClose,
+ kMenuActionSave,
+ kMenuActionSaveAs,
+ kMenuActionRevert,
+ kMenuActionQuit,
+
+ kMenuActionUndo,
+ kMenuActionCut,
+ kMenuActionCopy,
+ kMenuActionPaste,
+ kMenuActionClear
+};
+
+struct MenuData {
+ int menunum;
+ const char *title;
+ int action;
+ byte shortcut;
+} menuSubItems[] = {
+ { 1, "New", kMenuActionNew, 0 },
+ { 1, "Open...", kMenuActionOpen, 0 },
+ { 1, "Close", kMenuActionClose, 0 },
+ { 1, "Save", kMenuActionSave, 0 },
+ { 1, "Save as...", kMenuActionSaveAs, 0 },
+ { 1, "Revert", kMenuActionRevert, 0 },
+ { 1, "Quit", kMenuActionQuit, 0 },
+
+ { 2, "Undo", kMenuActionUndo, 'Z' },
+ { 2, NULL, 0, 0 },
+ { 2, "Cut", kMenuActionCut, 'K' },
+ { 2, "Copy", kMenuActionCopy, 'C' },
+ { 2, "Paste", kMenuActionPaste, 'V' },
+ { 2, "Clear", kMenuActionClear, 'B' },
+
+ { 0, NULL, 0, 0 }
+};
+
Menu::Menu(Gui *gui) : _gui(gui) {
MenuItem *about = new MenuItem(_gui->_builtInFonts ? "\xa9" : "\xf0"); // (c) Symbol as the most resembling apple
_items.push_back(about);
+ _items[0]->subitems.push_back(new MenuSubItem(_gui->_engine->_world->getAboutMenuItemName(), kMenuActionAbout));
MenuItem *file = new MenuItem("File");
_items.push_back(file);
@@ -84,6 +127,12 @@ Menu::Menu(Gui *gui) : _gui(gui) {
MenuItem *edit = new MenuItem("Edit");
_items.push_back(edit);
+ for (int i = 0; menuSubItems[i].menunum; i++) {
+ MenuData *m = &menuSubItems[i];
+
+ _items[i]->subitems.push_back(new MenuSubItem(m->title, m->action, m->shortcut));
+ }
+
MenuItem *commands = new MenuItem("Commands");
_items.push_back(commands);
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 1ef51de..deac19b 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -484,4 +484,10 @@ bool World::scenesAreConnected(Scene *scene1, Scene *scene2) {
return false;
}
+const char *World::getAboutMenuItemName() {
+ warning("STUB: getAboutMenuItemName");
+
+ return "About";
+}
+
} // End of namespace Wage
diff --git a/engines/wage/world.h b/engines/wage/world.h
index f59564f..a79d30c 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -66,6 +66,7 @@ public:
Scene *getRandomScene();
Scene *getSceneAt(int x, int y);
bool scenesAreConnected(Scene *scene1, Scene *scene2);
+ const char *getAboutMenuItemName();
WageEngine *_engine;
Commit: db503e967dbd93458cf59837679c0f4a60d1420e
https://github.com/scummvm/scummvm/commit/db503e967dbd93458cf59837679c0f4a60d1420e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-11T19:55:37+01:00
Commit Message:
WAGE: Stop leaking menu on exit
Changed paths:
engines/wage/menu.cpp
engines/wage/menu.h
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 4407ba2..1fc4028 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -62,6 +62,7 @@ struct MenuSubItem {
int style;
char shortcut;
bool enabled;
+ Common::Rect bbox;
MenuSubItem(const char *t, int a, int s = 0, char sh = 0, bool e = true) : text(t), action(a), style(s), shortcut(sh), enabled(e) {}
};
@@ -69,6 +70,7 @@ struct MenuSubItem {
struct MenuItem {
Common::String name;
Common::Array<MenuSubItem *> subitems;
+ Common::Rect bbox;
MenuItem(const char *n) : name(n) {}
};
@@ -145,6 +147,14 @@ Menu::Menu(Gui *gui) : _gui(gui) {
}
}
+Menu::~Menu() {
+ for (int i = 0; i < _items.size(); i++) {
+ for (int j = 0; j < _items[i]->subitems.size(); j++)
+ delete _items[i]->subitems[j];
+ delete _items[i];
+ }
+}
+
const Graphics::Font *Menu::getMenuFont() {
return _gui->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
}
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index aec92cf..6034ee4 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -55,6 +55,7 @@ struct MenuItem;
class Menu {
public:
Menu(Gui *gui);
+ ~Menu();
void render();
Commit: 2d2c8ab340e873b1d4abdbd7573cca40ee3c49b5
https://github.com/scummvm/scummvm/commit/2d2c8ab340e873b1d4abdbd7573cca40ee3c49b5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-11T20:17:38+01:00
Commit Message:
WAGE: Highlight first level menus
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/menu.cpp
engines/wage/menu.h
engines/wage/wage.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index e38d024..e40b7af 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -613,4 +613,9 @@ Designed *Gui::getClickTarget(int x, int y) {
return NULL;
}
+void Gui::mouseClick(int x, int y) {
+ if (_menu->mouseClick(x, y))
+ _menuDirty = true;
+}
+
} // End of namespace Wage
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 8ba9ce9..8dea4f8 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -82,6 +82,7 @@ public:
void appendText(Common::String &str);
void clearOutput();
void mouseMove(int x, int y);
+ void mouseClick(int x, int y);
Designed *getClickTarget(int x, int y);
void drawInput();
void setSceneDirty() { _sceneDirty = true; }
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 1fc4028..25bd3b9 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -132,7 +132,7 @@ Menu::Menu(Gui *gui) : _gui(gui) {
for (int i = 0; menuSubItems[i].menunum; i++) {
MenuData *m = &menuSubItems[i];
- _items[i]->subitems.push_back(new MenuSubItem(m->title, m->action, m->shortcut));
+ _items[m->menunum]->subitems.push_back(new MenuSubItem(m->title, m->action, m->shortcut));
}
MenuItem *commands = new MenuItem("Commands");
@@ -145,6 +145,15 @@ Menu::Menu(Gui *gui) : _gui(gui) {
MenuItem *weapons = new MenuItem("Weapons");
_items.push_back(weapons);
}
+
+ _bbox.left = 0;
+ _bbox.top = 0;
+ _bbox.right = _gui->_screen.w - 1;
+ _bbox.bottom = kMenuHeight - 1;
+
+ _menuActivated = false;
+ _activeItem = -1;
+ _activeSubItem = -1;
}
Menu::~Menu() {
@@ -160,7 +169,7 @@ const Graphics::Font *Menu::getMenuFont() {
}
void Menu::render() {
- Common::Rect r(0, 0, _gui->_screen.w - 1, kMenuHeight - 1);
+ Common::Rect r(_bbox);
Patterns p;
p.push_back(fillPattern);
@@ -176,7 +185,21 @@ void Menu::render() {
for (int i = 0; i < _items.size(); i++) {
int w = font->getStringWidth(_items[i]->name);
- font->drawString(&_gui->_screen, _items[i]->name, x, y, w, kColorBlack);
+ int color = kColorBlack;
+
+ if (_activeItem == i) {
+ Design::drawFilledRect(&_gui->_screen, _items[i]->bbox, kColorBlack, p, 1);
+ color = kColorWhite;
+ }
+
+ font->drawString(&_gui->_screen, _items[i]->name, x, y, w, color);
+
+ if (_items[i]->bbox.bottom == 0) {
+ _items[i]->bbox.left = x;
+ _items[i]->bbox.top = y;
+ _items[i]->bbox.right = x + w;
+ _items[i]->bbox.bottom = y + font->getFontHeight();
+ }
x += w + 13;
}
@@ -184,4 +207,17 @@ void Menu::render() {
g_system->copyRectToScreen(_gui->_screen.getPixels(), _gui->_screen.pitch, 0, 0, _gui->_screen.w, kMenuHeight);
}
+bool Menu::mouseClick(int x, int y) {
+ if (_bbox.contains(x, y)) {
+ for (int i = 0; i < _items.size(); i++)
+ if (_items[i]->bbox.contains(x, y)) {
+ _activeItem = i;
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
} // End of namespace Wage
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index 6034ee4..255f2e8 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -58,6 +58,9 @@ public:
~Menu();
void render();
+ bool mouseClick(int x, int y);
+
+ Common::Rect _bbox;
private:
Gui *_gui;
@@ -65,6 +68,11 @@ private:
private:
const Graphics::Font *getMenuFont();
Common::Array<MenuItem *> _items;
+
+ bool _menuActivated;
+
+ int _activeItem;
+ int _activeSubItem;
};
} // End of namespace Wage
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 73499d2..ff92a69 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -145,6 +145,7 @@ void WageEngine::processEvents() {
_gui->mouseMove(event.mouse.x, event.mouse.y);
break;
case Common::EVENT_LBUTTONDOWN:
+ _gui->mouseClick(event.mouse.x, event.mouse.y);
break;
case Common::EVENT_LBUTTONUP:
{
Commit: d485f7d7bb46889ef19eea1ae1b29f504c15a524
https://github.com/scummvm/scummvm/commit/d485f7d7bb46889ef19eea1ae1b29f504c15a524
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-11T20:31:24+01:00
Commit Message:
WAGE: Show menu only with mouse button on hold
Changed paths:
engines/wage/gui.cpp
engines/wage/menu.cpp
engines/wage/menu.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index e40b7af..0771cb0 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -576,6 +576,13 @@ void Gui::loadFonts() {
}
void Gui::mouseMove(int x, int y) {
+ if (_menu->_menuActivated) {
+ if (_menu->mouseMove(x, y))
+ _menuDirty = true;
+
+ return;
+ }
+
if (_consoleTextArea.contains(x, y)) {
if (_cursorIsArrow) {
CursorMan.replaceCursor(macCursorBeam, 11, 16, 3, 8, 3);
@@ -588,6 +595,12 @@ void Gui::mouseMove(int x, int y) {
}
Designed *Gui::getClickTarget(int x, int y) {
+ if (_menu->_menuActivated) {
+ if (_menu->mouseRelease(x, y))
+ _menuDirty = true;
+
+ return NULL;
+ }
if (_sceneArea.contains(x, y)) {
if (!_sceneIsActive) {
_sceneIsActive = true;
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 25bd3b9..f775a4d 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -212,6 +212,8 @@ bool Menu::mouseClick(int x, int y) {
for (int i = 0; i < _items.size(); i++)
if (_items[i]->bbox.contains(x, y)) {
_activeItem = i;
+ _activeSubItem = -1;
+ _menuActivated = true;
return true;
}
@@ -220,4 +222,23 @@ bool Menu::mouseClick(int x, int y) {
return false;
}
+bool Menu::mouseMove(int x, int y) {
+ if (_menuActivated)
+ if (mouseClick(x, y))
+ return true;
+
+ return false;
+}
+
+bool Menu::mouseRelease(int x, int y) {
+ if (_menuActivated) {
+ _menuActivated = false;
+ _activeItem = -1;
+
+ return true;
+ }
+
+ return false;
+}
+
} // End of namespace Wage
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index 255f2e8..e444c1a 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -59,7 +59,10 @@ public:
void render();
bool mouseClick(int x, int y);
+ bool mouseRelease(int x, int y);
+ bool mouseMove(int x, int y);
+ bool _menuActivated;
Common::Rect _bbox;
private:
@@ -69,8 +72,6 @@ private:
const Graphics::Font *getMenuFont();
Common::Array<MenuItem *> _items;
- bool _menuActivated;
-
int _activeItem;
int _activeSubItem;
};
Commit: 644f1ef215eeb79ef70225b92ef6af1bf4f087e3
https://github.com/scummvm/scummvm/commit/644f1ef215eeb79ef70225b92ef6af1bf4f087e3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-11T20:46:57+01:00
Commit Message:
WAGE: Optimize menu redraws
Changed paths:
engines/wage/gui.cpp
engines/wage/menu.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 0771cb0..09468f5 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -596,8 +596,12 @@ void Gui::mouseMove(int x, int y) {
Designed *Gui::getClickTarget(int x, int y) {
if (_menu->_menuActivated) {
- if (_menu->mouseRelease(x, y))
+ if (_menu->mouseRelease(x, y)) {
+ _sceneDirty = true;
+ _consoleDirty = true;
+ _bordersDirty = true;
_menuDirty = true;
+ }
return NULL;
}
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index f775a4d..fe5de5a 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -211,6 +211,9 @@ bool Menu::mouseClick(int x, int y) {
if (_bbox.contains(x, y)) {
for (int i = 0; i < _items.size(); i++)
if (_items[i]->bbox.contains(x, y)) {
+ if (_activeItem == i)
+ return false;
+
_activeItem = i;
_activeSubItem = -1;
_menuActivated = true;
Commit: a65fdcf7567e4a8a1ce1d5ee4ec7e483781befd9
https://github.com/scummvm/scummvm/commit/a65fdcf7567e4a8a1ce1d5ee4ec7e483781befd9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-11T20:51:48+01:00
Commit Message:
WAGE: Fixed menu highlight size
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index fe5de5a..bb58398 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -195,9 +195,9 @@ void Menu::render() {
font->drawString(&_gui->_screen, _items[i]->name, x, y, w, color);
if (_items[i]->bbox.bottom == 0) {
- _items[i]->bbox.left = x;
+ _items[i]->bbox.left = x - 7;
_items[i]->bbox.top = y;
- _items[i]->bbox.right = x + w;
+ _items[i]->bbox.right = x + w + 6;
_items[i]->bbox.bottom = y + font->getFontHeight();
}
Commit: db9a9665a47a16852613fd0a15799cdaeaa4bb97
https://github.com/scummvm/scummvm/commit/db9a9665a47a16852613fd0a15799cdaeaa4bb97
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-11T20:58:37+01:00
Commit Message:
WAGE: Precalculate menu dimensions
Changed paths:
engines/wage/gui.h
engines/wage/menu.cpp
engines/wage/menu.h
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 8dea4f8..c5c1aad 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -65,6 +65,8 @@ enum WindowType {
enum {
kMenuHeight = 20,
+ kMenuLeftMargin = 7,
+ kMenuSpacing = 13,
kMenuPadding = 6,
kMenuItemHeight = 20,
kBorderWidth = 17,
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index bb58398..f7ab7e9 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -146,6 +146,24 @@ Menu::Menu(Gui *gui) : _gui(gui) {
_items.push_back(weapons);
}
+ // Calculate menu dimensions
+ _font = getMenuFont();
+ int y = _gui->_builtInFonts ? 3 : 2;
+ int x = 18;
+
+ for (int i = 0; i < _items.size(); i++) {
+ int w = _font->getStringWidth(_items[i]->name);
+
+ if (_items[i]->bbox.bottom == 0) {
+ _items[i]->bbox.left = x - kMenuLeftMargin;
+ _items[i]->bbox.top = y;
+ _items[i]->bbox.right = x + w + kMenuSpacing - kMenuLeftMargin;
+ _items[i]->bbox.bottom = y + _font->getFontHeight();
+ }
+
+ x += w + kMenuSpacing;
+ }
+
_bbox.left = 0;
_bbox.top = 0;
_bbox.right = _gui->_screen.w - 1;
@@ -179,12 +197,7 @@ void Menu::render() {
r.top = kMenuHeight - 1;
Design::drawFilledRect(&_gui->_screen, r, kColorBlack, p, 1);
- const Graphics::Font *font = getMenuFont();
- int y = _gui->_builtInFonts ? 3 : 2;
- int x = 18;
-
for (int i = 0; i < _items.size(); i++) {
- int w = font->getStringWidth(_items[i]->name);
int color = kColorBlack;
if (_activeItem == i) {
@@ -192,16 +205,7 @@ void Menu::render() {
color = kColorWhite;
}
- font->drawString(&_gui->_screen, _items[i]->name, x, y, w, color);
-
- if (_items[i]->bbox.bottom == 0) {
- _items[i]->bbox.left = x - 7;
- _items[i]->bbox.top = y;
- _items[i]->bbox.right = x + w + 6;
- _items[i]->bbox.bottom = y + font->getFontHeight();
- }
-
- x += w + 13;
+ _font->drawString(&_gui->_screen, _items[i]->name, _items[i]->bbox.left + kMenuLeftMargin, _items[i]->bbox.top, _items[i]->bbox.width(), color);
}
g_system->copyRectToScreen(_gui->_screen.getPixels(), _gui->_screen.pitch, 0, 0, _gui->_screen.w, kMenuHeight);
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index e444c1a..0a8c498 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -72,6 +72,8 @@ private:
const Graphics::Font *getMenuFont();
Common::Array<MenuItem *> _items;
+ const Graphics::Font *_font;
+
int _activeItem;
int _activeSubItem;
};
Commit: 80bea99436ad6ec6c73cc775227d5dd1f72b6e35
https://github.com/scummvm/scummvm/commit/80bea99436ad6ec6c73cc775227d5dd1f72b6e35
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-11T21:00:19+01:00
Commit Message:
WAGE: Simplify code
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index f7ab7e9..ef3d723 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -199,13 +199,14 @@ void Menu::render() {
for (int i = 0; i < _items.size(); i++) {
int color = kColorBlack;
+ MenuItem *it = _items[i];
if (_activeItem == i) {
- Design::drawFilledRect(&_gui->_screen, _items[i]->bbox, kColorBlack, p, 1);
+ Design::drawFilledRect(&_gui->_screen, it->bbox, kColorBlack, p, 1);
color = kColorWhite;
}
- _font->drawString(&_gui->_screen, _items[i]->name, _items[i]->bbox.left + kMenuLeftMargin, _items[i]->bbox.top, _items[i]->bbox.width(), color);
+ _font->drawString(&_gui->_screen, it->name, it->bbox.left + kMenuLeftMargin, it->bbox.top, it->bbox.width(), color);
}
g_system->copyRectToScreen(_gui->_screen.getPixels(), _gui->_screen.pitch, 0, 0, _gui->_screen.w, kMenuHeight);
Commit: a2053eb40522fd1bdbbd1993261fbb53fb407697
https://github.com/scummvm/scummvm/commit/a2053eb40522fd1bdbbd1993261fbb53fb407697
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-12T11:01:11+01:00
Commit Message:
WAGE: Calculate submenu bounds
Changed paths:
engines/wage/gui.h
engines/wage/menu.cpp
engines/wage/menu.h
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index c5c1aad..335af86 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -68,6 +68,8 @@ enum {
kMenuLeftMargin = 7,
kMenuSpacing = 13,
kMenuPadding = 6,
+ kMenuDropdownPadding = 6,
+ kMenuDropdownItemHeight = 19,
kMenuItemHeight = 20,
kBorderWidth = 17,
kDesktopArc = 7,
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index ef3d723..c63c39b 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -67,10 +67,13 @@ struct MenuSubItem {
MenuSubItem(const char *t, int a, int s = 0, char sh = 0, bool e = true) : text(t), action(a), style(s), shortcut(sh), enabled(e) {}
};
+typedef Common::Array<MenuSubItem *> SubItemArray;
+
struct MenuItem {
Common::String name;
- Common::Array<MenuSubItem *> subitems;
+ SubItemArray subitems;
Common::Rect bbox;
+ Common::Rect subbbox;
MenuItem(const char *n) : name(n) {}
};
@@ -161,6 +164,8 @@ Menu::Menu(Gui *gui) : _gui(gui) {
_items[i]->bbox.bottom = y + _font->getFontHeight();
}
+ calcMenuBounds(_items[i]);
+
x += w + kMenuSpacing;
}
@@ -186,6 +191,50 @@ const Graphics::Font *Menu::getMenuFont() {
return _gui->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
}
+const char *Menu::getAcceleratorString(MenuSubItem *item) {
+ static char res[20];
+ *res = 0;
+
+ if (item->shortcut != 0)
+ sprintf(res, " \u2318%c", item->shortcut);
+
+ return res;
+}
+
+int Menu::calculateMenuWidth(MenuItem *menu) {
+ int maxWidth = 0;
+ for (int i = 0; i < menu->subitems.size(); i++) {
+ MenuSubItem *item = menu->subitems[i];
+ if (item->text != NULL) {
+ Common::String text(item->text);
+ Common::String acceleratorText(getAcceleratorString(item));
+ if (acceleratorText.size()) {
+ text += acceleratorText;
+ }
+
+ int width = _font->getStringWidth(text);
+ if (width > maxWidth) {
+ maxWidth = width;
+ }
+ }
+ }
+ return maxWidth;
+}
+
+void Menu::calcMenuBounds(MenuItem *menu) {
+ // TODO: cache maxWidth
+ int maxWidth = calculateMenuWidth(menu);
+ int x1 = menu->bbox.left - kMenuDropdownPadding;
+ int y1 = menu->bbox.bottom;
+ int x2 = x1 + maxWidth + kMenuDropdownPadding * 3;
+ int y2 = y1 + menu->subitems.size() * kMenuDropdownItemHeight;
+
+ menu->subbbox.left = x1;
+ menu->subbbox.top = y1;
+ menu->subbbox.right = x2;
+ menu->subbbox.bottom = y2;
+}
+
void Menu::render() {
Common::Rect r(_bbox);
Patterns p;
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index 0a8c498..a6b5db2 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -51,6 +51,7 @@
namespace Wage {
struct MenuItem;
+struct MenuSubItem;
class Menu {
public:
@@ -70,6 +71,10 @@ private:
private:
const Graphics::Font *getMenuFont();
+ const char *getAcceleratorString(MenuSubItem *item);
+ int calculateMenuWidth(MenuItem *menu);
+ void calcMenuBounds(MenuItem *menu);
+
Common::Array<MenuItem *> _items;
const Graphics::Font *_font;
Commit: 5a9acaa1624864006bac516e5460322665ad68b8
https://github.com/scummvm/scummvm/commit/5a9acaa1624864006bac516e5460322665ad68b8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-12T19:31:27+01:00
Commit Message:
WAGE: Render submenu rectangle
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
engines/wage/menu.cpp
engines/wage/menu.h
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index abed29b..621da1e 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -442,6 +442,20 @@ void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in) {
tmp.free();
}
+void Design::drawRect(Graphics::Surface *surface, Common::Rect &rect, int thickness, int color, Patterns &patterns, byte fillType) {
+ plotData pd(surface, &patterns, fillType, thickness);
+ int x1 = rect.left;
+ int y1 = rect.top;
+ int x2 = rect.right;
+ int y2 = rect.bottom;
+
+ Graphics::drawLine(x1, y1, x2, y1, kColorBlack, drawPixel, &pd);
+ Graphics::drawLine(x2, y1, x2, y2, kColorBlack, drawPixel, &pd);
+ Graphics::drawLine(x2, y2, x1, y2, kColorBlack, drawPixel, &pd);
+ Graphics::drawLine(x1, y2, x1, y1, kColorBlack, drawPixel, &pd);
+}
+
+
void Design::drawFilledRect(Graphics::Surface *surface, Common::Rect &rect, int color, Patterns &patterns, byte fillType) {
plotData pd(surface, &patterns, fillType, 1);
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 300d6fa..459862e 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -69,9 +69,11 @@ public:
void paint(Graphics::Surface *canvas, Patterns &patterns, int x, int y);
bool isPointOpaque(int x, int y);
+ static void drawRect(Graphics::Surface *surface, Common::Rect &rect, int thickness, int color, Patterns &patterns, byte fillType);
static void drawFilledRect(Graphics::Surface *surface, Common::Rect &rect, int color, Patterns &patterns, byte fillType);
static void drawFilledRoundRect(Graphics::Surface *surface, Common::Rect &rect, int arc, int color, Patterns &patterns, byte fillType);
+
private:
byte *_data;
int _len;
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index c63c39b..09846cf 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -122,6 +122,8 @@ struct MenuData {
};
Menu::Menu(Gui *gui) : _gui(gui) {
+ _patterns.push_back(fillPattern);
+
MenuItem *about = new MenuItem(_gui->_builtInFonts ? "\xa9" : "\xf0"); // (c) Symbol as the most resembling apple
_items.push_back(about);
_items[0]->subitems.push_back(new MenuSubItem(_gui->_engine->_world->getAboutMenuItemName(), kMenuActionAbout));
@@ -205,7 +207,7 @@ int Menu::calculateMenuWidth(MenuItem *menu) {
int maxWidth = 0;
for (int i = 0; i < menu->subitems.size(); i++) {
MenuSubItem *item = menu->subitems[i];
- if (item->text != NULL) {
+ if (item->text.size()) {
Common::String text(item->text);
Common::String acceleratorText(getAcceleratorString(item));
if (acceleratorText.size()) {
@@ -237,22 +239,22 @@ void Menu::calcMenuBounds(MenuItem *menu) {
void Menu::render() {
Common::Rect r(_bbox);
- Patterns p;
- p.push_back(fillPattern);
- Design::drawFilledRoundRect(&_gui->_screen, r, kDesktopArc, kColorWhite, p, 1);
+ Design::drawFilledRoundRect(&_gui->_screen, r, kDesktopArc, kColorWhite, _patterns, 1);
r.top = 7;
- Design::drawFilledRect(&_gui->_screen, r, kColorWhite, p, 1);
+ Design::drawFilledRect(&_gui->_screen, r, kColorWhite, _patterns, 1);
r.top = kMenuHeight - 1;
- Design::drawFilledRect(&_gui->_screen, r, kColorBlack, p, 1);
+ Design::drawFilledRect(&_gui->_screen, r, kColorBlack, _patterns, 1);
for (int i = 0; i < _items.size(); i++) {
int color = kColorBlack;
MenuItem *it = _items[i];
if (_activeItem == i) {
- Design::drawFilledRect(&_gui->_screen, it->bbox, kColorBlack, p, 1);
+ Design::drawFilledRect(&_gui->_screen, it->bbox, kColorBlack, _patterns, 1);
color = kColorWhite;
+
+ renderSubmenu(it);
}
_font->drawString(&_gui->_screen, it->name, it->bbox.left + kMenuLeftMargin, it->bbox.top, it->bbox.width(), color);
@@ -261,6 +263,11 @@ void Menu::render() {
g_system->copyRectToScreen(_gui->_screen.getPixels(), _gui->_screen.pitch, 0, 0, _gui->_screen.w, kMenuHeight);
}
+void Menu::renderSubmenu(MenuItem *menu) {
+ Design::drawFilledRect(&_gui->_screen, menu->subbbox, kColorWhite, _patterns, 1);
+ Design::drawRect(&_gui->_screen, menu->subbbox, 1, kColorBlack, _patterns, 1);
+}
+
bool Menu::mouseClick(int x, int y) {
if (_bbox.contains(x, y)) {
for (int i = 0; i < _items.size(); i++)
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index a6b5db2..bfcb730 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -68,12 +68,14 @@ public:
private:
Gui *_gui;
+ Patterns _patterns;
private:
const Graphics::Font *getMenuFont();
const char *getAcceleratorString(MenuSubItem *item);
int calculateMenuWidth(MenuItem *menu);
void calcMenuBounds(MenuItem *menu);
+ void renderSubmenu(MenuItem *menu);
Common::Array<MenuItem *> _items;
Commit: 91ef3e6dcde78456bec624a82f28119c122aa08b
https://github.com/scummvm/scummvm/commit/91ef3e6dcde78456bec624a82f28119c122aa08b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-12T19:40:27+01:00
Commit Message:
WAGE: Blit submenu to screen
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 09846cf..2ed41bc 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -264,8 +264,12 @@ void Menu::render() {
}
void Menu::renderSubmenu(MenuItem *menu) {
- Design::drawFilledRect(&_gui->_screen, menu->subbbox, kColorWhite, _patterns, 1);
- Design::drawRect(&_gui->_screen, menu->subbbox, 1, kColorBlack, _patterns, 1);
+ Common::Rect *r = &menu->subbbox;
+
+ Design::drawFilledRect(&_gui->_screen, *r, kColorWhite, _patterns, 1);
+ Design::drawRect(&_gui->_screen, *r, 1, kColorBlack, _patterns, 1);
+
+ g_system->copyRectToScreen(_gui->_screen.getBasePtr(r->left, r->top), _gui->_screen.pitch, r->left, r->top, r->width() + 1, r->height() + 1);
}
bool Menu::mouseClick(int x, int y) {
Commit: 506748c82f70e809d5a1cd2270164506ca1fbb06
https://github.com/scummvm/scummvm/commit/506748c82f70e809d5a1cd2270164506ca1fbb06
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-12T19:41:52+01:00
Commit Message:
WAGE: Do not crash on empty submenus
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 2ed41bc..bae8d76 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -266,6 +266,9 @@ void Menu::render() {
void Menu::renderSubmenu(MenuItem *menu) {
Common::Rect *r = &menu->subbbox;
+ if (r->width() == 0 || r->height() == 0)
+ return;
+
Design::drawFilledRect(&_gui->_screen, *r, kColorWhite, _patterns, 1);
Design::drawRect(&_gui->_screen, *r, 1, kColorBlack, _patterns, 1);
Commit: b911c63750f259a158ebe34d327a92b56e1f0f3a
https://github.com/scummvm/scummvm/commit/b911c63750f259a158ebe34d327a92b56e1f0f3a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-12T19:47:47+01:00
Commit Message:
WAGE: Render submenu item texts
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index bae8d76..2b2f2c5 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -272,6 +272,14 @@ void Menu::renderSubmenu(MenuItem *menu) {
Design::drawFilledRect(&_gui->_screen, *r, kColorWhite, _patterns, 1);
Design::drawRect(&_gui->_screen, *r, 1, kColorBlack, _patterns, 1);
+ int x = r->left + kMenuLeftMargin;
+ int y = r->top;
+ for (int i = 0; i < menu->subitems.size(); i++) {
+ _font->drawString(&_gui->_screen, menu->subitems[i]->text, x, y, r->width(), kColorBlack);
+
+ y += kMenuDropdownItemHeight;
+ }
+
g_system->copyRectToScreen(_gui->_screen.getBasePtr(r->left, r->top), _gui->_screen.pitch, r->left, r->top, r->width() + 1, r->height() + 1);
}
Commit: a1e9c825794a47b3c5b1c85be544f819d824d6e0
https://github.com/scummvm/scummvm/commit/a1e9c825794a47b3c5b1c85be544f819d824d6e0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-13T09:51:15+01:00
Commit Message:
WAGE: Fix menu dropdown dimensions
Changed paths:
engines/wage/gui.h
engines/wage/menu.cpp
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 335af86..0b35ac4 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -67,8 +67,8 @@ enum {
kMenuHeight = 20,
kMenuLeftMargin = 7,
kMenuSpacing = 13,
- kMenuPadding = 6,
- kMenuDropdownPadding = 6,
+ kMenuPadding = 16,
+ kMenuDropdownPadding = 12,
kMenuDropdownItemHeight = 19,
kMenuItemHeight = 20,
kBorderWidth = 17,
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 2b2f2c5..bcbb0fd 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -226,10 +226,10 @@ int Menu::calculateMenuWidth(MenuItem *menu) {
void Menu::calcMenuBounds(MenuItem *menu) {
// TODO: cache maxWidth
int maxWidth = calculateMenuWidth(menu);
- int x1 = menu->bbox.left - kMenuDropdownPadding;
+ int x1 = menu->bbox.left;
int y1 = menu->bbox.bottom;
- int x2 = x1 + maxWidth + kMenuDropdownPadding * 3;
- int y2 = y1 + menu->subitems.size() * kMenuDropdownItemHeight;
+ int x2 = x1 + maxWidth + kMenuDropdownPadding * 2;
+ int y2 = y1 + menu->subitems.size() * kMenuDropdownItemHeight - 3;
menu->subbbox.left = x1;
menu->subbbox.top = y1;
@@ -272,7 +272,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
Design::drawFilledRect(&_gui->_screen, *r, kColorWhite, _patterns, 1);
Design::drawRect(&_gui->_screen, *r, 1, kColorBlack, _patterns, 1);
- int x = r->left + kMenuLeftMargin;
+ int x = r->left + kMenuDropdownPadding;
int y = r->top;
for (int i = 0; i < menu->subitems.size(); i++) {
_font->drawString(&_gui->_screen, menu->subitems[i]->text, x, y, r->width(), kColorBlack);
Commit: d0b60fe4b7e9b0768f967bc5541bb6d182edfc86
https://github.com/scummvm/scummvm/commit/d0b60fe4b7e9b0768f967bc5541bb6d182edfc86
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-13T10:41:54+01:00
Commit Message:
WAGE: Fix crash with empty submenus
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index bcbb0fd..e0a64aa 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -254,7 +254,8 @@ void Menu::render() {
Design::drawFilledRect(&_gui->_screen, it->bbox, kColorBlack, _patterns, 1);
color = kColorWhite;
- renderSubmenu(it);
+ if (it->subitems.size())
+ renderSubmenu(it);
}
_font->drawString(&_gui->_screen, it->name, it->bbox.left + kMenuLeftMargin, it->bbox.top, it->bbox.width(), color);
Commit: 02e0498e368b7ebee18dd4415ea47da718b81500
https://github.com/scummvm/scummvm/commit/02e0498e368b7ebee18dd4415ea47da718b81500
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-13T10:42:10+01:00
Commit Message:
WAGE: Copy screen to backbuffer when entering menu
Changed paths:
engines/wage/menu.cpp
engines/wage/menu.h
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index e0a64aa..681fb62 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -179,6 +179,8 @@ Menu::Menu(Gui *gui) : _gui(gui) {
_menuActivated = false;
_activeItem = -1;
_activeSubItem = -1;
+
+ _screenCopy.create(_gui->_screen.w, _gui->_screen.h, Graphics::PixelFormat::createFormatCLUT8());
}
Menu::~Menu() {
@@ -286,6 +288,8 @@ void Menu::renderSubmenu(MenuItem *menu) {
bool Menu::mouseClick(int x, int y) {
if (_bbox.contains(x, y)) {
+ _screenCopy.copyFrom(_gui->_screen);
+
for (int i = 0; i < _items.size(); i++)
if (_items[i]->bbox.contains(x, y)) {
if (_activeItem == i)
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index bfcb730..6f8e14a 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -69,6 +69,7 @@ public:
private:
Gui *_gui;
Patterns _patterns;
+ Graphics::Surface _screenCopy;
private:
const Graphics::Font *getMenuFont();
Commit: a45c66b5a78f9aed00a494ab84ff164791ae7538
https://github.com/scummvm/scummvm/commit/a45c66b5a78f9aed00a494ab84ff164791ae7538
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-13T11:08:41+01:00
Commit Message:
WAGE: Retore background with menu hovering
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 681fb62..7c680d7 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -288,13 +288,21 @@ void Menu::renderSubmenu(MenuItem *menu) {
bool Menu::mouseClick(int x, int y) {
if (_bbox.contains(x, y)) {
- _screenCopy.copyFrom(_gui->_screen);
+ if (!_menuActivated)
+ _screenCopy.copyFrom(_gui->_screen);
for (int i = 0; i < _items.size(); i++)
if (_items[i]->bbox.contains(x, y)) {
if (_activeItem == i)
return false;
+ if (_activeItem != -1) {
+ Common::Rect *r = &_items[_activeItem]->subbbox;
+
+ _gui->_screen.copyRectToSurface(_screenCopy, r->left, r->top, *r);
+ g_system->copyRectToScreen(_gui->_screen.getBasePtr(r->left, r->top), _gui->_screen.pitch, r->left, r->top, r->width() + 1, r->height() + 1);
+ }
+
_activeItem = i;
_activeSubItem = -1;
_menuActivated = true;
Commit: a6cf96853384d1e6aafd8e4ced76eac1fd6026f0
https://github.com/scummvm/scummvm/commit/a6cf96853384d1e6aafd8e4ced76eac1fd6026f0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-13T19:21:42+01:00
Commit Message:
WAGE: Draw drop-down menu shadow
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
engines/wage/menu.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 621da1e..3db9d27 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -661,6 +661,12 @@ void Design::drawEllipse(int x0, int y0, int x1, int y1, bool filled, void (*plo
}
}
+void Design::drawHLine(Graphics::Surface *surface, int x1, int x2, int y, int thickness, int color, Patterns &patterns, byte fillType) {
+ plotData pd(surface, &patterns, fillType, thickness);
+
+ drawHLine(x1, x2, y, color, drawPixel, &pd);
+}
+
void Design::drawHLine(int x1, int x2, int y, int color, void (*plotProc)(int, int, int, void *), void *data) {
if (x1 > x2)
SWAP(x1, x2);
@@ -669,6 +675,12 @@ void Design::drawHLine(int x1, int x2, int y, int color, void (*plotProc)(int, i
(*plotProc)(x, y, color, data);
}
+void Design::drawVLine(Graphics::Surface *surface, int x, int y1, int y2, int thickness, int color, Patterns &patterns, byte fillType) {
+ plotData pd(surface, &patterns, fillType, thickness);
+
+ drawVLine(x, y1, y2, color, drawPixel, &pd);
+}
+
void Design::drawVLine(int x, int y1, int y2, int color, void (*plotProc)(int, int, int, void *), void *data) {
if (y1 > y2)
SWAP(y1, y2);
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 459862e..26f832e 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -72,6 +72,8 @@ public:
static void drawRect(Graphics::Surface *surface, Common::Rect &rect, int thickness, int color, Patterns &patterns, byte fillType);
static void drawFilledRect(Graphics::Surface *surface, Common::Rect &rect, int color, Patterns &patterns, byte fillType);
static void drawFilledRoundRect(Graphics::Surface *surface, Common::Rect &rect, int arc, int color, Patterns &patterns, byte fillType);
+ static void drawHLine(Graphics::Surface *surface, int x1, int x2, int y, int thickness, int color, Patterns &patterns, byte fillType);
+ static void drawVLine(Graphics::Surface *surface, int x, int y1, int y2, int thickness, int color, Patterns &patterns, byte fillType);
private:
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 7c680d7..5dc761b 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -274,6 +274,10 @@ void Menu::renderSubmenu(MenuItem *menu) {
Design::drawFilledRect(&_gui->_screen, *r, kColorWhite, _patterns, 1);
Design::drawRect(&_gui->_screen, *r, 1, kColorBlack, _patterns, 1);
+ Design::drawVLine(&_gui->_screen, r->right + 1, r->top + 2, r->bottom + 2, 1, kColorBlack, _patterns, 1);
+ Design::drawVLine(&_gui->_screen, r->right + 2, r->top + 2, r->bottom + 2, 1, kColorBlack, _patterns, 1);
+ Design::drawHLine(&_gui->_screen, r->left + 3, r->right + 2, r->bottom + 1, 1, kColorBlack, _patterns, 1);
+ Design::drawHLine(&_gui->_screen, r->left + 3, r->right + 2, r->bottom + 2, 1, kColorBlack, _patterns, 1);
int x = r->left + kMenuDropdownPadding;
int y = r->top;
@@ -283,7 +287,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
y += kMenuDropdownItemHeight;
}
- g_system->copyRectToScreen(_gui->_screen.getBasePtr(r->left, r->top), _gui->_screen.pitch, r->left, r->top, r->width() + 1, r->height() + 1);
+ g_system->copyRectToScreen(_gui->_screen.getBasePtr(r->left, r->top), _gui->_screen.pitch, r->left, r->top, r->width() + 3, r->height() + 3);
}
bool Menu::mouseClick(int x, int y) {
@@ -296,11 +300,13 @@ bool Menu::mouseClick(int x, int y) {
if (_activeItem == i)
return false;
- if (_activeItem != -1) {
- Common::Rect *r = &_items[_activeItem]->subbbox;
+ if (_activeItem != -1) { // Restore background
+ Common::Rect r(_items[_activeItem]->subbbox);
+ r.right += 3;
+ r.bottom += 3;
- _gui->_screen.copyRectToSurface(_screenCopy, r->left, r->top, *r);
- g_system->copyRectToScreen(_gui->_screen.getBasePtr(r->left, r->top), _gui->_screen.pitch, r->left, r->top, r->width() + 1, r->height() + 1);
+ _gui->_screen.copyRectToSurface(_screenCopy, r.left, r.top, r);
+ g_system->copyRectToScreen(_gui->_screen.getBasePtr(r.left, r.top), _gui->_screen.pitch, r.left, r.top, r.width() + 1, r.height() + 1);
}
_activeItem = i;
Commit: f9412921f4869080ab85342b30fcfd548f7d53ef
https://github.com/scummvm/scummvm/commit/f9412921f4869080ab85342b30fcfd548f7d53ef
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-13T19:34:27+01:00
Commit Message:
WAGE: Show accelerator keys for submenus
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 5dc761b..a75924f 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -137,7 +137,7 @@ Menu::Menu(Gui *gui) : _gui(gui) {
for (int i = 0; menuSubItems[i].menunum; i++) {
MenuData *m = &menuSubItems[i];
- _items[m->menunum]->subitems.push_back(new MenuSubItem(m->title, m->action, m->shortcut));
+ _items[m->menunum]->subitems.push_back(new MenuSubItem(m->title, m->action, 0, m->shortcut));
}
MenuItem *commands = new MenuItem("Commands");
@@ -200,7 +200,7 @@ const char *Menu::getAcceleratorString(MenuSubItem *item) {
*res = 0;
if (item->shortcut != 0)
- sprintf(res, " \u2318%c", item->shortcut);
+ sprintf(res, " \x11%c", item->shortcut);
return res;
}
@@ -282,7 +282,12 @@ void Menu::renderSubmenu(MenuItem *menu) {
int x = r->left + kMenuDropdownPadding;
int y = r->top;
for (int i = 0; i < menu->subitems.size(); i++) {
- _font->drawString(&_gui->_screen, menu->subitems[i]->text, x, y, r->width(), kColorBlack);
+ Common::String text(menu->subitems[i]->text);
+ Common::String acceleratorText(getAcceleratorString(menu->subitems[i]));
+ if (acceleratorText.size()) {
+ text += acceleratorText;
+ }
+ _font->drawString(&_gui->_screen, text, x, y, r->width(), kColorBlack);
y += kMenuDropdownItemHeight;
}
Commit: 0476f0ea36709562574b7dd2411d1b0921ec2920
https://github.com/scummvm/scummvm/commit/0476f0ea36709562574b7dd2411d1b0921ec2920
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-13T19:54:01+01:00
Commit Message:
WAGE: Highlight submenu items
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index a75924f..a906c9c 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -287,7 +287,15 @@ void Menu::renderSubmenu(MenuItem *menu) {
if (acceleratorText.size()) {
text += acceleratorText;
}
- _font->drawString(&_gui->_screen, text, x, y, r->width(), kColorBlack);
+
+ int color = kColorBlack;
+ if (i == _activeSubItem) {
+ color = kColorWhite;
+ Common::Rect trect(r->left, y, r->right, y + kMenuDropdownItemHeight);
+
+ Design::drawFilledRect(&_gui->_screen, trect, kColorBlack, _patterns, 1);
+ }
+ _font->drawString(&_gui->_screen, text, x, y, r->width(), color);
y += kMenuDropdownItemHeight;
}
@@ -320,6 +328,15 @@ bool Menu::mouseClick(int x, int y) {
return true;
}
+ } else if (_menuActivated && _items[_activeItem]->subbbox.contains(x, y)) {
+ MenuItem *it = _items[_activeItem];
+ int numSubItem = (y - it->subbbox.top) / kMenuDropdownItemHeight;
+
+ if (numSubItem != _activeSubItem) {
+ _activeSubItem = numSubItem;
+
+ renderSubmenu(_items[_activeItem]);
+ }
}
return false;
Commit: 5c2ed06dc6f3b62ab6c8fe17df4e0de175c07429
https://github.com/scummvm/scummvm/commit/5c2ed06dc6f3b62ab6c8fe17df4e0de175c07429
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-13T19:56:35+01:00
Commit Message:
WAGE: Do not highlight separators
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index a906c9c..d13c6f9 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -289,7 +289,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
}
int color = kColorBlack;
- if (i == _activeSubItem) {
+ if (i == _activeSubItem && menu->subitems[_activeSubItem]->text.size()) {
color = kColorWhite;
Common::Rect trect(r->left, y, r->right, y + kMenuDropdownItemHeight);
Commit: 1c3a4e3dbb6659e46292db6507e249723c701b68
https://github.com/scummvm/scummvm/commit/1c3a4e3dbb6659e46292db6507e249723c701b68
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-13T21:40:27+01:00
Commit Message:
WAGE: Adjustments to precise menu rendering
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index d13c6f9..db6a365 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -153,7 +153,7 @@ Menu::Menu(Gui *gui) : _gui(gui) {
// Calculate menu dimensions
_font = getMenuFont();
- int y = _gui->_builtInFonts ? 3 : 2;
+ int y = _gui->_builtInFonts ? 3 : 1;
int x = 18;
for (int i = 0; i < _items.size(); i++) {
@@ -163,7 +163,7 @@ Menu::Menu(Gui *gui) : _gui(gui) {
_items[i]->bbox.left = x - kMenuLeftMargin;
_items[i]->bbox.top = y;
_items[i]->bbox.right = x + w + kMenuSpacing - kMenuLeftMargin;
- _items[i]->bbox.bottom = y + _font->getFontHeight();
+ _items[i]->bbox.bottom = y + _font->getFontHeight() + 2;
}
calcMenuBounds(_items[i]);
@@ -229,7 +229,7 @@ void Menu::calcMenuBounds(MenuItem *menu) {
// TODO: cache maxWidth
int maxWidth = calculateMenuWidth(menu);
int x1 = menu->bbox.left;
- int y1 = menu->bbox.bottom;
+ int y1 = menu->bbox.bottom + 1;
int x2 = x1 + maxWidth + kMenuDropdownPadding * 2;
int y2 = y1 + menu->subitems.size() * kMenuDropdownItemHeight - 3;
@@ -260,7 +260,7 @@ void Menu::render() {
renderSubmenu(it);
}
- _font->drawString(&_gui->_screen, it->name, it->bbox.left + kMenuLeftMargin, it->bbox.top, it->bbox.width(), color);
+ _font->drawString(&_gui->_screen, it->name, it->bbox.left + kMenuLeftMargin, it->bbox.top + 1, it->bbox.width(), color);
}
g_system->copyRectToScreen(_gui->_screen.getPixels(), _gui->_screen.pitch, 0, 0, _gui->_screen.w, kMenuHeight);
@@ -274,13 +274,13 @@ void Menu::renderSubmenu(MenuItem *menu) {
Design::drawFilledRect(&_gui->_screen, *r, kColorWhite, _patterns, 1);
Design::drawRect(&_gui->_screen, *r, 1, kColorBlack, _patterns, 1);
- Design::drawVLine(&_gui->_screen, r->right + 1, r->top + 2, r->bottom + 2, 1, kColorBlack, _patterns, 1);
- Design::drawVLine(&_gui->_screen, r->right + 2, r->top + 2, r->bottom + 2, 1, kColorBlack, _patterns, 1);
- Design::drawHLine(&_gui->_screen, r->left + 3, r->right + 2, r->bottom + 1, 1, kColorBlack, _patterns, 1);
- Design::drawHLine(&_gui->_screen, r->left + 3, r->right + 2, r->bottom + 2, 1, kColorBlack, _patterns, 1);
+ Design::drawVLine(&_gui->_screen, r->right + 1, r->top + 3, r->bottom + 1, 1, kColorBlack, _patterns, 1);
+ //Design::drawVLine(&_gui->_screen, r->right + 2, r->top + 2, r->bottom + 2, 1, kColorBlack, _patterns, 1);
+ Design::drawHLine(&_gui->_screen, r->left + 3, r->right + 1, r->bottom + 1, 1, kColorBlack, _patterns, 1);
+ //Design::drawHLine(&_gui->_screen, r->left + 3, r->right + 2, r->bottom + 2, 1, kColorBlack, _patterns, 1);
int x = r->left + kMenuDropdownPadding;
- int y = r->top;
+ int y = r->top + 1;
for (int i = 0; i < menu->subitems.size(); i++) {
Common::String text(menu->subitems[i]->text);
Common::String acceleratorText(getAcceleratorString(menu->subitems[i]));
@@ -291,7 +291,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
int color = kColorBlack;
if (i == _activeSubItem && menu->subitems[_activeSubItem]->text.size()) {
color = kColorWhite;
- Common::Rect trect(r->left, y, r->right, y + kMenuDropdownItemHeight);
+ Common::Rect trect(r->left, y, r->right, y + _font->getFontHeight());
Design::drawFilledRect(&_gui->_screen, trect, kColorBlack, _patterns, 1);
}
Commit: ab1fdb518f73d5d56125ec8cfb70b465ba513a6d
https://github.com/scummvm/scummvm/commit/ab1fdb518f73d5d56125ec8cfb70b465ba513a6d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-13T21:52:53+01:00
Commit Message:
WAGE: Menu fixes for fallback fonts
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index db6a365..959d50f 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -153,7 +153,7 @@ Menu::Menu(Gui *gui) : _gui(gui) {
// Calculate menu dimensions
_font = getMenuFont();
- int y = _gui->_builtInFonts ? 3 : 1;
+ int y = 1;
int x = 18;
for (int i = 0; i < _items.size(); i++) {
@@ -163,7 +163,7 @@ Menu::Menu(Gui *gui) : _gui(gui) {
_items[i]->bbox.left = x - kMenuLeftMargin;
_items[i]->bbox.top = y;
_items[i]->bbox.right = x + w + kMenuSpacing - kMenuLeftMargin;
- _items[i]->bbox.bottom = y + _font->getFontHeight() + 2;
+ _items[i]->bbox.bottom = y + _font->getFontHeight() + (_gui->_builtInFonts ? 3 : 2);
}
calcMenuBounds(_items[i]);
@@ -260,7 +260,7 @@ void Menu::render() {
renderSubmenu(it);
}
- _font->drawString(&_gui->_screen, it->name, it->bbox.left + kMenuLeftMargin, it->bbox.top + 1, it->bbox.width(), color);
+ _font->drawString(&_gui->_screen, it->name, it->bbox.left + kMenuLeftMargin, it->bbox.top + (_gui->_builtInFonts ? 2 : 1), it->bbox.width(), color);
}
g_system->copyRectToScreen(_gui->_screen.getPixels(), _gui->_screen.pitch, 0, 0, _gui->_screen.w, kMenuHeight);
@@ -291,7 +291,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
int color = kColorBlack;
if (i == _activeSubItem && menu->subitems[_activeSubItem]->text.size()) {
color = kColorWhite;
- Common::Rect trect(r->left, y, r->right, y + _font->getFontHeight());
+ Common::Rect trect(r->left, y - (_gui->_builtInFonts ? 1 : 0), r->right, y + _font->getFontHeight());
Design::drawFilledRect(&_gui->_screen, trect, kColorBlack, _patterns, 1);
}
Commit: 00fce85c7427be7c59b24539abcc00372ea492e4
https://github.com/scummvm/scummvm/commit/00fce85c7427be7c59b24539abcc00372ea492e4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-13T21:56:27+01:00
Commit Message:
WAGE: Show Ctrl synbol for built-in fonts
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 959d50f..8d9518b 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -200,7 +200,7 @@ const char *Menu::getAcceleratorString(MenuSubItem *item) {
*res = 0;
if (item->shortcut != 0)
- sprintf(res, " \x11%c", item->shortcut);
+ sprintf(res, " %c%c", (_gui->_builtInFonts ? '^' : '\x11'), item->shortcut);
return res;
}
Commit: b0387a4a767f48865fc8139837a44ce247e8ea66
https://github.com/scummvm/scummvm/commit/b0387a4a767f48865fc8139837a44ce247e8ea66
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-13T22:10:55+01:00
Commit Message:
WAGE: Render submenu delimeter
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 8d9518b..bd384c8 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -275,9 +275,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
Design::drawFilledRect(&_gui->_screen, *r, kColorWhite, _patterns, 1);
Design::drawRect(&_gui->_screen, *r, 1, kColorBlack, _patterns, 1);
Design::drawVLine(&_gui->_screen, r->right + 1, r->top + 3, r->bottom + 1, 1, kColorBlack, _patterns, 1);
- //Design::drawVLine(&_gui->_screen, r->right + 2, r->top + 2, r->bottom + 2, 1, kColorBlack, _patterns, 1);
Design::drawHLine(&_gui->_screen, r->left + 3, r->right + 1, r->bottom + 1, 1, kColorBlack, _patterns, 1);
- //Design::drawHLine(&_gui->_screen, r->left + 3, r->right + 2, r->bottom + 2, 1, kColorBlack, _patterns, 1);
int x = r->left + kMenuDropdownPadding;
int y = r->top + 1;
@@ -289,13 +287,16 @@ void Menu::renderSubmenu(MenuItem *menu) {
}
int color = kColorBlack;
- if (i == _activeSubItem && menu->subitems[_activeSubItem]->text.size()) {
+ if (i == _activeSubItem && text.size()) {
color = kColorWhite;
Common::Rect trect(r->left, y - (_gui->_builtInFonts ? 1 : 0), r->right, y + _font->getFontHeight());
Design::drawFilledRect(&_gui->_screen, trect, kColorBlack, _patterns, 1);
}
- _font->drawString(&_gui->_screen, text, x, y, r->width(), color);
+ if (text.size())
+ _font->drawString(&_gui->_screen, text, x, y, r->width(), color);
+ else
+ Design::drawHLine(&_gui->_screen, r->left, r->right, y + kMenuDropdownItemHeight / 2, 1, kColorBlack, _patterns, 1);
y += kMenuDropdownItemHeight;
}
Commit: b34308a03c6771f46fb6a0b119024e65949a65d4
https://github.com/scummvm/scummvm/commit/b34308a03c6771f46fb6a0b119024e65949a65d4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-13T22:11:31+01:00
Commit Message:
WAGE: Fix vertical submenu size
Changed paths:
engines/wage/gui.h
engines/wage/menu.cpp
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 0b35ac4..4017702 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -69,7 +69,7 @@ enum {
kMenuSpacing = 13,
kMenuPadding = 16,
kMenuDropdownPadding = 12,
- kMenuDropdownItemHeight = 19,
+ kMenuDropdownItemHeight = 15,
kMenuItemHeight = 20,
kBorderWidth = 17,
kDesktopArc = 7,
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index bd384c8..e9557a5 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -231,7 +231,7 @@ void Menu::calcMenuBounds(MenuItem *menu) {
int x1 = menu->bbox.left;
int y1 = menu->bbox.bottom + 1;
int x2 = x1 + maxWidth + kMenuDropdownPadding * 2;
- int y2 = y1 + menu->subitems.size() * kMenuDropdownItemHeight - 3;
+ int y2 = y1 + menu->subitems.size() * kMenuDropdownItemHeight + 2;
menu->subbbox.left = x1;
menu->subbbox.top = y1;
Commit: d7bbe3a6c51d2876b95ffcdcf17ac397ab005c51
https://github.com/scummvm/scummvm/commit/d7bbe3a6c51d2876b95ffcdcf17ac397ab005c51
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-13T22:13:56+01:00
Commit Message:
WAGE: Fix submenu delimiter rendering
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index e9557a5..9a2101c 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -79,6 +79,7 @@ struct MenuItem {
};
static byte fillPattern[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+static byte fillPatternStripes[8] = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa };
enum {
kMenuActionAbout,
@@ -123,6 +124,7 @@ struct MenuData {
Menu::Menu(Gui *gui) : _gui(gui) {
_patterns.push_back(fillPattern);
+ _patterns.push_back(fillPatternStripes);
MenuItem *about = new MenuItem(_gui->_builtInFonts ? "\xa9" : "\xf0"); // (c) Symbol as the most resembling apple
_items.push_back(about);
@@ -296,7 +298,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
if (text.size())
_font->drawString(&_gui->_screen, text, x, y, r->width(), color);
else
- Design::drawHLine(&_gui->_screen, r->left, r->right, y + kMenuDropdownItemHeight / 2, 1, kColorBlack, _patterns, 1);
+ Design::drawHLine(&_gui->_screen, r->left, r->right, y + kMenuDropdownItemHeight / 2, 1, kColorBlack, _patterns, 2);
y += kMenuDropdownItemHeight;
}
Commit: c196d5fa7e4e1254510937fd8b8b58b14be396a7
https://github.com/scummvm/scummvm/commit/c196d5fa7e4e1254510937fd8b8b58b14be396a7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-13T22:18:13+01:00
Commit Message:
WAGE: Use named constants for patterns
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 9a2101c..61c4788 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -82,6 +82,11 @@ static byte fillPattern[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
static byte fillPatternStripes[8] = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa };
enum {
+ kPatternSolid = 1,
+ kPaternStripes = 2
+};
+
+enum {
kMenuActionAbout,
kMenuActionNew,
kMenuActionOpen,
@@ -244,18 +249,18 @@ void Menu::calcMenuBounds(MenuItem *menu) {
void Menu::render() {
Common::Rect r(_bbox);
- Design::drawFilledRoundRect(&_gui->_screen, r, kDesktopArc, kColorWhite, _patterns, 1);
+ Design::drawFilledRoundRect(&_gui->_screen, r, kDesktopArc, kColorWhite, _patterns, kPatternSolid);
r.top = 7;
- Design::drawFilledRect(&_gui->_screen, r, kColorWhite, _patterns, 1);
+ Design::drawFilledRect(&_gui->_screen, r, kColorWhite, _patterns, kPatternSolid);
r.top = kMenuHeight - 1;
- Design::drawFilledRect(&_gui->_screen, r, kColorBlack, _patterns, 1);
+ Design::drawFilledRect(&_gui->_screen, r, kColorBlack, _patterns, kPatternSolid);
for (int i = 0; i < _items.size(); i++) {
int color = kColorBlack;
MenuItem *it = _items[i];
if (_activeItem == i) {
- Design::drawFilledRect(&_gui->_screen, it->bbox, kColorBlack, _patterns, 1);
+ Design::drawFilledRect(&_gui->_screen, it->bbox, kColorBlack, _patterns, kPatternSolid);
color = kColorWhite;
if (it->subitems.size())
@@ -274,10 +279,10 @@ void Menu::renderSubmenu(MenuItem *menu) {
if (r->width() == 0 || r->height() == 0)
return;
- Design::drawFilledRect(&_gui->_screen, *r, kColorWhite, _patterns, 1);
- Design::drawRect(&_gui->_screen, *r, 1, kColorBlack, _patterns, 1);
- Design::drawVLine(&_gui->_screen, r->right + 1, r->top + 3, r->bottom + 1, 1, kColorBlack, _patterns, 1);
- Design::drawHLine(&_gui->_screen, r->left + 3, r->right + 1, r->bottom + 1, 1, kColorBlack, _patterns, 1);
+ Design::drawFilledRect(&_gui->_screen, *r, kColorWhite, _patterns, kPatternSolid);
+ Design::drawRect(&_gui->_screen, *r, 1, kColorBlack, _patterns, kPatternSolid);
+ Design::drawVLine(&_gui->_screen, r->right + 1, r->top + 3, r->bottom + 1, 1, kColorBlack, _patterns, kPatternSolid);
+ Design::drawHLine(&_gui->_screen, r->left + 3, r->right + 1, r->bottom + 1, 1, kColorBlack, _patterns, kPatternSolid);
int x = r->left + kMenuDropdownPadding;
int y = r->top + 1;
@@ -293,12 +298,12 @@ void Menu::renderSubmenu(MenuItem *menu) {
color = kColorWhite;
Common::Rect trect(r->left, y - (_gui->_builtInFonts ? 1 : 0), r->right, y + _font->getFontHeight());
- Design::drawFilledRect(&_gui->_screen, trect, kColorBlack, _patterns, 1);
+ Design::drawFilledRect(&_gui->_screen, trect, kColorBlack, _patterns, kPatternSolid);
}
if (text.size())
_font->drawString(&_gui->_screen, text, x, y, r->width(), color);
else
- Design::drawHLine(&_gui->_screen, r->left, r->right, y + kMenuDropdownItemHeight / 2, 1, kColorBlack, _patterns, 2);
+ Design::drawHLine(&_gui->_screen, r->left, r->right, y + kMenuDropdownItemHeight / 2, 1, kColorBlack, _patterns, kPaternStripes);
y += kMenuDropdownItemHeight;
}
Commit: 0299f5c5800371b2ea5291ec9c3ee084ab1cb0c8
https://github.com/scummvm/scummvm/commit/0299f5c5800371b2ea5291ec9c3ee084ab1cb0c8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-13T22:29:54+01:00
Commit Message:
WAGE: Support for disabled submenu items
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 61c4788..aa59e51 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -108,23 +108,24 @@ struct MenuData {
const char *title;
int action;
byte shortcut;
+ bool enabled;
} menuSubItems[] = {
- { 1, "New", kMenuActionNew, 0 },
- { 1, "Open...", kMenuActionOpen, 0 },
- { 1, "Close", kMenuActionClose, 0 },
- { 1, "Save", kMenuActionSave, 0 },
- { 1, "Save as...", kMenuActionSaveAs, 0 },
- { 1, "Revert", kMenuActionRevert, 0 },
- { 1, "Quit", kMenuActionQuit, 0 },
-
- { 2, "Undo", kMenuActionUndo, 'Z' },
- { 2, NULL, 0, 0 },
- { 2, "Cut", kMenuActionCut, 'K' },
- { 2, "Copy", kMenuActionCopy, 'C' },
- { 2, "Paste", kMenuActionPaste, 'V' },
- { 2, "Clear", kMenuActionClear, 'B' },
-
- { 0, NULL, 0, 0 }
+ { 1, "New", kMenuActionNew, 0, false },
+ { 1, "Open...", kMenuActionOpen, 0, false },
+ { 1, "Close", kMenuActionClose, 0, true },
+ { 1, "Save", kMenuActionSave, 0, true },
+ { 1, "Save as...", kMenuActionSaveAs, 0, true },
+ { 1, "Revert", kMenuActionRevert, 0, true },
+ { 1, "Quit", kMenuActionQuit, 0, true },
+
+ { 2, "Undo", kMenuActionUndo, 'Z', false },
+ { 2, NULL, 0, 0, false },
+ { 2, "Cut", kMenuActionCut, 'K', false },
+ { 2, "Copy", kMenuActionCopy, 'C', false },
+ { 2, "Paste", kMenuActionPaste, 'V', false },
+ { 2, "Clear", kMenuActionClear, 'B', false },
+
+ { 0, NULL, 0, 0, false }
};
Menu::Menu(Gui *gui) : _gui(gui) {
@@ -144,7 +145,7 @@ Menu::Menu(Gui *gui) : _gui(gui) {
for (int i = 0; menuSubItems[i].menunum; i++) {
MenuData *m = &menuSubItems[i];
- _items[m->menunum]->subitems.push_back(new MenuSubItem(m->title, m->action, 0, m->shortcut));
+ _items[m->menunum]->subitems.push_back(new MenuSubItem(m->title, m->action, 0, m->shortcut, m->enabled));
}
MenuItem *commands = new MenuItem("Commands");
@@ -294,7 +295,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
}
int color = kColorBlack;
- if (i == _activeSubItem && text.size()) {
+ if (i == _activeSubItem && text.size() && menu->subitems[i]->enabled) {
color = kColorWhite;
Common::Rect trect(r->left, y - (_gui->_builtInFonts ? 1 : 0), r->right, y + _font->getFontHeight());
Commit: 3646555a666b28d793e653e95c9109d1111fc77c
https://github.com/scummvm/scummvm/commit/3646555a666b28d793e653e95c9109d1111fc77c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-13T22:52:56+01:00
Commit Message:
WAGE: Implement rendering disabled submenu items
Changed paths:
engines/wage/menu.cpp
engines/wage/menu.h
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index aa59e51..3685e30 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -80,10 +80,12 @@ struct MenuItem {
static byte fillPattern[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
static byte fillPatternStripes[8] = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa };
+static byte fillPatternCheckers[8] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa };
enum {
kPatternSolid = 1,
- kPaternStripes = 2
+ kPatternStripes = 2,
+ kPatternCheckers = 3
};
enum {
@@ -131,6 +133,7 @@ struct MenuData {
Menu::Menu(Gui *gui) : _gui(gui) {
_patterns.push_back(fillPattern);
_patterns.push_back(fillPatternStripes);
+ _patterns.push_back(fillPatternCheckers);
MenuItem *about = new MenuItem(_gui->_builtInFonts ? "\xa9" : "\xf0"); // (c) Symbol as the most resembling apple
_items.push_back(about);
@@ -189,6 +192,7 @@ Menu::Menu(Gui *gui) : _gui(gui) {
_activeSubItem = -1;
_screenCopy.create(_gui->_screen.w, _gui->_screen.h, Graphics::PixelFormat::createFormatCLUT8());
+ _tempSurface.create(_gui->_screen.w, _font->getFontHeight(), Graphics::PixelFormat::createFormatCLUT8());
}
Menu::~Menu() {
@@ -301,10 +305,30 @@ void Menu::renderSubmenu(MenuItem *menu) {
Design::drawFilledRect(&_gui->_screen, trect, kColorBlack, _patterns, kPatternSolid);
}
- if (text.size())
- _font->drawString(&_gui->_screen, text, x, y, r->width(), color);
- else
- Design::drawHLine(&_gui->_screen, r->left, r->right, y + kMenuDropdownItemHeight / 2, 1, kColorBlack, _patterns, kPaternStripes);
+ if (text.size()) {
+ if (menu->subitems[i]->enabled) {
+ _font->drawString(&_gui->_screen, text, x, y, r->width(), color);
+ } else {
+ // I am lazy to extend drawString() with plotProc as a parameter, so
+ // fake it here
+ _tempSurface.fillRect(Common::Rect(0, 0, _tempSurface.w, _tempSurface.h), kColorGreen);
+ _font->drawString(&_tempSurface, text, 0, 0, r->width(), kColorBlack);
+
+ for (int ii = 0; ii < _tempSurface.h; ii++) {
+ const byte *src = (const byte *)_tempSurface.getBasePtr(0, ii);
+ byte *dst = (byte *)_gui->_screen.getBasePtr(x, y+ii);
+ byte pat = _patterns[kPatternCheckers - 1][(y + ii) % 8];
+ for (int j = 0; j < r->width(); j++) {
+ if (*src != kColorGreen && (pat & (1 << (7 - (x + j) % 8))))
+ *dst = *src;
+ src++;
+ dst++;
+ }
+ }
+ }
+ } else { // Delimiter
+ Design::drawHLine(&_gui->_screen, r->left, r->right, y + kMenuDropdownItemHeight / 2, 1, kColorBlack, _patterns, kPatternStripes);
+ }
y += kMenuDropdownItemHeight;
}
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index 6f8e14a..737e9ea 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -70,6 +70,7 @@ private:
Gui *_gui;
Patterns _patterns;
Graphics::Surface _screenCopy;
+ Graphics::Surface _tempSurface;
private:
const Graphics::Font *getMenuFont();
Commit: 4c8b9bb52cfba6b1a723f12ec19463c4cf6282be
https://github.com/scummvm/scummvm/commit/4c8b9bb52cfba6b1a723f12ec19463c4cf6282be
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-13T23:00:30+01:00
Commit Message:
WAGE: Moved global patterns to Gui class
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/menu.cpp
engines/wage/menu.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 09468f5..8731b4b 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -67,7 +67,9 @@ static const byte palette[] = {
0x00, 0xff, 0x00 // Green
};
-static byte checkersPattern[8] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa };
+static byte fillPattern[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+static byte fillPatternStripes[8] = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa };
+static byte fillPatternCheckers[8] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa };
static const byte macCursorArrow[] = {
2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3,
@@ -158,6 +160,10 @@ Gui::Gui(WageEngine *engine) {
_cursorIsArrow = true;
CursorMan.showMouse(true);
+ _patterns.push_back(fillPattern);
+ _patterns.push_back(fillPatternStripes);
+ _patterns.push_back(fillPatternCheckers);
+
loadFonts();
g_system->getTimerManager()->installTimerProc(&cursor_timer_handler, 200000, this, "wageCursor");
@@ -240,10 +246,8 @@ void Gui::draw() {
_scene = _engine->_world->_player->_currentScene;
// Draw desktop
- Patterns p;
- p.push_back(checkersPattern);
Common::Rect r(0, 0, _screen.w - 1, _screen.h - 1);
- Design::drawFilledRoundRect(&_screen, r, kDesktopArc, kColorBlack, p, 1);
+ Design::drawFilledRoundRect(&_screen, r, kDesktopArc, kColorBlack, _patterns, kPatternCheckers);
g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, _screen.h);
_sceneDirty = true;
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 4017702..c1af13d 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -77,6 +77,12 @@ enum {
kCursorHeight = 12
};
+enum {
+ kPatternSolid = 1,
+ kPatternStripes = 2,
+ kPatternCheckers = 3
+};
+
class Gui {
public:
Gui(WageEngine *engine);
@@ -112,6 +118,8 @@ public:
bool _builtInFonts;
WageEngine *_engine;
+ Patterns _patterns;
+
private:
Graphics::Surface _console;
Menu *_menu;
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 3685e30..b9e59fb 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -78,16 +78,6 @@ struct MenuItem {
MenuItem(const char *n) : name(n) {}
};
-static byte fillPattern[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
-static byte fillPatternStripes[8] = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa };
-static byte fillPatternCheckers[8] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa };
-
-enum {
- kPatternSolid = 1,
- kPatternStripes = 2,
- kPatternCheckers = 3
-};
-
enum {
kMenuActionAbout,
kMenuActionNew,
@@ -131,10 +121,6 @@ struct MenuData {
};
Menu::Menu(Gui *gui) : _gui(gui) {
- _patterns.push_back(fillPattern);
- _patterns.push_back(fillPatternStripes);
- _patterns.push_back(fillPatternCheckers);
-
MenuItem *about = new MenuItem(_gui->_builtInFonts ? "\xa9" : "\xf0"); // (c) Symbol as the most resembling apple
_items.push_back(about);
_items[0]->subitems.push_back(new MenuSubItem(_gui->_engine->_world->getAboutMenuItemName(), kMenuActionAbout));
@@ -254,18 +240,18 @@ void Menu::calcMenuBounds(MenuItem *menu) {
void Menu::render() {
Common::Rect r(_bbox);
- Design::drawFilledRoundRect(&_gui->_screen, r, kDesktopArc, kColorWhite, _patterns, kPatternSolid);
+ Design::drawFilledRoundRect(&_gui->_screen, r, kDesktopArc, kColorWhite, _gui->_patterns, kPatternSolid);
r.top = 7;
- Design::drawFilledRect(&_gui->_screen, r, kColorWhite, _patterns, kPatternSolid);
+ Design::drawFilledRect(&_gui->_screen, r, kColorWhite, _gui->_patterns, kPatternSolid);
r.top = kMenuHeight - 1;
- Design::drawFilledRect(&_gui->_screen, r, kColorBlack, _patterns, kPatternSolid);
+ Design::drawFilledRect(&_gui->_screen, r, kColorBlack, _gui->_patterns, kPatternSolid);
for (int i = 0; i < _items.size(); i++) {
int color = kColorBlack;
MenuItem *it = _items[i];
if (_activeItem == i) {
- Design::drawFilledRect(&_gui->_screen, it->bbox, kColorBlack, _patterns, kPatternSolid);
+ Design::drawFilledRect(&_gui->_screen, it->bbox, kColorBlack, _gui->_patterns, kPatternSolid);
color = kColorWhite;
if (it->subitems.size())
@@ -284,10 +270,10 @@ void Menu::renderSubmenu(MenuItem *menu) {
if (r->width() == 0 || r->height() == 0)
return;
- Design::drawFilledRect(&_gui->_screen, *r, kColorWhite, _patterns, kPatternSolid);
- Design::drawRect(&_gui->_screen, *r, 1, kColorBlack, _patterns, kPatternSolid);
- Design::drawVLine(&_gui->_screen, r->right + 1, r->top + 3, r->bottom + 1, 1, kColorBlack, _patterns, kPatternSolid);
- Design::drawHLine(&_gui->_screen, r->left + 3, r->right + 1, r->bottom + 1, 1, kColorBlack, _patterns, kPatternSolid);
+ Design::drawFilledRect(&_gui->_screen, *r, kColorWhite, _gui->_patterns, kPatternSolid);
+ Design::drawRect(&_gui->_screen, *r, 1, kColorBlack, _gui->_patterns, kPatternSolid);
+ Design::drawVLine(&_gui->_screen, r->right + 1, r->top + 3, r->bottom + 1, 1, kColorBlack, _gui->_patterns, kPatternSolid);
+ Design::drawHLine(&_gui->_screen, r->left + 3, r->right + 1, r->bottom + 1, 1, kColorBlack, _gui->_patterns, kPatternSolid);
int x = r->left + kMenuDropdownPadding;
int y = r->top + 1;
@@ -303,7 +289,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
color = kColorWhite;
Common::Rect trect(r->left, y - (_gui->_builtInFonts ? 1 : 0), r->right, y + _font->getFontHeight());
- Design::drawFilledRect(&_gui->_screen, trect, kColorBlack, _patterns, kPatternSolid);
+ Design::drawFilledRect(&_gui->_screen, trect, kColorBlack, _gui->_patterns, kPatternSolid);
}
if (text.size()) {
if (menu->subitems[i]->enabled) {
@@ -317,7 +303,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
for (int ii = 0; ii < _tempSurface.h; ii++) {
const byte *src = (const byte *)_tempSurface.getBasePtr(0, ii);
byte *dst = (byte *)_gui->_screen.getBasePtr(x, y+ii);
- byte pat = _patterns[kPatternCheckers - 1][(y + ii) % 8];
+ byte pat = _gui->_patterns[kPatternCheckers - 1][(y + ii) % 8];
for (int j = 0; j < r->width(); j++) {
if (*src != kColorGreen && (pat & (1 << (7 - (x + j) % 8))))
*dst = *src;
@@ -327,7 +313,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
}
}
} else { // Delimiter
- Design::drawHLine(&_gui->_screen, r->left, r->right, y + kMenuDropdownItemHeight / 2, 1, kColorBlack, _patterns, kPatternStripes);
+ Design::drawHLine(&_gui->_screen, r->left, r->right, y + kMenuDropdownItemHeight / 2, 1, kColorBlack, _gui->_patterns, kPatternStripes);
}
y += kMenuDropdownItemHeight;
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index 737e9ea..58195dd 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -68,7 +68,6 @@ public:
private:
Gui *_gui;
- Patterns _patterns;
Graphics::Surface _screenCopy;
Graphics::Surface _tempSurface;
Commit: 7c04b4ddf7b464fa89a7e17279a995da15c3a5bf
https://github.com/scummvm/scummvm/commit/7c04b4ddf7b464fa89a7e17279a995da15c3a5bf
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-13T23:33:52+01:00
Commit Message:
WAGE: Proper rendering of accelerators
Changed paths:
engines/wage/gui.cpp
engines/wage/menu.cpp
engines/wage/menu.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 8731b4b..21ff005 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -69,7 +69,7 @@ static const byte palette[] = {
static byte fillPattern[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
static byte fillPatternStripes[8] = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa };
-static byte fillPatternCheckers[8] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa };
+static byte fillPatternCheckers[8] = { 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55 };
static const byte macCursorArrow[] = {
2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3,
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index b9e59fb..094eea1 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -193,12 +193,12 @@ const Graphics::Font *Menu::getMenuFont() {
return _gui->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
}
-const char *Menu::getAcceleratorString(MenuSubItem *item) {
+const char *Menu::getAcceleratorString(MenuSubItem *item, const char *prefix) {
static char res[20];
*res = 0;
if (item->shortcut != 0)
- sprintf(res, " %c%c", (_gui->_builtInFonts ? '^' : '\x11'), item->shortcut);
+ sprintf(res, "%s%c%c", prefix, (_gui->_builtInFonts ? '^' : '\x11'), item->shortcut);
return res;
}
@@ -209,7 +209,7 @@ int Menu::calculateMenuWidth(MenuItem *menu) {
MenuSubItem *item = menu->subitems[i];
if (item->text.size()) {
Common::String text(item->text);
- Common::String acceleratorText(getAcceleratorString(item));
+ Common::String acceleratorText(getAcceleratorString(item, " "));
if (acceleratorText.size()) {
text += acceleratorText;
}
@@ -279,10 +279,8 @@ void Menu::renderSubmenu(MenuItem *menu) {
int y = r->top + 1;
for (int i = 0; i < menu->subitems.size(); i++) {
Common::String text(menu->subitems[i]->text);
- Common::String acceleratorText(getAcceleratorString(menu->subitems[i]));
- if (acceleratorText.size()) {
- text += acceleratorText;
- }
+ Common::String acceleratorText(getAcceleratorString(menu->subitems[i], ""));
+ int accelX = r->right - 25;
int color = kColorBlack;
if (i == _activeSubItem && text.size() && menu->subitems[i]->enabled) {
@@ -291,19 +289,32 @@ void Menu::renderSubmenu(MenuItem *menu) {
Design::drawFilledRect(&_gui->_screen, trect, kColorBlack, _gui->_patterns, kPatternSolid);
}
+
if (text.size()) {
- if (menu->subitems[i]->enabled) {
- _font->drawString(&_gui->_screen, text, x, y, r->width(), color);
- } else {
- // I am lazy to extend drawString() with plotProc as a parameter, so
- // fake it here
+ Graphics::Surface *s = &_gui->_screen;
+ int tx = x, ty = y;
+
+ if (!menu->subitems[i]->enabled) {
+ s = &_tempSurface;
+ tx = 0;
+ ty = 0;
+ accelX -= x;
+
_tempSurface.fillRect(Common::Rect(0, 0, _tempSurface.w, _tempSurface.h), kColorGreen);
- _font->drawString(&_tempSurface, text, 0, 0, r->width(), kColorBlack);
+ }
+
+ _font->drawString(s, text, tx, ty, r->width(), color);
+
+ if (acceleratorText.size())
+ _font->drawString(s, acceleratorText, accelX, ty, r->width(), color);
+ if (!menu->subitems[i]->enabled) {
+ // I am lazy to extend drawString() with plotProc as a parameter, so
+ // fake it here
for (int ii = 0; ii < _tempSurface.h; ii++) {
const byte *src = (const byte *)_tempSurface.getBasePtr(0, ii);
byte *dst = (byte *)_gui->_screen.getBasePtr(x, y+ii);
- byte pat = _gui->_patterns[kPatternCheckers - 1][(y + ii) % 8];
+ byte pat = _gui->_patterns[kPatternCheckers - 1][ii % 8];
for (int j = 0; j < r->width(); j++) {
if (*src != kColorGreen && (pat & (1 << (7 - (x + j) % 8))))
*dst = *src;
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index 58195dd..00b7a3f 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -73,7 +73,7 @@ private:
private:
const Graphics::Font *getMenuFont();
- const char *getAcceleratorString(MenuSubItem *item);
+ const char *getAcceleratorString(MenuSubItem *item, const char *prefix);
int calculateMenuWidth(MenuItem *menu);
void calcMenuBounds(MenuItem *menu);
void renderSubmenu(MenuItem *menu);
Commit: 3dc92233997b86990665fee972487faf5de99bde
https://github.com/scummvm/scummvm/commit/3dc92233997b86990665fee972487faf5de99bde
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-14T08:47:46+01:00
Commit Message:
WAGE: Deactivate submenu on hovering away
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 094eea1..713f3bc 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -367,6 +367,10 @@ bool Menu::mouseClick(int x, int y) {
renderSubmenu(_items[_activeItem]);
}
+ } else if (_menuActivated && _activeItem != -1) {
+ _activeSubItem = -1;
+
+ renderSubmenu(_items[_activeItem]);
}
return false;
Commit: 0c6b063f1ef472a11ddc3714f720ffc4be697739
https://github.com/scummvm/scummvm/commit/0c6b063f1ef472a11ddc3714f720ffc4be697739
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-01-14T13:43:42+01:00
Commit Message:
WAGE: Generate Commands menu
Changed paths:
engines/wage/menu.cpp
engines/wage/menu.h
engines/wage/world.cpp
engines/wage/world.h
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 713f3bc..a8fa2b2 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -92,7 +92,9 @@ enum {
kMenuActionCut,
kMenuActionCopy,
kMenuActionPaste,
- kMenuActionClear
+ kMenuActionClear,
+
+ kMenuActionCommand
};
struct MenuData {
@@ -121,6 +123,9 @@ struct MenuData {
};
Menu::Menu(Gui *gui) : _gui(gui) {
+ assert(_gui->_engine);
+ assert(_gui->_engine->_world);
+
MenuItem *about = new MenuItem(_gui->_builtInFonts ? "\xa9" : "\xf0"); // (c) Symbol as the most resembling apple
_items.push_back(about);
_items[0]->subitems.push_back(new MenuSubItem(_gui->_engine->_world->getAboutMenuItemName(), kMenuActionAbout));
@@ -137,14 +142,11 @@ Menu::Menu(Gui *gui) : _gui(gui) {
_items[m->menunum]->subitems.push_back(new MenuSubItem(m->title, m->action, 0, m->shortcut, m->enabled));
}
- MenuItem *commands = new MenuItem("Commands");
+ MenuItem *commands = createCommandsMenu();
_items.push_back(commands);
- assert(_gui->_engine);
- assert(_gui->_engine->_world);
-
if (!_gui->_engine->_world->_weaponMenuDisabled) {
- MenuItem *weapons = new MenuItem("Weapons");
+ MenuItem *weapons = new MenuItem(_gui->_engine->_world->_weaponsMenuName.c_str());
_items.push_back(weapons);
}
@@ -189,6 +191,75 @@ Menu::~Menu() {
}
}
+MenuItem *Menu::createCommandsMenu() {
+ MenuItem *menu = new MenuItem(_gui->_engine->_world->_commandsMenuName.c_str());
+ Common::String string(_gui->_engine->_world->_commandsMenu);
+
+ Common::String item;
+
+ for (int i = 0; i < string.size(); i++) {
+ while(i < string.size() && string[i] != ';') // Read token
+ item += string[i++];
+
+ if (item == "(-") {
+ menu->subitems.push_back(new MenuSubItem(NULL, 0));
+ } else {
+ bool enabled = true;
+ int style = 0;
+ char shortcut = 0;
+ char *shortptr = strrchr(item.c_str(), '/');
+ if (shortptr != NULL) {
+ if (strlen(shortptr) == 2) {
+ shortcut = shortptr[1];
+ item.deleteLastChar();
+ item.deleteLastChar();
+ } else {
+ error("Unexpected shortcut: '%s', item '%s' in menu '%s'", shortptr, item.c_str(), string.c_str());
+ }
+ }
+
+ while (item.size() >= 2 && item[item.size() - 2] == '<') {
+ char c = item.lastChar();
+ if (c == 'B') {
+ style |= kFontStyleBold;
+ } else if (c == 'I') {
+ style |= kFontStyleItalic;
+ } else if (c == 'U') {
+ style |= kFontStyleUnderline;
+ } else if (c == 'O') {
+ style |= kFontStyleOutline;
+ } else if (c == 'S') {
+ style |= kFontStyleShadow;
+ } else if (c == 'C') {
+ style |= kFontStyleCondensed;
+ } else if (c == 'E') {
+ style |= kFontStyleExtended;
+ }
+ item.deleteLastChar();
+ item.deleteLastChar();
+ }
+
+ Common::String tmpitem(item);
+ tmpitem.trim();
+ if (tmpitem[0] == '(') {
+ enabled = false;
+
+ for (int j = 0; j < item.size(); j++)
+ if (item[j] == '(') {
+ item.deleteChar(j);
+ break;
+ }
+ }
+
+ menu->subitems.push_back(new MenuSubItem(item.c_str(), kMenuActionCommand, style, shortcut, enabled));
+ }
+
+ item = "";
+ }
+
+ return menu;
+}
+
const Graphics::Font *Menu::getMenuFont() {
return _gui->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
}
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index 00b7a3f..67d061d 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -53,6 +53,16 @@ namespace Wage {
struct MenuItem;
struct MenuSubItem;
+enum {
+ kFontStyleBold = 1,
+ kFontStyleItalic = 2,
+ kFontStyleUnderline = 4,
+ kFontStyleOutline = 8,
+ kFontStyleShadow = 16,
+ kFontStyleCondensed = 32,
+ kFontStyleExtended = 64
+};
+
class Menu {
public:
Menu(Gui *gui);
@@ -77,6 +87,7 @@ private:
int calculateMenuWidth(MenuItem *menu);
void calcMenuBounds(MenuItem *menu);
void renderSubmenu(MenuItem *menu);
+ MenuItem *createCommandsMenu();
Common::Array<MenuItem *> _items;
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index deac19b..ca1e585 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -273,17 +273,17 @@ bool World::loadWorld(Common::MacResManager *resMan) {
}
res = resMan->getResource(MKTAG('M','E','N','U'), 2004);
if (res != NULL) {
- readMenu(res);
- warning("STUB: commandsMenu");
- //world.setCommandsMenuName(commandsMenu[0]);
- //world.setDefaultCommandsMenu(commandsMenu[1]);
+ Common::StringArray *menu = readMenu(res);
+ _commandsMenuName = menu->operator[](0);
+ _commandsMenu = menu->operator[](1);
+ delete menu;
delete res;
}
res = resMan->getResource(MKTAG('M','E','N','U'), 2005);
if (res != NULL) {
- readMenu(res);
- warning("STUB: weaponsMenu");
- //world.setWeaponsMenuName(weaponsMenu[0]);
+ Common::StringArray *menu = readMenu(res);
+ _weaponsMenuName = menu->operator[](0);
+ delete menu;
delete res;
}
// TODO: Read Apple menu and get the name of that menu item..
@@ -294,7 +294,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
return true;
}
-Common::StringArray World::readMenu(Common::SeekableReadStream *res) {
+Common::StringArray *World::readMenu(Common::SeekableReadStream *res) {
res->skip(10);
int enableFlags = res->readUint32BE();
String menuName = readPascalString(res);
@@ -327,9 +327,9 @@ Common::StringArray World::readMenu(Common::SeekableReadStream *res) {
menuItemNumber++;
}
- Common::StringArray result;
- result.push_back(menuName);
- result.push_back(sb);
+ Common::StringArray *result = new Common::StringArray;
+ result->push_back(menuName);
+ result->push_back(sb);
warning("menuName: %s", menuName.c_str());
warning("sb: %s", sb.c_str());
diff --git a/engines/wage/world.h b/engines/wage/world.h
index a79d30c..2d2a16d 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -95,6 +95,10 @@ public:
Common::String *_saveBeforeCloseMessage;
Common::String *_revertMessage;
+ Common::String _commandsMenuName;
+ Common::String _commandsMenu;
+ Common::String _weaponsMenuName;
+
void addScene(Scene *room) {
if (room->_name.size() != 0) {
String s = room->_name;
@@ -128,7 +132,7 @@ public:
}
private:
- Common::StringArray readMenu(Common::SeekableReadStream *res);
+ Common::StringArray *readMenu(Common::SeekableReadStream *res);
};
} // End of namespace Wage
Commit: d9187245680911442c30d9dee3bf1eb40f44db7c
https://github.com/scummvm/scummvm/commit/d9187245680911442c30d9dee3bf1eb40f44db7c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:30+01:00
Commit Message:
WAGE: Fix compilation on some platforms
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index a8fa2b2..559ace1 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -207,7 +207,7 @@ MenuItem *Menu::createCommandsMenu() {
bool enabled = true;
int style = 0;
char shortcut = 0;
- char *shortptr = strrchr(item.c_str(), '/');
+ const char *shortptr = strrchr(item.c_str(), '/');
if (shortptr != NULL) {
if (strlen(shortptr) == 2) {
shortcut = shortptr[1];
Commit: 72b95e639ee9fc270df05e8d1738774fd35ac4ca
https://github.com/scummvm/scummvm/commit/72b95e639ee9fc270df05e8d1738774fd35ac4ca
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:44+01:00
Commit Message:
WAGE: Create weapons menu
Changed paths:
engines/wage/entities.h
engines/wage/menu.cpp
engines/wage/menu.h
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 362e9b5..6a97abf 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -237,25 +237,7 @@ public:
void resetState();
};
-class Weapon {
-public:
- uint _accuracy;
- String _operativeVerb;
- int _type;
- int _damage;
- String _sound;
- int _numberOfUses;
-
- Weapon() : _numberOfUses(0) {}
-
- void decrementNumberOfUses() {
- if (_numberOfUses != -1) {
- _numberOfUses--;
- }
- }
-};
-
-class Obj : public Weapon, public Designed {
+class Obj : public Designed {
public:
Obj() : _currentOwner(NULL), _currentScene(NULL) {}
Obj(String name, Common::SeekableReadStream *data);
@@ -298,6 +280,12 @@ public:
Scene *_currentScene;
Chr *_currentOwner;
+ int _type;
+ uint _accuracy;
+ String _operativeVerb;
+ int _damage;
+ String _sound;
+
public:
void setCurrentOwner(Chr *currentOwner) {
_currentOwner = currentOwner;
@@ -315,6 +303,19 @@ public:
Designed *removeFromCharOrScene();
};
+class Weapon : public Obj {
+public:
+ int _numberOfUses;
+
+ Weapon() : _numberOfUses(0) {}
+
+ void decrementNumberOfUses() {
+ if (_numberOfUses != -1) {
+ _numberOfUses--;
+ }
+ }
+};
+
class Scene : public Designed {
public:
enum Directions {
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 559ace1..2dde420 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -146,7 +146,7 @@ Menu::Menu(Gui *gui) : _gui(gui) {
_items.push_back(commands);
if (!_gui->_engine->_world->_weaponMenuDisabled) {
- MenuItem *weapons = new MenuItem(_gui->_engine->_world->_weaponsMenuName.c_str());
+ MenuItem *weapons = createWeaponsMenu();
_items.push_back(weapons);
}
@@ -260,6 +260,32 @@ MenuItem *Menu::createCommandsMenu() {
return menu;
}
+MenuItem *Menu::createWeaponsMenu() {
+ Chr *player = _gui->_engine->_world->_player;
+ MenuItem *menu = new MenuItem(_gui->_engine->_world->_weaponsMenuName.c_str());
+ WeaponArray *weapons = player->getWeapons(true);
+
+ for (int i = 0; i < weapons->size(); i++) {
+ Weapon *obj = (*weapons)[i];
+ if (obj->_type == Obj::REGULAR_WEAPON ||
+ obj->_type == Obj::THROW_WEAPON ||
+ obj->_type == Obj::MAGICAL_OBJECT) {
+ Common::String command(obj->_operativeVerb);
+ command += " ";
+ command += obj->_name;
+
+ menu->subitems.push_back(new MenuSubItem(command.c_str(), kMenuActionCommand, 0, 0, true));
+
+ }
+ }
+ delete weapons;
+
+ if (menu->subitems.size() == 0)
+ menu->subitems.push_back(new MenuSubItem("You have no weapons", 0, 0, 0, false));
+
+ return menu;
+}
+
const Graphics::Font *Menu::getMenuFont() {
return _gui->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
}
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index 67d061d..62ad835 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -88,6 +88,7 @@ private:
void calcMenuBounds(MenuItem *menu);
void renderSubmenu(MenuItem *menu);
MenuItem *createCommandsMenu();
+ MenuItem *createWeaponsMenu();
Common::Array<MenuItem *> _items;
Commit: 61c4f2091b0e3d70c51223f50240ee9e822b3f78
https://github.com/scummvm/scummvm/commit/61c4f2091b0e3d70c51223f50240ee9e822b3f78
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:45+01:00
Commit Message:
WAGE: Make menu commands working
Changed paths:
engines/wage/menu.cpp
engines/wage/menu.h
engines/wage/wage.h
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 2dde420..5bf6fc7 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -484,7 +484,12 @@ bool Menu::mouseMove(int x, int y) {
bool Menu::mouseRelease(int x, int y) {
if (_menuActivated) {
_menuActivated = false;
+
+ if (_activeItem != -1 && _activeSubItem != -1 && _items[_activeItem]->subitems[_activeSubItem]->enabled)
+ executeCommand(_items[_activeItem]->subitems[_activeSubItem]);
+
_activeItem = -1;
+ _activeSubItem = -1;
return true;
}
@@ -492,4 +497,32 @@ bool Menu::mouseRelease(int x, int y) {
return false;
}
+void Menu::executeCommand(MenuSubItem *subitem) {
+ switch(subitem->action) {
+ case kMenuActionAbout:
+ case kMenuActionNew:
+ case kMenuActionOpen:
+ case kMenuActionClose:
+ case kMenuActionSave:
+ case kMenuActionSaveAs:
+ case kMenuActionRevert:
+ case kMenuActionQuit:
+
+ case kMenuActionUndo:
+ case kMenuActionCut:
+ case kMenuActionCopy:
+ case kMenuActionPaste:
+ case kMenuActionClear:
+ break;
+
+ case kMenuActionCommand:
+ _gui->_engine->processTurn(&subitem->text, NULL);
+ break;
+
+ default:
+ warning("Unknown action: %d", subitem->action);
+
+ }
+}
+
} // End of namespace Wage
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index 62ad835..4169697 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -89,6 +89,7 @@ private:
void renderSubmenu(MenuItem *menu);
MenuItem *createCommandsMenu();
MenuItem *createWeaponsMenu();
+ void executeCommand(MenuSubItem *subitem);
Common::Array<MenuItem *> _items;
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 375425b..2eb9803 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -119,12 +119,12 @@ public:
bool canSaveGameStateCurrently();
const char *getGameFile() const;
+ void processTurn(Common::String *textInput, Designed *clickInput);
private:
bool loadWorld(Common::MacResManager *resMan);
void performInitialSetup();
void wearObjs(Chr *chr);
- void processTurn(Common::String *textInput, Designed *clickInput);
void processTurnInternal(Common::String *textInput, Designed *clickInput);
void regen();
void performCombatAction(Chr *npc, Chr *player);
Commit: 5a887808aba3d3a496828549201f563f9ad70c6e
https://github.com/scummvm/scummvm/commit/5a887808aba3d3a496828549201f563f9ad70c6e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:45+01:00
Commit Message:
WAGE: Regenerate weapons menu on demand
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/menu.cpp
engines/wage/menu.h
engines/wage/wage.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 21ff005..268e2dc 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -579,6 +579,10 @@ void Gui::loadFonts() {
delete dat;
}
+void Gui::regenWeaponsMenu() {
+ _menu->regenWeaponsMenu();
+}
+
void Gui::mouseMove(int x, int y) {
if (_menu->_menuActivated) {
if (_menu->mouseMove(x, y))
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index c1af13d..53722d5 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -97,6 +97,7 @@ public:
void drawInput();
void setSceneDirty() { _sceneDirty = true; }
const Graphics::Font *getFont(const char *name, Graphics::FontManager::FontUsage fallback);
+ void regenWeaponsMenu();
private:
void paintBorder(Graphics::Surface *g, Common::Rect &r, WindowType windowType);
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 5bf6fc7..65bc303 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -126,6 +126,8 @@ Menu::Menu(Gui *gui) : _gui(gui) {
assert(_gui->_engine);
assert(_gui->_engine->_world);
+ _font = getMenuFont();
+
MenuItem *about = new MenuItem(_gui->_builtInFonts ? "\xa9" : "\xf0"); // (c) Symbol as the most resembling apple
_items.push_back(about);
_items[0]->subitems.push_back(new MenuSubItem(_gui->_engine->_world->getAboutMenuItemName(), kMenuActionAbout));
@@ -146,12 +148,13 @@ Menu::Menu(Gui *gui) : _gui(gui) {
_items.push_back(commands);
if (!_gui->_engine->_world->_weaponMenuDisabled) {
- MenuItem *weapons = createWeaponsMenu();
- _items.push_back(weapons);
+ _weapons = new MenuItem(_gui->_engine->_world->_weaponsMenuName.c_str());
+ _items.push_back(_weapons);
+
+ regenWeaponsMenu();
}
// Calculate menu dimensions
- _font = getMenuFont();
int y = 1;
int x = 18;
@@ -260,9 +263,21 @@ MenuItem *Menu::createCommandsMenu() {
return menu;
}
-MenuItem *Menu::createWeaponsMenu() {
+void Menu::regenWeaponsMenu() {
+ if (_gui->_engine->_world->_weaponMenuDisabled)
+ return;
+
+ for (int j = 0; j < _weapons->subitems.size(); j++)
+ delete _weapons->subitems[j];
+
+ _weapons->subitems.clear();
+
+ createWeaponsMenu(_weapons);
+ calcMenuBounds(_weapons);
+}
+
+void Menu::createWeaponsMenu(MenuItem *menu) {
Chr *player = _gui->_engine->_world->_player;
- MenuItem *menu = new MenuItem(_gui->_engine->_world->_weaponsMenuName.c_str());
WeaponArray *weapons = player->getWeapons(true);
for (int i = 0; i < weapons->size(); i++) {
@@ -275,15 +290,12 @@ MenuItem *Menu::createWeaponsMenu() {
command += obj->_name;
menu->subitems.push_back(new MenuSubItem(command.c_str(), kMenuActionCommand, 0, 0, true));
-
}
}
delete weapons;
if (menu->subitems.size() == 0)
menu->subitems.push_back(new MenuSubItem("You have no weapons", 0, 0, 0, false));
-
- return menu;
}
const Graphics::Font *Menu::getMenuFont() {
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index 4169697..91c996b 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -73,6 +73,8 @@ public:
bool mouseRelease(int x, int y);
bool mouseMove(int x, int y);
+ void regenWeaponsMenu();
+
bool _menuActivated;
Common::Rect _bbox;
@@ -88,10 +90,11 @@ private:
void calcMenuBounds(MenuItem *menu);
void renderSubmenu(MenuItem *menu);
MenuItem *createCommandsMenu();
- MenuItem *createWeaponsMenu();
+ void createWeaponsMenu(MenuItem *menu);
void executeCommand(MenuSubItem *subitem);
Common::Array<MenuItem *> _items;
+ MenuItem *_weapons;
const Graphics::Font *_font;
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index ff92a69..960f155 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -305,6 +305,9 @@ void WageEngine::onMove(Designed *what, Designed *from, Designed *to) {
(what->_classType == OBJ && ((Obj *)what)->_currentScene == currentScene))
_gui->setSceneDirty();
+ if ((from == player || to == player) && !_temporarilyHidden)
+ _gui->regenWeaponsMenu();
+
if (what != player && what->_classType == CHR) {
Chr *chr = (Chr *)what;
if (to == _world->_storageScene) {
Commit: 402a9cf8efe6e040b5892cf80b613d907ed01931
https://github.com/scummvm/scummvm/commit/402a9cf8efe6e040b5892cf80b613d907ed01931
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:45+01:00
Commit Message:
WAGE: Implemented getAboutMenuItemName()
Changed paths:
engines/wage/world.cpp
engines/wage/world.h
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index ca1e585..640feed 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -265,10 +265,13 @@ bool World::loadWorld(Common::MacResManager *resMan) {
res = resMan->getResource(MKTAG('M','E','N','U'), 2001);
if (res != NULL) {
- readMenu(res);
- warning("STUB: aboutMenu");
- //String aboutMenuItemName = appleMenu[1].split(";")[0];
- //world.setAboutMenuItemName(aboutMenuItemName);
+ Common::StringArray *menu = readMenu(res);
+ _aboutMenuItemName = "";
+ Common::String string = menu->operator[](0);
+
+ for (int i = 0; i < string.size() && string[i] != ';'; i++) // Read token
+ _aboutMenuItemName += string[i];
+
delete res;
}
res = resMan->getResource(MKTAG('M','E','N','U'), 2004);
@@ -485,9 +488,23 @@ bool World::scenesAreConnected(Scene *scene1, Scene *scene2) {
}
const char *World::getAboutMenuItemName() {
- warning("STUB: getAboutMenuItemName");
+ static char menu[256];
+
+ *menu = '\0';
+
+ if (_aboutMenuItemName.size() == 0) {
+ sprintf(menu, "About %s...", _name.c_str());
+ } else { // Replace '@' with name
+ const char *str = _aboutMenuItemName.c_str();
+ char *pos = strchr(str, '@');
+ if (pos) {
+ strncat(menu, str, (pos - str));
+ strcat(menu, _name.c_str());
+ strcat(menu, pos + 1);
+ }
+ }
- return "About";
+ return menu;
}
} // End of namespace Wage
diff --git a/engines/wage/world.h b/engines/wage/world.h
index 2d2a16d..ba1aa16 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -95,6 +95,7 @@ public:
Common::String *_saveBeforeCloseMessage;
Common::String *_revertMessage;
+ Common::String _aboutMenuItemName;
Common::String _commandsMenuName;
Common::String _commandsMenu;
Common::String _weaponsMenuName;
Commit: 540a2e78e5f4b00c705ec1c6e89fede4e7b0a373
https://github.com/scummvm/scummvm/commit/540a2e78e5f4b00c705ec1c6e89fede4e7b0a373
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:45+01:00
Commit Message:
WAGE: Fix compilation on some platforms
Changed paths:
engines/wage/world.cpp
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 640feed..79e428a 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -496,7 +496,7 @@ const char *World::getAboutMenuItemName() {
sprintf(menu, "About %s...", _name.c_str());
} else { // Replace '@' with name
const char *str = _aboutMenuItemName.c_str();
- char *pos = strchr(str, '@');
+ const char *pos = strchr(str, '@');
if (pos) {
strncat(menu, str, (pos - str));
strcat(menu, _name.c_str());
Commit: 84b382db003492effead11f21e26aa421ea135fe
https://github.com/scummvm/scummvm/commit/84b382db003492effead11f21e26aa421ea135fe
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:45+01:00
Commit Message:
WAGE: Fix about menu
Changed paths:
engines/wage/world.cpp
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 79e428a..af68e6a 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -112,6 +112,8 @@ bool World::loadWorld(Common::MacResManager *resMan) {
if ((resArray = resMan->getResIDArray(MKTAG('V','E','R','S'))).size() == 0)
return false;
+ _name = resMan->getBaseFileName();
+
if (resArray.size() > 1)
warning("Too many VERS resources");
@@ -267,7 +269,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
if (res != NULL) {
Common::StringArray *menu = readMenu(res);
_aboutMenuItemName = "";
- Common::String string = menu->operator[](0);
+ Common::String string = menu->operator[](1);
for (int i = 0; i < string.size() && string[i] != ';'; i++) // Read token
_aboutMenuItemName += string[i];
Commit: c3824f40bac45571032652be2b18a34d9633530a
https://github.com/scummvm/scummvm/commit/c3824f40bac45571032652be2b18a34d9633530a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:46+01:00
Commit Message:
WAGE: Hide debug output
Changed paths:
engines/wage/world.cpp
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index af68e6a..85c72bb 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -305,28 +305,28 @@ Common::StringArray *World::readMenu(Common::SeekableReadStream *res) {
String menuName = readPascalString(res);
String menuItem = readPascalString(res);
int menuItemNumber = 1;
- Common::String sb;
+ Common::String menu;
byte itemData[4];
while (menuItem.size() > 0) {
- if (sb.size() > 0) {
- sb += ';';
+ if (menu.size() > 0) {
+ menu += ';';
}
if ((enableFlags & (1 << menuItemNumber)) == 0) {
- sb += '(';
+ menu += '(';
}
- sb += menuItem;
+ menu += menuItem;
res->read(itemData, 4);
static const char styles[] = {'B', 'I', 'U', 'O', 'S', 'C', 'E', 0};
for (int i = 0; styles[i] != 0; i++) {
if ((itemData[3] & (1 << i)) != 0) {
- sb += '<';
- sb += styles[i];
+ menu += '<';
+ menu += styles[i];
}
}
if (itemData[1] != 0) {
- sb += '/';
- sb += (char)itemData[1];
+ menu += '/';
+ menu += (char)itemData[1];
}
menuItem = readPascalString(res);
menuItemNumber++;
@@ -334,10 +334,11 @@ Common::StringArray *World::readMenu(Common::SeekableReadStream *res) {
Common::StringArray *result = new Common::StringArray;
result->push_back(menuName);
- result->push_back(sb);
+ result->push_back(menu);
+
+ debug(4, "menuName: %s", menuName.c_str());
+ debug(4, "menu: %s", menu.c_str());
- warning("menuName: %s", menuName.c_str());
- warning("sb: %s", sb.c_str());
return result;
}
Commit: 43df45d610aa2014f07d1f0307365627fc61ef8e
https://github.com/scummvm/scummvm/commit/43df45d610aa2014f07d1f0307365627fc61ef8e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:46+01:00
Commit Message:
WAGE: Implement handleRestCommand
Changed paths:
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/script.cpp
engines/wage/wage.h
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 8472e78..e229daf 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -439,5 +439,8 @@ const char *Chr::getDefiniteArticle(bool capitalize) {
return "";
}
+void Chr::printPlayerCondition() {
+ warning("STUB: printPlayerCondition()");
+}
} // End of namespace Wage
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 6a97abf..0a3fa28 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -222,6 +222,7 @@ public:
WeaponArray *getWeapons(bool includeMagic);
ObjArray *getMagicalObjects();
const char *getDefiniteArticle(bool capitalize);
+ void printPlayerCondition();
public:
bool hasNativeWeapon1() {
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 48e01c0..0b38f37 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -1034,7 +1034,13 @@ void Script::handleStatusCommand() {
}
void Script::handleRestCommand() {
- warning("STUB: handleRestCommand");
+ if (_callbacks->getMonster() != NULL) {
+ appendText("This is no time to rest!");
+ _callbacks->_commandWasQuick = true;
+ } else {
+ _callbacks->regen();
+ _world->_player->printPlayerCondition();
+ }
}
void Script::handleAcceptCommand() {
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 2eb9803..10541b3 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -120,13 +120,13 @@ public:
const char *getGameFile() const;
void processTurn(Common::String *textInput, Designed *clickInput);
+ void regen();
private:
bool loadWorld(Common::MacResManager *resMan);
void performInitialSetup();
void wearObjs(Chr *chr);
void processTurnInternal(Common::String *textInput, Designed *clickInput);
- void regen();
void performCombatAction(Chr *npc, Chr *player);
int getValidMoveDirections(Chr *npc);
void performAttack(Chr *attacker, Chr *victim, Weapon *weapon);
@@ -150,6 +150,7 @@ public:
int _aim;
bool _temporarilyHidden;
bool _isGameOver;
+ bool _commandWasQuick;
Common::String _inputText;
@@ -172,8 +173,6 @@ private:
Common::MacResManager *_resManager;
- bool _commandWasQuick;
-
bool _shouldQuit;
};
Commit: 87698593db098cd906a5b8f7f19eb7f6db5a6e7a
https://github.com/scummvm/scummvm/commit/87698593db098cd906a5b8f7f19eb7f6db5a6e7a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:46+01:00
Commit Message:
WAGE: Implement printPlayerCondition()
Changed paths:
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/script.cpp
engines/wage/script.h
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index e229daf..7f40353 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -439,8 +439,4 @@ const char *Chr::getDefiniteArticle(bool capitalize) {
return "";
}
-void Chr::printPlayerCondition() {
- warning("STUB: printPlayerCondition()");
-}
-
} // End of namespace Wage
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 0a3fa28..6a97abf 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -222,7 +222,6 @@ public:
WeaponArray *getWeapons(bool includeMagic);
ObjArray *getMagicalObjects();
const char *getDefiniteArticle(bool capitalize);
- void printPlayerCondition();
public:
bool hasNativeWeapon1() {
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 0b38f37..c4567a5 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -1039,7 +1039,7 @@ void Script::handleRestCommand() {
_callbacks->_commandWasQuick = true;
} else {
_callbacks->regen();
- _world->_player->printPlayerCondition();
+ printPlayerCondition(_world->_player);
}
}
@@ -1282,4 +1282,35 @@ void Script::convertToText() {
delete scr;
}
+const char *Script::getPercentMessage(double percent) {
+ if (percent < 0.40) {
+ return "very bad";
+ } else if (percent < 0.55) {
+ return "bad";
+ } else if (percent < 0.70) {
+ return "average";
+ } else if (percent < 0.85) {
+ return "good";
+ } else if (percent <= 1.00) {
+ return "very good";
+ } else {
+ return "enhanced";
+ }
+}
+
+void Script::printPlayerCondition(Chr *player) {
+ double physicalPercent = (double)player->_context._statVariables[PHYS_HIT_CUR] / player->_context._statVariables[PHYS_HIT_BAS];
+ double spiritualPercent = (double)player->_context._statVariables[SPIR_HIT_CUR] / player->_context._statVariables[SPIR_HIT_BAS];
+
+ Common::String msg = "Your physical condition is ";
+ msg += getPercentMessage(physicalPercent);
+ msg += ".";
+ appendText(msg);
+
+ msg = "Your spiritual condition is ";
+ msg += getPercentMessage(spiritualPercent);
+ msg += ".";
+ appendText(msg);
+}
+
} // End of namespace Wage
diff --git a/engines/wage/script.h b/engines/wage/script.h
index 529efa8..ed27725 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -191,6 +191,9 @@ private:
Common::Array<ScriptText *> _scriptText;
void convertToText();
+
+ void printPlayerCondition(Chr *player);
+ const char *getPercentMessage(double percent);
};
} // End of namespace Wage
Commit: 8e30167e854a12cf545e7ad56a33e20122fe58c0
https://github.com/scummvm/scummvm/commit/8e30167e854a12cf545e7ad56a33e20122fe58c0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:46+01:00
Commit Message:
WAGE: Implement handleAcceptCommand()
Changed paths:
engines/wage/combat.cpp
engines/wage/script.cpp
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index cdf336f..2d1e02a 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -53,9 +53,13 @@
namespace Wage {
Obj *WageEngine::getOffer() {
- warning("STUB: WageEngine::getOffer");
-
- return NULL;
+ if (_offer != NULL) {
+ Chr *owner = _offer->_currentOwner;
+ if (owner == NULL || owner->_playerCharacter || owner->_currentScene != _world->_player->_currentScene) {
+ _offer = NULL;
+ }
+ }
+ return _offer;
}
Chr *WageEngine::getMonster() {
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index c4567a5..6ccb7b3 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -1044,7 +1044,16 @@ void Script::handleRestCommand() {
}
void Script::handleAcceptCommand() {
- warning("STUB: handleAcceptCommand");
+ Obj *offer = _callbacks->_offer;
+ Chr *chr = offer->_currentOwner;
+
+ char buf[512];
+ snprintf(buf, 512, "%s%s lays the %s on the ground and departs peacefully.",
+ chr->getDefiniteArticle(true), chr->_name.c_str(), offer->_name.c_str());
+ appendText(buf);
+
+ _world->move(offer, chr->_currentScene);
+ _world->move(chr, _world->_storageScene);
}
void Script::handleTakeCommand(const char *target) {
@@ -1077,6 +1086,37 @@ void Script::handleAttack(Weapon *weapon) {
warning("STUB: handleAttack");
}
+const char *Script::getPercentMessage(double percent) {
+ if (percent < 0.40) {
+ return "very bad";
+ } else if (percent < 0.55) {
+ return "bad";
+ } else if (percent < 0.70) {
+ return "average";
+ } else if (percent < 0.85) {
+ return "good";
+ } else if (percent <= 1.00) {
+ return "very good";
+ } else {
+ return "enhanced";
+ }
+}
+
+void Script::printPlayerCondition(Chr *player) {
+ double physicalPercent = (double)player->_context._statVariables[PHYS_HIT_CUR] / player->_context._statVariables[PHYS_HIT_BAS];
+ double spiritualPercent = (double)player->_context._statVariables[SPIR_HIT_CUR] / player->_context._statVariables[SPIR_HIT_BAS];
+
+ Common::String msg = "Your physical condition is ";
+ msg += getPercentMessage(physicalPercent);
+ msg += ".";
+ appendText(msg);
+
+ msg = "Your spiritual condition is ";
+ msg += getPercentMessage(spiritualPercent);
+ msg += ".";
+ appendText(msg);
+}
+
enum {
BLOCK_START,
BLOCK_END,
@@ -1282,35 +1322,4 @@ void Script::convertToText() {
delete scr;
}
-const char *Script::getPercentMessage(double percent) {
- if (percent < 0.40) {
- return "very bad";
- } else if (percent < 0.55) {
- return "bad";
- } else if (percent < 0.70) {
- return "average";
- } else if (percent < 0.85) {
- return "good";
- } else if (percent <= 1.00) {
- return "very good";
- } else {
- return "enhanced";
- }
-}
-
-void Script::printPlayerCondition(Chr *player) {
- double physicalPercent = (double)player->_context._statVariables[PHYS_HIT_CUR] / player->_context._statVariables[PHYS_HIT_BAS];
- double spiritualPercent = (double)player->_context._statVariables[SPIR_HIT_CUR] / player->_context._statVariables[SPIR_HIT_BAS];
-
- Common::String msg = "Your physical condition is ";
- msg += getPercentMessage(physicalPercent);
- msg += ".";
- appendText(msg);
-
- msg = "Your spiritual condition is ";
- msg += getPercentMessage(spiritualPercent);
- msg += ".";
- appendText(msg);
-}
-
} // End of namespace Wage
Commit: 2a16cef20e6d2686bbeae466cc74f772e7c4f66e
https://github.com/scummvm/scummvm/commit/2a16cef20e6d2686bbeae466cc74f772e7c4f66e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:46+01:00
Commit Message:
WAGE: Simplified message output formation
Changed paths:
engines/wage/combat.cpp
engines/wage/wage.cpp
engines/wage/wage.h
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index 2d1e02a..17b03d1 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -70,41 +70,31 @@ Chr *WageEngine::getMonster() {
}
void WageEngine::encounter(Chr *player, Chr *chr) {
- Common::String msg("You encounter ");
- if (!chr->_nameProperNoun)
- msg += getIndefiniteArticle(chr->_name);
- msg += chr->_name;
- msg += ".";
- appendText(msg);
+ char buf[512];
+
+ snprintf(buf, 512, "You encounter %s%s.", chr->_nameProperNoun ? "" : getIndefiniteArticle(chr->_name),
+ chr->_name.c_str());
+ appendText(buf);
if (!chr->_initialComment.empty())
appendText(chr->_initialComment);
if (chr->_armor[Chr::HEAD_ARMOR] != NULL) {
- msg = chr->getDefiniteArticle(true);
- msg += chr->_name;
- msg += " is wearing ";
- msg += getIndefiniteArticle(chr->_armor[Chr::HEAD_ARMOR]->_name);
- msg += ".";
- appendText(msg);
+ snprintf(buf, 512, "%s%s is wearing %s.", chr->getDefiniteArticle(true), chr->_name.c_str(),
+ getIndefiniteArticle(chr->_armor[Chr::HEAD_ARMOR]->_name));
+ appendText(buf);
}
if (chr->_armor[Chr::BODY_ARMOR] != NULL) {
- msg = getGenderSpecificPronoun(chr->_gender, true);
- msg += " is protected by ";
- msg += prependGenderSpecificPronoun(chr->_gender);
- msg += chr->_armor[Chr::BODY_ARMOR]->_name;
- msg += ".";
- appendText(msg);
+ snprintf(buf, 512, "%s is protected by %s%s.", getGenderSpecificPronoun(chr->_gender, true),
+ prependGenderSpecificPronoun(chr->_gender), chr->_armor[Chr::BODY_ARMOR]->_name.c_str());
+ appendText(buf);
}
if (chr->_armor[Chr::SHIELD_ARMOR] != NULL) {
Obj *obj = chr->_armor[Chr::SHIELD_ARMOR];
- msg = getGenderSpecificPronoun(chr->_gender, true);
- msg += " carries ";
- if (!obj->_namePlural)
- msg += getIndefiniteArticle(obj->_name);
- msg += obj->_name;
- msg += ".";
- appendText(msg);
+
+ snprintf(buf, 512, "%s carries %s%s.", getGenderSpecificPronoun(chr->_gender, true),
+ obj->_namePlural ? "" : getIndefiniteArticle(obj->_name), obj->_name.c_str());
+ appendText(buf);
}
}
@@ -202,23 +192,23 @@ void WageEngine::performMove(Chr *chr, int validMoves) {
void WageEngine::performOffer(Chr *attacker, Chr *victim) {
/* TODO: choose in a smarter way? */
Obj *obj = attacker->_inventory[0];
- Common::String msg(attacker->getDefiniteArticle(true));
- msg += attacker->_name;
- msg += " offers ";
- msg += obj->_namePlural ? "some " : getIndefiniteArticle(obj->_name);
- msg += obj->_name;
- msg += ".";
+ char buf[512];
+
+ snprintf(buf, 512, "%s%s offers %s%s.", attacker->getDefiniteArticle(true), attacker->_name.c_str(),
+ obj->_namePlural ? "some " : getIndefiniteArticle(obj->_name), obj->_name.c_str());
+
+ appendText(buf);
_offer = obj;
}
void WageEngine::performTake(Chr *npc, Obj *obj) {
- Common::String msg(npc->getDefiniteArticle(true));
- msg += npc->_name;
- msg += " picks up the ";
- msg += getIndefiniteArticle(obj->_name);
- msg += obj->_name;
- msg += ".";
+ char buf[512];
+
+ snprintf(buf, 512, "%s%s picks up the %s%s.", npc->getDefiniteArticle(true), npc->_name.c_str(),
+ getIndefiniteArticle(obj->_name), obj->_name.c_str());
+
+ appendText(buf);
_world->move(obj, npc);
}
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 960f155..db7e364 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -210,6 +210,12 @@ void WageEngine::appendText(String &str) {
_gui->appendText(str);
}
+void WageEngine::appendText(char *str) {
+ Common::String s(str);
+
+ appendText(s);
+}
+
void WageEngine::gameOver() {
warning("STUB: WageEngine::gameOver()");
}
@@ -434,20 +440,16 @@ void WageEngine::processTurn(Common::String *textInput, Designed *clickInput) {
}
}
- Common::String msg;
+ char buf[512];
if (followed) {
- msg = prevMonster->getDefiniteArticle(true);
- msg += prevMonster->_name;
- msg += " follows you.";
- appendText(msg);
+ snprintf(buf, 512, "%s%s follows you.", prevMonster->getDefiniteArticle(true), prevMonster->_name.c_str());
+ appendText(buf);
+
_world->move(prevMonster, playerScene);
} else {
- msg = "You escape ";
- msg += prevMonster->getDefiniteArticle(false);
- msg += prevMonster->_name;
- msg += ".";
- appendText(msg);
+ snprintf(buf, 512, "You escape %s%s.", prevMonster->getDefiniteArticle(false), prevMonster->_name.c_str());
+ appendText(buf);
}
}
}
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 10541b3..245fc9b 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -157,6 +157,7 @@ public:
void playSound(String soundName);
void setMenu(String soundName);
void appendText(String &str);
+ void appendText(char *str);
void gameOver();
Obj *getOffer();
Chr *getMonster();
Commit: 76639b5d3a8cf4b869a7b81cffe6ae1f8c6c0557
https://github.com/scummvm/scummvm/commit/76639b5d3a8cf4b869a7b81cffe6ae1f8c6c0557
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:47+01:00
Commit Message:
WAGE: Add Enchanced Scepters detection
Changed paths:
engines/wage/detection.cpp
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
index bdc59e9..594fc5d 100644
--- a/engines/wage/detection.cpp
+++ b/engines/wage/detection.cpp
@@ -43,6 +43,7 @@ static const PlainGameDescriptor wageGames[] = {
{"cantitoe", "Camp Cantitoe"},
{"escapefromschool", "Escape from School!"},
{"queenquest", "Queen Quest"},
+ {"scepters", "Enchanced Scepters"},
{"wage", "World Adventure Game Engine game"},
{0, 0}
};
@@ -95,6 +96,15 @@ static const ADGameDescription gameDescriptions[] = {
ADGF_NO_FLAGS,
GUIO0()
},
+ {
+ "scepters",
+ "",
+ AD_ENTRY1s("Scepters", "b80bff315897776dda7689cdf829fab4", 360832),
+ Common::EN_ANY,
+ Common::kPlatformMacintosh,
+ ADGF_NO_FLAGS,
+ GUIO0()
+ },
AD_TABLE_END_MARKER
};
Commit: 61dec8fd964fa710107c3e6f1abb7ee72ec90a6b
https://github.com/scummvm/scummvm/commit/61dec8fd964fa710107c3e6f1abb7ee72ec90a6b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:47+01:00
Commit Message:
WAGE: Fix scene and text position as it is provided by the game data
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 268e2dc..b5edafd 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -255,23 +255,17 @@ void Gui::draw() {
_menuDirty = true;
_consoleFullRedraw = true;
- _scene->paint(&_screen, 0 + kComponentsPadding, kMenuHeight + kComponentsPadding);
-
- _sceneArea.left = 0 + kComponentsPadding + kBorderWidth;
- _sceneArea.top = kMenuHeight + kComponentsPadding + kBorderWidth;
- _sceneArea.setWidth(_scene->_design->getBounds()->width() - 2 * kBorderWidth);
- _sceneArea.setHeight(_scene->_design->getBounds()->height() - 2 * kBorderWidth);
-
- int sceneW = _scene->_design->getBounds()->width();
- int consoleW = _screen.w - sceneW - 2 * kComponentsPadding - 2 * kBorderWidth;
- int consoleH = _scene->_design->getBounds()->height() - 2 * kBorderWidth;
- int consoleX = sceneW + kComponentsPadding + kBorderWidth;
- int consoleY = kMenuHeight + kComponentsPadding + kBorderWidth;
-
- _consoleTextArea.left = consoleX;
- _consoleTextArea.top = consoleY;
- _consoleTextArea.right = consoleX + consoleW;
- _consoleTextArea.bottom = consoleY + consoleH;
+ _scene->paint(&_screen, _scene->_designBounds->left, _scene->_designBounds->top);
+
+ _sceneArea.left = _scene->_designBounds->left + kBorderWidth;
+ _sceneArea.top = _scene->_designBounds->top + kBorderWidth;
+ _sceneArea.setWidth(_scene->_designBounds->width() - 2 * kBorderWidth);
+ _sceneArea.setHeight(_scene->_designBounds->height() - 2 * kBorderWidth);
+
+ _consoleTextArea.left = _scene->_textBounds->left + kBorderWidth;
+ _consoleTextArea.top = _scene->_textBounds->top + kBorderWidth;
+ _consoleTextArea.setWidth(_scene->_textBounds->width() - 2 * kBorderWidth);
+ _consoleTextArea.setHeight(_scene->_textBounds->height() - 2 * kBorderWidth);
}
if (_scene && (_bordersDirty || _sceneDirty))
Commit: f428f597887b6d96c6832250d4a713ede92e4b04
https://github.com/scummvm/scummvm/commit/f428f597887b6d96c6832250d4a713ede92e4b04
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:47+01:00
Commit Message:
WAGE: Remove now useess warning
Changed paths:
engines/wage/world.cpp
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 85c72bb..cead6ae 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -180,9 +180,6 @@ bool World::loadWorld(Common::MacResManager *resMan) {
scene->_fontType = res->readUint16BE();
scene->_fontSize = res->readUint16BE();
- if (scene->_fontType != 3 || scene->_fontSize != 9)
- warning("scene: %s font: '%s' (%d) size: %d", scene->_name.c_str(), scene->getFontName(), scene->_fontType, scene->_fontSize);
-
String text;
while (res->pos() < res->size()) {
char c = res->readByte();
Commit: 40eb91da3ce5d3bd96f749ebc749238d364cc15d
https://github.com/scummvm/scummvm/commit/40eb91da3ce5d3bd96f749ebc749238d364cc15d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:47+01:00
Commit Message:
WAGE: More menu finetuning
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/menu.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index b5edafd..0c83852 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -257,13 +257,13 @@ void Gui::draw() {
_scene->paint(&_screen, _scene->_designBounds->left, _scene->_designBounds->top);
- _sceneArea.left = _scene->_designBounds->left + kBorderWidth;
- _sceneArea.top = _scene->_designBounds->top + kBorderWidth;
+ _sceneArea.left = _scene->_designBounds->left + kBorderWidth - 2;
+ _sceneArea.top = _scene->_designBounds->top + kBorderWidth - 2;
_sceneArea.setWidth(_scene->_designBounds->width() - 2 * kBorderWidth);
_sceneArea.setHeight(_scene->_designBounds->height() - 2 * kBorderWidth);
- _consoleTextArea.left = _scene->_textBounds->left + kBorderWidth;
- _consoleTextArea.top = _scene->_textBounds->top + kBorderWidth;
+ _consoleTextArea.left = _scene->_textBounds->left + kBorderWidth - 2;
+ _consoleTextArea.top = _scene->_textBounds->top + kBorderWidth - 2;
_consoleTextArea.setWidth(_scene->_textBounds->width() - 2 * kBorderWidth);
_consoleTextArea.setHeight(_scene->_textBounds->height() - 2 * kBorderWidth);
}
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 53722d5..4494771 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -68,8 +68,8 @@ enum {
kMenuLeftMargin = 7,
kMenuSpacing = 13,
kMenuPadding = 16,
- kMenuDropdownPadding = 12,
- kMenuDropdownItemHeight = 15,
+ kMenuDropdownPadding = 14,
+ kMenuDropdownItemHeight = 16,
kMenuItemHeight = 20,
kBorderWidth = 17,
kDesktopArc = 7,
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 65bc303..b5066ac 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -335,9 +335,9 @@ int Menu::calculateMenuWidth(MenuItem *menu) {
void Menu::calcMenuBounds(MenuItem *menu) {
// TODO: cache maxWidth
int maxWidth = calculateMenuWidth(menu);
- int x1 = menu->bbox.left;
+ int x1 = menu->bbox.left - 1;
int y1 = menu->bbox.bottom + 1;
- int x2 = x1 + maxWidth + kMenuDropdownPadding * 2;
+ int x2 = x1 + maxWidth + kMenuDropdownPadding * 2 - 4;
int y2 = y1 + menu->subitems.size() * kMenuDropdownItemHeight + 2;
menu->subbbox.left = x1;
@@ -360,7 +360,12 @@ void Menu::render() {
MenuItem *it = _items[i];
if (_activeItem == i) {
- Design::drawFilledRect(&_gui->_screen, it->bbox, kColorBlack, _gui->_patterns, kPatternSolid);
+ Common::Rect hbox = it->bbox;
+
+ hbox.left -= 1;
+ hbox.right += 2;
+
+ Design::drawFilledRect(&_gui->_screen, hbox, kColorBlack, _gui->_patterns, kPatternSolid);
color = kColorWhite;
if (it->subitems.size())
Commit: ee8999241e115b4f38c8481ed8257176ced0dbc2
https://github.com/scummvm/scummvm/commit/ee8999241e115b4f38c8481ed8257176ced0dbc2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:47+01:00
Commit Message:
WAGE: Fix submenu rendering
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/menu.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 0c83852..a5e9018 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -68,8 +68,9 @@ static const byte palette[] = {
};
static byte fillPattern[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
-static byte fillPatternStripes[8] = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa };
+static byte fillPatternStripes[8] = { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 };
static byte fillPatternCheckers[8] = { 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55 };
+static byte fillPatternCheckers2[8] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa };
static const byte macCursorArrow[] = {
2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3,
@@ -163,6 +164,7 @@ Gui::Gui(WageEngine *engine) {
_patterns.push_back(fillPattern);
_patterns.push_back(fillPatternStripes);
_patterns.push_back(fillPatternCheckers);
+ _patterns.push_back(fillPatternCheckers2);
loadFonts();
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 4494771..3f5a824 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -80,7 +80,8 @@ enum {
enum {
kPatternSolid = 1,
kPatternStripes = 2,
- kPatternCheckers = 3
+ kPatternCheckers = 3,
+ kPatternCheckers2 = 4
};
class Gui {
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index b5066ac..0577ad5 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -107,9 +107,9 @@ struct MenuData {
{ 1, "New", kMenuActionNew, 0, false },
{ 1, "Open...", kMenuActionOpen, 0, false },
{ 1, "Close", kMenuActionClose, 0, true },
- { 1, "Save", kMenuActionSave, 0, true },
+ { 1, "Save", kMenuActionSave, 0, false },
{ 1, "Save as...", kMenuActionSaveAs, 0, true },
- { 1, "Revert", kMenuActionRevert, 0, true },
+ { 1, "Revert", kMenuActionRevert, 0, false },
{ 1, "Quit", kMenuActionQuit, 0, true },
{ 2, "Undo", kMenuActionUndo, 'Z', false },
@@ -428,7 +428,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
for (int ii = 0; ii < _tempSurface.h; ii++) {
const byte *src = (const byte *)_tempSurface.getBasePtr(0, ii);
byte *dst = (byte *)_gui->_screen.getBasePtr(x, y+ii);
- byte pat = _gui->_patterns[kPatternCheckers - 1][ii % 8];
+ byte pat = _gui->_patterns[kPatternCheckers2 - 1][ii % 8];
for (int j = 0; j < r->width(); j++) {
if (*src != kColorGreen && (pat & (1 << (7 - (x + j) % 8))))
*dst = *src;
@@ -438,7 +438,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
}
}
} else { // Delimiter
- Design::drawHLine(&_gui->_screen, r->left, r->right, y + kMenuDropdownItemHeight / 2, 1, kColorBlack, _gui->_patterns, kPatternStripes);
+ Design::drawHLine(&_gui->_screen, r->left + 1, r->right - 1, y + kMenuDropdownItemHeight / 2, 1, kColorBlack, _gui->_patterns, kPatternStripes);
}
y += kMenuDropdownItemHeight;
Commit: d9c3cd18d65c3c3fdaaa2001641a1e02bd7d5373
https://github.com/scummvm/scummvm/commit/d9c3cd18d65c3c3fdaaa2001641a1e02bd7d5373
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:48+01:00
Commit Message:
WAGE: Simplified default pattern setting
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index a5e9018..a776dba 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -67,10 +67,11 @@ static const byte palette[] = {
0x00, 0xff, 0x00 // Green
};
-static byte fillPattern[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
-static byte fillPatternStripes[8] = { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 };
-static byte fillPatternCheckers[8] = { 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55 };
-static byte fillPatternCheckers2[8] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa };
+static byte fillPatterns[][8] = { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, // kPatternSolid
+ { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 }, // kPatternStripes
+ { 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55 }, // kPatternCheckers
+ { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa } // kPatternCheckers2
+};
static const byte macCursorArrow[] = {
2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3,
@@ -161,10 +162,8 @@ Gui::Gui(WageEngine *engine) {
_cursorIsArrow = true;
CursorMan.showMouse(true);
- _patterns.push_back(fillPattern);
- _patterns.push_back(fillPatternStripes);
- _patterns.push_back(fillPatternCheckers);
- _patterns.push_back(fillPatternCheckers2);
+ for (int i = 0; i < ARRAYSIZE(fillPatterns); i++)
+ _patterns.push_back(fillPatterns[i]);
loadFonts();
Commit: 028e3c14d52e7a8d22cc0bcfaee0f365c856c85f
https://github.com/scummvm/scummvm/commit/028e3c14d52e7a8d22cc0bcfaee0f365c856c85f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:48+01:00
Commit Message:
WAGE: Fix border title drawing
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index a776dba..02b735d 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -389,12 +389,12 @@ void Gui::paintBorder(Graphics::Surface *g, Common::Rect &r, WindowType windowTy
const Graphics::Font *font = getTitleFont();
int yOff = _builtInFonts ? 3 : 1;
- int w = font->getStringWidth(_scene->_name) + 6;
+ int w = font->getStringWidth(_scene->_name) + 10;
int maxWidth = width - size*2 - 7;
if (w > maxWidth)
w = maxWidth;
drawBox(g, x + (width - w) / 2, y, w, size);
- font->drawString(g, _scene->_name, x + (width - w) / 2 + 3, y + yOff, w, kColorBlack);
+ font->drawString(g, _scene->_name, x + (width - w) / 2 + 5, y + yOff, w, kColorBlack);
}
g_system->copyRectToScreen(g->getBasePtr(x, y), g->pitch, x, y, width, height);
Commit: 5f5280d8cf1df16177f3920e6011401e8bff00a6
https://github.com/scummvm/scummvm/commit/5f5280d8cf1df16177f3920e6011401e8bff00a6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:48+01:00
Commit Message:
WAGE: Stub for dialogs
Changed paths:
A engines/wage/dialog.cpp
A engines/wage/dialog.h
engines/wage/module.mk
diff --git a/engines/wage/dialog.cpp b/engines/wage/dialog.cpp
new file mode 100644
index 0000000..665bf52
--- /dev/null
+++ b/engines/wage/dialog.cpp
@@ -0,0 +1,72 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "common/system.h"
+
+#include "wage/wage.h"
+#include "wage/gui.h"
+#include "wage/dialog.h"
+
+namespace Wage {
+
+Dialog::Dialog(Gui *gui) : _gui(gui) {
+ assert(_gui->_engine);
+ assert(_gui->_engine->_world);
+
+ _font = getDialogFont();
+
+ _tempSurface.create(_gui->_screen.w, _font->getFontHeight(), Graphics::PixelFormat::createFormatCLUT8());
+}
+
+Dialog::~Dialog() {
+}
+
+const Graphics::Font *Dialog::getDialogFont() {
+ return _gui->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
+}
+
+} // End of namespace Wage
diff --git a/engines/wage/dialog.h b/engines/wage/dialog.h
new file mode 100644
index 0000000..63f7ded
--- /dev/null
+++ b/engines/wage/dialog.h
@@ -0,0 +1,70 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef WAGE_DIALOG_H
+#define WAGE_DIALOG_H
+
+namespace Wage {
+
+class Dialog {
+public:
+ Dialog(Gui *gui);
+ ~Dialog();
+
+private:
+ Gui *_gui;
+ Graphics::Surface _tempSurface;
+
+ const Graphics::Font *_font;
+
+private:
+ const Graphics::Font *getDialogFont();
+};
+
+} // End of namespace Wage
+
+#endif
diff --git a/engines/wage/module.mk b/engines/wage/module.mk
index 798e5b5..d2a4be4 100644
--- a/engines/wage/module.mk
+++ b/engines/wage/module.mk
@@ -4,6 +4,7 @@ MODULE_OBJS := \
combat.o \
design.o \
detection.o \
+ dialog.o \
entities.o \
gui.o \
menu.o \
Commit: 876036230246418aa86711d33f485f5c83e769c4
https://github.com/scummvm/scummvm/commit/876036230246418aa86711d33f485f5c83e769c4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:48+01:00
Commit Message:
WAGE: Draw dialog
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
engines/wage/dialog.cpp
engines/wage/dialog.h
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 3db9d27..8e5c753 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -443,11 +443,11 @@ void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in) {
}
void Design::drawRect(Graphics::Surface *surface, Common::Rect &rect, int thickness, int color, Patterns &patterns, byte fillType) {
+ drawRect(surface, rect.left, rect.top, rect.right, rect.bottom, thickness, color, patterns, fillType);
+}
+
+void Design::drawRect(Graphics::Surface *surface, int x1, int y1, int x2, int y2, int thickness, int color, Patterns &patterns, byte fillType) {
plotData pd(surface, &patterns, fillType, thickness);
- int x1 = rect.left;
- int y1 = rect.top;
- int x2 = rect.right;
- int y2 = rect.bottom;
Graphics::drawLine(x1, y1, x2, y1, kColorBlack, drawPixel, &pd);
Graphics::drawLine(x2, y1, x2, y2, kColorBlack, drawPixel, &pd);
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 26f832e..d98d30c 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -70,6 +70,7 @@ public:
void paint(Graphics::Surface *canvas, Patterns &patterns, int x, int y);
bool isPointOpaque(int x, int y);
static void drawRect(Graphics::Surface *surface, Common::Rect &rect, int thickness, int color, Patterns &patterns, byte fillType);
+ static void drawRect(Graphics::Surface *surface, int x1, int y1, int x2, int y2, int thickness, int color, Patterns &patterns, byte fillType);
static void drawFilledRect(Graphics::Surface *surface, Common::Rect &rect, int color, Patterns &patterns, byte fillType);
static void drawFilledRoundRect(Graphics::Surface *surface, Common::Rect &rect, int arc, int color, Patterns &patterns, byte fillType);
static void drawHLine(Graphics::Surface *surface, int x1, int x2, int y, int thickness, int color, Patterns &patterns, byte fillType);
diff --git a/engines/wage/dialog.cpp b/engines/wage/dialog.cpp
index 665bf52..eb29f80 100644
--- a/engines/wage/dialog.cpp
+++ b/engines/wage/dialog.cpp
@@ -48,18 +48,34 @@
#include "common/system.h"
#include "wage/wage.h"
+#include "wage/design.h"
#include "wage/gui.h"
#include "wage/dialog.h"
namespace Wage {
-Dialog::Dialog(Gui *gui) : _gui(gui) {
+enum {
+ kDialogWidth = 292,
+ kDialogHeight = 114
+};
+
+Dialog::Dialog(Gui *gui, const char *text, DialogButtonArray *buttons) : _gui(gui), _text(text), _buttons(buttons) {
assert(_gui->_engine);
assert(_gui->_engine->_world);
_font = getDialogFont();
- _tempSurface.create(_gui->_screen.w, _font->getFontHeight(), Graphics::PixelFormat::createFormatCLUT8());
+ _tempSurface.create(kDialogWidth, kDialogHeight, Graphics::PixelFormat::createFormatCLUT8());
+
+ _bbox.left = (_gui->_screen.w - kDialogWidth) / 2;
+ _bbox.top = (_gui->_screen.h - kDialogHeight) / 2;
+ _bbox.right = (_gui->_screen.w + kDialogWidth) / 2;
+ _bbox.bottom = (_gui->_screen.h + kDialogHeight) / 2;
+
+ _defaultButton = NULL;
+ _pressedButton = NULL;
+
+ _mouseOverPressedButton = false;
}
Dialog::~Dialog() {
@@ -69,4 +85,51 @@ const Graphics::Font *Dialog::getDialogFont() {
return _gui->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
}
+void Dialog::paint() {
+ Design::drawFilledRect(&_gui->_screen, _bbox, kColorWhite, _gui->_patterns, kPatternSolid);
+ _font->drawString(&_gui->_screen, _text, _bbox.left + 24, _bbox.right + 32, _bbox.width(), kColorBlack);
+
+ static int boxOutline[] = { 1, 0, 0, 1, 1 };
+ drawOutline(_bbox, boxOutline, ARRAYSIZE(boxOutline));
+
+ for (int i = 0; i < _buttons->size(); i++) {
+ DialogButton *button = _buttons->operator[](i);
+ static int buttonOutline[] = { 0, 0, 0, 0, 1 };
+
+ if (button == _defaultButton) {
+ buttonOutline[0] = buttonOutline[1] = 1;
+ } else {
+ buttonOutline[0] = buttonOutline[1] = 0;
+ }
+
+ int color = kColorBlack;
+
+ if (_pressedButton == button && _mouseOverPressedButton) {
+ Common::Rect bb(button->bounds.left + 5, button->bounds.top + 5,
+ button->bounds.right - 5, button->bounds.bottom - 5);
+
+ Design::drawFilledRect(&_gui->_screen, bb, kColorBlack, _gui->_patterns, kPatternSolid);
+
+ color = kColorWhite;
+ }
+ int w = _font->getStringWidth(button->text);
+ int x = button->bounds.left + (button->bounds.width() - w) / 2;
+ int y = button->bounds.top + 19;
+
+ _font->drawString(&_gui->_screen, button->text, _bbox.left + x, _bbox.right + y, _bbox.width(), color);
+
+ drawOutline(button->bounds, buttonOutline, ARRAYSIZE(buttonOutline));
+ }
+
+ g_system->copyRectToScreen(_gui->_screen.getBasePtr(_bbox.left, _bbox.top), _gui->_screen.pitch,
+ _bbox.left, _bbox.top, _bbox.width(), _bbox.height());
+}
+
+void Dialog::drawOutline(Common::Rect &bounds, int *spec, int speclen) {
+ for (int i = 0; i < speclen; i++)
+ if (spec[i] != 0)
+ Design::drawRect(&_gui->_screen, bounds.left + i, bounds.top + i, bounds.right - 1 - 2*i, bounds.bottom - 1 - 2*i,
+ 1, kColorBlack, _gui->_patterns, kPatternSolid);
+}
+
} // End of namespace Wage
diff --git a/engines/wage/dialog.h b/engines/wage/dialog.h
index 63f7ded..747d9de 100644
--- a/engines/wage/dialog.h
+++ b/engines/wage/dialog.h
@@ -50,19 +50,34 @@
namespace Wage {
+struct DialogButton {
+ Common::String text;
+ Common::Rect bounds;
+};
+
+typedef Common::Array<DialogButton *> DialogButtonArray;
+
class Dialog {
public:
- Dialog(Gui *gui);
+ Dialog(Gui *gui, const char *text, DialogButtonArray *buttons);
~Dialog();
private:
Gui *_gui;
Graphics::Surface _tempSurface;
+ Common::Rect _bbox;
+ Common::String _text;
const Graphics::Font *_font;
+ DialogButtonArray *_buttons;
+ DialogButton *_pressedButton;
+ DialogButton *_defaultButton;
+ bool _mouseOverPressedButton;
private:
const Graphics::Font *getDialogFont();
+ void drawOutline(Common::Rect &bounds, int *spec, int speclen);
+ void paint();
};
} // End of namespace Wage
Commit: 750e44219f246c404b44170001287b1ffb64ec89
https://github.com/scummvm/scummvm/commit/750e44219f246c404b44170001287b1ffb64ec89
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:48+01:00
Commit Message:
WAGE: Dialog loop
Changed paths:
engines/wage/dialog.cpp
engines/wage/dialog.h
engines/wage/wage.cpp
engines/wage/wage.h
diff --git a/engines/wage/dialog.cpp b/engines/wage/dialog.cpp
index eb29f80..abd4d1b 100644
--- a/engines/wage/dialog.cpp
+++ b/engines/wage/dialog.cpp
@@ -46,6 +46,7 @@
*/
#include "common/system.h"
+#include "common/events.h"
#include "wage/wage.h"
#include "wage/design.h"
@@ -132,4 +133,27 @@ void Dialog::drawOutline(Common::Rect &bounds, int *spec, int speclen) {
1, kColorBlack, _gui->_patterns, kPatternSolid);
}
+void Dialog::run() {
+ bool shouldQuit = false;
+
+ paint();
+
+ while (!shouldQuit) {
+ Common::Event event;
+
+ while (_gui->_engine->_eventMan->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_QUIT:
+ shouldQuit = true;
+ break;
+ default:
+ break;
+ }
+ }
+
+ g_system->updateScreen();
+ g_system->delayMillis(50);
+ }
+}
+
} // End of namespace Wage
diff --git a/engines/wage/dialog.h b/engines/wage/dialog.h
index 747d9de..7983417 100644
--- a/engines/wage/dialog.h
+++ b/engines/wage/dialog.h
@@ -53,6 +53,14 @@ namespace Wage {
struct DialogButton {
Common::String text;
Common::Rect bounds;
+
+ DialogButton(const char *t, int x1, int y1, int x2, int y2) {
+ text = t;
+ bounds.left = x1;
+ bounds.top = y1;
+ bounds.right = x2;
+ bounds.bottom = y2;
+ }
};
typedef Common::Array<DialogButton *> DialogButtonArray;
@@ -62,6 +70,8 @@ public:
Dialog(Gui *gui, const char *text, DialogButtonArray *buttons);
~Dialog();
+ void run();
+
private:
Gui *_gui;
Graphics::Surface _tempSurface;
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index db7e364..b8d0977 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -54,6 +54,7 @@
#include "wage/wage.h"
#include "wage/entities.h"
#include "wage/gui.h"
+#include "wage/dialog.h"
#include "wage/script.h"
#include "wage/world.h"
@@ -139,6 +140,7 @@ void WageEngine::processEvents() {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_QUIT:
+ gameOver();
_shouldQuit = true;
break;
case Common::EVENT_MOUSEMOVE:
@@ -217,7 +219,15 @@ void WageEngine::appendText(char *str) {
}
void WageEngine::gameOver() {
- warning("STUB: WageEngine::gameOver()");
+ DialogButtonArray buttons;
+
+ buttons.push_back(new DialogButton("OK", 112, 67, 68, 28));
+
+ Dialog gameOver(_gui, _world->_gameOverMessage->c_str(), &buttons);
+
+ gameOver.run();
+
+ doClose();
}
void WageEngine::performInitialSetup() {
@@ -278,6 +288,10 @@ void WageEngine::performInitialSetup() {
}
}
+void WageEngine::doClose() {
+ warning("STUB: doClose()");
+}
+
Scene *WageEngine::getSceneByName(String &location) {
Scene *scene;
if (location.equals("random@")) {
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 245fc9b..0d540d3 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -63,6 +63,7 @@ namespace Wage {
class Console;
class Chr;
class Designed;
+class Dialog;
class Gui;
class Obj;
class Scene;
@@ -107,6 +108,7 @@ const char *getGenderSpecificPronoun(int gender, bool capitalize);
typedef Common::Array<byte *> Patterns;
class WageEngine : public Engine {
+ friend class Dialog;
public:
WageEngine(OSystem *syst, const ADGameDescription *gameDesc);
~WageEngine();
@@ -135,6 +137,8 @@ private:
void performOffer(Chr *attacker, Chr *victim);
void performTake(Chr *npc, Obj *obj);
+ void doClose();
+
public:
Common::RandomSource *_rnd;
Commit: efdf51d3ddbb89f2fc1858c9f13ee6bb1a8b005a
https://github.com/scummvm/scummvm/commit/efdf51d3ddbb89f2fc1858c9f13ee6bb1a8b005a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:49+01:00
Commit Message:
WAGE: Draw gameover dialog
Changed paths:
engines/wage/dialog.cpp
engines/wage/dialog.h
engines/wage/wage.cpp
diff --git a/engines/wage/dialog.cpp b/engines/wage/dialog.cpp
index abd4d1b..a02058c 100644
--- a/engines/wage/dialog.cpp
+++ b/engines/wage/dialog.cpp
@@ -56,8 +56,8 @@
namespace Wage {
enum {
- kDialogWidth = 292,
- kDialogHeight = 114
+ kDialogWidth = 199,
+ kDialogHeight = 113
};
Dialog::Dialog(Gui *gui, const char *text, DialogButtonArray *buttons) : _gui(gui), _text(text), _buttons(buttons) {
@@ -73,10 +73,17 @@ Dialog::Dialog(Gui *gui, const char *text, DialogButtonArray *buttons) : _gui(gu
_bbox.right = (_gui->_screen.w + kDialogWidth) / 2;
_bbox.bottom = (_gui->_screen.h + kDialogHeight) / 2;
- _defaultButton = NULL;
- _pressedButton = NULL;
+ _defaultButton = -1;
+ _pressedButton = -1;
_mouseOverPressedButton = false;
+
+ // Adjust button positions
+ for (int i = 0; i < _buttons->size(); i++)
+ _buttons->operator[](i)->bounds.translate(_bbox.left, _bbox.top);
+
+ if (_buttons->size() == 1)
+ _defaultButton = 0;
}
Dialog::~Dialog() {
@@ -88,7 +95,7 @@ const Graphics::Font *Dialog::getDialogFont() {
void Dialog::paint() {
Design::drawFilledRect(&_gui->_screen, _bbox, kColorWhite, _gui->_patterns, kPatternSolid);
- _font->drawString(&_gui->_screen, _text, _bbox.left + 24, _bbox.right + 32, _bbox.width(), kColorBlack);
+ _font->drawString(&_gui->_screen, _text, _bbox.left + 24, _bbox.top + 16, _bbox.width(), kColorBlack);
static int boxOutline[] = { 1, 0, 0, 1, 1 };
drawOutline(_bbox, boxOutline, ARRAYSIZE(boxOutline));
@@ -97,7 +104,7 @@ void Dialog::paint() {
DialogButton *button = _buttons->operator[](i);
static int buttonOutline[] = { 0, 0, 0, 0, 1 };
- if (button == _defaultButton) {
+ if (i == _defaultButton) {
buttonOutline[0] = buttonOutline[1] = 1;
} else {
buttonOutline[0] = buttonOutline[1] = 0;
@@ -105,7 +112,7 @@ void Dialog::paint() {
int color = kColorBlack;
- if (_pressedButton == button && _mouseOverPressedButton) {
+ if (i == _pressedButton && _mouseOverPressedButton) {
Common::Rect bb(button->bounds.left + 5, button->bounds.top + 5,
button->bounds.right - 5, button->bounds.bottom - 5);
@@ -115,21 +122,21 @@ void Dialog::paint() {
}
int w = _font->getStringWidth(button->text);
int x = button->bounds.left + (button->bounds.width() - w) / 2;
- int y = button->bounds.top + 19;
+ int y = button->bounds.top + 6;
- _font->drawString(&_gui->_screen, button->text, _bbox.left + x, _bbox.right + y, _bbox.width(), color);
+ _font->drawString(&_gui->_screen, button->text, x, y, _bbox.width(), color);
drawOutline(button->bounds, buttonOutline, ARRAYSIZE(buttonOutline));
}
g_system->copyRectToScreen(_gui->_screen.getBasePtr(_bbox.left, _bbox.top), _gui->_screen.pitch,
- _bbox.left, _bbox.top, _bbox.width(), _bbox.height());
+ _bbox.left, _bbox.top, _bbox.width() + 1, _bbox.height() + 1);
}
void Dialog::drawOutline(Common::Rect &bounds, int *spec, int speclen) {
for (int i = 0; i < speclen; i++)
if (spec[i] != 0)
- Design::drawRect(&_gui->_screen, bounds.left + i, bounds.top + i, bounds.right - 1 - 2*i, bounds.bottom - 1 - 2*i,
+ Design::drawRect(&_gui->_screen, bounds.left + i, bounds.top + i, bounds.right - i, bounds.bottom - i,
1, kColorBlack, _gui->_patterns, kPatternSolid);
}
diff --git a/engines/wage/dialog.h b/engines/wage/dialog.h
index 7983417..6e972e2 100644
--- a/engines/wage/dialog.h
+++ b/engines/wage/dialog.h
@@ -54,12 +54,12 @@ struct DialogButton {
Common::String text;
Common::Rect bounds;
- DialogButton(const char *t, int x1, int y1, int x2, int y2) {
+ DialogButton(const char *t, int x1, int y1, int w, int h) {
text = t;
bounds.left = x1;
bounds.top = y1;
- bounds.right = x2;
- bounds.bottom = y2;
+ bounds.right = x1 + w - 1;
+ bounds.bottom = y1 + h - 1;
}
};
@@ -80,8 +80,8 @@ private:
const Graphics::Font *_font;
DialogButtonArray *_buttons;
- DialogButton *_pressedButton;
- DialogButton *_defaultButton;
+ int _pressedButton;
+ int _defaultButton;
bool _mouseOverPressedButton;
private:
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index b8d0977..9cb3a01 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -140,7 +140,6 @@ void WageEngine::processEvents() {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_QUIT:
- gameOver();
_shouldQuit = true;
break;
case Common::EVENT_MOUSEMOVE:
@@ -221,7 +220,7 @@ void WageEngine::appendText(char *str) {
void WageEngine::gameOver() {
DialogButtonArray buttons;
- buttons.push_back(new DialogButton("OK", 112, 67, 68, 28));
+ buttons.push_back(new DialogButton("OK", 66, 67, 68, 28));
Dialog gameOver(_gui, _world->_gameOverMessage->c_str(), &buttons);
Commit: c7eed7f0ad4b3c23694c1b97578a4b8b86be54f9
https://github.com/scummvm/scummvm/commit/c7eed7f0ad4b3c23694c1b97578a4b8b86be54f9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:49+01:00
Commit Message:
WAGE: Implement getWeapons(). Got rid of class Weapon
Changed paths:
engines/wage/combat.cpp
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/menu.cpp
engines/wage/script.cpp
engines/wage/script.h
engines/wage/wage.h
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index 17b03d1..be765a8 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -106,7 +106,7 @@ void WageEngine::performCombatAction(Chr *npc, Chr *player) {
bool winning = (npc->_context._statVariables[PHYS_HIT_CUR] > player->_context._statVariables[PHYS_HIT_CUR]);
int validMoves = getValidMoveDirections(npc);
- WeaponArray *weapons = npc->getWeapons(false);
+ ObjArray *weapons = npc->getWeapons(false);
ObjArray *magics = npc->getMagicalObjects();
// TODO: Figure out under what circumstances we need to add +1
// for the chance (e.g. only when all values were set to 0?).
@@ -177,7 +177,7 @@ void WageEngine::performCombatAction(Chr *npc, Chr *player) {
delete magics;
}
-void WageEngine::performAttack(Chr *attacker, Chr *victim, Weapon *weapon) {
+void WageEngine::performAttack(Chr *attacker, Chr *victim, Obj *weapon) {
warning("STUB: performAttack()");
}
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 7f40353..0503b85 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -361,6 +361,32 @@ Chr::Chr(String name, Common::SeekableReadStream *data) {
for (int i = 0; i < NUMBER_OF_ARMOR_TYPES; i++)
_armor[i] = NULL;
+ _weapon1 = NULL;
+ _weapon2 = NULL;
+
+ // Create native weapons
+ if (_nativeWeapon1.size() && _operativeVerb1.size()) {
+ _weapon1 = new Obj;
+
+ _weapon1->_name = _nativeWeapon1;
+ _weapon1->_operativeVerb = _operativeVerb1;
+ _weapon1->_type = Obj::REGULAR_WEAPON;
+ _weapon1->_accuracy = 0;
+ _weapon1->_damage = _weaponDamage1;
+ _weapon1->_sound = _weaponSound1;
+ }
+
+ if (_nativeWeapon2.size() && _operativeVerb2.size()) {
+ _weapon2 = new Obj;
+
+ _weapon2->_name = _nativeWeapon2;
+ _weapon2->_operativeVerb = _operativeVerb2;
+ _weapon2->_type = Obj::REGULAR_WEAPON;
+ _weapon2->_accuracy = 0;
+ _weapon2->_damage = _weaponDamage2;
+ _weapon2->_sound = _weaponSound2;
+ }
+
delete data;
}
@@ -378,10 +404,28 @@ void Chr::resetState() {
_context._statVariables[PHYS_SPE_BAS] = _context._statVariables[PHYS_SPE_CUR] = _runningSpeed;
}
-WeaponArray *Chr::getWeapons(bool includeMagic) {
- WeaponArray *list = new WeaponArray;
+ObjArray *Chr::getWeapons(bool includeMagic) {
+ ObjArray *list = new ObjArray;
+
+ if (_weapon1)
+ list->push_back(_weapon1);
+
+ if (_weapon2)
+ list->push_back(_weapon2);
- warning("STUB: getWeapons");
+ for (uint i = 0; i < _inventory.size(); i++)
+ switch (_inventory[i]->_type) {
+ case Obj::REGULAR_WEAPON:
+ case Obj::THROW_WEAPON:
+ list->push_back(_inventory[i]);
+ break;
+ case Obj::MAGICAL_OBJECT:
+ if (includeMagic)
+ list->push_back(_inventory[i]);
+ break;
+ default:
+ break;
+ }
return list;
}
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 6a97abf..5fc1a08 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -58,9 +58,7 @@ class Design;
class Obj;
class Scene;
class Script;
-class Weapon;
-typedef Common::Array<Weapon *> WeaponArray;
typedef Common::Array<Obj *> ObjArray;
typedef Common::Array<Chr *> ChrArray;
typedef Common::List<Obj *> ObjList;
@@ -219,18 +217,14 @@ public:
Context _context;
- WeaponArray *getWeapons(bool includeMagic);
+ ObjArray *getWeapons(bool includeMagic);
ObjArray *getMagicalObjects();
const char *getDefiniteArticle(bool capitalize);
-public:
- bool hasNativeWeapon1() {
- return (_nativeWeapon1.size() > 0 && _operativeVerb1.size() > 0);
- }
+ Obj *_weapon1;
+ Obj *_weapon2;
- bool hasNativeWeapon2() {
- return (_nativeWeapon2.size() > 0 && _operativeVerb2.size() > 0);
- }
+public:
int wearObjIfPossible(Obj *obj);
void wearObjs();
@@ -299,21 +293,13 @@ public:
_currentOwner = NULL;
}
- Chr *removeFromChr();
- Designed *removeFromCharOrScene();
-};
-
-class Weapon : public Obj {
-public:
- int _numberOfUses;
-
- Weapon() : _numberOfUses(0) {}
-
void decrementNumberOfUses() {
- if (_numberOfUses != -1) {
+ if (_numberOfUses != -1)
_numberOfUses--;
- }
}
+
+ Chr *removeFromChr();
+ Designed *removeFromCharOrScene();
};
class Scene : public Designed {
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 0577ad5..e9cecfc 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -278,10 +278,10 @@ void Menu::regenWeaponsMenu() {
void Menu::createWeaponsMenu(MenuItem *menu) {
Chr *player = _gui->_engine->_world->_player;
- WeaponArray *weapons = player->getWeapons(true);
+ ObjArray *weapons = player->getWeapons(true);
for (int i = 0; i < weapons->size(); i++) {
- Weapon *obj = (*weapons)[i];
+ Obj *obj = (*weapons)[i];
if (obj->_type == Obj::REGULAR_WEAPON ||
obj->_type == Obj::THROW_WEAPON ||
obj->_type == Obj::MAGICAL_OBJECT) {
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 6ccb7b3..52e0dbf 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -199,8 +199,8 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
handleAcceptCommand();
} else {
Chr *player = _world->_player;
- WeaponArray *weapons = player->getWeapons(true);
- for (WeaponArray::const_iterator weapon = weapons->begin(); weapon != weapons->end(); ++weapon) {
+ ObjArray *weapons = player->getWeapons(true);
+ for (ObjArray::const_iterator weapon = weapons->begin(); weapon != weapons->end(); ++weapon) {
if (tryAttack(*weapon, input)) {
handleAttack(*weapon);
break;
@@ -1076,13 +1076,13 @@ void Script::handleOfferCommand(const char *target) {
warning("STUB: handleOfferCommand");
}
-bool Script::tryAttack(Weapon *weapon, Common::String &input) {
+bool Script::tryAttack(Obj *weapon, Common::String &input) {
warning("STUB: tryAttack");
return false;
}
-void Script::handleAttack(Weapon *weapon) {
+void Script::handleAttack(Obj *weapon) {
warning("STUB: handleAttack");
}
diff --git a/engines/wage/script.h b/engines/wage/script.h
index ed27725..788188d 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -186,8 +186,8 @@ private:
void handleWearCommand(const char *target);
void handleOfferCommand(const char *target);
- bool tryAttack(Weapon *weapon, Common::String &input);
- void handleAttack(Weapon *weapon);
+ bool tryAttack(Obj *weapon, Common::String &input);
+ void handleAttack(Obj *weapon);
Common::Array<ScriptText *> _scriptText;
void convertToText();
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 0d540d3..06304d0 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -67,7 +67,6 @@ class Dialog;
class Gui;
class Obj;
class Scene;
-class Weapon;
class World;
using Common::String;
@@ -131,7 +130,7 @@ private:
void processTurnInternal(Common::String *textInput, Designed *clickInput);
void performCombatAction(Chr *npc, Chr *player);
int getValidMoveDirections(Chr *npc);
- void performAttack(Chr *attacker, Chr *victim, Weapon *weapon);
+ void performAttack(Chr *attacker, Chr *victim, Obj *weapon);
void performMagic(Chr *attacker, Chr *victim, Obj *magicalObject);
void performMove(Chr *chr, int validMoves);
void performOffer(Chr *attacker, Chr *victim);
Commit: 936609fb11e9a75f7cb5b2f0d5e22c94a7e0ff80
https://github.com/scummvm/scummvm/commit/936609fb11e9a75f7cb5b2f0d5e22c94a7e0ff80
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:49+01:00
Commit Message:
WAGE: Implemented saveDialog()
Changed paths:
engines/wage/dialog.cpp
engines/wage/dialog.h
engines/wage/wage.cpp
engines/wage/wage.h
diff --git a/engines/wage/dialog.cpp b/engines/wage/dialog.cpp
index a02058c..b58e4af 100644
--- a/engines/wage/dialog.cpp
+++ b/engines/wage/dialog.cpp
@@ -56,24 +56,23 @@
namespace Wage {
enum {
- kDialogWidth = 199,
kDialogHeight = 113
};
-Dialog::Dialog(Gui *gui, const char *text, DialogButtonArray *buttons) : _gui(gui), _text(text), _buttons(buttons) {
+Dialog::Dialog(Gui *gui, int width, const char *text, DialogButtonArray *buttons, int defaultButton) :
+ _gui(gui), _text(text), _buttons(buttons), _defaultButton(defaultButton) {
assert(_gui->_engine);
assert(_gui->_engine->_world);
_font = getDialogFont();
- _tempSurface.create(kDialogWidth, kDialogHeight, Graphics::PixelFormat::createFormatCLUT8());
+ _tempSurface.create(width, kDialogHeight, Graphics::PixelFormat::createFormatCLUT8());
- _bbox.left = (_gui->_screen.w - kDialogWidth) / 2;
+ _bbox.left = (_gui->_screen.w - width) / 2;
_bbox.top = (_gui->_screen.h - kDialogHeight) / 2;
- _bbox.right = (_gui->_screen.w + kDialogWidth) / 2;
+ _bbox.right = (_gui->_screen.w + width) / 2;
_bbox.bottom = (_gui->_screen.h + kDialogHeight) / 2;
- _defaultButton = -1;
_pressedButton = -1;
_mouseOverPressedButton = false;
@@ -81,9 +80,6 @@ Dialog::Dialog(Gui *gui, const char *text, DialogButtonArray *buttons) : _gui(gu
// Adjust button positions
for (int i = 0; i < _buttons->size(); i++)
_buttons->operator[](i)->bounds.translate(_bbox.left, _bbox.top);
-
- if (_buttons->size() == 1)
- _defaultButton = 0;
}
Dialog::~Dialog() {
@@ -151,8 +147,11 @@ void Dialog::run() {
while (_gui->_engine->_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_QUIT:
+ _gui->_engine->_shouldQuit = true;
shouldQuit = true;
break;
+ case Common::EVENT_MOUSEMOVE:
+
default:
break;
}
diff --git a/engines/wage/dialog.h b/engines/wage/dialog.h
index 6e972e2..1dc7777 100644
--- a/engines/wage/dialog.h
+++ b/engines/wage/dialog.h
@@ -67,7 +67,7 @@ typedef Common::Array<DialogButton *> DialogButtonArray;
class Dialog {
public:
- Dialog(Gui *gui, const char *text, DialogButtonArray *buttons);
+ Dialog(Gui *gui, int width, const char *text, DialogButtonArray *buttons, int defaultButton);
~Dialog();
void run();
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 9cb3a01..9ecd4c7 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -140,6 +140,7 @@ void WageEngine::processEvents() {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_QUIT:
+ saveDialog();
_shouldQuit = true;
break;
case Common::EVENT_MOUSEMOVE:
@@ -222,13 +223,27 @@ void WageEngine::gameOver() {
buttons.push_back(new DialogButton("OK", 66, 67, 68, 28));
- Dialog gameOver(_gui, _world->_gameOverMessage->c_str(), &buttons);
+ Dialog gameOver(_gui, 199, _world->_gameOverMessage->c_str(), &buttons, 0);
gameOver.run();
doClose();
}
+void WageEngine::saveDialog() {
+ DialogButtonArray buttons;
+
+ buttons.push_back(new DialogButton("No", 19, 67, 68, 28));
+ buttons.push_back(new DialogButton("Yes", 112, 67, 68, 28));
+ buttons.push_back(new DialogButton("Cancel", 205, 67, 68, 28));
+
+ Dialog save(_gui, 291, "Save changes before closing?", &buttons, 1);
+
+ save.run();
+
+ doClose();
+}
+
void WageEngine::performInitialSetup() {
debug(5, "Resetting Objs: %d", _world->_orderedObjs.size());
for (uint i = 0; i < _world->_orderedObjs.size() - 1; i++)
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 06304d0..122eced 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -162,6 +162,7 @@ public:
void appendText(String &str);
void appendText(char *str);
void gameOver();
+ void saveDialog();
Obj *getOffer();
Chr *getMonster();
void processEvents();
Commit: ad02d2eb953f721049623242366f7e15539746ad
https://github.com/scummvm/scummvm/commit/ad02d2eb953f721049623242366f7e15539746ad
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:49+01:00
Commit Message:
WAGE: Implement dialog interaction
Changed paths:
engines/wage/dialog.cpp
engines/wage/dialog.h
diff --git a/engines/wage/dialog.cpp b/engines/wage/dialog.cpp
index b58e4af..88b2c65 100644
--- a/engines/wage/dialog.cpp
+++ b/engines/wage/dialog.cpp
@@ -66,7 +66,7 @@ Dialog::Dialog(Gui *gui, int width, const char *text, DialogButtonArray *buttons
_font = getDialogFont();
- _tempSurface.create(width, kDialogHeight, Graphics::PixelFormat::createFormatCLUT8());
+ _tempSurface.create(width + 1, kDialogHeight + 1, Graphics::PixelFormat::createFormatCLUT8());
_bbox.left = (_gui->_screen.w - width) / 2;
_bbox.top = (_gui->_screen.h - kDialogHeight) / 2;
@@ -80,6 +80,8 @@ Dialog::Dialog(Gui *gui, int width, const char *text, DialogButtonArray *buttons
// Adjust button positions
for (int i = 0; i < _buttons->size(); i++)
_buttons->operator[](i)->bounds.translate(_bbox.left, _bbox.top);
+
+ _needsRedraw = true;
}
Dialog::~Dialog() {
@@ -127,6 +129,8 @@ void Dialog::paint() {
g_system->copyRectToScreen(_gui->_screen.getBasePtr(_bbox.left, _bbox.top), _gui->_screen.pitch,
_bbox.left, _bbox.top, _bbox.width() + 1, _bbox.height() + 1);
+
+ _needsRedraw = false;
}
void Dialog::drawOutline(Common::Rect &bounds, int *spec, int speclen) {
@@ -136,10 +140,14 @@ void Dialog::drawOutline(Common::Rect &bounds, int *spec, int speclen) {
1, kColorBlack, _gui->_patterns, kPatternSolid);
}
-void Dialog::run() {
+int Dialog::run() {
bool shouldQuit = false;
+ Common::Rect r(_bbox);
- paint();
+ r.right++;
+ r.bottom++;
+
+ _gui->_screen.copyRectToSurface(_tempSurface, r.left, r.top, r);
while (!shouldQuit) {
Common::Event event;
@@ -151,15 +159,82 @@ void Dialog::run() {
shouldQuit = true;
break;
case Common::EVENT_MOUSEMOVE:
-
+ mouseMove(event.mouse.x, event.mouse.y);
+ break;
+ case Common::EVENT_LBUTTONDOWN:
+ mouseClick(event.mouse.x, event.mouse.y);
+ break;
+ case Common::EVENT_LBUTTONUP:
+ shouldQuit = mouseRaise(event.mouse.x, event.mouse.y);
+ break;
+ case Common::EVENT_KEYDOWN:
+ switch (event.kbd.keycode) {
+ case Common::KEYCODE_ESCAPE:
+ _pressedButton = -1;
+ shouldQuit = true;
+ default:
+ break;
+ }
+ break;
default:
break;
}
}
+ if (_needsRedraw)
+ paint();
+
g_system->updateScreen();
g_system->delayMillis(50);
}
+
+ _tempSurface.copyRectToSurface(_gui->_screen, r.left, r.top, r);
+
+ return _pressedButton;
+}
+
+int Dialog::matchButton(int x, int y) {
+ for (int i = 0; i < _buttons->size(); i++)
+ if (_buttons->operator[](i)->bounds.contains(x, y))
+ return i;
+
+ return -1;
+}
+
+void Dialog::mouseMove(int x, int y) {
+ if (_pressedButton != -1) {
+ int match = matchButton(x, y);
+
+ if (_mouseOverPressedButton && match != _pressedButton) {
+ _mouseOverPressedButton = false;
+ _needsRedraw = true;
+ } else if (!_mouseOverPressedButton && match == _pressedButton) {
+ _mouseOverPressedButton = true;
+ _needsRedraw = true;
+ }
+ }
+}
+
+void Dialog::mouseClick(int x, int y) {
+ int match = matchButton(x, y);
+
+ if (match) {
+ _pressedButton = match;
+ _mouseOverPressedButton = true;
+
+ _needsRedraw = true;
+ }
+}
+
+int Dialog::mouseRaise(int x, int y) {
+ bool res = false;
+
+ if (_pressedButton != -1) {
+ if (matchButton(x, y) == _pressedButton)
+ res = true;
+ }
+
+ return res;
}
} // End of namespace Wage
diff --git a/engines/wage/dialog.h b/engines/wage/dialog.h
index 1dc7777..544b457 100644
--- a/engines/wage/dialog.h
+++ b/engines/wage/dialog.h
@@ -70,7 +70,7 @@ public:
Dialog(Gui *gui, int width, const char *text, DialogButtonArray *buttons, int defaultButton);
~Dialog();
- void run();
+ int run();
private:
Gui *_gui;
@@ -84,10 +84,16 @@ private:
int _defaultButton;
bool _mouseOverPressedButton;
+ bool _needsRedraw;
+
private:
const Graphics::Font *getDialogFont();
void drawOutline(Common::Rect &bounds, int *spec, int speclen);
void paint();
+ void mouseMove(int x, int y);
+ void mouseClick(int x, int y);
+ int mouseRaise(int x, int y);
+ int matchButton(int x, int y);
};
} // End of namespace Wage
Commit: 632825d71bb54020c343db4ae45f6af221531557
https://github.com/scummvm/scummvm/commit/632825d71bb54020c343db4ae45f6af221531557
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:49+01:00
Commit Message:
WAGE: Fix crash on menu exiting
Changed paths:
engines/wage/dialog.cpp
diff --git a/engines/wage/dialog.cpp b/engines/wage/dialog.cpp
index 88b2c65..69bef75 100644
--- a/engines/wage/dialog.cpp
+++ b/engines/wage/dialog.cpp
@@ -188,7 +188,7 @@ int Dialog::run() {
g_system->delayMillis(50);
}
- _tempSurface.copyRectToSurface(_gui->_screen, r.left, r.top, r);
+ _tempSurface.copyRectToSurface(_gui->_screen, 0, 0, r);
return _pressedButton;
}
Commit: f11721d036eac47c3e69725f40fb8961093d8869
https://github.com/scummvm/scummvm/commit/f11721d036eac47c3e69725f40fb8961093d8869
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:49+01:00
Commit Message:
WAGE: Proper background restoriation on dialog closing
Changed paths:
engines/wage/dialog.cpp
diff --git a/engines/wage/dialog.cpp b/engines/wage/dialog.cpp
index 69bef75..3cee886 100644
--- a/engines/wage/dialog.cpp
+++ b/engines/wage/dialog.cpp
@@ -144,10 +144,7 @@ int Dialog::run() {
bool shouldQuit = false;
Common::Rect r(_bbox);
- r.right++;
- r.bottom++;
-
- _gui->_screen.copyRectToSurface(_tempSurface, r.left, r.top, r);
+ _tempSurface.copyRectToSurface(_gui->_screen.getBasePtr(_bbox.left, _bbox.top), _gui->_screen.pitch, 0, 0, _bbox.width() + 1, _bbox.height() + 1);
while (!shouldQuit) {
Common::Event event;
@@ -188,7 +185,8 @@ int Dialog::run() {
g_system->delayMillis(50);
}
- _tempSurface.copyRectToSurface(_gui->_screen, 0, 0, r);
+ _gui->_screen.copyRectToSurface(_tempSurface.getBasePtr(0, 0), _tempSurface.pitch, _bbox.left, _bbox.top, _bbox.width() + 1, _bbox.height() + 1);
+ g_system->copyRectToScreen(_gui->_screen.getBasePtr(r.left, r.top), _gui->_screen.pitch, r.left, r.top, r.width() + 1, r.height() + 1);
return _pressedButton;
}
@@ -218,7 +216,7 @@ void Dialog::mouseMove(int x, int y) {
void Dialog::mouseClick(int x, int y) {
int match = matchButton(x, y);
- if (match) {
+ if (match != -1) {
_pressedButton = match;
_mouseOverPressedButton = true;
Commit: 6c205ad46df457c6e2dca56413c85a0e7a424ec4
https://github.com/scummvm/scummvm/commit/6c205ad46df457c6e2dca56413c85a0e7a424ec4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:50+01:00
Commit Message:
WAGE: Made save dialog functional
Changed paths:
engines/wage/wage.cpp
engines/wage/wage.h
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 9ecd4c7..620f1b5 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -140,8 +140,8 @@ void WageEngine::processEvents() {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_QUIT:
- saveDialog();
- _shouldQuit = true;
+ if (saveDialog())
+ _shouldQuit = true;
break;
case Common::EVENT_MOUSEMOVE:
_gui->mouseMove(event.mouse.x, event.mouse.y);
@@ -230,7 +230,7 @@ void WageEngine::gameOver() {
doClose();
}
-void WageEngine::saveDialog() {
+bool WageEngine::saveDialog() {
DialogButtonArray buttons;
buttons.push_back(new DialogButton("No", 19, 67, 68, 28));
@@ -239,9 +239,21 @@ void WageEngine::saveDialog() {
Dialog save(_gui, 291, "Save changes before closing?", &buttons, 1);
- save.run();
+ int button = save.run();
+
+ if (button == 2) // Cancel
+ return false;
+
+ if (button == 1)
+ saveGame();
doClose();
+
+ return true;
+}
+
+void WageEngine::saveGame() {
+ warning("STUB: saveGame()");
}
void WageEngine::performInitialSetup() {
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 122eced..fa52c24 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -162,7 +162,7 @@ public:
void appendText(String &str);
void appendText(char *str);
void gameOver();
- void saveDialog();
+ bool saveDialog();
Obj *getOffer();
Chr *getMonster();
void processEvents();
@@ -170,6 +170,7 @@ public:
void onMove(Designed *what, Designed *from, Designed *to);
void encounter(Chr *player, Chr *chr);
void redrawScene();
+ void saveGame();
private:
Console *_console;
Commit: c76b7ec63cc9ec61623ec98f4bf1149489fe9e54
https://github.com/scummvm/scummvm/commit/c76b7ec63cc9ec61623ec98f4bf1149489fe9e54
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:50+01:00
Commit Message:
WAGE: Implement performAttack()
Changed paths:
engines/wage/combat.cpp
engines/wage/wage.cpp
engines/wage/wage.h
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index be765a8..5a9426c 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -177,8 +177,66 @@ void WageEngine::performCombatAction(Chr *npc, Chr *player) {
delete magics;
}
+const char *targets[] = { "head", "chest", "side" };
+
void WageEngine::performAttack(Chr *attacker, Chr *victim, Obj *weapon) {
- warning("STUB: performAttack()");
+ if (_world->_weaponMenuDisabled)
+ return;
+
+ // TODO: verify that a player not aiming will always target the chest??
+ int targetIndex = -1;
+ char buf[256];
+
+ if (weapon->_type != Obj::MAGICAL_OBJECT) {
+ if (attacker->_playerCharacter) {
+ targetIndex = _aim;
+ } else {
+ targetIndex = _rnd->getRandomNumber(ARRAYSIZE(targets) - 1);
+ _opponentAim = targetIndex + 1;
+ }
+
+ if (!attacker->_playerCharacter) {
+ snprintf(buf, 256, "%s%s %ss %s%s at %s%s's %s.",
+ attacker->getDefiniteArticle(true), attacker->_name.c_str(),
+ weapon->_operativeVerb.c_str(),
+ prependGenderSpecificPronoun(attacker->_gender), weapon->_name.c_str(),
+ victim->getDefiniteArticle(true), victim->_name.c_str(),
+ targets[targetIndex]);
+ appendText(buf);
+ }
+ } else if (!attacker->_playerCharacter) {
+ snprintf(buf, 256, "%s%s %ss %s%s at %s%s.",
+ attacker->getDefiniteArticle(true), attacker->_name.c_str(),
+ weapon->_operativeVerb.c_str(),
+ prependGenderSpecificPronoun(attacker->_gender), weapon->_name.c_str(),
+ victim->getDefiniteArticle(true), victim->_name.c_str());
+ appendText(buf);
+ }
+
+ playSound(weapon->_sound);
+
+ bool usesDecremented = false;
+ int chance = _rnd->getRandomNumber(255);
+ // TODO: what about obj accuracy
+ if (chance < attacker->_physicalAccuracy) {
+ usesDecremented = attackHit(attacker, victim, weapon, targetIndex);
+ } else if (weapon->_type != Obj::MAGICAL_OBJECT) {
+ appendText((char *)"A miss!");
+ } else if (attacker->_playerCharacter) {
+ appendText((char *)"The spell has no effect.");
+ }
+
+ if (!usesDecremented) {
+ decrementUses(weapon);
+ }
+}
+
+void WageEngine::decrementUses(Obj *obj) {
+ warning("STUB: decrementUses()");
+}
+
+bool WageEngine::attackHit(Chr *attacker, Chr *victim, Obj *weapon, int targetIndex) {
+ warning("STUB: attackHit");
}
void WageEngine::performMagic(Chr *attacker, Chr *victim, Obj *magicalObject) {
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 620f1b5..7815ee0 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -64,6 +64,7 @@ WageEngine::WageEngine(OSystem *syst, const ADGameDescription *desc) : Engine(sy
_rnd = new Common::RandomSource("wage");
_aim = -1;
+ _opponentAim = -1;
_temporarilyHidden = false;
_isGameOver = false;
_monster = NULL;
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index fa52c24..1a0fe76 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -135,6 +135,8 @@ private:
void performMove(Chr *chr, int validMoves);
void performOffer(Chr *attacker, Chr *victim);
void performTake(Chr *npc, Obj *obj);
+ void decrementUses(Obj *obj);
+ bool attackHit(Chr *attacker, Chr *victim, Obj *weapon, int targetIndex);
void doClose();
@@ -151,6 +153,7 @@ public:
Chr *_running;
Obj *_offer;
int _aim;
+ int _opponentAim;
bool _temporarilyHidden;
bool _isGameOver;
bool _commandWasQuick;
Commit: b70ae62d4bc5467e77ff8c1ec15cd526c67787a3
https://github.com/scummvm/scummvm/commit/b70ae62d4bc5467e77ff8c1ec15cd526c67787a3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:50+01:00
Commit Message:
WAGE: Implement performMagic()
Changed paths:
engines/wage/combat.cpp
engines/wage/wage.h
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index 5a9426c..b057b7e 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -237,10 +237,24 @@ void WageEngine::decrementUses(Obj *obj) {
bool WageEngine::attackHit(Chr *attacker, Chr *victim, Obj *weapon, int targetIndex) {
warning("STUB: attackHit");
+
+ return false;
}
void WageEngine::performMagic(Chr *attacker, Chr *victim, Obj *magicalObject) {
- warning("STUB: performMagic()");
+ switch (magicalObject->_attackType) {
+ case Obj::HEALS_PHYSICAL_DAMAGE:
+ case Obj::HEALS_SPIRITUAL_DAMAGE:
+ case Obj::HEALS_PHYSICAL_AND_SPIRITUAL_DAMAGE:
+ performHealingMagic(attacker, magicalObject);
+ return;
+ }
+
+ performAttack(attacker, victim, magicalObject);
+}
+
+void WageEngine::performHealingMagic(Chr *chr, Obj *magicalObject) {
+ warning("STUB: performHealingMagic()");
}
void WageEngine::performMove(Chr *chr, int validMoves) {
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 1a0fe76..e5228e6 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -137,6 +137,7 @@ private:
void performTake(Chr *npc, Obj *obj);
void decrementUses(Obj *obj);
bool attackHit(Chr *attacker, Chr *victim, Obj *weapon, int targetIndex);
+ void performHealingMagic(Chr *chr, Obj *magicalObject);
void doClose();
Commit: b90e9361feaa844b8ca097bcef2a4fc5558e15b1
https://github.com/scummvm/scummvm/commit/b90e9361feaa844b8ca097bcef2a4fc5558e15b1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:50+01:00
Commit Message:
WAGE: Implement handleDropCommand()
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 52e0dbf..ee70709 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -1061,7 +1061,22 @@ void Script::handleTakeCommand(const char *target) {
}
void Script::handleDropCommand(const char *target) {
- warning("STUB: handleDropCommand");
+ Common::String t(target);
+
+ t.toLowercase();
+
+ for (ObjArray::const_iterator it = _world->_player->_inventory.begin(); it != _world->_player->_inventory.end(); ++it) {
+ Common::String n((*it)->_name);
+ n.toLowercase();
+
+ if (t.contains(n)) {
+ char buf[256];
+
+ snprintf(buf, 256, "You no longer have the %s.", (*it)->_name.c_str());
+ _world->move(*it, _world->_player->_currentScene);
+ break;
+ }
+ }
}
void Script::handleAimCommand(const char *target) {
Commit: 3cdc17be949ba72ee185f2c33e1f1949a08a0054
https://github.com/scummvm/scummvm/commit/3cdc17be949ba72ee185f2c33e1f1949a08a0054
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:51+01:00
Commit Message:
WAGE: Implement handleTakeCommand()
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index ee70709..578267f 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -1057,7 +1057,21 @@ void Script::handleAcceptCommand() {
}
void Script::handleTakeCommand(const char *target) {
- warning("STUB: handleTakeCommand");
+ Common::String t(target);
+
+ for (ObjList::const_iterator it = _world->_player->_currentScene->_objs.begin(); it != _world->_player->_currentScene->_objs.end(); ++it) {
+ Common::String n((*it)->_name);
+ n.toLowercase();
+
+ if (t.contains(n)) {
+ if ((*it)->_type == Obj::IMMOBILE_OBJECT) {
+ appendText((char *)"You can't move it.");
+ } else {
+ takeObj(*it);
+ }
+ break;
+ }
+ }
}
void Script::handleDropCommand(const char *target) {
Commit: b066a592ee394b01823d4c94245f27de0ae49799
https://github.com/scummvm/scummvm/commit/b066a592ee394b01823d4c94245f27de0ae49799
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:51+01:00
Commit Message:
WAGE: Implement handleStatusCommand()
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 578267f..71f2cec 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -1029,8 +1029,47 @@ void Script::handleInventoryCommand() {
warning("STUB: handleInventoryCommand");
}
+static const char *armorMessages[] = {
+ "Head protection:",
+ "Chest protection:",
+ "Shield protection:", // TODO: check message
+ "Magical protection:"
+};
+
void Script::handleStatusCommand() {
- warning("STUB: handleStatusCommand");
+ Chr *player = _world->_player;
+ char buf[512];
+
+ snprintf(buf, 512, "Character name: %s%s", player->getDefiniteArticle(false), player->_name.c_str());
+ appendText(buf);
+ snprintf(buf, 512, "Experience: %d", player->_context._experience);
+ appendText(buf);
+
+ int wealth = 0;
+ for (ObjArray::const_iterator it = player->_inventory.begin(); it != player->_inventory.end(); ++it)
+ wealth += (*it)->_value;
+
+ snprintf(buf, 512, "Wealth: %d", wealth);
+ appendText(buf);
+
+ for (int i = 0; i < Chr::NUMBER_OF_ARMOR_TYPES; i++) {
+ if (player->_armor[i] != NULL) {
+ snprintf(buf, 512, "%s %s", armorMessages[i], player->_armor[i]->_name.c_str());
+ appendText(buf);
+ }
+ }
+
+ for (ObjArray::const_iterator it = player->_inventory.begin(); it != player->_inventory.end(); ++it) {
+ int uses = (*it)->_numberOfUses;
+
+ if (uses > 0) {
+ snprintf(buf, 512, "Your %s has %d uses left.", (*it)->_name.c_str(), uses);
+ }
+ }
+
+ printPlayerCondition(player);
+
+ _callbacks->_commandWasQuick = true;
}
void Script::handleRestCommand() {
Commit: 2dc5841fcc843a5c3657acf86c0cdbcc516f9940
https://github.com/scummvm/scummvm/commit/2dc5841fcc843a5c3657acf86c0cdbcc516f9940
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:51+01:00
Commit Message:
WAGE: Implement handleInventoryCommand()
Changed paths:
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/script.cpp
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 0503b85..588a7cf 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -483,4 +483,12 @@ const char *Chr::getDefiniteArticle(bool capitalize) {
return "";
}
+bool Chr::isWearing(Obj *obj) {
+ for (int i = 0; i < NUMBER_OF_ARMOR_TYPES; i++)
+ if (_armor[i] == obj)
+ return true;
+
+ return false;
+}
+
} // End of namespace Wage
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 5fc1a08..b1101f9 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -229,6 +229,8 @@ public:
void wearObjs();
void resetState();
+
+ bool isWearing(Obj *obj);
};
class Obj : public Designed {
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 71f2cec..7ede7ea 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -1026,7 +1026,20 @@ void Script::appendObjNames(Common::String &str, ObjArray &objs) {
}
void Script::handleInventoryCommand() {
- warning("STUB: handleInventoryCommand");
+ Chr *player = _world->_player;
+ ObjArray objs;
+
+ for (ObjArray::const_iterator it = player->_inventory.begin(); it != player->_inventory.end(); ++it)
+ if (!player->isWearing(*it))
+ objs.push_back(*it);
+
+ if (!objs.size()) {
+ appendText("Your pack is empty.");
+ } else {
+ Common::String res("Your pack contains ");
+ appendObjNames(res, objs);
+ appendText(res);
+ }
}
static const char *armorMessages[] = {
Commit: 02374868f7ff8ea8bc3992aa1b6941cdccd44703
https://github.com/scummvm/scummvm/commit/02374868f7ff8ea8bc3992aa1b6941cdccd44703
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:51+01:00
Commit Message:
WAGE: Implement handleAimCommand()
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 7ede7ea..b6a44d1 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -1145,8 +1145,25 @@ void Script::handleDropCommand(const char *target) {
}
}
-void Script::handleAimCommand(const char *target) {
- warning("STUB: handleAimCommand");
+void Script::handleAimCommand(const char *t) {
+ bool wasHandled = true;
+ Common::String target(t);
+
+ if (target.contains("head")) {
+ _callbacks->_aim = Chr::HEAD;
+ } else if (target.contains("chest")) {
+ _callbacks->_aim = Chr::CHEST;
+ } else if (target.contains("side")) {
+ _callbacks->_aim = Chr::SIDE;
+ } else {
+ wasHandled = false;
+ appendText((char *)"Please aim for the head, chest, or side.");
+ }
+
+ if (wasHandled)
+ _handled = true;
+
+ _callbacks->_commandWasQuick = true;
}
void Script::handleWearCommand(const char *target) {
Commit: 42c74403760365258a4841cd139aa69be43328c7
https://github.com/scummvm/scummvm/commit/42c74403760365258a4841cd139aa69be43328c7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:51+01:00
Commit Message:
WAGE: Implement handleWearCommand()
Changed paths:
engines/wage/script.cpp
engines/wage/script.h
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index b6a44d1..51fb40e 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -1149,6 +1149,8 @@ void Script::handleAimCommand(const char *t) {
bool wasHandled = true;
Common::String target(t);
+ target.toLowercase();
+
if (target.contains("head")) {
_callbacks->_aim = Chr::HEAD;
} else if (target.contains("chest")) {
@@ -1166,10 +1168,48 @@ void Script::handleAimCommand(const char *t) {
_callbacks->_commandWasQuick = true;
}
-void Script::handleWearCommand(const char *target) {
- warning("STUB: handleWearCommand");
+void Script::handleWearCommand(const char *t) {
+ Chr *player = _world->_player;
+ char buf[512];
+ Common::String target(t);
+
+ target.toLowercase();
+
+ for (ObjArray::const_iterator it = _world->_player->_inventory.begin(); it != _world->_player->_inventory.end(); ++it) {
+ Common::String n((*it)->_name);
+
+ if (target.contains(n)) {
+ if ((*it)->_type == Obj::HELMET) {
+ wearObj(*it, Chr::HEAD_ARMOR);
+ } else if ((*it)->_type == Obj::CHEST_ARMOR) {
+ wearObj(*it, Chr::BODY_ARMOR);
+ } else if ((*it)->_type == Obj::SHIELD) {
+ wearObj(*it, Chr::SHIELD_ARMOR);
+ } else if ((*it)->_type == Obj::SPIRITUAL_ARMOR) {
+ wearObj(*it, Chr::MAGIC_ARMOR);
+ } else {
+ appendText((char *)"You cannot wear that object.");
+ }
+ break;
+ }
+ }
+
+ for (ObjList::const_iterator it = player->_currentScene->_objs.begin(); it != player->_currentScene->_objs.end(); ++it) {
+ Common::String n((*it)->_name);
+ n.toLowercase();
+ if (target.contains(n)) {
+ snprintf(buf, 512, "First you must get the %s.", (*it)->_name.c_str());
+ appendText(buf);
+ break;
+ }
+ }
+}
+
+void Script::wearObj(Obj *o, int pos) {
+ warning("STUB: wearObj()");
}
+
void Script::handleOfferCommand(const char *target) {
warning("STUB: handleOfferCommand");
}
diff --git a/engines/wage/script.h b/engines/wage/script.h
index 788188d..adcff88 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -186,6 +186,8 @@ private:
void handleWearCommand(const char *target);
void handleOfferCommand(const char *target);
+ void wearObj(Obj *o, int pos);
+
bool tryAttack(Obj *weapon, Common::String &input);
void handleAttack(Obj *weapon);
Commit: 605a32d9bf8407931eac52b7960b2c7b011f08e8
https://github.com/scummvm/scummvm/commit/605a32d9bf8407931eac52b7960b2c7b011f08e8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:51+01:00
Commit Message:
WAGE: Implement wearObj()
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 51fb40e..6ca3ecb 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -1206,7 +1206,22 @@ void Script::handleWearCommand(const char *t) {
}
void Script::wearObj(Obj *o, int pos) {
- warning("STUB: wearObj()");
+ Chr *player = _world->_player;
+ char buf[512];
+
+ if (player->_armor[pos] == o) {
+ snprintf(buf, 512, "You are already wearing the %s.", o->_name.c_str());
+ appendText(buf);
+ } else {
+ if (player->_armor[pos] != NULL) {
+ snprintf(buf, 512, "You are no longer wearing the %s.", player->_armor[pos]->_name.c_str());
+ appendText(buf);
+ }
+
+ player->_armor[pos] = o;
+ snprintf(buf, 512, "You are now wearing the %s.", o->_name.c_str());
+ appendText(buf);
+ }
}
Commit: f43a36edb55f52aa81c5a4120807e293a77017d3
https://github.com/scummvm/scummvm/commit/f43a36edb55f52aa81c5a4120807e293a77017d3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:52+01:00
Commit Message:
WAGE: Rename Script::_callbacks to _engine
Changed paths:
engines/wage/script.cpp
engines/wage/script.h
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 6ca3ecb..152abe1 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -80,12 +80,12 @@ void Script::printLine(int offset) {
}
}
-bool Script::execute(World *world, int loopCount, String *inputText, Designed *inputClick, WageEngine *callbacks) {
+bool Script::execute(World *world, int loopCount, String *inputText, Designed *inputClick, WageEngine *engine) {
_world = world;
_loopCount = loopCount;
_inputText = inputText;
_inputClick = inputClick;
- _callbacks = callbacks;
+ _engine = engine;
_handled = false;
Common::String input;
@@ -130,7 +130,7 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
Operand *op = readOperand();
// TODO check op type is string.
_handled = true;
- callbacks->playSound(op->toString());
+ _engine->playSound(op->toString());
delete op;
byte d = _data->readByte();
if (d != 0xFD)
@@ -144,7 +144,7 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
{
Operand *op = readStringOperand(); // allows empty menu
// TODO check op type is string.
- _callbacks->setMenu(op->toString());
+ _engine->setMenu(op->toString());
byte d = _data->readByte();
if (d != 0xFD)
warning("Operand 0x8B (PRINT) End Byte != 0xFD");
@@ -158,7 +158,7 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
if (_world->_globalScript != this) {
debug(1, "Executing global script...");
- bool globalHandled = _world->_globalScript->execute(_world, _loopCount, &input, _inputClick, _callbacks);
+ bool globalHandled = _world->_globalScript->execute(_world, _loopCount, &input, _inputClick, _engine);
if (globalHandled)
_handled = true;
} else if (!input.empty()) {
@@ -195,7 +195,7 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
handleStatusCommand();
} else if (input.contains("rest") || input.equals("wait")) {
handleRestCommand();
- } else if (callbacks->getOffer() != NULL && input.contains("accept")) {
+ } else if (_engine->getOffer() != NULL && input.contains("accept")) {
handleAcceptCommand();
} else {
Chr *player = _world->_player;
@@ -240,19 +240,19 @@ Script::Operand *Script::readOperand() {
case 0xC2: // PLAYER@
return new Operand(_world->_player, CHR);
case 0xC3: // MONSTER@
- return new Operand(_callbacks->getMonster(), CHR);
+ return new Operand(_engine->getMonster(), CHR);
case 0xC4: // RANDOMSCN@
- return new Operand(_world->_orderedScenes[_callbacks->_rnd->getRandomNumber(_world->_orderedScenes.size())], SCENE);
+ return new Operand(_world->_orderedScenes[_engine->_rnd->getRandomNumber(_world->_orderedScenes.size())], SCENE);
case 0xC5: // RANDOMCHR@
- return new Operand(_world->_orderedChrs[_callbacks->_rnd->getRandomNumber(_world->_orderedChrs.size())], CHR);
+ return new Operand(_world->_orderedChrs[_engine->_rnd->getRandomNumber(_world->_orderedChrs.size())], CHR);
case 0xC6: // RANDOMOBJ@
- return new Operand(_world->_orderedObjs[_callbacks->_rnd->getRandomNumber(_world->_orderedObjs.size())], OBJ);
+ return new Operand(_world->_orderedObjs[_engine->_rnd->getRandomNumber(_world->_orderedObjs.size())], OBJ);
case 0xB0: // VISITS#
return new Operand(cont->_visits, NUMBER);
case 0xB1: // RANDOM# for Star Trek, but VISITS# for some other games?
- return new Operand(1 + _callbacks->_rnd->getRandomNumber(100), NUMBER);
+ return new Operand(1 + _engine->_rnd->getRandomNumber(100), NUMBER);
case 0xB5: // RANDOM# // A random number between 1 and 100.
- return new Operand(1 + _callbacks->_rnd->getRandomNumber(100), NUMBER);
+ return new Operand(1 + _engine->_rnd->getRandomNumber(100), NUMBER);
case 0xB2: // LOOP#
return new Operand(_loopCount, NUMBER);
case 0xB3: // VICTORY#
@@ -940,7 +940,7 @@ void Script::processLet() {
void Script::appendText(String str) {
_handled = true;
- _callbacks->appendText(str);
+ _engine->appendText(str);
}
static const int directionsX[] = { 0, 0, 1, -1 };
@@ -1082,21 +1082,21 @@ void Script::handleStatusCommand() {
printPlayerCondition(player);
- _callbacks->_commandWasQuick = true;
+ _engine->_commandWasQuick = true;
}
void Script::handleRestCommand() {
- if (_callbacks->getMonster() != NULL) {
+ if (_engine->getMonster() != NULL) {
appendText("This is no time to rest!");
- _callbacks->_commandWasQuick = true;
+ _engine->_commandWasQuick = true;
} else {
- _callbacks->regen();
+ _engine->regen();
printPlayerCondition(_world->_player);
}
}
void Script::handleAcceptCommand() {
- Obj *offer = _callbacks->_offer;
+ Obj *offer = _engine->_offer;
Chr *chr = offer->_currentOwner;
char buf[512];
@@ -1152,11 +1152,11 @@ void Script::handleAimCommand(const char *t) {
target.toLowercase();
if (target.contains("head")) {
- _callbacks->_aim = Chr::HEAD;
+ _engine->_aim = Chr::HEAD;
} else if (target.contains("chest")) {
- _callbacks->_aim = Chr::CHEST;
+ _engine->_aim = Chr::CHEST;
} else if (target.contains("side")) {
- _callbacks->_aim = Chr::SIDE;
+ _engine->_aim = Chr::SIDE;
} else {
wasHandled = false;
appendText((char *)"Please aim for the head, chest, or side.");
@@ -1165,7 +1165,7 @@ void Script::handleAimCommand(const char *t) {
if (wasHandled)
_handled = true;
- _callbacks->_commandWasQuick = true;
+ _engine->_commandWasQuick = true;
}
void Script::handleWearCommand(const char *t) {
diff --git a/engines/wage/script.h b/engines/wage/script.h
index adcff88..5f34a27 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -58,7 +58,7 @@ public:
private:
Common::SeekableReadStream *_data;
- WageEngine *_callbacks;
+ WageEngine *_engine;
World *_world;
int _loopCount;
String *_inputText;
@@ -149,7 +149,7 @@ private:
public:
void print();
void printLine(int offset);
- bool execute(World *world, int loopCount, String *inputText, Designed *inputClick, WageEngine *callbacks);
+ bool execute(World *world, int loopCount, String *inputText, Designed *inputClick, WageEngine *engine);
private:
Operand *readOperand();
Commit: 47b3f404b89e23918a3afd688c7865dc12e8f521
https://github.com/scummvm/scummvm/commit/47b3f404b89e23918a3afd688c7865dc12e8f521
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:52+01:00
Commit Message:
WAGE: Moved all interaction-related methods from script.cpp to combat.cpp
Changed paths:
engines/wage/combat.cpp
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/script.cpp
engines/wage/script.h
engines/wage/wage.cpp
engines/wage/wage.h
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index b057b7e..4bd62b8 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -77,7 +77,7 @@ void WageEngine::encounter(Chr *player, Chr *chr) {
appendText(buf);
if (!chr->_initialComment.empty())
- appendText(chr->_initialComment);
+ appendText(chr->_initialComment.c_str());
if (chr->_armor[Chr::HEAD_ARMOR] != NULL) {
snprintf(buf, 512, "%s%s is wearing %s.", chr->getDefiniteArticle(true), chr->_name.c_str(),
@@ -303,4 +303,387 @@ void WageEngine::regen() {
}
}
+void WageEngine::takeObj(Obj *obj) {
+ if ((int)_world->_player->_inventory.size() >= _world->_player->_maximumCarriedObjects) {
+ appendText("Your pack is full, you must drop something.");
+ } else {
+ char buf[256];
+
+ _world->move(obj, _world->_player);
+ int type = _world->_player->wearObjIfPossible(obj);
+ if (type == Chr::HEAD_ARMOR) {
+ snprintf(buf, 256, "You are now wearing the %s.", obj->_name.c_str());
+ appendText(buf);
+ } else if (type == Chr::BODY_ARMOR) {
+ snprintf(buf, 256, "You are now wearing the %s.", obj->_name.c_str());
+ appendText(buf);
+ } else if (type == Chr::SHIELD_ARMOR) {
+ snprintf(buf, 256, "You are now wearing the %s.", obj->_name.c_str());
+ appendText(buf);
+ } else if (type == Chr::MAGIC_ARMOR) {
+ snprintf(buf, 256, "You are now wearing the %s.", obj->_name.c_str());
+ appendText(buf);
+ } else {
+ snprintf(buf, 256, "You now have the %s.", obj->_name.c_str());
+ appendText(buf);
+ }
+ appendText(obj->_clickMessage.c_str());
+ }
+}
+
+static const int directionsX[] = { 0, 0, 1, -1 };
+static const int directionsY[] = { -1, 1, 0, 0 };
+
+bool WageEngine::handleMoveCommand(Directions dir, const char *dirName) {
+ Scene *playerScene = _world->_player->_currentScene;
+ const char *msg = playerScene->_messages[dir].c_str();
+
+ warning("Dir: %s msg: %s", dirName, msg);
+
+ if (!playerScene->_blocked[dir]) {
+ int destX = playerScene->_worldX + directionsX[dir];
+ int destY = playerScene->_worldY + directionsY[dir];
+
+ Scene *scene = _world->getSceneAt(destX, destY);
+
+ if (scene != NULL) {
+ if (strlen(msg) > 0) {
+ appendText(msg);
+ }
+ _world->move(_world->_player, scene);
+ return true;
+ }
+ }
+ if (strlen(msg) > 0) {
+ appendText(msg);
+ } else {
+ Common::String txt("You can't go ");
+ txt += dirName;
+ txt += ".";
+ appendText(txt.c_str());
+ }
+
+ return true;
+}
+
+bool WageEngine::handleLookCommand() {
+ appendText(_world->_player->_currentScene->_text.c_str());
+
+ Common::String *items = getGroundItemsList(_world->_player->_currentScene);
+ if (items != NULL) {
+ appendText(items->c_str());
+
+ delete items;
+ }
+
+ return true;
+}
+
+Common::String *WageEngine::getGroundItemsList(Scene *scene) {
+ ObjArray objs;
+
+ for (ObjList::const_iterator it = scene->_objs.begin(); it != scene->_objs.end(); ++it)
+ if ((*it)->_type != Obj::IMMOBILE_OBJECT)
+ objs.push_back(*it);
+
+ if (objs.size()) {
+ Common::String *res = new Common::String("On the ground you see ");
+ appendObjNames(*res, objs);
+ return res;
+ }
+ return NULL;
+}
+
+void WageEngine::appendObjNames(Common::String &str, ObjArray &objs) {
+ for (uint i = 0; i < objs.size(); i++) {
+ Obj *obj = objs[i];
+
+ if (!obj->_namePlural)
+ str += getIndefiniteArticle(obj->_name);
+ else
+ str += "some ";
+
+ str += obj->_name;
+
+ if (i == objs.size() - 1) {
+ str += ".";
+ } else if (i == objs.size() - 2) {
+ if (objs.size() > 2)
+ str += ",";
+ str += " and ";
+ } else {
+ str += ", ";
+ }
+ }
+}
+
+bool WageEngine::handleInventoryCommand() {
+ Chr *player = _world->_player;
+ ObjArray objs;
+
+ for (ObjArray::const_iterator it = player->_inventory.begin(); it != player->_inventory.end(); ++it)
+ if (!player->isWearing(*it))
+ objs.push_back(*it);
+
+ if (!objs.size()) {
+ appendText((char *)"Your pack is empty.");
+ } else {
+ Common::String res("Your pack contains ");
+ appendObjNames(res, objs);
+ appendText(res.c_str());
+ }
+
+ return true;
+}
+
+static const char *armorMessages[] = {
+ "Head protection:",
+ "Chest protection:",
+ "Shield protection:", // TODO: check message
+ "Magical protection:"
+};
+
+bool WageEngine::handleStatusCommand() {
+ Chr *player = _world->_player;
+ char buf[512];
+
+ snprintf(buf, 512, "Character name: %s%s", player->getDefiniteArticle(false), player->_name.c_str());
+ appendText(buf);
+ snprintf(buf, 512, "Experience: %d", player->_context._experience);
+ appendText(buf);
+
+ int wealth = 0;
+ for (ObjArray::const_iterator it = player->_inventory.begin(); it != player->_inventory.end(); ++it)
+ wealth += (*it)->_value;
+
+ snprintf(buf, 512, "Wealth: %d", wealth);
+ appendText(buf);
+
+ for (int i = 0; i < Chr::NUMBER_OF_ARMOR_TYPES; i++) {
+ if (player->_armor[i] != NULL) {
+ snprintf(buf, 512, "%s %s", armorMessages[i], player->_armor[i]->_name.c_str());
+ appendText(buf);
+ }
+ }
+
+ for (ObjArray::const_iterator it = player->_inventory.begin(); it != player->_inventory.end(); ++it) {
+ int uses = (*it)->_numberOfUses;
+
+ if (uses > 0) {
+ snprintf(buf, 512, "Your %s has %d uses left.", (*it)->_name.c_str(), uses);
+ }
+ }
+
+ printPlayerCondition(player);
+
+ _commandWasQuick = true;
+
+ return true;
+}
+
+bool WageEngine::handleRestCommand() {
+ if (getMonster() != NULL) {
+ appendText((char *)"This is no time to rest!");
+ _commandWasQuick = true;
+ } else {
+ regen();
+ printPlayerCondition(_world->_player);
+ }
+
+ return true;
+}
+
+bool WageEngine::handleAcceptCommand() {
+ Chr *chr = _offer->_currentOwner;
+
+ char buf[512];
+ snprintf(buf, 512, "%s%s lays the %s on the ground and departs peacefully.",
+ chr->getDefiniteArticle(true), chr->_name.c_str(), _offer->_name.c_str());
+ appendText(buf);
+
+ _world->move(_offer, chr->_currentScene);
+ _world->move(chr, _world->_storageScene);
+
+ return true;
+}
+
+bool WageEngine::handleTakeCommand(const char *target) {
+ Common::String t(target);
+ bool handled = false;
+
+ for (ObjList::const_iterator it = _world->_player->_currentScene->_objs.begin(); it != _world->_player->_currentScene->_objs.end(); ++it) {
+ Common::String n((*it)->_name);
+ n.toLowercase();
+
+ if (t.contains(n)) {
+ if ((*it)->_type == Obj::IMMOBILE_OBJECT) {
+ appendText((char *)"You can't move it.");
+ } else {
+ takeObj(*it);
+ }
+
+ handled = true;
+ break;
+ }
+ }
+
+ return handled;
+}
+
+bool WageEngine::handleDropCommand(const char *target) {
+ Common::String t(target);
+ bool handled = false;
+
+ t.toLowercase();
+
+ for (ObjArray::const_iterator it = _world->_player->_inventory.begin(); it != _world->_player->_inventory.end(); ++it) {
+ Common::String n((*it)->_name);
+ n.toLowercase();
+
+ if (t.contains(n)) {
+ char buf[256];
+
+ snprintf(buf, 256, "You no longer have the %s.", (*it)->_name.c_str());
+ _world->move(*it, _world->_player->_currentScene);
+
+ handled = true;
+ break;
+ }
+ }
+
+ return handled;
+}
+
+bool WageEngine::handleAimCommand(const char *t) {
+ bool wasHandled = true;
+ Common::String target(t);
+
+ target.toLowercase();
+
+ if (target.contains("head")) {
+ _aim = Chr::HEAD;
+ } else if (target.contains("chest")) {
+ _aim = Chr::CHEST;
+ } else if (target.contains("side")) {
+ _aim = Chr::SIDE;
+ } else {
+ wasHandled = false;
+ appendText((char *)"Please aim for the head, chest, or side.");
+ }
+
+ _commandWasQuick = true;
+
+ return wasHandled;
+}
+
+bool WageEngine::handleWearCommand(const char *t) {
+ Chr *player = _world->_player;
+ char buf[512];
+ Common::String target(t);
+ bool handled = false;
+
+ target.toLowercase();
+
+ for (ObjArray::const_iterator it = _world->_player->_inventory.begin(); it != _world->_player->_inventory.end(); ++it) {
+ Common::String n((*it)->_name);
+
+ if (target.contains(n)) {
+ if ((*it)->_type == Obj::HELMET) {
+ wearObj(*it, Chr::HEAD_ARMOR);
+ } else if ((*it)->_type == Obj::CHEST_ARMOR) {
+ wearObj(*it, Chr::BODY_ARMOR);
+ } else if ((*it)->_type == Obj::SHIELD) {
+ wearObj(*it, Chr::SHIELD_ARMOR);
+ } else if ((*it)->_type == Obj::SPIRITUAL_ARMOR) {
+ wearObj(*it, Chr::MAGIC_ARMOR);
+ } else {
+ appendText((char *)"You cannot wear that object.");
+ }
+
+ handled = true;
+ break;
+ }
+ }
+
+ for (ObjList::const_iterator it = player->_currentScene->_objs.begin(); it != player->_currentScene->_objs.end(); ++it) {
+ Common::String n((*it)->_name);
+ n.toLowercase();
+ if (target.contains(n)) {
+ snprintf(buf, 512, "First you must get the %s.", (*it)->_name.c_str());
+ appendText(buf);
+
+ handled = true;
+ break;
+ }
+ }
+
+ return handled;
+}
+
+void WageEngine::wearObj(Obj *o, int pos) {
+ Chr *player = _world->_player;
+ char buf[512];
+
+ if (player->_armor[pos] == o) {
+ snprintf(buf, 512, "You are already wearing the %s.", o->_name.c_str());
+ appendText(buf);
+ } else {
+ if (player->_armor[pos] != NULL) {
+ snprintf(buf, 512, "You are no longer wearing the %s.", player->_armor[pos]->_name.c_str());
+ appendText(buf);
+ }
+
+ player->_armor[pos] = o;
+ snprintf(buf, 512, "You are now wearing the %s.", o->_name.c_str());
+ appendText(buf);
+ }
+}
+
+
+bool WageEngine::handleOfferCommand(const char *target) {
+ warning("STUB: handleOfferCommand");
+
+ return false;
+}
+
+bool WageEngine::tryAttack(Obj *weapon, Common::String &input) {
+ warning("STUB: tryAttack");
+
+ return false;
+}
+
+bool WageEngine::handleAttack(Obj *weapon) {
+ warning("STUB: handleAttack");
+
+ return true;
+}
+
+const char *WageEngine::getPercentMessage(double percent) {
+ if (percent < 0.40) {
+ return "very bad";
+ } else if (percent < 0.55) {
+ return "bad";
+ } else if (percent < 0.70) {
+ return "average";
+ } else if (percent < 0.85) {
+ return "good";
+ } else if (percent <= 1.00) {
+ return "very good";
+ } else {
+ return "enhanced";
+ }
+}
+
+void WageEngine::printPlayerCondition(Chr *player) {
+ double physicalPercent = (double)player->_context._statVariables[PHYS_HIT_CUR] / player->_context._statVariables[PHYS_HIT_BAS];
+ double spiritualPercent = (double)player->_context._statVariables[SPIR_HIT_CUR] / player->_context._statVariables[SPIR_HIT_BAS];
+ char buf[256];
+
+ snprintf(buf, 256, "Your physical condition is %s.", getPercentMessage(physicalPercent));
+ appendText(buf);
+
+ snprintf(buf, 256, "Your spiritual condition is %s.", getPercentMessage(spiritualPercent));
+ appendText(buf);
+}
+
} // End of namespace Wage
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 588a7cf..747d486 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -109,17 +109,17 @@ Scene::Scene(String name, Common::SeekableReadStream *data) {
setDesignBounds(readRect(data));
_worldY = data->readSint16BE();
_worldX = data->readSint16BE();
- _blocked[Scene::NORTH] = (data->readByte() != 0);
- _blocked[Scene::SOUTH] = (data->readByte() != 0);
- _blocked[Scene::EAST] = (data->readByte() != 0);
- _blocked[Scene::WEST] = (data->readByte() != 0);
+ _blocked[NORTH] = (data->readByte() != 0);
+ _blocked[SOUTH] = (data->readByte() != 0);
+ _blocked[EAST] = (data->readByte() != 0);
+ _blocked[WEST] = (data->readByte() != 0);
_soundFrequency = data->readSint16BE();
_soundType = data->readByte();
data->readByte(); // unknown
- _messages[Scene::NORTH] = readPascalString(data);
- _messages[Scene::SOUTH] = readPascalString(data);
- _messages[Scene::EAST] = readPascalString(data);
- _messages[Scene::WEST] = readPascalString(data);
+ _messages[NORTH] = readPascalString(data);
+ _messages[SOUTH] = readPascalString(data);
+ _messages[EAST] = readPascalString(data);
+ _messages[WEST] = readPascalString(data);
_soundName = readPascalString(data);
_visited = false;
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index b1101f9..58cc82a 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -55,15 +55,8 @@ namespace Graphics {
namespace Wage {
class Design;
-class Obj;
-class Scene;
class Script;
-typedef Common::Array<Obj *> ObjArray;
-typedef Common::Array<Chr *> ChrArray;
-typedef Common::List<Obj *> ObjList;
-typedef Common::List<Chr *> ChrList;
-
enum StatVariable {
/** The base physical accuracy of the player. */
PHYS_ACC_BAS = 0,
@@ -306,13 +299,6 @@ public:
class Scene : public Designed {
public:
- enum Directions {
- NORTH = 0,
- SOUTH = 1,
- EAST = 2,
- WEST = 3
- };
-
enum SceneTypes {
PERIODIC = 0,
RANDOM = 1
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 02b735d..5bebc39 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -214,7 +214,8 @@ void Gui::clearOutput() {
_consoleFullRedraw = true;
}
-void Gui::appendText(String &str) {
+void Gui::appendText(const char *s) {
+ Common::String str(s);
_consoleDirty = true;
if (!str.contains('\n')) {
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 3f5a824..45ef50c 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -90,7 +90,7 @@ public:
~Gui();
void draw();
- void appendText(Common::String &str);
+ void appendText(const char *str);
void clearOutput();
void mouseMove(int x, int y);
void mouseClick(int x, int y);
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 152abe1..410186e 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -118,7 +118,8 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
{
Operand *op = readOperand();
// TODO check op type is string or number, or something good...
- appendText(op->toString());
+ _handled = true;
+ _engine->appendText(op->toString().c_str());
delete op;
byte d = _data->readByte();
if (d != 0xFD)
@@ -164,45 +165,45 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
} else if (!input.empty()) {
input.toLowercase();
if (input.equals("n") || input.contains("north")) {
- handleMoveCommand(Scene::NORTH, "north");
+ _handled = _engine->handleMoveCommand(NORTH, "north");
} else if (input.equals("e") || input.contains("east")) {
- handleMoveCommand(Scene::EAST, "east");
+ _handled = _engine->handleMoveCommand(EAST, "east");
} else if (input.equals("s") || input.contains("south")) {
- handleMoveCommand(Scene::SOUTH, "south");
+ _handled = _engine->handleMoveCommand(SOUTH, "south");
} else if (input.equals("w") || input.contains("west")) {
- handleMoveCommand(Scene::WEST, "west");
+ _handled = _engine->handleMoveCommand(WEST, "west");
} else if (input.hasPrefix("take ")) {
- handleTakeCommand(&input.c_str()[5]);
+ _handled = _engine->handleTakeCommand(&input.c_str()[5]);
} else if (input.hasPrefix("get ")) {
- handleTakeCommand(&input.c_str()[4]);
+ _handled = _engine->handleTakeCommand(&input.c_str()[4]);
} else if (input.hasPrefix("pick up ")) {
- handleTakeCommand(&input.c_str()[8]);
+ _handled = _engine->handleTakeCommand(&input.c_str()[8]);
} else if (input.hasPrefix("drop ")) {
- handleDropCommand(&input.c_str()[5]);
+ _handled = _engine->handleDropCommand(&input.c_str()[5]);
} else if (input.hasPrefix("aim ")) {
- handleAimCommand(&input.c_str()[4]);
+ _handled = _engine->handleAimCommand(&input.c_str()[4]);
} else if (input.hasPrefix("wear ")) {
- handleWearCommand(&input.c_str()[5]);
+ _handled = _engine->handleWearCommand(&input.c_str()[5]);
} else if (input.hasPrefix("put on ")) {
- handleWearCommand(&input.c_str()[7]);
+ _handled = _engine->handleWearCommand(&input.c_str()[7]);
} else if (input.hasPrefix("offer ")) {
- handleOfferCommand(&input.c_str()[6]);
+ _handled = _engine->handleOfferCommand(&input.c_str()[6]);
} else if (input.contains("look")) {
- handleLookCommand();
+ _handled = _engine->handleLookCommand();
} else if (input.contains("inventory")) {
- handleInventoryCommand();
+ _handled = _engine->handleInventoryCommand();
} else if (input.contains("status")) {
- handleStatusCommand();
+ _handled = _engine->handleStatusCommand();
} else if (input.contains("rest") || input.equals("wait")) {
- handleRestCommand();
+ _handled = _engine->handleRestCommand();
} else if (_engine->getOffer() != NULL && input.contains("accept")) {
- handleAcceptCommand();
+ _handled = _engine->handleAcceptCommand();
} else {
Chr *player = _world->_player;
ObjArray *weapons = player->getWeapons(true);
for (ObjArray::const_iterator weapon = weapons->begin(); weapon != weapons->end(); ++weapon) {
- if (tryAttack(*weapon, input)) {
- handleAttack(*weapon);
+ if (_engine->tryAttack(*weapon, input)) {
+ _handled = _engine->handleAttack(*weapon);
break;
}
}
@@ -213,10 +214,12 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
} else if (_inputClick->_classType == OBJ) {
Obj *obj = (Obj *)_inputClick;
if (obj->_type != Obj::IMMOBILE_OBJECT) {
- takeObj(obj);
+ _engine->takeObj(obj);
} else {
- appendText(obj->_clickMessage);
+ _engine->appendText(obj->_clickMessage.c_str());
}
+
+ _handled = true;
}
return _handled;
@@ -858,27 +861,6 @@ bool Script::evalClickCondition(Operand *lhs, const char *op, Operand *rhs) {
return result;
}
-void Script::takeObj(Obj *obj) {
- if ((int)_world->_player->_inventory.size() >= _world->_player->_maximumCarriedObjects) {
- appendText("Your pack is full, you must drop something.");
- } else {
- _world->move(obj, _world->_player);
- int type = _world->_player->wearObjIfPossible(obj);
- if (type == Chr::HEAD_ARMOR) {
- appendText(String("You are now wearing the ") + obj->_name + ".");
- } else if (type == Chr::BODY_ARMOR) {
- appendText(String("You are now wearing the ") + obj->_name + ".");
- } else if (type == Chr::SHIELD_ARMOR) {
- appendText(String("You are now wearing the ") + obj->_name + ".");
- } else if (type == Chr::MAGIC_ARMOR) {
- appendText(String("You are now wearing the ") + obj->_name + ".");
- } else {
- appendText(String("You now have the ") + obj->_name + ".");
- }
- appendText(obj->_clickMessage);
- }
-}
-
void Script::processMove() {
Operand *what = readOperand();
byte skip = _data->readByte();
@@ -938,338 +920,6 @@ void Script::processLet() {
assign(operandType, uservar, result);
}
-void Script::appendText(String str) {
- _handled = true;
- _engine->appendText(str);
-}
-
-static const int directionsX[] = { 0, 0, 1, -1 };
-static const int directionsY[] = { -1, 1, 0, 0 };
-
-void Script::handleMoveCommand(Scene::Directions dir, const char *dirName) {
- Scene *playerScene = _world->_player->_currentScene;
- Common::String msg(playerScene->_messages[dir]);
-
- warning("Dir: %s msg: %s", dirName, msg.c_str());
-
- if (!playerScene->_blocked[dir]) {
- int destX = playerScene->_worldX + directionsX[dir];
- int destY = playerScene->_worldY + directionsY[dir];
-
- Scene *scene = _world->getSceneAt(destX, destY);
-
- if (scene != NULL) {
- if (msg.size() > 0) {
- appendText(msg);
- }
- _world->move(_world->_player, scene);
- return;
- }
- }
- if (msg.size() > 0) {
- appendText(msg);
- } else {
- Common::String txt("You can't go ");
- txt += dirName;
- txt += ".";
- appendText(txt);
- }
-}
-
-void Script::handleLookCommand() {
- appendText(_world->_player->_currentScene->_text);
-
- Common::String *items = getGroundItemsList(_world->_player->_currentScene);
- if (items != NULL) {
- appendText(*items);
-
- delete items;
- }
-}
-
-Common::String *Script::getGroundItemsList(Scene *scene) {
- ObjArray objs;
-
- for (ObjList::const_iterator it = scene->_objs.begin(); it != scene->_objs.end(); ++it)
- if ((*it)->_type != Obj::IMMOBILE_OBJECT)
- objs.push_back(*it);
-
- if (objs.size()) {
- Common::String *res = new Common::String("On the ground you see ");
- appendObjNames(*res, objs);
- return res;
- }
- return NULL;
-}
-
-void Script::appendObjNames(Common::String &str, ObjArray &objs) {
- for (uint i = 0; i < objs.size(); i++) {
- Obj *obj = objs[i];
-
- if (!obj->_namePlural)
- str += getIndefiniteArticle(obj->_name);
- else
- str += "some ";
-
- str += obj->_name;
-
- if (i == objs.size() - 1) {
- str += ".";
- } else if (i == objs.size() - 2) {
- if (objs.size() > 2)
- str += ",";
- str += " and ";
- } else {
- str += ", ";
- }
- }
-}
-
-void Script::handleInventoryCommand() {
- Chr *player = _world->_player;
- ObjArray objs;
-
- for (ObjArray::const_iterator it = player->_inventory.begin(); it != player->_inventory.end(); ++it)
- if (!player->isWearing(*it))
- objs.push_back(*it);
-
- if (!objs.size()) {
- appendText("Your pack is empty.");
- } else {
- Common::String res("Your pack contains ");
- appendObjNames(res, objs);
- appendText(res);
- }
-}
-
-static const char *armorMessages[] = {
- "Head protection:",
- "Chest protection:",
- "Shield protection:", // TODO: check message
- "Magical protection:"
-};
-
-void Script::handleStatusCommand() {
- Chr *player = _world->_player;
- char buf[512];
-
- snprintf(buf, 512, "Character name: %s%s", player->getDefiniteArticle(false), player->_name.c_str());
- appendText(buf);
- snprintf(buf, 512, "Experience: %d", player->_context._experience);
- appendText(buf);
-
- int wealth = 0;
- for (ObjArray::const_iterator it = player->_inventory.begin(); it != player->_inventory.end(); ++it)
- wealth += (*it)->_value;
-
- snprintf(buf, 512, "Wealth: %d", wealth);
- appendText(buf);
-
- for (int i = 0; i < Chr::NUMBER_OF_ARMOR_TYPES; i++) {
- if (player->_armor[i] != NULL) {
- snprintf(buf, 512, "%s %s", armorMessages[i], player->_armor[i]->_name.c_str());
- appendText(buf);
- }
- }
-
- for (ObjArray::const_iterator it = player->_inventory.begin(); it != player->_inventory.end(); ++it) {
- int uses = (*it)->_numberOfUses;
-
- if (uses > 0) {
- snprintf(buf, 512, "Your %s has %d uses left.", (*it)->_name.c_str(), uses);
- }
- }
-
- printPlayerCondition(player);
-
- _engine->_commandWasQuick = true;
-}
-
-void Script::handleRestCommand() {
- if (_engine->getMonster() != NULL) {
- appendText("This is no time to rest!");
- _engine->_commandWasQuick = true;
- } else {
- _engine->regen();
- printPlayerCondition(_world->_player);
- }
-}
-
-void Script::handleAcceptCommand() {
- Obj *offer = _engine->_offer;
- Chr *chr = offer->_currentOwner;
-
- char buf[512];
- snprintf(buf, 512, "%s%s lays the %s on the ground and departs peacefully.",
- chr->getDefiniteArticle(true), chr->_name.c_str(), offer->_name.c_str());
- appendText(buf);
-
- _world->move(offer, chr->_currentScene);
- _world->move(chr, _world->_storageScene);
-}
-
-void Script::handleTakeCommand(const char *target) {
- Common::String t(target);
-
- for (ObjList::const_iterator it = _world->_player->_currentScene->_objs.begin(); it != _world->_player->_currentScene->_objs.end(); ++it) {
- Common::String n((*it)->_name);
- n.toLowercase();
-
- if (t.contains(n)) {
- if ((*it)->_type == Obj::IMMOBILE_OBJECT) {
- appendText((char *)"You can't move it.");
- } else {
- takeObj(*it);
- }
- break;
- }
- }
-}
-
-void Script::handleDropCommand(const char *target) {
- Common::String t(target);
-
- t.toLowercase();
-
- for (ObjArray::const_iterator it = _world->_player->_inventory.begin(); it != _world->_player->_inventory.end(); ++it) {
- Common::String n((*it)->_name);
- n.toLowercase();
-
- if (t.contains(n)) {
- char buf[256];
-
- snprintf(buf, 256, "You no longer have the %s.", (*it)->_name.c_str());
- _world->move(*it, _world->_player->_currentScene);
- break;
- }
- }
-}
-
-void Script::handleAimCommand(const char *t) {
- bool wasHandled = true;
- Common::String target(t);
-
- target.toLowercase();
-
- if (target.contains("head")) {
- _engine->_aim = Chr::HEAD;
- } else if (target.contains("chest")) {
- _engine->_aim = Chr::CHEST;
- } else if (target.contains("side")) {
- _engine->_aim = Chr::SIDE;
- } else {
- wasHandled = false;
- appendText((char *)"Please aim for the head, chest, or side.");
- }
-
- if (wasHandled)
- _handled = true;
-
- _engine->_commandWasQuick = true;
-}
-
-void Script::handleWearCommand(const char *t) {
- Chr *player = _world->_player;
- char buf[512];
- Common::String target(t);
-
- target.toLowercase();
-
- for (ObjArray::const_iterator it = _world->_player->_inventory.begin(); it != _world->_player->_inventory.end(); ++it) {
- Common::String n((*it)->_name);
-
- if (target.contains(n)) {
- if ((*it)->_type == Obj::HELMET) {
- wearObj(*it, Chr::HEAD_ARMOR);
- } else if ((*it)->_type == Obj::CHEST_ARMOR) {
- wearObj(*it, Chr::BODY_ARMOR);
- } else if ((*it)->_type == Obj::SHIELD) {
- wearObj(*it, Chr::SHIELD_ARMOR);
- } else if ((*it)->_type == Obj::SPIRITUAL_ARMOR) {
- wearObj(*it, Chr::MAGIC_ARMOR);
- } else {
- appendText((char *)"You cannot wear that object.");
- }
- break;
- }
- }
-
- for (ObjList::const_iterator it = player->_currentScene->_objs.begin(); it != player->_currentScene->_objs.end(); ++it) {
- Common::String n((*it)->_name);
- n.toLowercase();
- if (target.contains(n)) {
- snprintf(buf, 512, "First you must get the %s.", (*it)->_name.c_str());
- appendText(buf);
- break;
- }
- }
-}
-
-void Script::wearObj(Obj *o, int pos) {
- Chr *player = _world->_player;
- char buf[512];
-
- if (player->_armor[pos] == o) {
- snprintf(buf, 512, "You are already wearing the %s.", o->_name.c_str());
- appendText(buf);
- } else {
- if (player->_armor[pos] != NULL) {
- snprintf(buf, 512, "You are no longer wearing the %s.", player->_armor[pos]->_name.c_str());
- appendText(buf);
- }
-
- player->_armor[pos] = o;
- snprintf(buf, 512, "You are now wearing the %s.", o->_name.c_str());
- appendText(buf);
- }
-}
-
-
-void Script::handleOfferCommand(const char *target) {
- warning("STUB: handleOfferCommand");
-}
-
-bool Script::tryAttack(Obj *weapon, Common::String &input) {
- warning("STUB: tryAttack");
-
- return false;
-}
-
-void Script::handleAttack(Obj *weapon) {
- warning("STUB: handleAttack");
-}
-
-const char *Script::getPercentMessage(double percent) {
- if (percent < 0.40) {
- return "very bad";
- } else if (percent < 0.55) {
- return "bad";
- } else if (percent < 0.70) {
- return "average";
- } else if (percent < 0.85) {
- return "good";
- } else if (percent <= 1.00) {
- return "very good";
- } else {
- return "enhanced";
- }
-}
-
-void Script::printPlayerCondition(Chr *player) {
- double physicalPercent = (double)player->_context._statVariables[PHYS_HIT_CUR] / player->_context._statVariables[PHYS_HIT_BAS];
- double spiritualPercent = (double)player->_context._statVariables[SPIR_HIT_CUR] / player->_context._statVariables[SPIR_HIT_BAS];
-
- Common::String msg = "Your physical condition is ";
- msg += getPercentMessage(physicalPercent);
- msg += ".";
- appendText(msg);
-
- msg = "Your spiritual condition is ";
- msg += getPercentMessage(spiritualPercent);
- msg += ".";
- appendText(msg);
-}
-
enum {
BLOCK_START,
BLOCK_END,
diff --git a/engines/wage/script.h b/engines/wage/script.h
index 5f34a27..143a93d 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -164,38 +164,13 @@ private:
Operand *convertOperand(Operand *operand, int type);
bool evalClickCondition(Operand *lhs, const char *op, Operand *rhs);
bool evalClickEquality(Operand *lhs, Operand *rhs, bool partialMatch);
- void takeObj(Obj *obj);
void processMove();
void processLet();
void assign(byte operandType, int uservar, uint16 value);
- void appendText(String str);
- void handleMoveCommand(Scene::Directions dir, const char *dirName);
- void handleLookCommand();
- Common::String *getGroundItemsList(Scene *scene);
- void appendObjNames(Common::String &str, ObjArray &objs);
- void handleInventoryCommand();
- void handleStatusCommand();
- void handleRestCommand();
- void handleAcceptCommand();
-
- void handleTakeCommand(const char *target);
- void handleDropCommand(const char *target);
- void handleAimCommand(const char *target);
- void handleWearCommand(const char *target);
- void handleOfferCommand(const char *target);
-
- void wearObj(Obj *o, int pos);
-
- bool tryAttack(Obj *weapon, Common::String &input);
- void handleAttack(Obj *weapon);
-
Common::Array<ScriptText *> _scriptText;
void convertToText();
-
- void printPlayerCondition(Chr *player);
- const char *getPercentMessage(double percent);
};
} // End of namespace Wage
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 7815ee0..310f093 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -204,21 +204,15 @@ void WageEngine::setMenu(String soundName) {
warning("STUB: WageEngine::setMenu");
}
-void WageEngine::appendText(String &str) {
+void WageEngine::appendText(const char *str) {
if (_inputText.size())
- _gui->appendText(_inputText);
+ _gui->appendText(_inputText.c_str());
_inputText = "";
_gui->appendText(str);
}
-void WageEngine::appendText(char *str) {
- Common::String s(str);
-
- appendText(s);
-}
-
void WageEngine::gameOver() {
DialogButtonArray buttons;
@@ -456,7 +450,7 @@ void WageEngine::processTurnInternal(Common::String *textInput, Designed *clickI
if (monsterWasNull && getMonster() != NULL)
return;
- Common::String rant(_rnd->getRandomNumber(1) ? "What?" : "Huh?");
+ const char *rant = _rnd->getRandomNumber(1) ? "What?" : "Huh?";
appendText(rant);
_commandWasQuick = true;
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index e5228e6..af5766e 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -69,6 +69,11 @@ class Obj;
class Scene;
class World;
+typedef Common::Array<Obj *> ObjArray;
+typedef Common::Array<Chr *> ChrArray;
+typedef Common::List<Obj *> ObjList;
+typedef Common::List<Chr *> ChrList;
+
using Common::String;
enum OperandType {
@@ -82,6 +87,13 @@ enum OperandType {
UNKNOWN = 100
};
+enum Directions {
+ NORTH = 0,
+ SOUTH = 1,
+ EAST = 2,
+ WEST = 3
+};
+
// our engine debug levels
enum {
kWageDebugExample = 1 << 0,
@@ -142,6 +154,32 @@ private:
void doClose();
public:
+ void takeObj(Obj *obj);
+
+ bool handleMoveCommand(Directions dir, const char *dirName);
+ bool handleLookCommand();
+ Common::String *getGroundItemsList(Scene *scene);
+ void appendObjNames(Common::String &str, ObjArray &objs);
+ bool handleInventoryCommand();
+ bool handleStatusCommand();
+ bool handleRestCommand();
+ bool handleAcceptCommand();
+
+ bool handleTakeCommand(const char *target);
+ bool handleDropCommand(const char *target);
+ bool handleAimCommand(const char *target);
+ bool handleWearCommand(const char *target);
+ bool handleOfferCommand(const char *target);
+
+ void wearObj(Obj *o, int pos);
+
+ bool tryAttack(Obj *weapon, Common::String &input);
+ bool handleAttack(Obj *weapon);
+
+ void printPlayerCondition(Chr *player);
+ const char *getPercentMessage(double percent);
+
+public:
Common::RandomSource *_rnd;
Gui *_gui;
@@ -163,8 +201,7 @@ public:
void playSound(String soundName);
void setMenu(String soundName);
- void appendText(String &str);
- void appendText(char *str);
+ void appendText(const char *str);
void gameOver();
bool saveDialog();
Obj *getOffer();
Commit: 9713e260a2918b1d5a172488bdeaa45c3cc033c6
https://github.com/scummvm/scummvm/commit/9713e260a2918b1d5a172488bdeaa45c3cc033c6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:52+01:00
Commit Message:
WAGE: Added missing messages
Changed paths:
engines/wage/combat.cpp
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index 4bd62b8..96235d7 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -471,6 +471,7 @@ bool WageEngine::handleStatusCommand() {
if (uses > 0) {
snprintf(buf, 512, "Your %s has %d uses left.", (*it)->_name.c_str(), uses);
+ appendText(buf);
}
}
@@ -544,6 +545,7 @@ bool WageEngine::handleDropCommand(const char *target) {
char buf[256];
snprintf(buf, 256, "You no longer have the %s.", (*it)->_name.c_str());
+ appendText(buf);
_world->move(*it, _world->_player->_currentScene);
handled = true;
Commit: 851c2d6f70649f048d9723d3012354fcda8594f8
https://github.com/scummvm/scummvm/commit/851c2d6f70649f048d9723d3012354fcda8594f8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:52+01:00
Commit Message:
WAGE: Implement getValidMoveDirections()
Changed paths:
engines/wage/combat.cpp
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index 96235d7..9002fa9 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -285,10 +285,26 @@ void WageEngine::performTake(Chr *npc, Obj *obj) {
_world->move(obj, npc);
}
+static const int directionsX[] = { 0, 0, 1, -1 };
+static const int directionsY[] = { -1, 1, 0, 0 };
+
int WageEngine::getValidMoveDirections(Chr *npc) {
- warning("STUB: getValidMoveDirections()");
+ int directions = 0;
+ Scene *currentScene = npc->_currentScene;
+ for (int dir = 0; dir < 4; dir++) {
+ if (!currentScene->_blocked[dir]) {
+ int destX = currentScene->_worldX + directionsX[dir];
+ int destY = currentScene->_worldY + directionsY[dir];
- return 0;
+ Scene *scene = _world->getSceneAt(destX, destY);
+
+ if (scene != NULL && scene->_chrs.size() == 0) {
+ directions |= (1 << dir);
+ }
+ }
+ }
+
+ return directions;
}
void WageEngine::regen() {
@@ -331,9 +347,6 @@ void WageEngine::takeObj(Obj *obj) {
}
}
-static const int directionsX[] = { 0, 0, 1, -1 };
-static const int directionsY[] = { -1, 1, 0, 0 };
-
bool WageEngine::handleMoveCommand(Directions dir, const char *dirName) {
Scene *playerScene = _world->_player->_currentScene;
const char *msg = playerScene->_messages[dir].c_str();
Commit: 2fba6e3a174fe5c4c8573c9431816b26636dcff3
https://github.com/scummvm/scummvm/commit/2fba6e3a174fe5c4c8573c9431816b26636dcff3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:52+01:00
Commit Message:
WAGE: Unstub redrawScene()
Changed paths:
engines/wage/wage.cpp
engines/wage/wage.h
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 310f093..6f3f4b2 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -386,21 +386,18 @@ void WageEngine::onMove(Designed *what, Designed *from, Designed *to) {
void WageEngine::redrawScene() {
Scene *currentScene = _world->_player->_currentScene;
- if (currentScene != NULL) {
- //bool firstTime = (_lastScene != currentScene);
- warning("STUB: WageEngine::redrawScene()");
+ if (currentScene != NULL) {
+ bool firstTime = (_lastScene != currentScene);
- //updateConsoleForScene(console, currentScene);
- //updateSceneViewerForScene(viewer, currentScene);
- //viewer.paintImmediately(viewer.getBounds());
- //getContentPane().validate();
- //getContentPane().repaint();
- //console.postUpdateUI();
- //soundManager.updateSoundTimerForScene(currentScene, firstTime);
+ updateSoundTimerForScene(currentScene, firstTime);
}
}
+void WageEngine::updateSoundTimerForScene(Scene *scene, bool firstTime) {
+ //warning("STUB: WageEngine::updateSoundTimerForScene()");
+}
+
void WageEngine::processTurnInternal(Common::String *textInput, Designed *clickInput) {
Scene *playerScene = _world->_player->_currentScene;
if (playerScene == _world->_storageScene)
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index af5766e..416c8b2 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -152,6 +152,7 @@ private:
void performHealingMagic(Chr *chr, Obj *magicalObject);
void doClose();
+ void updateSoundTimerForScene(Scene *scene, bool firstTime);
public:
void takeObj(Obj *obj);
Commit: df609fb468cef9e4cc4dca3112db596ba0b01190
https://github.com/scummvm/scummvm/commit/df609fb468cef9e4cc4dca3112db596ba0b01190
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:52+01:00
Commit Message:
WAGE: Implement performMove()
Changed paths:
engines/wage/combat.cpp
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index 9002fa9..96cab1e 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -257,8 +257,41 @@ void WageEngine::performHealingMagic(Chr *chr, Obj *magicalObject) {
warning("STUB: performHealingMagic()");
}
+static const int directionsX[] = { 0, 0, 1, -1 };
+static const int directionsY[] = { -1, 1, 0, 0 };
+static const char *directionsS[] = { "north", "south", "east", "west" };
+
void WageEngine::performMove(Chr *chr, int validMoves) {
- warning("STUB: performMove()");
+ // count how many valid moves we have
+ int numValidMoves = 0;
+
+ for (int dir = 0; dir < 4; dir++)
+ if ((validMoves & (1 << dir)) != 0)
+ numValidMoves++;
+
+ // Now pick random dir
+ int dir = _rnd->getRandomNumber(numValidMoves);
+
+ // And get it
+
+ for (int i = 0; i < 4; i++, dir--)
+ if ((validMoves & (1 << i)) != 0) {
+ if (dir == 0) {
+ dir = i;
+ break;
+ }
+ }
+
+ char buf[256];
+ snprintf(buf, 256, "%s%s runs %s.", chr->getDefiniteArticle(true), chr->_name.c_str(), directionsS[dir]);
+ appendText(buf);
+
+ _running = chr;
+ Scene *currentScene = chr->_currentScene;
+ int destX = currentScene->_worldX + directionsX[dir];
+ int destY = currentScene->_worldY + directionsY[dir];
+
+ _world->move(chr, _world->getSceneAt(destX, destY));
}
void WageEngine::performOffer(Chr *attacker, Chr *victim) {
@@ -285,9 +318,6 @@ void WageEngine::performTake(Chr *npc, Obj *obj) {
_world->move(obj, npc);
}
-static const int directionsX[] = { 0, 0, 1, -1 };
-static const int directionsY[] = { -1, 1, 0, 0 };
-
int WageEngine::getValidMoveDirections(Chr *npc) {
int directions = 0;
Scene *currentScene = npc->_currentScene;
Commit: adc5b87cb6e52f7fa22d8395020121249718e5e4
https://github.com/scummvm/scummvm/commit/adc5b87cb6e52f7fa22d8395020121249718e5e4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:53+01:00
Commit Message:
WAGE: Implement performHealingMagic()
Changed paths:
engines/wage/combat.cpp
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index 96cab1e..2f87119 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -254,7 +254,42 @@ void WageEngine::performMagic(Chr *attacker, Chr *victim, Obj *magicalObject) {
}
void WageEngine::performHealingMagic(Chr *chr, Obj *magicalObject) {
- warning("STUB: performHealingMagic()");
+ char buf[512];
+
+ if (!chr->_playerCharacter) {
+ snprintf(buf, 512, "%s%s %ss %s%s.",
+ chr->getDefiniteArticle(true), chr->_name.c_str(),
+ magicalObject->_operativeVerb.c_str(),
+ getIndefiniteArticle(magicalObject->_name), magicalObject->_name.c_str());
+ appendText(buf);
+ }
+
+ int chance = _rnd->getRandomNumber(255);
+ if (chance < magicalObject->_accuracy) {
+ int type = magicalObject->_attackType;
+
+ if (type == Obj::HEALS_PHYSICAL_DAMAGE || type == Obj::HEALS_PHYSICAL_AND_SPIRITUAL_DAMAGE)
+ chr->_context._statVariables[PHYS_HIT_CUR] += magicalObject->_damage;
+
+ if (type == Obj::HEALS_SPIRITUAL_DAMAGE || type == Obj::HEALS_PHYSICAL_AND_SPIRITUAL_DAMAGE)
+ chr->_context._statVariables[SPIR_HIT_CUR] += magicalObject->_damage;
+
+ playSound(magicalObject->_sound);
+ appendText(magicalObject->_useMessage.c_str());
+
+ // TODO: what if enemy heals himself?
+ if (chr->_playerCharacter) {
+ double physicalPercent = (double)chr->_context._statVariables[PHYS_HIT_CUR] / chr->_context._statVariables[PHYS_HIT_BAS];
+ double spiritualPercent = (double)chr->_context._statVariables[SPIR_HIT_CUR] / chr->_context._statVariables[SPIR_HIT_BAS];
+ snprintf(buf, 256, "Your physical condition is %s.", getPercentMessage(physicalPercent));
+ appendText(buf);
+
+ snprintf(buf, 256, "Your spiritual condition is %s.", getPercentMessage(spiritualPercent));
+ appendText(buf);
+ }
+ }
+
+ decrementUses(magicalObject);
}
static const int directionsX[] = { 0, 0, 1, -1 };
Commit: b5d55fdf2b171ef6ff8f56d49b9f350283fde242
https://github.com/scummvm/scummvm/commit/b5d55fdf2b171ef6ff8f56d49b9f350283fde242
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:53+01:00
Commit Message:
WAGE: Implement decrementUses()
Changed paths:
engines/wage/combat.cpp
engines/wage/entities.cpp
engines/wage/entities.h
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index 2f87119..4a04331 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -232,7 +232,23 @@ void WageEngine::performAttack(Chr *attacker, Chr *victim, Obj *weapon) {
}
void WageEngine::decrementUses(Obj *obj) {
- warning("STUB: decrementUses()");
+ int numberOfUses = obj->_numberOfUses;
+ if (numberOfUses != -1) {
+ numberOfUses--;
+ if (numberOfUses > 0) {
+ obj->_numberOfUses = numberOfUses;
+ } else {
+ if (!obj->_failureMessage.empty()) {
+ appendText(obj->_failureMessage.c_str());
+ }
+ if (obj->_returnToRandomScene) {
+ _world->move(obj, _world->getRandomScene());
+ } else {
+ _world->move(obj, _world->_storageScene);
+ }
+ obj->resetState(obj->_currentOwner, obj->_currentScene);
+ }
+ }
}
bool WageEngine::attackHit(Chr *attacker, Chr *victim, Obj *weapon, int targetIndex) {
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 747d486..5149fb3 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -281,6 +281,10 @@ Designed *Obj::removeFromCharOrScene() {
return from;
}
+void Obj::resetState(Chr *owner, Scene *scene) {
+ warning("STUB: Obj::resetState()");
+}
+
Chr::Chr(String name, Common::SeekableReadStream *data) {
_name = name;
_classType = CHR;
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 58cc82a..aaaaee5 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -288,13 +288,10 @@ public:
_currentOwner = NULL;
}
- void decrementNumberOfUses() {
- if (_numberOfUses != -1)
- _numberOfUses--;
- }
-
Chr *removeFromChr();
Designed *removeFromCharOrScene();
+
+ void resetState(Chr *owner, Scene *scene);
};
class Scene : public Designed {
Commit: a9b7b0463056e23b0bcd229876e7d4285e2b5f5e
https://github.com/scummvm/scummvm/commit/a9b7b0463056e23b0bcd229876e7d4285e2b5f5e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:53+01:00
Commit Message:
WAGE: Implement tryAttack()
Changed paths:
engines/wage/combat.cpp
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index 4a04331..d1f5d26 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -743,9 +743,14 @@ bool WageEngine::handleOfferCommand(const char *target) {
}
bool WageEngine::tryAttack(Obj *weapon, Common::String &input) {
- warning("STUB: tryAttack");
-
- return false;
+ Common::String w(weapon->_name);
+ w.toLowercase();
+ Common::String i(input);
+ i.toLowercase();
+ Common::String v(weapon->_operativeVerb);
+ v.toLowercase();
+
+ return i.contains(w) && i.contains(v);
}
bool WageEngine::handleAttack(Obj *weapon) {
Commit: 45afdbbd5c9e5ddb8ac470b0b05dcb65f1f75d39
https://github.com/scummvm/scummvm/commit/45afdbbd5c9e5ddb8ac470b0b05dcb65f1f75d39
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:53+01:00
Commit Message:
WAGE: Implement handleOfferCommand()
Changed paths:
engines/wage/combat.cpp
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index d1f5d26..f769e17 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -737,7 +737,31 @@ void WageEngine::wearObj(Obj *o, int pos) {
bool WageEngine::handleOfferCommand(const char *target) {
- warning("STUB: handleOfferCommand");
+ Chr *player = _world->_player;
+ Chr *enemy = getMonster();
+
+ if (enemy != NULL) {
+ Common::String t(target);
+ t.toLowercase();
+
+ for (ObjArray::const_iterator it = player->_inventory.begin(); it != player->_inventory.end(); ++it) {
+ Common::String n((*it)->_name);
+ n.toLowercase();
+
+ if (t.contains(n)) {
+ if ((*it)->_value < enemy->_rejectsOffers) {
+ appendText("Your offer is rejected.");
+ } else {
+ appendText("Your offer is accepted.");
+ appendText(enemy->_acceptsOfferComment.c_str());
+ _world->move(*it, enemy);
+ _world->move(enemy, _world->_storageScene);
+ }
+
+ return true;
+ }
+ }
+ }
return false;
}
Commit: 34f9a1375dec7bf6b42104fd5ffed0c36c112130
https://github.com/scummvm/scummvm/commit/34f9a1375dec7bf6b42104fd5ffed0c36c112130
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:53+01:00
Commit Message:
WAGE: Get rid of Common::String import
Changed paths:
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/gui.cpp
engines/wage/script.cpp
engines/wage/script.h
engines/wage/util.cpp
engines/wage/wage.cpp
engines/wage/wage.h
engines/wage/world.cpp
engines/wage/world.h
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 5149fb3..85ce8cf 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -96,7 +96,7 @@ Scene::Scene() {
_visited = false;
}
-Scene::Scene(String name, Common::SeekableReadStream *data) {
+Scene::Scene(Common::String name, Common::SeekableReadStream *data) {
_name = name;
_classType = SCENE;
_design = new Design(data);
@@ -200,7 +200,7 @@ const char *Scene::getFontName() {
return "Unknown";
}
-Obj::Obj(String name, Common::SeekableReadStream *data) {
+Obj::Obj(Common::String name, Common::SeekableReadStream *data) {
_name = name;
_classType = OBJ;
_currentOwner = NULL;
@@ -285,7 +285,7 @@ void Obj::resetState(Chr *owner, Scene *scene) {
warning("STUB: Obj::resetState()");
}
-Chr::Chr(String name, Common::SeekableReadStream *data) {
+Chr::Chr(Common::String name, Common::SeekableReadStream *data) {
_name = name;
_classType = CHR;
_design = new Design(data);
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index aaaaee5..a9066fe 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -113,7 +113,7 @@ public:
Designed() : _design(NULL), _designBounds(NULL), _classType(UNKNOWN) {}
~Designed();
- String _name;
+ Common::String _name;
Design *_design;
Common::Rect *_designBounds;
OperandType _classType;
@@ -124,7 +124,7 @@ public:
void setDesignBounds(Common::Rect *bounds);
- String toString() { return _name; }
+ Common::String toString() { return _name; }
};
class Chr : public Designed {
@@ -149,10 +149,10 @@ public:
NUMBER_OF_ARMOR_TYPES = 4
};
- Chr(String name, Common::SeekableReadStream *data);
+ Chr(Common::String name, Common::SeekableReadStream *data);
int _index;
- String _initialScene;
+ Common::String _initialScene;
int _gender;
bool _nameProperNoun;
bool _playerCharacter;
@@ -171,20 +171,20 @@ public:
int _rejectsOffers;
int _followsOpponent;
- String _initialSound;
- String _scoresHitSound;
- String _receivesHitSound;
- String _dyingSound;
+ Common::String _initialSound;
+ Common::String _scoresHitSound;
+ Common::String _receivesHitSound;
+ Common::String _dyingSound;
- String _nativeWeapon1;
- String _operativeVerb1;
+ Common::String _nativeWeapon1;
+ Common::String _operativeVerb1;
int _weaponDamage1;
- String _weaponSound1;
+ Common::String _weaponSound1;
- String _nativeWeapon2;
- String _operativeVerb2;
+ Common::String _nativeWeapon2;
+ Common::String _operativeVerb2;
int _weaponDamage2;
- String _weaponSound2;
+ Common::String _weaponSound2;
int _winningWeapons;
int _winningMagic;
@@ -195,13 +195,13 @@ public:
int _losingRun;
int _losingOffer;
- String _initialComment;
- String _scoresHitComment;
- String _receivesHitComment;
- String _makesOfferComment;
- String _rejectsOfferComment;
- String _acceptsOfferComment;
- String _dyingWords;
+ Common::String _initialComment;
+ Common::String _scoresHitComment;
+ Common::String _receivesHitComment;
+ Common::String _makesOfferComment;
+ Common::String _rejectsOfferComment;
+ Common::String _acceptsOfferComment;
+ Common::String _dyingWords;
Scene *_currentScene;
ObjArray _inventory;
@@ -229,7 +229,7 @@ public:
class Obj : public Designed {
public:
Obj() : _currentOwner(NULL), _currentScene(NULL) {}
- Obj(String name, Common::SeekableReadStream *data);
+ Obj(Common::String name, Common::SeekableReadStream *data);
~Obj();
enum ObjectType {
@@ -261,19 +261,19 @@ public:
int _attackType;
int _numberOfUses;
bool _returnToRandomScene;
- String _sceneOrOwner;
- String _clickMessage;
- String _failureMessage;
- String _useMessage;
+ Common::String _sceneOrOwner;
+ Common::String _clickMessage;
+ Common::String _failureMessage;
+ Common::String _useMessage;
Scene *_currentScene;
Chr *_currentOwner;
int _type;
uint _accuracy;
- String _operativeVerb;
+ Common::String _operativeVerb;
int _damage;
- String _sound;
+ Common::String _sound;
public:
void setCurrentOwner(Chr *currentOwner) {
@@ -302,15 +302,15 @@ public:
};
Script *_script;
- String _text;
+ Common::String _text;
Common::Rect *_textBounds;
int _fontSize;
int _fontType; // 3 => Geneva, 22 => Courier, param to TextFont() function
bool _blocked[4];
- String _messages[4];
+ Common::String _messages[4];
int _soundFrequency; // times a minute, max 3600
int _soundType;
- String _soundName;
+ Common::String _soundName;
int _worldX;
int _worldY;
bool _visited;
@@ -319,7 +319,7 @@ public:
ChrList _chrs;
Scene();
- Scene(String name, Common::SeekableReadStream *data);
+ Scene(Common::String name, Common::SeekableReadStream *data);
~Scene();
Common::Rect *getTextBounds() {
@@ -333,10 +333,10 @@ public:
class Sound {
public:
- Sound(String name, Common::SeekableReadStream *data) : _name(name), _data(data) {}
+ Sound(Common::String name, Common::SeekableReadStream *data) : _name(name), _data(data) {}
~Sound() { }
- String _name;
+ Common::String _name;
Common::SeekableReadStream *_data;
};
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 5bebc39..967628b 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -409,7 +409,7 @@ enum {
kConOverscan = 3
};
-void Gui::flowText(String &str) {
+void Gui::flowText(Common::String &str) {
Common::StringArray wrappedLines;
int textW = _consoleTextArea.width() - kConWPadding * 2;
const Graphics::Font *font = getConsoleFont();
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 410186e..78ec766 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -80,7 +80,7 @@ void Script::printLine(int offset) {
}
}
-bool Script::execute(World *world, int loopCount, String *inputText, Designed *inputClick, WageEngine *engine) {
+bool Script::execute(World *world, int loopCount, Common::String *inputText, Designed *inputClick, WageEngine *engine) {
_world = world;
_loopCount = loopCount;
_inputText = inputText;
@@ -384,10 +384,10 @@ void Script::assign(byte operandType, int uservar, uint16 value) {
}
Script::Operand *Script::readStringOperand() {
- String *sb;
+ Common::String *sb;
bool allDigits = true;
- sb = new String();
+ sb = new Common::String();
while (true) {
byte c = _data->readByte();
diff --git a/engines/wage/script.h b/engines/wage/script.h
index 143a93d..39fbbc5 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -61,7 +61,7 @@ private:
WageEngine *_engine;
World *_world;
int _loopCount;
- String *_inputText;
+ Common::String *_inputText;
Designed *_inputClick;
bool _handled;
@@ -73,7 +73,7 @@ private:
Designed *designed;
Scene *scene;
int16 number;
- String *string;
+ Common::String *string;
Designed *inputClick;
} _value;
OperandType _type;
@@ -99,7 +99,7 @@ private:
_type = type;
}
- Operand(String *value, OperandType type) {
+ Operand(Common::String *value, OperandType type) {
_value.string = value;
_type = type;
}
@@ -149,7 +149,7 @@ private:
public:
void print();
void printLine(int offset);
- bool execute(World *world, int loopCount, String *inputText, Designed *inputClick, WageEngine *engine);
+ bool execute(World *world, int loopCount, Common::String *inputText, Designed *inputClick, WageEngine *engine);
private:
Operand *readOperand();
diff --git a/engines/wage/util.cpp b/engines/wage/util.cpp
index 1216a27..2586c28 100644
--- a/engines/wage/util.cpp
+++ b/engines/wage/util.cpp
@@ -87,7 +87,7 @@ Common::Rect *readRect(Common::SeekableReadStream *in) {
return new Common::Rect(x1, y1, x2, y2);
}
-const char *getIndefiniteArticle(String &word) {
+const char *getIndefiniteArticle(Common::String &word) {
switch (word[0]) {
case 'a': case 'A':
case 'e': case 'E':
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 6f3f4b2..de5f9e1 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -196,11 +196,11 @@ void WageEngine::processEvents() {
}
}
-void WageEngine::playSound(String soundName) {
+void WageEngine::playSound(Common::String soundName) {
warning("STUB: WageEngine::playSound(%s)", soundName.c_str());
}
-void WageEngine::setMenu(String soundName) {
+void WageEngine::setMenu(Common::String soundName) {
warning("STUB: WageEngine::setMenu");
}
@@ -268,7 +268,7 @@ void WageEngine::performInitialSetup() {
for (uint i = 0; i < _world->_orderedObjs.size(); i++) {
Obj *obj = _world->_orderedObjs[i];
if (!obj->_sceneOrOwner.equalsIgnoreCase(STORAGESCENE)) {
- String location = obj->_sceneOrOwner;
+ Common::String location = obj->_sceneOrOwner;
location.toLowercase();
if (_world->_scenes.contains(location)) {
_world->move(obj, _world->_scenes[location]);
@@ -288,7 +288,7 @@ void WageEngine::performInitialSetup() {
for (uint i = 0; i < _world->_orderedChrs.size(); i++) {
Chr *chr = _world->_orderedChrs[i];
if (!chr->_initialScene.equalsIgnoreCase(STORAGESCENE)) {
- String key = chr->_initialScene;
+ Common::String key = chr->_initialScene;
key.toLowercase();
if (_world->_scenes.contains(key)) {
_world->move(chr, _world->_scenes[key]);
@@ -313,7 +313,7 @@ void WageEngine::doClose() {
warning("STUB: doClose()");
}
-Scene *WageEngine::getSceneByName(String &location) {
+Scene *WageEngine::getSceneByName(Common::String &location) {
Scene *scene;
if (location.equals("random@")) {
scene = _world->getRandomScene();
@@ -354,7 +354,7 @@ void WageEngine::onMove(Designed *what, Designed *from, Designed *to) {
if (to == _world->_storageScene) {
int returnTo = chr->_returnTo;
if (returnTo != Chr::RETURN_TO_STORAGE) {
- String returnToSceneName;
+ Common::String returnToSceneName;
if (returnTo == Chr::RETURN_TO_INITIAL_SCENE) {
returnToSceneName = chr->_initialScene;
returnToSceneName.toLowercase();
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 416c8b2..65bfa91 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -74,8 +74,6 @@ typedef Common::Array<Chr *> ChrArray;
typedef Common::List<Obj *> ObjList;
typedef Common::List<Chr *> ChrList;
-using Common::String;
-
enum OperandType {
OBJ = 0,
CHR = 1,
@@ -111,7 +109,7 @@ enum {
Common::String readPascalString(Common::SeekableReadStream *in);
Common::Rect *readRect(Common::SeekableReadStream *in);
-const char *getIndefiniteArticle(String &word);
+const char *getIndefiniteArticle(Common::String &word);
const char *prependGenderSpecificPronoun(int gender);
const char *getGenderSpecificPronoun(int gender, bool capitalize);
@@ -200,15 +198,15 @@ public:
Common::String _inputText;
- void playSound(String soundName);
- void setMenu(String soundName);
+ void playSound(Common::String soundName);
+ void setMenu(Common::String soundName);
void appendText(const char *str);
void gameOver();
bool saveDialog();
Obj *getOffer();
Chr *getMonster();
void processEvents();
- Scene *getSceneByName(String &location);
+ Scene *getSceneByName(Common::String &location);
void onMove(Designed *what, Designed *from, Designed *to);
void encounter(Chr *player, Chr *chr);
void redrawScene();
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index cead6ae..fbb7245 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -180,7 +180,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
scene->_fontType = res->readUint16BE();
scene->_fontSize = res->readUint16BE();
- String text;
+ Common::String text;
while (res->pos() < res->size()) {
char c = res->readByte();
if (c == 0x0d)
@@ -299,8 +299,8 @@ bool World::loadWorld(Common::MacResManager *resMan) {
Common::StringArray *World::readMenu(Common::SeekableReadStream *res) {
res->skip(10);
int enableFlags = res->readUint32BE();
- String menuName = readPascalString(res);
- String menuItem = readPascalString(res);
+ Common::String menuName = readPascalString(res);
+ Common::String menuItem = readPascalString(res);
int menuItemNumber = 1;
Common::String menu;
byte itemData[4];
@@ -339,7 +339,7 @@ Common::StringArray *World::readMenu(Common::SeekableReadStream *res) {
return result;
}
-void World::loadExternalSounds(String fname) {
+void World::loadExternalSounds(Common::String fname) {
Common::File in;
in.open(fname);
diff --git a/engines/wage/world.h b/engines/wage/world.h
index ba1aa16..cb72391 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -58,7 +58,7 @@ public:
~World();
bool loadWorld(Common::MacResManager *resMan);
- void loadExternalSounds(String fname);
+ void loadExternalSounds(Common::String fname);
Common::String *loadStringFromDITL(Common::MacResManager *resMan, int resourceId, int itemIndex);
void move(Obj *obj, Chr *chr);
void move(Obj *obj, Scene *scene, bool skipSort = false);
@@ -70,17 +70,17 @@ public:
WageEngine *_engine;
- String _name;
- String _aboutMessage;
- String _soundLibrary1;
- String _soundLibrary2;
+ Common::String _name;
+ Common::String _aboutMessage;
+ Common::String _soundLibrary1;
+ Common::String _soundLibrary2;
bool _weaponMenuDisabled;
Script *_globalScript;
- Common::HashMap<String, Scene *> _scenes;
- Common::HashMap<String, Obj *> _objs;
- Common::HashMap<String, Chr *> _chrs;
- Common::HashMap<String, Sound *> _sounds;
+ Common::HashMap<Common::String, Scene *> _scenes;
+ Common::HashMap<Common::String, Obj *> _objs;
+ Common::HashMap<Common::String, Chr *> _chrs;
+ Common::HashMap<Common::String, Sound *> _sounds;
Common::Array<Scene *> _orderedScenes;
ObjArray _orderedObjs;
ChrArray _orderedChrs;
@@ -102,7 +102,7 @@ public:
void addScene(Scene *room) {
if (room->_name.size() != 0) {
- String s = room->_name;
+ Common::String s = room->_name;
s.toLowercase();
_scenes[s] = room;
}
@@ -110,7 +110,7 @@ public:
}
void addObj(Obj *obj) {
- String s = obj->_name;
+ Common::String s = obj->_name;
s.toLowercase();
_objs[s] = obj;
obj->_index = _orderedObjs.size();
@@ -118,7 +118,7 @@ public:
}
void addChr(Chr *chr) {
- String s = chr->_name;
+ Common::String s = chr->_name;
s.toLowercase();
_chrs[s] = chr;
chr->_index = _orderedChrs.size();
@@ -126,7 +126,7 @@ public:
}
void addSound(Sound *sound) {
- String s = sound->_name;
+ Common::String s = sound->_name;
s.toLowercase();
_sounds[s] = sound;
_orderedSounds.push_back(sound);
Commit: f813c0e556883254e9b9e2275535c4e7fc0859dc
https://github.com/scummvm/scummvm/commit/f813c0e556883254e9b9e2275535c4e7fc0859dc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:54+01:00
Commit Message:
WAGE: Some renames
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 78ec766..bc43f29 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -384,15 +384,15 @@ void Script::assign(byte operandType, int uservar, uint16 value) {
}
Script::Operand *Script::readStringOperand() {
- Common::String *sb;
+ Common::String *str;
bool allDigits = true;
- sb = new Common::String();
+ str = new Common::String();
while (true) {
byte c = _data->readByte();
if (c >= 0x20 && c < 0x80)
- *sb += c;
+ *str += c;
else
break;
if (c < '0' || c > '9')
@@ -400,14 +400,14 @@ Script::Operand *Script::readStringOperand() {
}
_data->seek(-1, SEEK_CUR);
- if (allDigits && sb->size() > 0) {
- int r = atol(sb->c_str());
- delete sb;
+ if (allDigits && str->size() > 0) {
+ int r = atol(str->c_str());
+ delete str;
return new Operand(r, NUMBER);
} else {
// TODO: This string could be a room name or something like that.
- return new Operand(sb, STRING);
+ return new Operand(str, STRING);
}
}
Commit: e22626529489301ecb0298c7dcf06a40c8b36d99
https://github.com/scummvm/scummvm/commit/e22626529489301ecb0298c7dcf06a40c8b36d99
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:54+01:00
Commit Message:
WAGE: Implement attackHit()
Changed paths:
engines/wage/combat.cpp
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index f769e17..6864805 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -252,9 +252,94 @@ void WageEngine::decrementUses(Obj *obj) {
}
bool WageEngine::attackHit(Chr *attacker, Chr *victim, Obj *weapon, int targetIndex) {
- warning("STUB: attackHit");
+ bool receivedHitTextPrinted = false;
+ char buf[512];
- return false;
+ if (targetIndex != -1) {
+ Obj *armor = victim->_armor[targetIndex];
+ if (armor != NULL) {
+ // TODO: Absorb some damage.
+ snprintf(buf, 512, "%s%s's %s weakens the impact of %s%s's %s.",
+ victim->getDefiniteArticle(true), victim->_name.c_str(),
+ victim->_armor[targetIndex]->_name.c_str(),
+ attacker->getDefiniteArticle(false), attacker->_name.c_str(),
+ weapon->_name.c_str());
+ appendText(buf);
+ decrementUses(armor);
+ } else {
+ snprintf(buf, 512, "A hit to the %s!", targets[targetIndex]);
+ appendText(buf);
+ }
+ playSound(attacker->_scoresHitSound);
+ appendText(attacker->_scoresHitComment.c_str());
+ playSound(victim->_receivesHitSound);
+ appendText(victim->_receivesHitComment.c_str());
+ receivedHitTextPrinted = true;
+ } else if (weapon->_type == Obj::MAGICAL_OBJECT) {
+ appendText(weapon->_useMessage.c_str());
+ appendText("The spell is effective!");
+ }
+
+ bool causesPhysicalDamage = true;
+ bool causesSpiritualDamage = false;
+ bool freezesOpponent = false;
+ bool usesDecremented = false;
+
+ if (weapon->_type == Obj::THROW_WEAPON) {
+ _world->move(weapon, victim->_currentScene);
+ } else if (weapon->_type == Obj::MAGICAL_OBJECT) {
+ int type = weapon->_attackType;
+ causesPhysicalDamage = (type == Obj::CAUSES_PHYSICAL_DAMAGE || type == Obj::CAUSES_PHYSICAL_AND_SPIRITUAL_DAMAGE);
+ causesSpiritualDamage = (type == Obj::CAUSES_SPIRITUAL_DAMAGE || type == Obj::CAUSES_PHYSICAL_AND_SPIRITUAL_DAMAGE);
+ freezesOpponent = (type == Obj::FREEZES_OPPONENT);
+ }
+
+ if (causesPhysicalDamage) {
+ victim->_context._userVariables[PHYS_HIT_CUR] -= weapon->_damage;
+
+ /* Do it here to get the right order of messages in case of death. */
+ decrementUses(weapon);
+ usesDecremented = true;
+
+ if (victim->_context._userVariables[PHYS_HIT_CUR] < 0) {
+ playSound(victim->_dyingSound);
+ appendText(victim->_dyingWords.c_str());
+ snprintf(buf, 512, "%s%s is dead!", victim->getDefiniteArticle(true), victim->_name.c_str());
+ appendText(buf);
+
+ attacker->_context._kills++;
+ attacker->_context._experience += victim->_context._userVariables[SPIR_HIT_CUR] + victim->_context._userVariables[PHYS_HIT_CUR];
+
+ if (!victim->_playerCharacter && !victim->_inventory.empty()) {
+ Scene *currentScene = victim->_currentScene;
+
+ for (int i = victim->_inventory.size() - 1; i >= 0; i--) {
+ _world->move(victim->_inventory[i], currentScene);
+ }
+ Common::String *s = getGroundItemsList(currentScene);
+ appendText(s->c_str());
+ delete s;
+ }
+ _world->move(victim, _world->_storageScene);
+ } else if (attacker->_playerCharacter && !receivedHitTextPrinted) {
+ double physicalPercent = (double)victim->_context._userVariables[SPIR_HIT_CUR] /
+ victim->_context._userVariables[SPIR_HIT_BAS];
+ snprintf(buf, 512, "%s%s's condition appears to be %s.",
+ victim->getDefiniteArticle(true), victim->_name.c_str(),
+ getPercentMessage(physicalPercent));
+ appendText(buf);
+ }
+ }
+
+ if (causesSpiritualDamage) {
+ /* TODO */
+ }
+
+ if (freezesOpponent) {
+ victim->_context._frozen = true;
+ }
+
+ return usesDecremented;
}
void WageEngine::performMagic(Chr *attacker, Chr *victim, Obj *magicalObject) {
Commit: da0611ec30ad9a28b368ea062903a53bd3aa8d86
https://github.com/scummvm/scummvm/commit/da0611ec30ad9a28b368ea062903a53bd3aa8d86
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:54+01:00
Commit Message:
WAGE: Implement handleAttack()
Changed paths:
engines/wage/combat.cpp
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index 6864805..50b6e1d 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -863,7 +863,24 @@ bool WageEngine::tryAttack(Obj *weapon, Common::String &input) {
}
bool WageEngine::handleAttack(Obj *weapon) {
- warning("STUB: handleAttack");
+ Chr *player = _world->_player;
+ Chr *enemy = getMonster();
+
+ if (weapon->_type == Obj::MAGICAL_OBJECT) {
+ switch (weapon->_attackType) {
+ case Obj::HEALS_PHYSICAL_AND_SPIRITUAL_DAMAGE:
+ case Obj::HEALS_PHYSICAL_DAMAGE:
+ case Obj::HEALS_SPIRITUAL_DAMAGE:
+ performMagic(player, enemy, weapon);
+ return true;
+ }
+ }
+ if (enemy != NULL)
+ performAttack(player, enemy, weapon);
+ else if (weapon->_type == Obj::MAGICAL_OBJECT)
+ appendText("There is nobody to cast a spell at.");
+ else
+ appendText("There is no one to fight.");
return true;
}
Commit: 0e34bff8ab397b5af5d245e922516e40d22511a1
https://github.com/scummvm/scummvm/commit/0e34bff8ab397b5af5d245e922516e40d22511a1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:54+01:00
Commit Message:
WAGE: Implement getMagicalObjects()
Changed paths:
engines/wage/entities.cpp
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 85ce8cf..4852199 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -437,7 +437,9 @@ ObjArray *Chr::getWeapons(bool includeMagic) {
ObjArray *Chr::getMagicalObjects() {
ObjArray *list = new ObjArray;
- warning("STUB: getMagicalObjects");
+ for (uint i = 0; i < _inventory.size(); i++)
+ if (_inventory[i]->_type == Obj::MAGICAL_OBJECT)
+ list->push_back(_inventory[i]);
return list;
}
Commit: c2341f394895a4dc132b971e2b38660aef975beb
https://github.com/scummvm/scummvm/commit/c2341f394895a4dc132b971e2b38660aef975beb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:54+01:00
Commit Message:
WAGE: Refactor commands menu creation
Changed paths:
engines/wage/menu.cpp
engines/wage/menu.h
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index e9cecfc..2b25820 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -144,8 +144,9 @@ Menu::Menu(Gui *gui) : _gui(gui) {
_items[m->menunum]->subitems.push_back(new MenuSubItem(m->title, m->action, 0, m->shortcut, m->enabled));
}
- MenuItem *commands = createCommandsMenu();
- _items.push_back(commands);
+ _commands = new MenuItem(_gui->_engine->_world->_commandsMenuName.c_str());
+ _items.push_back(_commands);
+ regenCommandsMenu();
if (!_gui->_engine->_world->_weaponMenuDisabled) {
_weapons = new MenuItem(_gui->_engine->_world->_weaponsMenuName.c_str());
@@ -194,8 +195,17 @@ Menu::~Menu() {
}
}
-MenuItem *Menu::createCommandsMenu() {
- MenuItem *menu = new MenuItem(_gui->_engine->_world->_commandsMenuName.c_str());
+void Menu::regenCommandsMenu() {
+ for (int j = 0; j < _commands->subitems.size(); j++)
+ delete _commands->subitems[j];
+
+ _commands->subitems.clear();
+
+ createWeaponsMenu(_commands);
+ calcMenuBounds(_commands);
+}
+
+void Menu::createCommandsMenu(MenuItem *menu) {
Common::String string(_gui->_engine->_world->_commandsMenu);
Common::String item;
@@ -259,8 +269,6 @@ MenuItem *Menu::createCommandsMenu() {
item = "";
}
-
- return menu;
}
void Menu::regenWeaponsMenu() {
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index 91c996b..62bc252 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -89,12 +89,14 @@ private:
int calculateMenuWidth(MenuItem *menu);
void calcMenuBounds(MenuItem *menu);
void renderSubmenu(MenuItem *menu);
- MenuItem *createCommandsMenu();
+ void regenCommandsMenu();
+ void createCommandsMenu(MenuItem *menu);
void createWeaponsMenu(MenuItem *menu);
void executeCommand(MenuSubItem *subitem);
Common::Array<MenuItem *> _items;
MenuItem *_weapons;
+ MenuItem *_commands;
const Graphics::Font *_font;
Commit: 345effab985f93fdd4f5728fc9f46e58cf64019f
https://github.com/scummvm/scummvm/commit/345effab985f93fdd4f5728fc9f46e58cf64019f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:55+01:00
Commit Message:
WAGE: Implement WageEngine::setMenu()
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/menu.h
engines/wage/wage.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 967628b..354616b 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -575,6 +575,10 @@ void Gui::loadFonts() {
delete dat;
}
+void Gui::regenCommandsMenu() {
+ _menu->regenCommandsMenu();
+}
+
void Gui::regenWeaponsMenu() {
_menu->regenWeaponsMenu();
}
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 45ef50c..5f15067 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -98,6 +98,7 @@ public:
void drawInput();
void setSceneDirty() { _sceneDirty = true; }
const Graphics::Font *getFont(const char *name, Graphics::FontManager::FontUsage fallback);
+ void regenCommandsMenu();
void regenWeaponsMenu();
private:
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index 62bc252..82c0106 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -73,6 +73,7 @@ public:
bool mouseRelease(int x, int y);
bool mouseMove(int x, int y);
+ void regenCommandsMenu();
void regenWeaponsMenu();
bool _menuActivated;
@@ -89,7 +90,6 @@ private:
int calculateMenuWidth(MenuItem *menu);
void calcMenuBounds(MenuItem *menu);
void renderSubmenu(MenuItem *menu);
- void regenCommandsMenu();
void createCommandsMenu(MenuItem *menu);
void createWeaponsMenu(MenuItem *menu);
void executeCommand(MenuSubItem *subitem);
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index de5f9e1..038bef5 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -200,8 +200,10 @@ void WageEngine::playSound(Common::String soundName) {
warning("STUB: WageEngine::playSound(%s)", soundName.c_str());
}
-void WageEngine::setMenu(Common::String soundName) {
- warning("STUB: WageEngine::setMenu");
+void WageEngine::setMenu(Common::String menu) {
+ _world->_commandsMenu = menu;
+
+ _gui->regenCommandsMenu();
}
void WageEngine::appendText(const char *str) {
Commit: 07d176cace54afbdfbf100a67cbff261e5a0cb2f
https://github.com/scummvm/scummvm/commit/07d176cace54afbdfbf100a67cbff261e5a0cb2f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:55+01:00
Commit Message:
WAGE: Put less significant games to generic target
Changed paths:
engines/wage/detection.cpp
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
index 594fc5d..22ca7bc 100644
--- a/engines/wage/detection.cpp
+++ b/engines/wage/detection.cpp
@@ -41,10 +41,8 @@ static const PlainGameDescriptor wageGames[] = {
{"afm", "Another Fine Mess"},
{"amot", "A Mess O' Trouble"},
{"cantitoe", "Camp Cantitoe"},
- {"escapefromschool", "Escape from School!"},
- {"queenquest", "Queen Quest"},
{"scepters", "Enchanced Scepters"},
- {"wage", "World Adventure Game Engine game"},
+ {"wage", "WAGE"},
{0, 0}
};
@@ -79,8 +77,8 @@ static const ADGameDescription gameDescriptions[] = {
GUIO0()
},
{
- "escapefromschool",
- "",
+ "wage",
+ "Escape from School!",
AD_ENTRY1s("Escape from School!", "a854be48d4af20126d18a9cad93a969b", 51840),
Common::EN_ANY,
Common::kPlatformMacintosh,
@@ -88,8 +86,8 @@ static const ADGameDescription gameDescriptions[] = {
GUIO0()
},
{
- "queenquest",
- "",
+ "wage",
+ "Queen Quest",
AD_ENTRY1s("Queen Quest", "730605d312efedb5e3ff108522fcac18", 59776),
Common::EN_ANY,
Common::kPlatformMacintosh,
Commit: b44ba1b9015ba09bf3e4f9acc0c0cc523373d878
https://github.com/scummvm/scummvm/commit/b44ba1b9015ba09bf3e4f9acc0c0cc523373d878
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:55+01:00
Commit Message:
WAGE: Use extra as game name for generic games
Changed paths:
engines/wage/detection.cpp
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
index 22ca7bc..2a9bef2 100644
--- a/engines/wage/detection.cpp
+++ b/engines/wage/detection.cpp
@@ -82,7 +82,7 @@ static const ADGameDescription gameDescriptions[] = {
AD_ENTRY1s("Escape from School!", "a854be48d4af20126d18a9cad93a969b", 51840),
Common::EN_ANY,
Common::kPlatformMacintosh,
- ADGF_NO_FLAGS,
+ ADGF_USEEXTRAASTITLE,
GUIO0()
},
{
@@ -91,7 +91,7 @@ static const ADGameDescription gameDescriptions[] = {
AD_ENTRY1s("Queen Quest", "730605d312efedb5e3ff108522fcac18", 59776),
Common::EN_ANY,
Common::kPlatformMacintosh,
- ADGF_NO_FLAGS,
+ ADGF_USEEXTRAASTITLE,
GUIO0()
},
{
Commit: 3911c5c0311d252a26652c1dc5dea4faa9bf26ab
https://github.com/scummvm/scummvm/commit/3911c5c0311d252a26652c1dc5dea4faa9bf26ab
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:55+01:00
Commit Message:
WAGE: Added detection for Zoony
Changed paths:
engines/wage/detection.cpp
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
index 2a9bef2..1e05ccc 100644
--- a/engines/wage/detection.cpp
+++ b/engines/wage/detection.cpp
@@ -103,6 +103,15 @@ static const ADGameDescription gameDescriptions[] = {
ADGF_NO_FLAGS,
GUIO0()
},
+ {
+ "wage",
+ "Zoony",
+ AD_ENTRY1s("Zoony", "e6cc8a914a4215dafbcce6315dd12cf5", 160256),
+ Common::EN_ANY,
+ Common::kPlatformMacintosh,
+ ADGF_USEEXTRAASTITLE,
+ GUIO0()
+ },
AD_TABLE_END_MARKER
};
Commit: 6e91ae4b9f5adfb39eb163ffb4866d0d1e3bb83a
https://github.com/scummvm/scummvm/commit/6e91ae4b9f5adfb39eb163ffb4866d0d1e3bb83a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:56+01:00
Commit Message:
WAGE: Added ZikTuria detection
Changed paths:
engines/wage/detection.cpp
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
index 1e05ccc..9e44a6d 100644
--- a/engines/wage/detection.cpp
+++ b/engines/wage/detection.cpp
@@ -105,6 +105,15 @@ static const ADGameDescription gameDescriptions[] = {
},
{
"wage",
+ "ZikTuria",
+ AD_ENTRY1s("ZikTuria", "e793155bed1a70fa2074a3fcd696b751", 54784),
+ Common::EN_ANY,
+ Common::kPlatformMacintosh,
+ ADGF_USEEXTRAASTITLE,
+ GUIO0()
+ },
+ {
+ "wage",
"Zoony",
AD_ENTRY1s("Zoony", "e6cc8a914a4215dafbcce6315dd12cf5", 160256),
Common::EN_ANY,
Commit: 4aa7440ffd550439b2db755d31f6f051efa19195
https://github.com/scummvm/scummvm/commit/4aa7440ffd550439b2db755d31f6f051efa19195
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:56+01:00
Commit Message:
WAGE: Added Deep Angst detection
Changed paths:
engines/wage/detection.cpp
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
index 9e44a6d..f0e195c 100644
--- a/engines/wage/detection.cpp
+++ b/engines/wage/detection.cpp
@@ -78,6 +78,15 @@ static const ADGameDescription gameDescriptions[] = {
},
{
"wage",
+ "Deep Angst",
+ AD_ENTRY1s("Deep Angst", "635f62bbc569e72b03cab9107927d03d", 335232),
+ Common::EN_ANY,
+ Common::kPlatformMacintosh,
+ ADGF_USEEXTRAASTITLE,
+ GUIO0()
+ },
+ {
+ "wage",
"Escape from School!",
AD_ENTRY1s("Escape from School!", "a854be48d4af20126d18a9cad93a969b", 51840),
Common::EN_ANY,
Commit: cedee5b3d9bd6f1c99949347f49d799a9abc2f61
https://github.com/scummvm/scummvm/commit/cedee5b3d9bd6f1c99949347f49d799a9abc2f61
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:56+01:00
Commit Message:
WAGE: Drop language and platform for WAGE games
Changed paths:
engines/wage/detection.cpp
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
index f0e195c..80b1e1a 100644
--- a/engines/wage/detection.cpp
+++ b/engines/wage/detection.cpp
@@ -48,6 +48,9 @@ static const PlainGameDescriptor wageGames[] = {
namespace Wage {
+#define ADGF_DEFAULT (ADGF_DROPLANGUAGE|ADGF_DROPPLATFORM)
+#define ADGF_GENERIC (ADGF_DROPLANGUAGE|ADGF_DROPPLATFORM|ADGF_USEEXTRAASTITLE)
+
static const ADGameDescription gameDescriptions[] = {
{
"afm",
@@ -55,7 +58,7 @@ static const ADGameDescription gameDescriptions[] = {
AD_ENTRY1s("Another Fine Mess 1.8", "8e5aa915f3253efb2aab52435647b25e", 1456000),
Common::EN_ANY,
Common::kPlatformMacintosh,
- ADGF_NO_FLAGS,
+ ADGF_DEFAULT,
GUIO0()
},
{
@@ -64,7 +67,7 @@ static const ADGameDescription gameDescriptions[] = {
AD_ENTRY1s("A Mess O' Trouble 1.8", "b3ef53afed282671b704e45df829350c", 1895552),
Common::EN_ANY,
Common::kPlatformMacintosh,
- ADGF_NO_FLAGS,
+ ADGF_DEFAULT,
GUIO0()
},
{
@@ -73,7 +76,7 @@ static const ADGameDescription gameDescriptions[] = {
AD_ENTRY1s("Camp Cantitoe", "098aa5c11c58e1ef274a30a9e01b4755", 621440),
Common::EN_ANY,
Common::kPlatformMacintosh,
- ADGF_NO_FLAGS,
+ ADGF_DEFAULT,
GUIO0()
},
{
@@ -82,7 +85,7 @@ static const ADGameDescription gameDescriptions[] = {
AD_ENTRY1s("Deep Angst", "635f62bbc569e72b03cab9107927d03d", 335232),
Common::EN_ANY,
Common::kPlatformMacintosh,
- ADGF_USEEXTRAASTITLE,
+ ADGF_GENERIC,
GUIO0()
},
{
@@ -91,7 +94,7 @@ static const ADGameDescription gameDescriptions[] = {
AD_ENTRY1s("Escape from School!", "a854be48d4af20126d18a9cad93a969b", 51840),
Common::EN_ANY,
Common::kPlatformMacintosh,
- ADGF_USEEXTRAASTITLE,
+ ADGF_GENERIC,
GUIO0()
},
{
@@ -100,7 +103,7 @@ static const ADGameDescription gameDescriptions[] = {
AD_ENTRY1s("Queen Quest", "730605d312efedb5e3ff108522fcac18", 59776),
Common::EN_ANY,
Common::kPlatformMacintosh,
- ADGF_USEEXTRAASTITLE,
+ ADGF_GENERIC,
GUIO0()
},
{
@@ -109,7 +112,7 @@ static const ADGameDescription gameDescriptions[] = {
AD_ENTRY1s("Scepters", "b80bff315897776dda7689cdf829fab4", 360832),
Common::EN_ANY,
Common::kPlatformMacintosh,
- ADGF_NO_FLAGS,
+ ADGF_DEFAULT,
GUIO0()
},
{
@@ -118,7 +121,7 @@ static const ADGameDescription gameDescriptions[] = {
AD_ENTRY1s("ZikTuria", "e793155bed1a70fa2074a3fcd696b751", 54784),
Common::EN_ANY,
Common::kPlatformMacintosh,
- ADGF_USEEXTRAASTITLE,
+ ADGF_GENERIC,
GUIO0()
},
{
@@ -127,7 +130,7 @@ static const ADGameDescription gameDescriptions[] = {
AD_ENTRY1s("Zoony", "e6cc8a914a4215dafbcce6315dd12cf5", 160256),
Common::EN_ANY,
Common::kPlatformMacintosh,
- ADGF_USEEXTRAASTITLE,
+ ADGF_GENERIC,
GUIO0()
},
Commit: e41c3c50de4e1b077806b605466b5f01c9cb42c5
https://github.com/scummvm/scummvm/commit/e41c3c50de4e1b077806b605466b5f01c9cb42c5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:56+01:00
Commit Message:
WAGE: Fix crash in Deep Angst, when border is beyond the screen
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 354616b..ad212f2 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -398,6 +398,11 @@ void Gui::paintBorder(Graphics::Surface *g, Common::Rect &r, WindowType windowTy
font->drawString(g, _scene->_name, x + (width - w) / 2 + 5, y + yOff, w, kColorBlack);
}
+ if (x + width > _screen.w)
+ width = _screen.w - x;
+ if (y + height > _screen.h)
+ height = _screen.h - y;
+
g_system->copyRectToScreen(g->getBasePtr(x, y), g->pitch, x, y, width, height);
}
Commit: efc7bf645161a16799a6608a954ab518fa8d78b8
https://github.com/scummvm/scummvm/commit/efc7bf645161a16799a6608a954ab518fa8d78b8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:57+01:00
Commit Message:
WAGE: FIx crash in amot
Changed paths:
engines/wage/wage.cpp
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 038bef5..103be5d 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -292,7 +292,7 @@ void WageEngine::performInitialSetup() {
if (!chr->_initialScene.equalsIgnoreCase(STORAGESCENE)) {
Common::String key = chr->_initialScene;
key.toLowercase();
- if (_world->_scenes.contains(key)) {
+ if (_world->_scenes.contains(key) && _world->_scenes[key] != NULL) {
_world->move(chr, _world->_scenes[key]);
if (chr->_playerCharacter)
Commit: 12f02969beb3b16f1f9f7b887a622ff5ff018dfc
https://github.com/scummvm/scummvm/commit/12f02969beb3b16f1f9f7b887a622ff5ff018dfc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:57+01:00
Commit Message:
WAGE: Fix crashes during direction change
Changed paths:
engines/wage/combat.cpp
engines/wage/wage.cpp
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index 50b6e1d..576229f 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -409,10 +409,9 @@ void WageEngine::performMove(Chr *chr, int validMoves) {
int dir = _rnd->getRandomNumber(numValidMoves);
// And get it
-
for (int i = 0; i < 4; i++, dir--)
if ((validMoves & (1 << i)) != 0) {
- if (dir == 0) {
+ if (dir == 1) {
dir = i;
break;
}
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 103be5d..48f3c80 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -336,13 +336,6 @@ void WageEngine::onMove(Designed *what, Designed *from, Designed *to) {
return;
}
- if (!_temporarilyHidden) {
- assert(what);
- assert(from);
- assert(to);
- debug(6, "move: %s, %s -> %s", what->_name.c_str(), from->_name.c_str(), to->_name.c_str());
- }
-
if (from == currentScene || to == currentScene ||
(what->_classType == CHR && ((Chr *)what)->_currentScene == currentScene) ||
(what->_classType == OBJ && ((Obj *)what)->_currentScene == currentScene))
Commit: 6e3cd0bcb27c82dd042c191ff65f211cfc136094
https://github.com/scummvm/scummvm/commit/6e3cd0bcb27c82dd042c191ff65f211cfc136094
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:57+01:00
Commit Message:
WAGE: Better processing of direction abbreviations
Changed paths:
engines/wage/script.cpp
engines/wage/wage.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index bc43f29..1ee669a 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -164,13 +164,13 @@ bool Script::execute(World *world, int loopCount, Common::String *inputText, Des
_handled = true;
} else if (!input.empty()) {
input.toLowercase();
- if (input.equals("n") || input.contains("north")) {
+ if (input.contains("north")) {
_handled = _engine->handleMoveCommand(NORTH, "north");
- } else if (input.equals("e") || input.contains("east")) {
+ } else if (input.contains("east")) {
_handled = _engine->handleMoveCommand(EAST, "east");
- } else if (input.equals("s") || input.contains("south")) {
+ } else if (input.contains("south")) {
_handled = _engine->handleMoveCommand(SOUTH, "south");
- } else if (input.equals("w") || input.contains("west")) {
+ } else if (input.contains("west")) {
_handled = _engine->handleMoveCommand(WEST, "west");
} else if (input.hasPrefix("take ")) {
_handled = _engine->handleTakeCommand(&input.c_str()[5]);
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 48f3c80..b4819cb 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -453,7 +453,18 @@ void WageEngine::processTurn(Common::String *textInput, Designed *clickInput) {
_commandWasQuick = false;
Scene *prevScene = _world->_player->_currentScene;
Chr *prevMonster = getMonster();
- processTurnInternal(textInput, clickInput);
+ Common::String input(*textInput);
+ input.toLowercase();
+ if (input.equals("e"))
+ input = "east";
+ else if (input.equals("w"))
+ input = "west";
+ else if (input.equals("n"))
+ input = "north";
+ else if (input.equals("s"))
+ input = "south";
+
+ processTurnInternal(&input, clickInput);
Scene *playerScene = _world->_player->_currentScene;
if (prevScene != playerScene && playerScene != _world->_storageScene) {
Commit: 0a57ac4fc933d6dc3d16e1fe008a80fd429c08ed
https://github.com/scummvm/scummvm/commit/0a57ac4fc933d6dc3d16e1fe008a80fd429c08ed
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:57+01:00
Commit Message:
WAGE: Remove redundant operation
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 1ee669a..2c23a46 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -163,7 +163,6 @@ bool Script::execute(World *world, int loopCount, Common::String *inputText, Des
if (globalHandled)
_handled = true;
} else if (!input.empty()) {
- input.toLowercase();
if (input.contains("north")) {
_handled = _engine->handleMoveCommand(NORTH, "north");
} else if (input.contains("east")) {
Commit: 9d67bd022a8dbfe0dfa28124785f32031b5c6903
https://github.com/scummvm/scummvm/commit/9d67bd022a8dbfe0dfa28124785f32031b5c6903
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:57+01:00
Commit Message:
WAGE: Fix regression with commands menu
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 2b25820..a0d5dcd 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -201,7 +201,7 @@ void Menu::regenCommandsMenu() {
_commands->subitems.clear();
- createWeaponsMenu(_commands);
+ createCommandsMenu(_commands);
calcMenuBounds(_commands);
}
Commit: 95a3a31ee110df758317944b477d202d77384f42
https://github.com/scummvm/scummvm/commit/95a3a31ee110df758317944b477d202d77384f42
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:57+01:00
Commit Message:
WAGE: Initial code for shortcuts
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/menu.cpp
engines/wage/menu.h
engines/wage/wage.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index ad212f2..6285c48 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -588,6 +588,11 @@ void Gui::regenWeaponsMenu() {
_menu->regenWeaponsMenu();
}
+void Gui::processMenuShortCut(byte flags, uint16 ascii) {
+ _menu->processMenuShortCut(flags, ascii);
+}
+
+
void Gui::mouseMove(int x, int y) {
if (_menu->_menuActivated) {
if (_menu->mouseMove(x, y))
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 5f15067..b5f84e0 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -100,6 +100,7 @@ public:
const Graphics::Font *getFont(const char *name, Graphics::FontManager::FontUsage fallback);
void regenCommandsMenu();
void regenWeaponsMenu();
+ void processMenuShortCut(byte flags, uint16 ascii);
private:
void paintBorder(Graphics::Surface *g, Common::Rect &r, WindowType windowType);
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index a0d5dcd..5fc51bc 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -46,6 +46,7 @@
*/
#include "common/system.h"
+#include "common/keyboard.h"
#include "wage/wage.h"
#include "wage/entities.h"
@@ -550,4 +551,20 @@ void Menu::executeCommand(MenuSubItem *subitem) {
}
}
+void Menu::processMenuShortCut(byte flags, uint16 ascii) {
+ if (flags & (Common::KBD_CTRL | Common::KBD_META)) {
+ for (int i = 0; i < _items.size(); i++)
+ for (int j = 0; j < _items[i]->subitems.size(); j++)
+ if (_items[i]->subitems[j]->shortcut == ascii) {
+ if (_items[i]->subitems[j]->action == kMenuActionCommand)
+ _gui->_engine->processTurn(&_items[i]->subitems[j]->text, NULL);
+ else
+ warning("STUB: Unhandled shortcut");
+
+ break;
+ }
+ }
+}
+
+
} // End of namespace Wage
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index 82c0106..d817cf3 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -75,6 +75,7 @@ public:
void regenCommandsMenu();
void regenWeaponsMenu();
+ void processMenuShortCut(byte flags, uint16 ascii);
bool _menuActivated;
Common::Rect _bbox;
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index b4819cb..3d3fc6a 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -176,8 +176,10 @@ void WageEngine::processEvents() {
break;
default:
- if (event.kbd.flags & Common::KBD_ALT || event.kbd.flags & Common::KBD_CTRL) {
- warning("STUB: Shortcuts");
+ if (event.kbd.flags & (Common::KBD_ALT | Common::KBD_CTRL | Common::KBD_META)) {
+ if (event.kbd.ascii >= 0x20 && event.kbd.ascii <= 0x7f) {
+ _gui->processMenuShortCut(event.kbd.flags, event.kbd.ascii);
+ }
break;
}
Commit: 52c317b842db2bb272f61b1e12af1777c42a38c8
https://github.com/scummvm/scummvm/commit/52c317b842db2bb272f61b1e12af1777c42a38c8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:58+01:00
Commit Message:
WAGE: Make shortcuts functional
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 5fc51bc..a814934 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -552,10 +552,12 @@ void Menu::executeCommand(MenuSubItem *subitem) {
}
void Menu::processMenuShortCut(byte flags, uint16 ascii) {
+ ascii = tolower(ascii);
+
if (flags & (Common::KBD_CTRL | Common::KBD_META)) {
for (int i = 0; i < _items.size(); i++)
for (int j = 0; j < _items[i]->subitems.size(); j++)
- if (_items[i]->subitems[j]->shortcut == ascii) {
+ if (tolower(_items[i]->subitems[j]->shortcut) == ascii) {
if (_items[i]->subitems[j]->action == kMenuActionCommand)
_gui->_engine->processTurn(&_items[i]->subitems[j]->text, NULL);
else
Commit: 63ef49ec8afa761b89b809811699321c6fe5826e
https://github.com/scummvm/scummvm/commit/63ef49ec8afa761b89b809811699321c6fe5826e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:58+01:00
Commit Message:
WAGE: Rename mouse event processor to add clarity
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/wage.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 6285c48..1f07b2a 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -612,7 +612,7 @@ void Gui::mouseMove(int x, int y) {
}
}
-Designed *Gui::getClickTarget(int x, int y) {
+Designed *Gui::mouseUp(int x, int y) {
if (_menu->_menuActivated) {
if (_menu->mouseRelease(x, y)) {
_sceneDirty = true;
@@ -648,7 +648,7 @@ Designed *Gui::getClickTarget(int x, int y) {
return NULL;
}
-void Gui::mouseClick(int x, int y) {
+void Gui::mouseDown(int x, int y) {
if (_menu->mouseClick(x, y))
_menuDirty = true;
}
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index b5f84e0..488543e 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -93,8 +93,8 @@ public:
void appendText(const char *str);
void clearOutput();
void mouseMove(int x, int y);
- void mouseClick(int x, int y);
- Designed *getClickTarget(int x, int y);
+ void mouseDown(int x, int y);
+ Designed *mouseUp(int x, int y);
void drawInput();
void setSceneDirty() { _sceneDirty = true; }
const Graphics::Font *getFont(const char *name, Graphics::FontManager::FontUsage fallback);
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 3d3fc6a..043406f 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -148,11 +148,11 @@ void WageEngine::processEvents() {
_gui->mouseMove(event.mouse.x, event.mouse.y);
break;
case Common::EVENT_LBUTTONDOWN:
- _gui->mouseClick(event.mouse.x, event.mouse.y);
+ _gui->mouseDown(event.mouse.x, event.mouse.y);
break;
case Common::EVENT_LBUTTONUP:
{
- Designed *obj = _gui->getClickTarget(event.mouse.x, event.mouse.y);
+ Designed *obj = _gui->mouseUp(event.mouse.x, event.mouse.y);
if (obj != NULL)
processTurn(NULL, obj);
}
Commit: d812706328ddd31bd23b425d7d4eb7777d29ae55
https://github.com/scummvm/scummvm/commit/d812706328ddd31bd23b425d7d4eb7777d29ae55
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:58+01:00
Commit Message:
WAGE: Started text selection implementation
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 1f07b2a..3bd47bb 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -155,6 +155,8 @@ Gui::Gui(WageEngine *engine) {
_cursorState = false;
_cursorOff = false;
+ _inTextSelection = false;
+
g_system->getPaletteManager()->setPalette(palette, 0, 4);
CursorMan.replaceCursorPalette(palette, 0, 4);
@@ -649,8 +651,21 @@ Designed *Gui::mouseUp(int x, int y) {
}
void Gui::mouseDown(int x, int y) {
- if (_menu->mouseClick(x, y))
+ if (_menu->mouseClick(x, y)) {
_menuDirty = true;
+ } else if (_consoleTextArea.contains(x, y)) {
+ startMarking(x, y);
+ }
+}
+
+void Gui::startMarking(int x, int y) {
+ const int firstLine = _scrollPos / _consoleLineHeight;
+ int textLine = (y - kConHOverlap - kConHPadding - _scrollPos % _consoleLineHeight - _consoleTextArea.top) / _consoleLineHeight + firstLine;
+ int charPos = x - kConWOverlap - kConWPadding - _consoleTextArea.left;
+
+ _inTextSelection = true;
+
+ warning("x: %d y: %d", textLine, charPos);
}
} // End of namespace Wage
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 488543e..09c4693 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -111,6 +111,7 @@ private:
void flowText(Common::String &str);
const Graphics::Font *getConsoleFont();
const Graphics::Font *getTitleFont();
+ void startMarking(int x, int y);
public:
Graphics::Surface _screen;
@@ -143,6 +144,8 @@ private:
Common::Rect _sceneArea;
bool _sceneIsActive;
bool _cursorIsArrow;
+
+ bool _inTextSelection;
};
} // End of namespace Wage
Commit: 53e68cf92cd3dda8a428bce42015235766b0b70f
https://github.com/scummvm/scummvm/commit/53e68cf92cd3dda8a428bce42015235766b0b70f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:58+01:00
Commit Message:
WAGE: Calculate click position in text
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 3bd47bb..733241f 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -661,11 +661,23 @@ void Gui::mouseDown(int x, int y) {
void Gui::startMarking(int x, int y) {
const int firstLine = _scrollPos / _consoleLineHeight;
int textLine = (y - kConHOverlap - kConHPadding - _scrollPos % _consoleLineHeight - _consoleTextArea.top) / _consoleLineHeight + firstLine;
- int charPos = x - kConWOverlap - kConWPadding - _consoleTextArea.left;
+ int textChar = 0;
+ int charX = x - kConWOverlap - kConWPadding - _consoleTextArea.left;
+ const Graphics::Font *font = getConsoleFont();
+ Common::String str = _lines[textLine];
+
+ for (int i = str.size(); i >= 0; i--) {
+ if (font->getStringWidth(str) < charX) {
+ textChar = i;
+ break;
+ }
+
+ str.deleteLastChar();
+ }
_inTextSelection = true;
- warning("x: %d y: %d", textLine, charPos);
+ warning("x: %d y: %d", textLine, textChar);
}
} // End of namespace Wage
Commit: 0ab0daa1dc2717a39455b85048d26570544751a6
https://github.com/scummvm/scummvm/commit/0ab0daa1dc2717a39455b85048d26570544751a6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:58+01:00
Commit Message:
WAGE: Further work on console selection
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 733241f..b121258 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -156,6 +156,8 @@ Gui::Gui(WageEngine *engine) {
_cursorOff = false;
_inTextSelection = false;
+ _selectionStartX = _selectionStartY = -1;
+ _selectionEndX = _selectionEndY = -1;
g_system->getPaletteManager()->setPalette(palette, 0, 4);
@@ -494,9 +496,14 @@ void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) {
for (int line = firstLine; line < lastLine; line++) {
const char *str = _lines[line].c_str();
+ int color = kColorBlack;
+
+ if (line >= _selectionStartY && line <= _selectionEndY) {
+ color = kColorWhite;
+ }
if (*str)
- font->drawString(&_console, _lines[line], x1, y1, textW, kColorBlack);
+ font->drawString(&_console, _lines[line], x1, y1, textW, color);
y1 += _consoleLineHeight;
}
@@ -603,6 +610,11 @@ void Gui::mouseMove(int x, int y) {
return;
}
+ if (_inTextSelection) {
+ updateTextSelection(x, y);
+ return;
+ }
+
if (_consoleTextArea.contains(x, y)) {
if (_cursorIsArrow) {
CursorMan.replaceCursor(macCursorBeam, 11, 16, 3, 8, 3);
@@ -625,6 +637,10 @@ Designed *Gui::mouseUp(int x, int y) {
return NULL;
}
+
+ if (_inTextSelection)
+ _inTextSelection = false;
+
if (_sceneArea.contains(x, y)) {
if (!_sceneIsActive) {
_sceneIsActive = true;
@@ -658,26 +674,51 @@ void Gui::mouseDown(int x, int y) {
}
}
-void Gui::startMarking(int x, int y) {
- const int firstLine = _scrollPos / _consoleLineHeight;
- int textLine = (y - kConHOverlap - kConHPadding - _scrollPos % _consoleLineHeight - _consoleTextArea.top) / _consoleLineHeight + firstLine;
- int textChar = 0;
- int charX = x - kConWOverlap - kConWPadding - _consoleTextArea.left;
+int Gui::calcTextX(int x, int textLine) {
const Graphics::Font *font = getConsoleFont();
Common::String str = _lines[textLine];
+ x -= _consoleTextArea.left + kConWOverlap + kConWPadding;
+
for (int i = str.size(); i >= 0; i--) {
- if (font->getStringWidth(str) < charX) {
- textChar = i;
- break;
+ if (font->getStringWidth(str) < x) {
+ return i;
}
str.deleteLastChar();
}
+ return 0;
+}
+
+int Gui::calcTextY(int y) {
+ y -= _consoleTextArea.top + kConHOverlap + kConHPadding;
+
+ if (y < 0)
+ y = 0;
+
+ const int firstLine = _scrollPos / _consoleLineHeight;
+ int textLine = (y - _scrollPos % _consoleLineHeight) / _consoleLineHeight + firstLine;
+
+ return textLine;
+}
+
+void Gui::startMarking(int x, int y) {
+ warning("x: %d y: %d", x, y);
+ _selectionStartY = calcTextY(y);
+ _selectionStartX = calcTextX(x, _selectionStartY);
+
_inTextSelection = true;
- warning("x: %d y: %d", textLine, textChar);
+ warning("x: %d y: %d", _selectionStartX, _selectionStartY);
+}
+
+void Gui::updateTextSelection(int x, int y) {
+ warning("x: %d y: %d", x, y);
+ _selectionEndY = calcTextY(y);
+ _selectionEndX = calcTextX(x, _selectionStartY);
+
+ _consoleFullRedraw = true;
}
} // End of namespace Wage
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 09c4693..6adba27 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -112,6 +112,9 @@ private:
const Graphics::Font *getConsoleFont();
const Graphics::Font *getTitleFont();
void startMarking(int x, int y);
+ int calcTextX(int x, int textLine);
+ int calcTextY(int y);
+ void updateTextSelection(int x, int y);
public:
Graphics::Surface _screen;
@@ -146,6 +149,10 @@ private:
bool _cursorIsArrow;
bool _inTextSelection;
+ int _selectionStartX;
+ int _selectionStartY;
+ int _selectionEndX;
+ int _selectionEndY;
};
} // End of namespace Wage
Commit: 42793dac253314e574db295a7d989f523a906d7f
https://github.com/scummvm/scummvm/commit/42793dac253314e574db295a7d989f523a906d7f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:58+01:00
Commit Message:
WAGE: Show warning for missing functionality
Changed paths:
engines/wage/combat.cpp
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index 576229f..6e2403c 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -333,6 +333,7 @@ bool WageEngine::attackHit(Chr *attacker, Chr *victim, Obj *weapon, int targetIn
if (causesSpiritualDamage) {
/* TODO */
+ warning("TODO: Spiritual damage");
}
if (freezesOpponent) {
Commit: ed21eaef99466483ad921ce29e1de2b4b950ec64
https://github.com/scummvm/scummvm/commit/ed21eaef99466483ad921ce29e1de2b4b950ec64
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:59+01:00
Commit Message:
WAGE: Fixed typo in game name
Changed paths:
engines/wage/detection.cpp
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
index 80b1e1a..fd79eb6 100644
--- a/engines/wage/detection.cpp
+++ b/engines/wage/detection.cpp
@@ -41,7 +41,7 @@ static const PlainGameDescriptor wageGames[] = {
{"afm", "Another Fine Mess"},
{"amot", "A Mess O' Trouble"},
{"cantitoe", "Camp Cantitoe"},
- {"scepters", "Enchanced Scepters"},
+ {"scepters", "Enchanted Scepters"},
{"wage", "WAGE"},
{0, 0}
};
Commit: ed3372d8bf42e1300e4c875edc444c77c64864f3
https://github.com/scummvm/scummvm/commit/ed3372d8bf42e1300e4c875edc444c77c64864f3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:59+01:00
Commit Message:
WAGE: Fix formatting
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index b121258..200c8ff 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -342,41 +342,41 @@ void Gui::paintBorder(Graphics::Surface *g, Common::Rect &r, WindowType windowTy
break;
}
- drawBox(g, x, y, size, size);
- drawBox(g, x+width-size-1, y, size, size);
- drawBox(g, x+width-size-1, y+height-size-1, size, size);
- drawBox(g, x, y+height-size-1, size, size);
- drawBox(g, x + size, y + 2, width - 2*size - 1, size - 4);
- drawBox(g, x + size, y + height - size + 1, width - 2*size - 1, size - 4);
- drawBox(g, x + 2, y + size, size - 4, height - 2*size - 1);
- drawBox(g, x + width - size + 1, y + size, size - 4, height - 2*size-1);
+ drawBox(g, x, y, size, size);
+ drawBox(g, x + width - size - 1, y, size, size);
+ drawBox(g, x + width - size - 1, y + height - size - 1, size, size);
+ drawBox(g, x, y + height - size - 1, size, size);
+ drawBox(g, x + size, y + 2, width - 2 * size - 1, size - 4);
+ drawBox(g, x + size, y + height - size + 1, width - 2 * size - 1, size - 4);
+ drawBox(g, x + 2, y + size, size - 4, height - 2 * size - 1);
+ drawBox(g, x + width - size + 1, y + size, size - 4, height - 2 * size - 1);
if (active) {
- fillRect(g, x + size, y + 5, width - 2*size - 1, 8);
- fillRect(g, x + size, y + height - 13, width - 2*size - 1, 8);
- fillRect(g, x + 5, y + size, 8, height - 2*size - 1);
+ fillRect(g, x + size, y + 5, width - 2 * size - 1, 8);
+ fillRect(g, x + size, y + height - 13, width - 2 * size - 1, 8);
+ fillRect(g, x + 5, y + size, 8, height - 2 * size - 1);
if (!scrollable) {
- fillRect(g, x + width - 13, y + size, 8, height - 2*size - 1);
+ fillRect(g, x + width - 13, y + size, 8, height - 2 * size - 1);
} else {
int x1 = x + width - 15;
int y1 = y + size + 1;
for (int yy = 0; yy < ARROW_H; yy++) {
for (int xx = 0; xx < ARROW_W; xx++) {
if (arrowPixels[yy][xx] != 0) {
- g->hLine(x1+xx, y1+yy, x1+xx, kColorBlack);
+ g->hLine(x1 + xx, y1 + yy, x1 + xx, kColorBlack);
} else {
- g->hLine(x1+xx, y1+yy, x1+xx, kColorWhite);
+ g->hLine(x1 + xx, y1 + yy, x1 + xx, kColorWhite);
}
}
}
- fillRect(g, x + width - 13, y + size + ARROW_H, 8, height - 2*size - 1 - ARROW_H*2);
- y1 += height - 2*size - ARROW_H - 2;
+ fillRect(g, x + width - 13, y + size + ARROW_H, 8, height - 2 * size - 1 - ARROW_H * 2);
+ y1 += height - 2 * size - ARROW_H - 2;
for (int yy = 0; yy < ARROW_H; yy++) {
for (int xx = 0; xx < ARROW_W; xx++) {
- if (arrowPixels[ARROW_H-yy-1][xx] != 0) {
- g->hLine(x1+xx, y1+yy, x1+xx, kColorBlack);
+ if (arrowPixels[ARROW_H - yy - 1][xx] != 0) {
+ g->hLine(x1 + xx, y1 + yy, x1 + xx, kColorBlack);
} else {
- g->hLine(x1+xx, y1+yy, x1+xx, kColorWhite);
+ g->hLine(x1 + xx, y1 + yy, x1 + xx, kColorWhite);
}
}
}
@@ -395,7 +395,7 @@ void Gui::paintBorder(Graphics::Surface *g, Common::Rect &r, WindowType windowTy
int yOff = _builtInFonts ? 3 : 1;
int w = font->getStringWidth(_scene->_name) + 10;
- int maxWidth = width - size*2 - 7;
+ int maxWidth = width - size * 2 - 7;
if (w > maxWidth)
w = maxWidth;
drawBox(g, x + (width - w) / 2, y, w, size);
Commit: 81fb44960fd48563e6205cae08c5c29d9e162396
https://github.com/scummvm/scummvm/commit/81fb44960fd48563e6205cae08c5c29d9e162396
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:59+01:00
Commit Message:
WAGE: Rename function to CamelCase
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 200c8ff..2562456 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -111,7 +111,7 @@ static const byte macCursorBeam[] = {
0, 0, 3, 3, 3, 0, 0, 3, 3, 3, 3,
};
-static void cursor_timer_handler(void *refCon) {
+static void cursorTimerHandler(void *refCon) {
Gui *gui = (Gui *)refCon;
int x = gui->_cursorX;
@@ -171,7 +171,7 @@ Gui::Gui(WageEngine *engine) {
loadFonts();
- g_system->getTimerManager()->installTimerProc(&cursor_timer_handler, 200000, this, "wageCursor");
+ g_system->getTimerManager()->installTimerProc(&cursorTimerHandler, 200000, this, "wageCursor");
_menu = new Menu(this);
}
@@ -179,7 +179,7 @@ Gui::Gui(WageEngine *engine) {
Gui::~Gui() {
_screen.free();
_console.free();
- g_system->getTimerManager()->removeTimerProc(&cursor_timer_handler);
+ g_system->getTimerManager()->removeTimerProc(&cursorTimerHandler);
delete _menu;
}
@@ -531,7 +531,7 @@ void Gui::drawInput() {
// undraw cursor
_cursorOff = true;
_cursorState = false;
- cursor_timer_handler(this);
+ cursorTimerHandler(this);
_cursorOff = false;
Common::Rect r(x, y, x + textW + 10, y + font->getFontHeight());
Commit: 1d0eed9cddc89ff249343d08a472e7f5a5d2e4b6
https://github.com/scummvm/scummvm/commit/1d0eed9cddc89ff249343d08a472e7f5a5d2e4b6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:59+01:00
Commit Message:
WAGE: Remove leftover debug message
Changed paths:
engines/wage/combat.cpp
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index 6e2403c..4c3d6c9 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -517,8 +517,6 @@ bool WageEngine::handleMoveCommand(Directions dir, const char *dirName) {
Scene *playerScene = _world->_player->_currentScene;
const char *msg = playerScene->_messages[dir].c_str();
- warning("Dir: %s msg: %s", dirName, msg);
-
if (!playerScene->_blocked[dir]) {
int destX = playerScene->_worldX + directionsX[dir];
int destY = playerScene->_worldY + directionsY[dir];
Commit: db7d5aa21861874281082ba6f5671bf20c79842f
https://github.com/scummvm/scummvm/commit/db7d5aa21861874281082ba6f5671bf20c79842f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:59+01:00
Commit Message:
WAGE: Removed another leftover warning
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 2c23a46..79a5e4f 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -824,7 +824,6 @@ bool Script::evalClickEquality(Operand *lhs, Operand *rhs, bool partialMatch) {
Common::String name = lhs->_value.designed->_name;
name.toLowercase();
- warning("%s <> %s", name.c_str(), str.c_str());
if (partialMatch)
result = name.contains(str);
else
Commit: 6cbd4d4749a173ba321b3651eb1ef24a2317bf56
https://github.com/scummvm/scummvm/commit/6cbd4d4749a173ba321b3651eb1ef24a2317bf56
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:12:59+01:00
Commit Message:
WAGE: Hid debug message deeper
Changed paths:
engines/wage/wage.cpp
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 043406f..566c122 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -298,7 +298,7 @@ void WageEngine::performInitialSetup() {
_world->move(chr, _world->_scenes[key]);
if (chr->_playerCharacter)
- warning("Initial scene: %s", key.c_str());
+ debug(0, "Initial scene: %s", key.c_str());
} else {
_world->move(chr, _world->getRandomScene());
}
Commit: b0941e247caca0d6c88689f524d3eeb35ad27645
https://github.com/scummvm/scummvm/commit/b0941e247caca0d6c88689f524d3eeb35ad27645
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:00+01:00
Commit Message:
WAGE: Hid more debug messages
Changed paths:
engines/wage/world.cpp
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index fbb7245..daa2de9 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -143,22 +143,22 @@ bool World::loadWorld(Common::MacResManager *resMan) {
Common::String *message;
if ((message = loadStringFromDITL(resMan, 2910, 1)) != NULL) {
message->trim();
- warning("_gameOverMessage: %s", message->c_str());
+ debug(2, "_gameOverMessage: %s", message->c_str());
_gameOverMessage = message;
}
if ((message = loadStringFromDITL(resMan, 2480, 3)) != NULL) {
message->trim();
- warning("_saveBeforeQuitMessage: %s", message->c_str());
+ debug(2, "_saveBeforeQuitMessage: %s", message->c_str());
_saveBeforeQuitMessage = message;
}
if ((message = loadStringFromDITL(resMan, 2490, 3)) != NULL) {
message->trim();
- warning("_saveBeforeCloseMessage: %s", message->c_str());
+ debug(2, "_saveBeforeCloseMessage: %s", message->c_str());
_saveBeforeCloseMessage = message;
}
if ((message = loadStringFromDITL(resMan, 2940, 2)) != NULL) {
message->trim();
- warning("_revertMessage: %s", message->c_str());
+ debug(2, "_revertMessage: %s", message->c_str());
_revertMessage = message;
}
Commit: 9d9e769b5e8bd70a00a3e5bde9ce6b3ab95ee6ae
https://github.com/scummvm/scummvm/commit/9d9e769b5e8bd70a00a3e5bde9ce6b3ab95ee6ae
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:00+01:00
Commit Message:
WAGE: Mark full lines of selected text
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 2562456..fc7ae01 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -498,8 +498,12 @@ void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) {
const char *str = _lines[line].c_str();
int color = kColorBlack;
- if (line >= _selectionStartY && line <= _selectionEndY) {
+ if ((line > _selectionStartY && line < _selectionEndY) ||
+ (line > _selectionEndY && line < _selectionStartY)) {
color = kColorWhite;
+ Common::Rect trect(0, y1, _console.w, y1 + _consoleLineHeight);
+
+ Design::drawFilledRect(&_console, trect, kColorBlack, _patterns, kPatternSolid);
}
if (*str)
Commit: d585719c2d4034b17d9a49584e45775c1f357727
https://github.com/scummvm/scummvm/commit/d585719c2d4034b17d9a49584e45775c1f357727
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:00+01:00
Commit Message:
WAGE: First attempt to draw partial highlights
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index fc7ae01..0bf1c34 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -506,8 +506,41 @@ void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) {
Design::drawFilledRect(&_console, trect, kColorBlack, _patterns, kPatternSolid);
}
- if (*str)
- font->drawString(&_console, _lines[line], x1, y1, textW, color);
+ if (line == _selectionStartY || line == _selectionEndY) {
+ if (_selectionStartY != _selectionEndY) {
+ int color1 = kColorWhite;
+ int color2 = kColorBlack;
+ int midpoint = _selectionStartX;
+
+ if (_selectionStartY > _selectionEndY)
+ SWAP(color1, color2);
+
+ if (line == _selectionEndY) {
+ SWAP(color1, color2);
+ midpoint = _selectionEndY;
+ }
+
+ Common::String beg(_lines[line].c_str(), &_lines[line].c_str()[midpoint]);
+ Common::String end(&_lines[line].c_str()[midpoint]);
+
+ warning("beg: %s end: %s", beg.c_str(), end.c_str());
+
+ int rectW = font->getStringWidth(beg) + kConWPadding + kConWOverlap;
+ Common::Rect trect(0, y1, _console.w, y1 + _consoleLineHeight);
+ if (color1 == kColorWhite)
+ trect.right = rectW;
+ else
+ trect.left = rectW;
+
+ Design::drawFilledRect(&_console, trect, kColorBlack, _patterns, kPatternSolid);
+
+ font->drawString(&_console, beg, x1, y1, textW, color1);
+ font->drawString(&_console, end, x1 + rectW, y1, textW, color2);
+ }
+ } else {
+ if (*str)
+ font->drawString(&_console, _lines[line], x1, y1, textW, color);
+ }
y1 += _consoleLineHeight;
}
Commit: b24be406d27373b5ea1a041eceba4dfea42cbb82
https://github.com/scummvm/scummvm/commit/b24be406d27373b5ea1a041eceba4dfea42cbb82
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:00+01:00
Commit Message:
WAGE: Fixes to selection highlighting
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 0bf1c34..4f1bc98 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -508,8 +508,8 @@ void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) {
if (line == _selectionStartY || line == _selectionEndY) {
if (_selectionStartY != _selectionEndY) {
- int color1 = kColorWhite;
- int color2 = kColorBlack;
+ int color1 = kColorBlack;
+ int color2 = kColorWhite;
int midpoint = _selectionStartX;
if (_selectionStartY > _selectionEndY)
@@ -523,8 +523,6 @@ void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) {
Common::String beg(_lines[line].c_str(), &_lines[line].c_str()[midpoint]);
Common::String end(&_lines[line].c_str()[midpoint]);
- warning("beg: %s end: %s", beg.c_str(), end.c_str());
-
int rectW = font->getStringWidth(beg) + kConWPadding + kConWOverlap;
Common::Rect trect(0, y1, _console.w, y1 + _consoleLineHeight);
if (color1 == kColorWhite)
@@ -535,7 +533,7 @@ void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) {
Design::drawFilledRect(&_console, trect, kColorBlack, _patterns, kPatternSolid);
font->drawString(&_console, beg, x1, y1, textW, color1);
- font->drawString(&_console, end, x1 + rectW, y1, textW, color2);
+ font->drawString(&_console, end, x1 + rectW - kConWPadding - kConWOverlap, y1, textW, color2);
}
} else {
if (*str)
Commit: d56590784fb8f41fca25d6be184d6d71f9eed28c
https://github.com/scummvm/scummvm/commit/d56590784fb8f41fca25d6be184d6d71f9eed28c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:00+01:00
Commit Message:
WAGE: Fix text end marking
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 4f1bc98..970fbcd 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -517,7 +517,7 @@ void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) {
if (line == _selectionEndY) {
SWAP(color1, color2);
- midpoint = _selectionEndY;
+ midpoint = _selectionEndX;
}
Common::String beg(_lines[line].c_str(), &_lines[line].c_str()[midpoint]);
@@ -745,14 +745,15 @@ void Gui::startMarking(int x, int y) {
_inTextSelection = true;
- warning("x: %d y: %d", _selectionStartX, _selectionStartY);
+ warning("x: %d y: %d -> %d %d", x, y, _selectionStartX, _selectionStartY);
}
void Gui::updateTextSelection(int x, int y) {
- warning("x: %d y: %d", x, y);
_selectionEndY = calcTextY(y);
_selectionEndX = calcTextX(x, _selectionStartY);
+ warning("x: %d y: %d -> %d %d", x, y, _selectionEndX, _selectionEndY);
+
_consoleFullRedraw = true;
}
Commit: 61dc7d5d04577c7b2c4327e937e898908f793f3b
https://github.com/scummvm/scummvm/commit/61dc7d5d04577c7b2c4327e937e898908f793f3b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:01+01:00
Commit Message:
WAGE: Fix regression leading to a crash
Changed paths:
engines/wage/wage.cpp
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 566c122..c1d7033 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -455,7 +455,11 @@ void WageEngine::processTurn(Common::String *textInput, Designed *clickInput) {
_commandWasQuick = false;
Scene *prevScene = _world->_player->_currentScene;
Chr *prevMonster = getMonster();
- Common::String input(*textInput);
+ Common::String input;
+
+ if (textInput)
+ input = *textInput;
+
input.toLowercase();
if (input.equals("e"))
input = "east";
Commit: 40cdf028b3f6cafe02a44b568825f9de6eb4de0e
https://github.com/scummvm/scummvm/commit/40cdf028b3f6cafe02a44b568825f9de6eb4de0e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:01+01:00
Commit Message:
WAGE: Fix end of selection calculation
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 970fbcd..f9c5d12 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -750,7 +750,7 @@ void Gui::startMarking(int x, int y) {
void Gui::updateTextSelection(int x, int y) {
_selectionEndY = calcTextY(y);
- _selectionEndX = calcTextX(x, _selectionStartY);
+ _selectionEndX = calcTextX(x, _selectionEndY);
warning("x: %d y: %d -> %d %d", x, y, _selectionEndX, _selectionEndY);
Commit: 5ac25816456b24baae06f84708262397092efaea
https://github.com/scummvm/scummvm/commit/5ac25816456b24baae06f84708262397092efaea
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:01+01:00
Commit Message:
WAGE: Fix text coordinate calculation
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index f9c5d12..2ea8e82 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -713,7 +713,7 @@ int Gui::calcTextX(int x, int textLine) {
const Graphics::Font *font = getConsoleFont();
Common::String str = _lines[textLine];
- x -= _consoleTextArea.left + kConWOverlap + kConWPadding;
+ x -= _consoleTextArea.left;
for (int i = str.size(); i >= 0; i--) {
if (font->getStringWidth(str) < x) {
@@ -727,7 +727,7 @@ int Gui::calcTextX(int x, int textLine) {
}
int Gui::calcTextY(int y) {
- y -= _consoleTextArea.top + kConHOverlap + kConHPadding;
+ y -= _consoleTextArea.top;
if (y < 0)
y = 0;
Commit: 30713e4262fee800fcbafaab01e7c7b785c5d0c8
https://github.com/scummvm/scummvm/commit/30713e4262fee800fcbafaab01e7c7b785c5d0c8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:01+01:00
Commit Message:
WAGE: Implement highlighting one line selection
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 2ea8e82..fc606e0 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -534,6 +534,26 @@ void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) {
font->drawString(&_console, beg, x1, y1, textW, color1);
font->drawString(&_console, end, x1 + rectW - kConWPadding - kConWOverlap, y1, textW, color2);
+ } else {
+ int startPos = _selectionStartX;
+ int endPos = _selectionEndX;
+
+ if (startPos > endPos)
+ SWAP(startPos, endPos);
+
+ Common::String beg(_lines[line].c_str(), &_lines[line].c_str()[startPos]);
+ Common::String mid(&_lines[line].c_str()[startPos], &_lines[line].c_str()[endPos]);
+ Common::String end(&_lines[line].c_str()[endPos]);
+
+ int rectW1 = font->getStringWidth(beg) + kConWPadding + kConWOverlap;
+ int rectW2 = rectW1 + font->getStringWidth(mid);
+ Common::Rect trect(rectW1, y1, rectW2, y1 + _consoleLineHeight);
+
+ Design::drawFilledRect(&_console, trect, kColorBlack, _patterns, kPatternSolid);
+
+ font->drawString(&_console, beg, x1, y1, textW, kColorBlack);
+ font->drawString(&_console, mid, x1 + rectW1 - kConWPadding - kConWOverlap, y1, textW, kColorWhite);
+ font->drawString(&_console, end, x1 + rectW2 - kConWPadding - kConWOverlap, y1, textW, kColorBlack);
}
} else {
if (*str)
Commit: 8ee5d6e9d1cda74d4ad35ca4d19a4d36996f11c4
https://github.com/scummvm/scummvm/commit/8ee5d6e9d1cda74d4ad35ca4d19a4d36996f11c4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:01+01:00
Commit Message:
WAGE: Fix crash and remove debug output
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index fc606e0..2dc2e69 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -731,6 +731,10 @@ void Gui::mouseDown(int x, int y) {
int Gui::calcTextX(int x, int textLine) {
const Graphics::Font *font = getConsoleFont();
+
+ if (textLine >= _lines.size())
+ return 0;
+
Common::String str = _lines[textLine];
x -= _consoleTextArea.left;
@@ -759,21 +763,16 @@ int Gui::calcTextY(int y) {
}
void Gui::startMarking(int x, int y) {
- warning("x: %d y: %d", x, y);
_selectionStartY = calcTextY(y);
_selectionStartX = calcTextX(x, _selectionStartY);
_inTextSelection = true;
-
- warning("x: %d y: %d -> %d %d", x, y, _selectionStartX, _selectionStartY);
}
void Gui::updateTextSelection(int x, int y) {
_selectionEndY = calcTextY(y);
_selectionEndX = calcTextX(x, _selectionEndY);
- warning("x: %d y: %d -> %d %d", x, y, _selectionEndX, _selectionEndY);
-
_consoleFullRedraw = true;
}
Commit: 06ba17395d0bbd3a099d692a6e1356b4c67f1d8b
https://github.com/scummvm/scummvm/commit/06ba17395d0bbd3a099d692a6e1356b4c67f1d8b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:01+01:00
Commit Message:
WAGE: Fix cursors during dialogs
Changed paths:
engines/wage/dialog.cpp
engines/wage/gui.cpp
engines/wage/gui.h
diff --git a/engines/wage/dialog.cpp b/engines/wage/dialog.cpp
index 3cee886..d98af30 100644
--- a/engines/wage/dialog.cpp
+++ b/engines/wage/dialog.cpp
@@ -145,6 +145,7 @@ int Dialog::run() {
Common::Rect r(_bbox);
_tempSurface.copyRectToSurface(_gui->_screen.getBasePtr(_bbox.left, _bbox.top), _gui->_screen.pitch, 0, 0, _bbox.width() + 1, _bbox.height() + 1);
+ _gui->pushArrowCursor();
while (!shouldQuit) {
Common::Event event;
@@ -188,6 +189,8 @@ int Dialog::run() {
_gui->_screen.copyRectToSurface(_tempSurface.getBasePtr(0, 0), _tempSurface.pitch, _bbox.left, _bbox.top, _bbox.width() + 1, _bbox.height() + 1);
g_system->copyRectToScreen(_gui->_screen.getBasePtr(r.left, r.top), _gui->_screen.pitch, r.left, r.top, r.width() + 1, r.height() + 1);
+ _gui->popCursor();
+
return _pressedButton;
}
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 2dc2e69..ef05607 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -681,6 +681,14 @@ void Gui::mouseMove(int x, int y) {
}
}
+void Gui::pushArrowCursor() {
+ CursorMan.pushCursor(macCursorArrow, 11, 16, 1, 1, 3);
+}
+
+void Gui::popCursor() {
+ CursorMan.popCursor();
+}
+
Designed *Gui::mouseUp(int x, int y) {
if (_menu->_menuActivated) {
if (_menu->mouseRelease(x, y)) {
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 6adba27..4f3b0f9 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -101,6 +101,8 @@ public:
void regenCommandsMenu();
void regenWeaponsMenu();
void processMenuShortCut(byte flags, uint16 ascii);
+ void pushArrowCursor();
+ void popCursor();
private:
void paintBorder(Graphics::Surface *g, Common::Rect &r, WindowType windowType);
Commit: c02c36ce88f6de4cb3442898deb4f051364fb52e
https://github.com/scummvm/scummvm/commit/c02c36ce88f6de4cb3442898deb4f051364fb52e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:02+01:00
Commit Message:
WAGE: Implemented a way to remove selection
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index ef05607..4e52801 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -656,7 +656,6 @@ void Gui::processMenuShortCut(byte flags, uint16 ascii) {
_menu->processMenuShortCut(flags, ascii);
}
-
void Gui::mouseMove(int x, int y) {
if (_menu->_menuActivated) {
if (_menu->mouseMove(x, y))
@@ -701,9 +700,16 @@ Designed *Gui::mouseUp(int x, int y) {
return NULL;
}
- if (_inTextSelection)
+ if (_inTextSelection) {
_inTextSelection = false;
+ if (_selectionEndY == -1 ||
+ (_selectionEndX == _selectionStartX && _selectionEndY == _selectionStartY)) {
+ _selectionStartY = _selectionEndY = -1;
+ _consoleFullRedraw = true;
+ }
+ }
+
if (_sceneArea.contains(x, y)) {
if (!_sceneIsActive) {
_sceneIsActive = true;
@@ -774,6 +780,8 @@ void Gui::startMarking(int x, int y) {
_selectionStartY = calcTextY(y);
_selectionStartX = calcTextX(x, _selectionStartY);
+ _selectionEndY = -1;
+
_inTextSelection = true;
}
Commit: 7e8c1028d31e8b86fb6bc4cc05ac8dcf1e772eb2
https://github.com/scummvm/scummvm/commit/7e8c1028d31e8b86fb6bc4cc05ac8dcf1e772eb2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:02+01:00
Commit Message:
WAGE: Implement API to enable/disable menu items
Changed paths:
engines/wage/gui.cpp
engines/wage/menu.cpp
engines/wage/menu.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 4e52801..2564f67 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -707,6 +707,8 @@ Designed *Gui::mouseUp(int x, int y) {
(_selectionEndX == _selectionStartX && _selectionEndY == _selectionStartY)) {
_selectionStartY = _selectionEndY = -1;
_consoleFullRedraw = true;
+ } else {
+
}
}
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index a814934..69ac07b 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -79,25 +79,6 @@ struct MenuItem {
MenuItem(const char *n) : name(n) {}
};
-enum {
- kMenuActionAbout,
- kMenuActionNew,
- kMenuActionOpen,
- kMenuActionClose,
- kMenuActionSave,
- kMenuActionSaveAs,
- kMenuActionRevert,
- kMenuActionQuit,
-
- kMenuActionUndo,
- kMenuActionCut,
- kMenuActionCopy,
- kMenuActionPaste,
- kMenuActionClear,
-
- kMenuActionCommand
-};
-
struct MenuData {
int menunum;
const char *title;
@@ -568,5 +549,10 @@ void Menu::processMenuShortCut(byte flags, uint16 ascii) {
}
}
+void Menu::enableCommand(int menunum, int action, bool state) {
+ for (int i = 0; i < _items[menunum]->subitems.size(); i++)
+ if (_items[menunum]->subitems[i]->action == action)
+ _items[menunum]->subitems[i]->enabled = state;
+}
} // End of namespace Wage
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index d817cf3..a37e6b0 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -63,6 +63,25 @@ enum {
kFontStyleExtended = 64
};
+enum {
+ kMenuActionAbout,
+ kMenuActionNew,
+ kMenuActionOpen,
+ kMenuActionClose,
+ kMenuActionSave,
+ kMenuActionSaveAs,
+ kMenuActionRevert,
+ kMenuActionQuit,
+
+ kMenuActionUndo,
+ kMenuActionCut,
+ kMenuActionCopy,
+ kMenuActionPaste,
+ kMenuActionClear,
+
+ kMenuActionCommand
+};
+
class Menu {
public:
Menu(Gui *gui);
@@ -76,6 +95,7 @@ public:
void regenCommandsMenu();
void regenWeaponsMenu();
void processMenuShortCut(byte flags, uint16 ascii);
+ void enableCommand(int menunum, int action, bool state);
bool _menuActivated;
Common::Rect _bbox;
Commit: a2e3d33a2dd9c9500504990630d2e6bb2c0da25c
https://github.com/scummvm/scummvm/commit/a2e3d33a2dd9c9500504990630d2e6bb2c0da25c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:02+01:00
Commit Message:
WAGE: Get rid of magic constants in menu code for referring menu items
Changed paths:
engines/wage/menu.cpp
engines/wage/menu.h
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 69ac07b..a140254 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -86,20 +86,20 @@ struct MenuData {
byte shortcut;
bool enabled;
} menuSubItems[] = {
- { 1, "New", kMenuActionNew, 0, false },
- { 1, "Open...", kMenuActionOpen, 0, false },
- { 1, "Close", kMenuActionClose, 0, true },
- { 1, "Save", kMenuActionSave, 0, false },
- { 1, "Save as...", kMenuActionSaveAs, 0, true },
- { 1, "Revert", kMenuActionRevert, 0, false },
- { 1, "Quit", kMenuActionQuit, 0, true },
-
- { 2, "Undo", kMenuActionUndo, 'Z', false },
- { 2, NULL, 0, 0, false },
- { 2, "Cut", kMenuActionCut, 'K', false },
- { 2, "Copy", kMenuActionCopy, 'C', false },
- { 2, "Paste", kMenuActionPaste, 'V', false },
- { 2, "Clear", kMenuActionClear, 'B', false },
+ { kMenuFile, "New", kMenuActionNew, 0, false },
+ { kMenuFile, "Open...", kMenuActionOpen, 0, false },
+ { kMenuFile, "Close", kMenuActionClose, 0, true },
+ { kMenuFile, "Save", kMenuActionSave, 0, false },
+ { kMenuFile, "Save as...", kMenuActionSaveAs, 0, true },
+ { kMenuFile, "Revert", kMenuActionRevert, 0, false },
+ { kMenuFile, "Quit", kMenuActionQuit, 0, true },
+
+ { kMenuEdit, "Undo", kMenuActionUndo, 'Z', false },
+ { kMenuEdit, NULL, 0, 0, false },
+ { kMenuEdit, "Cut", kMenuActionCut, 'K', false },
+ { kMenuEdit, "Copy", kMenuActionCopy, 'C', false },
+ { kMenuEdit, "Paste", kMenuActionPaste, 'V', false },
+ { kMenuEdit, "Clear", kMenuActionClear, 'B', false },
{ 0, NULL, 0, 0, false }
};
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index a37e6b0..cee7611 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -64,6 +64,14 @@ enum {
};
enum {
+ kMenuAbout = 0,
+ kMenuFile = 1,
+ kMenuEdit = 2,
+ kMenuCommands = 3,
+ kMenuWeapons = 4
+};
+
+enum {
kMenuActionAbout,
kMenuActionNew,
kMenuActionOpen,
Commit: fe40bb284c7cefbfc82c59fc1fd3a0c081416902
https://github.com/scummvm/scummvm/commit/fe40bb284c7cefbfc82c59fc1fd3a0c081416902
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:02+01:00
Commit Message:
WAGE: Started copy command implementation
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/menu.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 2564f67..99876e0 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -707,8 +707,9 @@ Designed *Gui::mouseUp(int x, int y) {
(_selectionEndX == _selectionStartX && _selectionEndY == _selectionStartY)) {
_selectionStartY = _selectionEndY = -1;
_consoleFullRedraw = true;
+ _menu->enableCommand(kMenuEdit, kMenuActionCopy, false);
} else {
-
+ _menu->enableCommand(kMenuEdit, kMenuActionCopy, true);
}
}
@@ -794,4 +795,19 @@ void Gui::updateTextSelection(int x, int y) {
_consoleFullRedraw = true;
}
+void Gui::actionCopy() {
+ if (_selectionStartX == -1)
+ return;
+
+ int startX = _selectionStartX;
+ int startY = _selectionStartY;
+ int endX = _selectionEndX;
+ int endY = _selectionEndY;
+
+ if (startY > endY) {
+ SWAP(startX, endX);
+ SWAP(endX, endY);
+ }
+}
+
} // End of namespace Wage
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 4f3b0f9..1642127 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -104,6 +104,8 @@ public:
void pushArrowCursor();
void popCursor();
+ void actionCopy();
+
private:
void paintBorder(Graphics::Surface *g, Common::Rect &r, WindowType windowType);
void renderConsole(Graphics::Surface *g, Common::Rect &r);
@@ -155,6 +157,8 @@ private:
int _selectionStartY;
int _selectionEndX;
int _selectionEndY;
+
+ Common::String _clipboard;
};
} // End of namespace Wage
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index a140254..cb28ca1 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -517,7 +517,10 @@ void Menu::executeCommand(MenuSubItem *subitem) {
case kMenuActionUndo:
case kMenuActionCut:
+ break;
case kMenuActionCopy:
+ _gui->actionCopy();
+ break;
case kMenuActionPaste:
case kMenuActionClear:
break;
Commit: 08b3f89b099671fe1eb19e85dcc077a32cd69032
https://github.com/scummvm/scummvm/commit/08b3f89b099671fe1eb19e85dcc077a32cd69032
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:02+01:00
Commit Message:
WAGE: Made copy command working
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 99876e0..d90030c 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -808,6 +808,27 @@ void Gui::actionCopy() {
SWAP(startX, endX);
SWAP(endX, endY);
}
+
+ _clipboard.clear();
+
+ for (int i = startY; i <= endY; i++) {
+ if (startY == endY) {
+ _clipboard = Common::String(&_lines[i].c_str()[startX], &_lines[i].c_str()[endX]);
+ break;
+ }
+
+ if (i == startY) {
+ _clipboard += &_lines[i].c_str()[startX];
+ _clipboard += '\n';
+ } else if (i == endY) {
+ _clipboard += Common::String(_lines[i].c_str(), &_lines[i].c_str()[endX]);
+ } else {
+ _clipboard += _lines[i];
+ _clipboard += '\n';
+ }
+ }
+
+ _menu->enableCommand(kMenuEdit, kMenuActionPaste, true);
}
} // End of namespace Wage
Commit: e56d934836ab371563cae18fdb2fe8e5d89e2dbd
https://github.com/scummvm/scummvm/commit/e56d934836ab371563cae18fdb2fe8e5d89e2dbd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:02+01:00
Commit Message:
WAGE: Make keyboard shortcuts work for the Edit menu
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index cb28ca1..42a0954 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -517,12 +517,14 @@ void Menu::executeCommand(MenuSubItem *subitem) {
case kMenuActionUndo:
case kMenuActionCut:
+ warning("STUB: Unhandled shortcut");
break;
case kMenuActionCopy:
_gui->actionCopy();
break;
case kMenuActionPaste:
case kMenuActionClear:
+ warning("STUB: Unhandled shortcut");
break;
case kMenuActionCommand:
@@ -542,11 +544,7 @@ void Menu::processMenuShortCut(byte flags, uint16 ascii) {
for (int i = 0; i < _items.size(); i++)
for (int j = 0; j < _items[i]->subitems.size(); j++)
if (tolower(_items[i]->subitems[j]->shortcut) == ascii) {
- if (_items[i]->subitems[j]->action == kMenuActionCommand)
- _gui->_engine->processTurn(&_items[i]->subitems[j]->text, NULL);
- else
- warning("STUB: Unhandled shortcut");
-
+ executeCommand(_items[i]->subitems[j]);
break;
}
}
Commit: 3570e417c9ab4ab47be65b76d0481f6323e6e74e
https://github.com/scummvm/scummvm/commit/3570e417c9ab4ab47be65b76d0481f6323e6e74e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:03+01:00
Commit Message:
WAGE: Implement Paste action
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/menu.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index d90030c..cd4a62b 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -831,4 +831,9 @@ void Gui::actionCopy() {
_menu->enableCommand(kMenuEdit, kMenuActionPaste, true);
}
+void Gui::actionPaste() {
+ _engine->_inputText = _clipboard;
+ drawInput();
+}
+
} // End of namespace Wage
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 1642127..7270a78 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -105,6 +105,7 @@ public:
void popCursor();
void actionCopy();
+ void actionPaste();
private:
void paintBorder(Graphics::Surface *g, Common::Rect &r, WindowType windowType);
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 42a0954..2a1f6e6 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -523,6 +523,8 @@ void Menu::executeCommand(MenuSubItem *subitem) {
_gui->actionCopy();
break;
case kMenuActionPaste:
+ _gui->actionPaste();
+ break;
case kMenuActionClear:
warning("STUB: Unhandled shortcut");
break;
Commit: 1d5220ef3fb5ed1a869d88ee67b28cb0433f8578
https://github.com/scummvm/scummvm/commit/1d5220ef3fb5ed1a869d88ee67b28cb0433f8578
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:03+01:00
Commit Message:
WAGE: Implement Undo action
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/menu.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index cd4a62b..d158d48 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -832,8 +832,18 @@ void Gui::actionCopy() {
}
void Gui::actionPaste() {
- _engine->_inputText = _clipboard;
+ _undobuffer = _engine->_inputText;
+ _engine->_inputText += _clipboard;
drawInput();
+
+ _menu->enableCommand(kMenuEdit, kMenuActionUndo, true);
+}
+
+void Gui::actionUndo() {
+ _engine->_inputText = _undobuffer;
+ drawInput();
+
+ _menu->enableCommand(kMenuEdit, kMenuActionUndo, false);
}
} // End of namespace Wage
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 7270a78..6d33abb 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -106,6 +106,7 @@ public:
void actionCopy();
void actionPaste();
+ void actionUndo();
private:
void paintBorder(Graphics::Surface *g, Common::Rect &r, WindowType windowType);
@@ -160,6 +161,7 @@ private:
int _selectionEndY;
Common::String _clipboard;
+ Common::String _undobuffer;
};
} // End of namespace Wage
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 2a1f6e6..83e610a 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -516,6 +516,8 @@ void Menu::executeCommand(MenuSubItem *subitem) {
case kMenuActionQuit:
case kMenuActionUndo:
+ _gui->actionUndo();
+ break;
case kMenuActionCut:
warning("STUB: Unhandled shortcut");
break;
Commit: 5e002c4fe2e1019e2d4f33b335d41eabb41ed63f
https://github.com/scummvm/scummvm/commit/5e002c4fe2e1019e2d4f33b335d41eabb41ed63f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:03+01:00
Commit Message:
GRAPHICS: Move generic primitives from WAGE engine
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
graphics/primitives.cpp
graphics/primitives.h
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 8e5c753..2acd8728 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -226,7 +226,7 @@ void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in,
plotData pd(surface, &patterns, fillType, 1);
if (fillType <= patterns.size())
- drawFilledRect(r, kColorBlack, drawPixel, &pd);
+ Graphics::drawFilledRect(r, kColorBlack, drawPixel, &pd);
pd.fillType = borderFillType;
pd.thickness = borderThickness;
@@ -256,13 +256,13 @@ void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in,
plotData pd(surface, &patterns, fillType, 1);
if (fillType <= patterns.size())
- drawRoundRect(r, arc/2, kColorBlack, true, drawPixel, &pd);
+ Graphics::drawRoundRect(r, arc/2, kColorBlack, true, drawPixel, &pd);
pd.fillType = borderFillType;
pd.thickness = borderThickness;
if (borderThickness > 0 && borderFillType <= patterns.size())
- drawRoundRect(r, arc/2, kColorBlack, false, drawPixel, &pd);
+ Graphics::drawRoundRect(r, arc/2, kColorBlack, false, drawPixel, &pd);
}
void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in,
@@ -326,7 +326,7 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in,
plotData pd(surface, &patterns, fillType, 1);
if (fillType <= patterns.size()) {
- drawPolygonScan(xpoints, ypoints, npoints, bbox, kColorBlack, drawPixel, &pd);
+ Graphics::drawPolygonScan(xpoints, ypoints, npoints, bbox, kColorBlack, drawPixel, &pd);
}
pd.fillType = borderFillType;
@@ -349,13 +349,13 @@ void Design::drawOval(Graphics::Surface *surface, Common::ReadStream &in,
plotData pd(surface, &patterns, fillType, 1);
if (fillType <= patterns.size())
- drawEllipse(x1, y1, x2-1, y2-1, true, drawPixel, &pd);
+ Graphics::drawEllipse(x1, y1, x2-1, y2-1, kColorBlack, true, drawPixel, &pd);
pd.fillType = borderFillType;
pd.thickness = borderThickness;
if (borderThickness > 0 && borderFillType <= patterns.size())
- drawEllipse(x1, y1, x2-1, y2-1, false, drawPixel, &pd);
+ Graphics::drawEllipse(x1, y1, x2-1, y2-1, kColorBlack, false, drawPixel, &pd);
}
void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in) {
@@ -460,383 +460,25 @@ void Design::drawFilledRect(Graphics::Surface *surface, Common::Rect &rect, int
plotData pd(surface, &patterns, fillType, 1);
for (int y = rect.top; y <= rect.bottom; y++)
- drawHLine(rect.left, rect.right, y, color, drawPixel, &pd);
-}
-
-void Design::drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data) {
- for (int y = rect.top; y <= rect.bottom; y++)
- drawHLine(rect.left, rect.right, y, color, plotProc, data);
+ Graphics::drawHLine(rect.left, rect.right, y, color, drawPixel, &pd);
}
void Design::drawFilledRoundRect(Graphics::Surface *surface, Common::Rect &rect, int arc, int color, Patterns &patterns, byte fillType) {
plotData pd(surface, &patterns, fillType, 1);
- drawRoundRect(rect, arc, color, true, drawPixel, &pd);
-}
-
-// http://members.chello.at/easyfilter/bresenham.html
-void Design::drawRoundRect(Common::Rect &rect, int arc, int color, bool filled, void (*plotProc)(int, int, int, void *), void *data) {
- if (rect.height() < rect.width()) {
- int x = -arc, y = 0, err = 2-2*arc; /* II. Quadrant */
- int dy = rect.height() - arc * 2;
- int r = arc;
- int stop = 0;
- int lastx, lasty;
- if (dy < 0)
- stop = -dy / 2;
-
- do {
- if (filled) {
- drawHLine(rect.left+x+r, rect.right-x-r, rect.top-y+r-stop, color, plotProc, data);
- drawHLine(rect.left+x+r, rect.right-x-r, rect.bottom+y-r+stop, color, plotProc, data);
- } else {
- (*plotProc)(rect.left+x+r, rect.top-y+r-stop, color, data);
- (*plotProc)(rect.right-x-r, rect.top-y+r-stop, color, data);
- (*plotProc)(rect.left+x+r, rect.bottom+y-r+stop, color, data);
- (*plotProc)(rect.right-x-r, rect.bottom+y-r+stop, color, data);
-
- lastx = x;
- lasty = y;
- }
- arc = err;
- if (arc <= y) err += ++y*2+1; /* e_xy+e_y < 0 */
- if (arc > x || err > y) err += ++x*2+1; /* e_xy+e_x > 0 or no 2nd y-step */
- if (stop && y > stop)
- break;
- } while (x < 0);
-
- if (!filled) {
- x = lastx;
- y = lasty;
-
- drawHLine(rect.left+x+r, rect.right-x-r, rect.top-y+r-stop, color, plotProc, data);
- drawHLine(rect.left+x+r, rect.right-x-r, rect.bottom+y-r+stop, color, plotProc, data);
- }
-
- for (int i = 0; i < dy; i++) {
- if (filled) {
- drawHLine(rect.left, rect.right, rect.top + r + i, color, plotProc, data);
- } else {
- (*plotProc)(rect.left, rect.top + r + i, color, data);
- (*plotProc)(rect.right, rect.top + r + i, color, data);
- }
- }
- } else {
- int y = -arc, x = 0, err = 2-2*arc; /* II. Quadrant */
- int dx = rect.width() - arc * 2;
- int r = arc;
- int stop = 0;
- int lastx, lasty;
- if (dx < 0)
- stop = -dx / 2;
-
- do {
- if (filled) {
- drawVLine(rect.left-x+r-stop, rect.top+y+r, rect.bottom-y-r, color, plotProc, data);
- drawVLine(rect.right+x-r+stop, rect.top+y+r, rect.bottom-y-r, color, plotProc, data);
- } else {
- (*plotProc)(rect.left-x+r-stop, rect.top+y+r, color, data);
- (*plotProc)(rect.left-x+r-stop, rect.bottom-y-r, color, data);
- (*plotProc)(rect.right+x-r+stop, rect.top+y+r, color, data);
- (*plotProc)(rect.right+x-r+stop, rect.bottom-y-r, color, data);
-
- lastx = x;
- lasty = y;
- }
-
- arc = err;
- if (arc <= x) err += ++x*2+1; /* e_xy+e_y < 0 */
- if (arc > y || err > x) err += ++y*2+1; /* e_xy+e_x > 0 or no 2nd y-step */
- if (stop && x > stop)
- break;
- } while (y < 0);
-
- if (!filled) {
- x = lastx;
- y = lasty;
- drawVLine(rect.left-x+r-stop, rect.top+y+r, rect.bottom-y-r, color, plotProc, data);
- drawVLine(rect.right+x-r+stop, rect.top+y+r, rect.bottom-y-r, color, plotProc, data);
- }
-
- for (int i = 0; i < dx; i++) {
- if (filled) {
- drawVLine(rect.left + r + i, rect.top, rect.bottom, color, plotProc, data);
- } else {
- (*plotProc)(rect.left + r + i, rect.top, color, data);
- (*plotProc)(rect.left + r + i, rect.bottom, color, data);
- }
- }
- }
-}
-
-// Based on public-domain code by Darel Rex Finley, 2007
-// http://alienryderflex.com/polygon_fill/
-void Design::drawPolygonScan(int *polyX, int *polyY, int npoints, Common::Rect &bbox, int color,
- void (*plotProc)(int, int, int, void *), void *data) {
- int *nodeX = (int *)calloc(npoints, sizeof(int));
- int i, j;
-
- // Loop through the rows of the image.
- for (int pixelY = bbox.top; pixelY < bbox.bottom; pixelY++) {
- // Build a list of nodes.
- int nodes = 0;
- j = npoints - 1;
-
- for (i = 0; i < npoints; i++) {
- if ((polyY[i] < pixelY && polyY[j] >= pixelY) || (polyY[j] < pixelY && polyY[i] >= pixelY)) {
- nodeX[nodes++] = (int)(polyX[i] + (double)(pixelY - polyY[i]) / (double)(polyY[j]-polyY[i]) *
- (double)(polyX[j] - polyX[i]) + 0.5);
- }
- j = i;
- }
-
- // Sort the nodes, via a simple “Bubble” sort.
- i = 0;
- while (i < nodes - 1) {
- if (nodeX[i] > nodeX[i + 1]) {
- SWAP(nodeX[i], nodeX[i + 1]);
- if (i)
- i--;
- } else {
- i++;
- }
- }
-
- // Fill the pixels between node pairs.
- for (i = 0; i < nodes; i += 2) {
- if (nodeX[i ] >= bbox.right)
- break;
- if (nodeX[i + 1] > bbox.left) {
- nodeX[i] = MAX<int16>(nodeX[i], bbox.left);
- nodeX[i + 1] = MIN<int16>(nodeX[i + 1], bbox.right);
-
- drawHLine(nodeX[i], nodeX[i + 1], pixelY, color, plotProc, data);
- }
- }
- }
-
- free(nodeX);
-}
-
-// http://members.chello.at/easyfilter/bresenham.html
-void Design::drawEllipse(int x0, int y0, int x1, int y1, bool filled, void (*plotProc)(int, int, int, void *), void *data) {
- int a = abs(x1-x0), b = abs(y1-y0), b1 = b&1; /* values of diameter */
- long dx = 4*(1-a)*b*b, dy = 4*(b1+1)*a*a; /* error increment */
- long err = dx+dy+b1*a*a, e2; /* error of 1.step */
-
- if (x0 > x1) { x0 = x1; x1 += a; } /* if called with swapped points */
- if (y0 > y1) y0 = y1; /* .. exchange them */
- y0 += (b+1)/2; y1 = y0-b1; /* starting pixel */
- a *= 8*a; b1 = 8*b*b;
-
- do {
- if (filled) {
- drawHLine(x0, x1, y0, kColorBlack, plotProc, data);
- drawHLine(x0, x1, y1, kColorBlack, plotProc, data);
- } else {
- (*plotProc)(x1, y0, kColorBlack, data); /* I. Quadrant */
- (*plotProc)(x0, y0, kColorBlack, data); /* II. Quadrant */
- (*plotProc)(x0, y1, kColorBlack, data); /* III. Quadrant */
- (*plotProc)(x1, y1, kColorBlack, data); /* IV. Quadrant */
- }
- e2 = 2*err;
- if (e2 <= dy) { y0++; y1--; err += dy += a; } /* y step */
- if (e2 >= dx || 2*err > dy) { x0++; x1--; err += dx += b1; } /* x step */
- } while (x0 <= x1);
-
- while (y0-y1 < b) { /* too early stop of flat ellipses a=1 */
- if (filled) {
- drawHLine(x0-1, x0-1, y0, kColorBlack, plotProc, data); /* -> finish tip of ellipse */
- drawHLine(x1+1, x1+1, y0, kColorBlack, plotProc, data);
- drawHLine(x0-1, x0-1, y1, kColorBlack, plotProc, data);
- drawHLine(x1+1, x1+1, y1, kColorBlack, plotProc, data);
- } else {
- (*plotProc)(x0-1, y0, kColorBlack, data); /* -> finish tip of ellipse */
- (*plotProc)(x1+1, y0, kColorBlack, data);
- (*plotProc)(x0-1, y1, kColorBlack, data);
- (*plotProc)(x1+1, y1, kColorBlack, data);
- }
- y0++;
- y1--;
- }
+ Graphics::drawRoundRect(rect, arc, color, true, drawPixel, &pd);
}
void Design::drawHLine(Graphics::Surface *surface, int x1, int x2, int y, int thickness, int color, Patterns &patterns, byte fillType) {
plotData pd(surface, &patterns, fillType, thickness);
- drawHLine(x1, x2, y, color, drawPixel, &pd);
-}
-
-void Design::drawHLine(int x1, int x2, int y, int color, void (*plotProc)(int, int, int, void *), void *data) {
- if (x1 > x2)
- SWAP(x1, x2);
-
- for (int x = x1; x <= x2; x++)
- (*plotProc)(x, y, color, data);
+ Graphics::drawHLine(x1, x2, y, color, drawPixel, &pd);
}
void Design::drawVLine(Graphics::Surface *surface, int x, int y1, int y2, int thickness, int color, Patterns &patterns, byte fillType) {
plotData pd(surface, &patterns, fillType, thickness);
- drawVLine(x, y1, y2, color, drawPixel, &pd);
-}
-
-void Design::drawVLine(int x, int y1, int y2, int color, void (*plotProc)(int, int, int, void *), void *data) {
- if (y1 > y2)
- SWAP(y1, y2);
-
- for (int y = y1; y <= y2; y++)
- (*plotProc)(x, y, color, data);
-}
-
-/* Bresenham as presented in Foley & Van Dam */
-/* Code is based on GD lib http://libgd.github.io/ */
-void Design::drawThickLine (int x1, int y1, int x2, int y2, int thick, int color,
- void (*plotProc)(int, int, int, void *), void *data) {
- int incr1, incr2, d, x, y, xend, yend, xdirflag, ydirflag;
- int wid;
- int w, wstart;
-
- int dx = abs(x2 - x1);
- int dy = abs(y2 - y1);
-
- if (dx == 0) {
- if (y1 > y2)
- SWAP(y1, y2);
- Common::Rect r(x1, y1, x1 + thick - 1, y2);
- drawFilledRect(r, color, plotProc, data);
- return;
- } else if (dy == 0) {
- if (x1 > x2)
- SWAP(x1, x2);
- Common::Rect r(x1, y1, x2, y1 + thick - 1);
- drawFilledRect(r, color, plotProc, data);
- return;
- }
-
- if (dy <= dx) {
- /* More-or-less horizontal. use wid for vertical stroke */
- /* Doug Claar: watch out for NaN in atan2 (2.0.5) */
-
- /* 2.0.12: Michael Schwartz: divide rather than multiply;
- TBB: but watch out for /0! */
- double ac = cos(atan2 (dy, dx));
- if (ac != 0) {
- wid = thick / ac;
- } else {
- wid = 1;
- }
- if (wid == 0) {
- wid = 1;
- }
- d = 2 * dy - dx;
- incr1 = 2 * dy;
- incr2 = 2 * (dy - dx);
- if (x1 > x2) {
- x = x2;
- y = y2;
- ydirflag = (-1);
- xend = x1;
- } else {
- x = x1;
- y = y1;
- ydirflag = 1;
- xend = x2;
- }
-
- /* Set up line thickness */
- wstart = y - wid / 2;
- for (w = wstart; w < wstart + wid; w++)
- (*plotProc)(x, y, color, data);
-
- if (((y2 - y1) * ydirflag) > 0) {
- while (x < xend) {
- x++;
- if (d < 0) {
- d += incr1;
- } else {
- y++;
- d += incr2;
- }
- wstart = y - wid / 2;
- for (w = wstart; w < wstart + wid; w++)
- (*plotProc)(x, w, color, data);
- }
- } else {
- while (x < xend) {
- x++;
- if (d < 0) {
- d += incr1;
- } else {
- y--;
- d += incr2;
- }
- wstart = y - wid / 2;
- for (w = wstart; w < wstart + wid; w++)
- (*plotProc)(x, w, color, data);
- }
- }
- } else {
- /* More-or-less vertical. use wid for horizontal stroke */
- /* 2.0.12: Michael Schwartz: divide rather than multiply;
- TBB: but watch out for /0! */
- double as = sin(atan2(dy, dx));
- if (as != 0) {
- wid = thick / as;
- } else {
- wid = 1;
- }
- if (wid == 0)
- wid = 1;
-
- d = 2 * dx - dy;
- incr1 = 2 * dx;
- incr2 = 2 * (dx - dy);
- if (y1 > y2) {
- y = y2;
- x = x2;
- yend = y1;
- xdirflag = (-1);
- } else {
- y = y1;
- x = x1;
- yend = y2;
- xdirflag = 1;
- }
-
- /* Set up line thickness */
- wstart = x - wid / 2;
- for (w = wstart; w < wstart + wid; w++)
- (*plotProc)(w, y, color, data);
-
- if (((x2 - x1) * xdirflag) > 0) {
- while (y < yend) {
- y++;
- if (d < 0) {
- d += incr1;
- } else {
- x++;
- d += incr2;
- }
- wstart = x - wid / 2;
- for (w = wstart; w < wstart + wid; w++)
- (*plotProc)(w, y, color, data);
- }
- } else {
- while (y < yend) {
- y++;
- if (d < 0) {
- d += incr1;
- } else {
- x--;
- d += incr2;
- }
- wstart = x - wid / 2;
- for (w = wstart; w < wstart + wid; w++)
- (*plotProc)(w, y, color, data);
- }
- }
- }
+ Graphics::drawVLine(x, y1, y2, color, drawPixel, &pd);
}
FloodFill::FloodFill(Graphics::Surface *surface, byte color1, byte color2) {
diff --git a/engines/wage/design.h b/engines/wage/design.h
index d98d30c..43f9ce1 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -93,16 +93,6 @@ private:
void drawOval(Graphics::Surface *surface, Common::ReadStream &in,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
void drawBitmap(Graphics::Surface *surface, Common::ReadStream &in);
-
- void drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data);
- static void drawRoundRect(Common::Rect &rect, int arc, int color, bool filled, void (*plotProc)(int, int, int, void *), void *data);
- void drawPolygonScan(int *polyX, int *polyY, int npoints, Common::Rect &bbox, int color,
- void (*plotProc)(int, int, int, void *), void *data);
- void drawEllipse(int x0, int y0, int x1, int y1, bool filled, void (*plotProc)(int, int, int, void *), void *data);
- static void drawHLine(int x1, int x2, int y, int color, void (*plotProc)(int, int, int, void *), void *data);
- static void drawVLine(int x, int y1, int y2, int color, void (*plotProc)(int, int, int, void *), void *data);
- void drawThickLine (int x1, int y1, int x2, int y2, int thick, int color,
- void (*plotProc)(int, int, int, void *), void *data);
};
class FloodFill {
diff --git a/graphics/primitives.cpp b/graphics/primitives.cpp
index 564bdb9..0e97065 100644
--- a/graphics/primitives.cpp
+++ b/graphics/primitives.cpp
@@ -21,6 +21,7 @@
*/
#include "common/util.h"
+#include "graphics/primitives.h"
namespace Graphics {
@@ -62,6 +63,22 @@ void drawLine(int x0, int y0, int x1, int y1, int color, void (*plotProc)(int, i
}
}
+void drawHLine(int x1, int x2, int y, int color, void (*plotProc)(int, int, int, void *), void *data) {
+ if (x1 > x2)
+ SWAP(x1, x2);
+
+ for (int x = x1; x <= x2; x++)
+ (*plotProc)(x, y, color, data);
+}
+
+void drawVLine(int x, int y1, int y2, int color, void (*plotProc)(int, int, int, void *), void *data) {
+ if (y1 > y2)
+ SWAP(y1, y2);
+
+ for (int y = y1; y <= y2; y++)
+ (*plotProc)(x, y, color, data);
+}
+
void drawThickLine(int x0, int y0, int x1, int y1, int penX, int penY, int color, void (*plotProc)(int, int, int, void *), void *data) {
assert(penX > 0 && penY > 0);
@@ -79,4 +96,344 @@ void drawThickLine(int x0, int y0, int x1, int y1, int penX, int penY, int color
drawLine(x0 + x, y0 + y, x1 + x, y1 + y, color, plotProc, data);
}
+/* Bresenham as presented in Foley & Van Dam */
+/* Code is based on GD lib http://libgd.github.io/ */
+void drawThickLine2(int x1, int y1, int x2, int y2, int thick, int color, void (*plotProc)(int, int, int, void *), void *data) {
+ int incr1, incr2, d, x, y, xend, yend, xdirflag, ydirflag;
+ int wid;
+ int w, wstart;
+
+ int dx = abs(x2 - x1);
+ int dy = abs(y2 - y1);
+
+ if (dx == 0) {
+ if (y1 > y2)
+ SWAP(y1, y2);
+ Common::Rect r(x1, y1, x1 + thick - 1, y2);
+ drawFilledRect(r, color, plotProc, data);
+ return;
+ } else if (dy == 0) {
+ if (x1 > x2)
+ SWAP(x1, x2);
+ Common::Rect r(x1, y1, x2, y1 + thick - 1);
+ drawFilledRect(r, color, plotProc, data);
+ return;
+ }
+
+ if (dy <= dx) {
+ /* More-or-less horizontal. use wid for vertical stroke */
+ /* Doug Claar: watch out for NaN in atan2 (2.0.5) */
+
+ /* 2.0.12: Michael Schwartz: divide rather than multiply;
+ TBB: but watch out for /0! */
+ double ac = cos(atan2 (dy, dx));
+ if (ac != 0) {
+ wid = thick / ac;
+ } else {
+ wid = 1;
+ }
+ if (wid == 0) {
+ wid = 1;
+ }
+ d = 2 * dy - dx;
+ incr1 = 2 * dy;
+ incr2 = 2 * (dy - dx);
+ if (x1 > x2) {
+ x = x2;
+ y = y2;
+ ydirflag = (-1);
+ xend = x1;
+ } else {
+ x = x1;
+ y = y1;
+ ydirflag = 1;
+ xend = x2;
+ }
+
+ /* Set up line thickness */
+ wstart = y - wid / 2;
+ for (w = wstart; w < wstart + wid; w++)
+ (*plotProc)(x, y, color, data);
+
+ if (((y2 - y1) * ydirflag) > 0) {
+ while (x < xend) {
+ x++;
+ if (d < 0) {
+ d += incr1;
+ } else {
+ y++;
+ d += incr2;
+ }
+ wstart = y - wid / 2;
+ for (w = wstart; w < wstart + wid; w++)
+ (*plotProc)(x, w, color, data);
+ }
+ } else {
+ while (x < xend) {
+ x++;
+ if (d < 0) {
+ d += incr1;
+ } else {
+ y--;
+ d += incr2;
+ }
+ wstart = y - wid / 2;
+ for (w = wstart; w < wstart + wid; w++)
+ (*plotProc)(x, w, color, data);
+ }
+ }
+ } else {
+ /* More-or-less vertical. use wid for horizontal stroke */
+ /* 2.0.12: Michael Schwartz: divide rather than multiply;
+ TBB: but watch out for /0! */
+ double as = sin(atan2(dy, dx));
+ if (as != 0) {
+ wid = thick / as;
+ } else {
+ wid = 1;
+ }
+ if (wid == 0)
+ wid = 1;
+
+ d = 2 * dx - dy;
+ incr1 = 2 * dx;
+ incr2 = 2 * (dx - dy);
+ if (y1 > y2) {
+ y = y2;
+ x = x2;
+ yend = y1;
+ xdirflag = (-1);
+ } else {
+ y = y1;
+ x = x1;
+ yend = y2;
+ xdirflag = 1;
+ }
+
+ /* Set up line thickness */
+ wstart = x - wid / 2;
+ for (w = wstart; w < wstart + wid; w++)
+ (*plotProc)(w, y, color, data);
+
+ if (((x2 - x1) * xdirflag) > 0) {
+ while (y < yend) {
+ y++;
+ if (d < 0) {
+ d += incr1;
+ } else {
+ x++;
+ d += incr2;
+ }
+ wstart = x - wid / 2;
+ for (w = wstart; w < wstart + wid; w++)
+ (*plotProc)(w, y, color, data);
+ }
+ } else {
+ while (y < yend) {
+ y++;
+ if (d < 0) {
+ d += incr1;
+ } else {
+ x--;
+ d += incr2;
+ }
+ wstart = x - wid / 2;
+ for (w = wstart; w < wstart + wid; w++)
+ (*plotProc)(w, y, color, data);
+ }
+ }
+ }
+}
+
+void drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data) {
+ for (int y = rect.top; y <= rect.bottom; y++)
+ drawHLine(rect.left, rect.right, y, color, plotProc, data);
+}
+
+// http://members.chello.at/easyfilter/bresenham.html
+void drawRoundRect(Common::Rect &rect, int arc, int color, bool filled, void (*plotProc)(int, int, int, void *), void *data) {
+ if (rect.height() < rect.width()) {
+ int x = -arc, y = 0, err = 2-2*arc; /* II. Quadrant */
+ int dy = rect.height() - arc * 2;
+ int r = arc;
+ int stop = 0;
+ int lastx, lasty;
+ if (dy < 0)
+ stop = -dy / 2;
+
+ do {
+ if (filled) {
+ drawHLine(rect.left+x+r, rect.right-x-r, rect.top-y+r-stop, color, plotProc, data);
+ drawHLine(rect.left+x+r, rect.right-x-r, rect.bottom+y-r+stop, color, plotProc, data);
+ } else {
+ (*plotProc)(rect.left+x+r, rect.top-y+r-stop, color, data);
+ (*plotProc)(rect.right-x-r, rect.top-y+r-stop, color, data);
+ (*plotProc)(rect.left+x+r, rect.bottom+y-r+stop, color, data);
+ (*plotProc)(rect.right-x-r, rect.bottom+y-r+stop, color, data);
+
+ lastx = x;
+ lasty = y;
+ }
+ arc = err;
+ if (arc <= y) err += ++y*2+1; /* e_xy+e_y < 0 */
+ if (arc > x || err > y) err += ++x*2+1; /* e_xy+e_x > 0 or no 2nd y-step */
+ if (stop && y > stop)
+ break;
+ } while (x < 0);
+
+ if (!filled) {
+ x = lastx;
+ y = lasty;
+
+ drawHLine(rect.left+x+r, rect.right-x-r, rect.top-y+r-stop, color, plotProc, data);
+ drawHLine(rect.left+x+r, rect.right-x-r, rect.bottom+y-r+stop, color, plotProc, data);
+ }
+
+ for (int i = 0; i < dy; i++) {
+ if (filled) {
+ drawHLine(rect.left, rect.right, rect.top + r + i, color, plotProc, data);
+ } else {
+ (*plotProc)(rect.left, rect.top + r + i, color, data);
+ (*plotProc)(rect.right, rect.top + r + i, color, data);
+ }
+ }
+ } else {
+ int y = -arc, x = 0, err = 2-2*arc; /* II. Quadrant */
+ int dx = rect.width() - arc * 2;
+ int r = arc;
+ int stop = 0;
+ int lastx, lasty;
+ if (dx < 0)
+ stop = -dx / 2;
+
+ do {
+ if (filled) {
+ drawVLine(rect.left-x+r-stop, rect.top+y+r, rect.bottom-y-r, color, plotProc, data);
+ drawVLine(rect.right+x-r+stop, rect.top+y+r, rect.bottom-y-r, color, plotProc, data);
+ } else {
+ (*plotProc)(rect.left-x+r-stop, rect.top+y+r, color, data);
+ (*plotProc)(rect.left-x+r-stop, rect.bottom-y-r, color, data);
+ (*plotProc)(rect.right+x-r+stop, rect.top+y+r, color, data);
+ (*plotProc)(rect.right+x-r+stop, rect.bottom-y-r, color, data);
+
+ lastx = x;
+ lasty = y;
+ }
+
+ arc = err;
+ if (arc <= x) err += ++x*2+1; /* e_xy+e_y < 0 */
+ if (arc > y || err > x) err += ++y*2+1; /* e_xy+e_x > 0 or no 2nd y-step */
+ if (stop && x > stop)
+ break;
+ } while (y < 0);
+
+ if (!filled) {
+ x = lastx;
+ y = lasty;
+ drawVLine(rect.left-x+r-stop, rect.top+y+r, rect.bottom-y-r, color, plotProc, data);
+ drawVLine(rect.right+x-r+stop, rect.top+y+r, rect.bottom-y-r, color, plotProc, data);
+ }
+
+ for (int i = 0; i < dx; i++) {
+ if (filled) {
+ drawVLine(rect.left + r + i, rect.top, rect.bottom, color, plotProc, data);
+ } else {
+ (*plotProc)(rect.left + r + i, rect.top, color, data);
+ (*plotProc)(rect.left + r + i, rect.bottom, color, data);
+ }
+ }
+ }
+}
+
+// Based on public-domain code by Darel Rex Finley, 2007
+// http://alienryderflex.com/polygon_fill/
+void drawPolygonScan(int *polyX, int *polyY, int npoints, Common::Rect &bbox, int color, void (*plotProc)(int, int, int, void *), void *data) {
+ int *nodeX = (int *)calloc(npoints, sizeof(int));
+ int i, j;
+
+ // Loop through the rows of the image.
+ for (int pixelY = bbox.top; pixelY < bbox.bottom; pixelY++) {
+ // Build a list of nodes.
+ int nodes = 0;
+ j = npoints - 1;
+
+ for (i = 0; i < npoints; i++) {
+ if ((polyY[i] < pixelY && polyY[j] >= pixelY) || (polyY[j] < pixelY && polyY[i] >= pixelY)) {
+ nodeX[nodes++] = (int)(polyX[i] + (double)(pixelY - polyY[i]) / (double)(polyY[j]-polyY[i]) *
+ (double)(polyX[j] - polyX[i]) + 0.5);
+ }
+ j = i;
+ }
+
+ // Sort the nodes, via a simple “Bubble” sort.
+ i = 0;
+ while (i < nodes - 1) {
+ if (nodeX[i] > nodeX[i + 1]) {
+ SWAP(nodeX[i], nodeX[i + 1]);
+ if (i)
+ i--;
+ } else {
+ i++;
+ }
+ }
+
+ // Fill the pixels between node pairs.
+ for (i = 0; i < nodes; i += 2) {
+ if (nodeX[i ] >= bbox.right)
+ break;
+ if (nodeX[i + 1] > bbox.left) {
+ nodeX[i] = MAX<int16>(nodeX[i], bbox.left);
+ nodeX[i + 1] = MIN<int16>(nodeX[i + 1], bbox.right);
+
+ drawHLine(nodeX[i], nodeX[i + 1], pixelY, color, plotProc, data);
+ }
+ }
+ }
+
+ free(nodeX);
+}
+
+// http://members.chello.at/easyfilter/bresenham.html
+void drawEllipse(int x0, int y0, int x1, int y1, int color, bool filled, void (*plotProc)(int, int, int, void *), void *data) {
+ int a = abs(x1-x0), b = abs(y1-y0), b1 = b&1; /* values of diameter */
+ long dx = 4*(1-a)*b*b, dy = 4*(b1+1)*a*a; /* error increment */
+ long err = dx+dy+b1*a*a, e2; /* error of 1.step */
+
+ if (x0 > x1) { x0 = x1; x1 += a; } /* if called with swapped points */
+ if (y0 > y1) y0 = y1; /* .. exchange them */
+ y0 += (b+1)/2; y1 = y0-b1; /* starting pixel */
+ a *= 8*a; b1 = 8*b*b;
+
+ do {
+ if (filled) {
+ drawHLine(x0, x1, y0, color, plotProc, data);
+ drawHLine(x0, x1, y1, color, plotProc, data);
+ } else {
+ (*plotProc)(x1, y0, color, data); /* I. Quadrant */
+ (*plotProc)(x0, y0, color, data); /* II. Quadrant */
+ (*plotProc)(x0, y1, color, data); /* III. Quadrant */
+ (*plotProc)(x1, y1, color, data); /* IV. Quadrant */
+ }
+ e2 = 2*err;
+ if (e2 <= dy) { y0++; y1--; err += dy += a; } /* y step */
+ if (e2 >= dx || 2*err > dy) { x0++; x1--; err += dx += b1; } /* x step */
+ } while (x0 <= x1);
+
+ while (y0-y1 < b) { /* too early stop of flat ellipses a=1 */
+ if (filled) {
+ drawHLine(x0-1, x0-1, y0, color, plotProc, data); /* -> finish tip of ellipse */
+ drawHLine(x1+1, x1+1, y0, color, plotProc, data);
+ drawHLine(x0-1, x0-1, y1, color, plotProc, data);
+ drawHLine(x1+1, x1+1, y1, color, plotProc, data);
+ } else {
+ (*plotProc)(x0-1, y0, color, data); /* -> finish tip of ellipse */
+ (*plotProc)(x1+1, y0, color, data);
+ (*plotProc)(x0-1, y1, color, data);
+ (*plotProc)(x1+1, y1, color, data);
+ }
+ y0++;
+ y1--;
+ }
+}
+
} // End of namespace Graphics
diff --git a/graphics/primitives.h b/graphics/primitives.h
index a3e8ab1..62dc10b 100644
--- a/graphics/primitives.h
+++ b/graphics/primitives.h
@@ -23,10 +23,21 @@
#ifndef GRAPHICS_PRIMITIVES_H
#define GRAPHICS_PRIMITIVES_H
+#include "common/rect.h"
+
namespace Graphics {
void drawLine(int x0, int y0, int x1, int y1, int color, void (*plotProc)(int, int, int, void *), void *data);
+void drawHLine(int x1, int x2, int y, int color, void (*plotProc)(int, int, int, void *), void *data);
+void drawVLine(int x, int y1, int y2, int color, void (*plotProc)(int, int, int, void *), void *data);
void drawThickLine(int x0, int y0, int x1, int y1, int penX, int penY, int color, void (*plotProc)(int, int, int, void *), void *data);
+void drawThickLine2(int x1, int y1, int x2, int y2, int thick, int color,
+ void (*plotProc)(int, int, int, void *), void *data);
+void drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data);
+void drawRoundRect(Common::Rect &rect, int arc, int color, bool filled, void (*plotProc)(int, int, int, void *), void *data);
+void drawPolygonScan(int *polyX, int *polyY, int npoints, Common::Rect &bbox, int color,
+ void (*plotProc)(int, int, int, void *), void *data);
+void drawEllipse(int x0, int y0, int x1, int y1, int color, bool filled, void (*plotProc)(int, int, int, void *), void *data);
} // End of namespace Graphics
Commit: ab20b96f604f6819dfe6f03286a01bb899fde291
https://github.com/scummvm/scummvm/commit/ab20b96f604f6819dfe6f03286a01bb899fde291
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:03+01:00
Commit Message:
WAGE: Improve text entry
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/wage.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index d158d48..d7e1233 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -159,6 +159,8 @@ Gui::Gui(WageEngine *engine) {
_selectionStartX = _selectionStartY = -1;
_selectionEndX = _selectionEndY = -1;
+ _inputTextLineNum = 0;
+
g_system->getPaletteManager()->setPalette(palette, 0, 4);
CursorMan.replaceCursorPalette(palette, 0, 4);
@@ -432,14 +434,14 @@ void Gui::flowText(Common::String &str) {
_lines.push_back(*j);
uint pos = _scrollPos;
- _scrollPos = MAX<int>(0, (_lines.size() - _consoleNumLines) * _consoleLineHeight);
+ _scrollPos = MAX<int>(0, (_lines.size() - 1 - _consoleNumLines) * _consoleLineHeight);
_cursorX = kConWPadding;
if (_scrollPos)
_cursorY = (_consoleNumLines) * _consoleLineHeight + kConHPadding;
else
- _cursorY = (_lines.size()) * _consoleLineHeight + kConHPadding;
+ _cursorY = (_lines.size() - 1) * _consoleLineHeight + kConHPadding;
if (pos != _scrollPos)
_consoleFullRedraw = true;
@@ -576,28 +578,33 @@ void Gui::drawInput() {
_bordersDirty = true;
}
- const Graphics::Font *font = getConsoleFont();
+ _lines.pop_back();
+ appendText(_engine->_inputText.c_str());
+ _inputTextLineNum = _lines.size() - 1;
- int x = kConWPadding + _consoleTextArea.left;
- int y = _cursorY + _consoleTextArea.top;
- Common::String text(_engine->_inputText);
- int textW = font->getStringWidth(text);
+ const Graphics::Font *font = getConsoleFont();
- // undraw cursor
- _cursorOff = true;
- _cursorState = false;
- cursorTimerHandler(this);
- _cursorOff = false;
+ if (_engine->_inputText.contains('\n')) {
+ _consoleDirty = true;
+ } else {
+ int x = kConWPadding + _consoleTextArea.left;
+ int y = _cursorY + _consoleTextArea.top;
- Common::Rect r(x, y, x + textW + 10, y + font->getFontHeight());
+ Common::Rect r(x, y, x + _consoleTextArea.width(), y + font->getFontHeight());
+ _screen.fillRect(r, kColorWhite);
- _screen.fillRect(r, kColorWhite);
+ // undraw cursor
+ _cursorOff = true;
+ _cursorState = false;
+ cursorTimerHandler(this);
+ _cursorOff = false;
- font->drawString(&_screen, text, x, y, _screen.w, kColorBlack);
+ font->drawString(&_screen, _lines[_inputTextLineNum], x, y, _screen.w, kColorBlack);
- g_system->copyRectToScreen(_screen.getBasePtr(x, y), _screen.pitch, x, y, textW + 10, font->getFontHeight());
+ g_system->copyRectToScreen(_screen.getBasePtr(x, y), _screen.pitch, x, y, _consoleTextArea.width(), font->getFontHeight());
+ }
- _cursorX = font->getStringWidth(_engine->_inputText) + kConHPadding;
+ _cursorX = font->getStringWidth(_lines[_inputTextLineNum]) + kConHPadding;
}
void Gui::loadFonts() {
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 6d33abb..2353a59 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -162,6 +162,8 @@ private:
Common::String _clipboard;
Common::String _undobuffer;
+
+ int _inputTextLineNum;
};
} // End of namespace Wage
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index c1d7033..1c9a982 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -209,10 +209,12 @@ void WageEngine::setMenu(Common::String menu) {
}
void WageEngine::appendText(const char *str) {
- if (_inputText.size())
- _gui->appendText(_inputText.c_str());
+ if (_inputText.size()) {
+ _inputText += '\n';
+ _gui->drawInput();
- _inputText = "";
+ _inputText = "";
+ }
_gui->appendText(str);
}
Commit: 6f2c769aae0423f7860383335f22a301696c464f
https://github.com/scummvm/scummvm/commit/6f2c769aae0423f7860383335f22a301696c464f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:03+01:00
Commit Message:
WAGE: REmove redundant .gitignore
Changed paths:
R engines/wage/.gitignore
diff --git a/engines/wage/.gitignore b/engines/wage/.gitignore
deleted file mode 100644
index 81a48b8..0000000
--- a/engines/wage/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-.deps
-*.o
-lib*.a
Commit: c72c92a3ef5cb58878ea0ae156a6fc6855eb7fff
https://github.com/scummvm/scummvm/commit/c72c92a3ef5cb58878ea0ae156a6fc6855eb7fff
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:03+01:00
Commit Message:
WAGE: More const'ness
Changed paths:
engines/wage/combat.cpp
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index 4c3d6c9..91c65cf 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -396,7 +396,7 @@ void WageEngine::performHealingMagic(Chr *chr, Obj *magicalObject) {
static const int directionsX[] = { 0, 0, 1, -1 };
static const int directionsY[] = { -1, 1, 0, 0 };
-static const char *directionsS[] = { "north", "south", "east", "west" };
+static const char *const directionsS[] = { "north", "south", "east", "west" };
void WageEngine::performMove(Chr *chr, int validMoves) {
// count how many valid moves we have
Commit: 82fff0ab865b20a8aaa36fcfe3523c51b764cffb
https://github.com/scummvm/scummvm/commit/82fff0ab865b20a8aaa36fcfe3523c51b764cffb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:04+01:00
Commit Message:
WAGE: Made code cleaner
Changed paths:
engines/wage/combat.cpp
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index 91c65cf..b696324 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -464,7 +464,7 @@ int WageEngine::getValidMoveDirections(Chr *npc) {
Scene *scene = _world->getSceneAt(destX, destY);
- if (scene != NULL && scene->_chrs.size() == 0) {
+ if (scene != NULL && scene->_chrs.empty()) {
directions |= (1 << dir);
}
}
Commit: ab9bda22b2d3a6e0fa7414d1a3aa19781d1b7d98
https://github.com/scummvm/scummvm/commit/ab9bda22b2d3a6e0fa7414d1a3aa19781d1b7d98
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:04+01:00
Commit Message:
WAGE: Remove redundant type casts
Changed paths:
engines/wage/combat.cpp
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index b696324..c1c184a 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -221,9 +221,9 @@ void WageEngine::performAttack(Chr *attacker, Chr *victim, Obj *weapon) {
if (chance < attacker->_physicalAccuracy) {
usesDecremented = attackHit(attacker, victim, weapon, targetIndex);
} else if (weapon->_type != Obj::MAGICAL_OBJECT) {
- appendText((char *)"A miss!");
+ appendText("A miss!");
} else if (attacker->_playerCharacter) {
- appendText((char *)"The spell has no effect.");
+ appendText("The spell has no effect.");
}
if (!usesDecremented) {
@@ -486,7 +486,7 @@ void WageEngine::regen() {
}
void WageEngine::takeObj(Obj *obj) {
- if ((int)_world->_player->_inventory.size() >= _world->_player->_maximumCarriedObjects) {
+ if ((int)_world->_player->_inventory.size() >= _world->_player->_maximumCarriedObjects) {
appendText("Your pack is full, you must drop something.");
} else {
char buf[256];
@@ -603,7 +603,7 @@ bool WageEngine::handleInventoryCommand() {
objs.push_back(*it);
if (!objs.size()) {
- appendText((char *)"Your pack is empty.");
+ appendText("Your pack is empty.");
} else {
Common::String res("Your pack contains ");
appendObjNames(res, objs);
@@ -661,7 +661,7 @@ bool WageEngine::handleStatusCommand() {
bool WageEngine::handleRestCommand() {
if (getMonster() != NULL) {
- appendText((char *)"This is no time to rest!");
+ appendText("This is no time to rest!");
_commandWasQuick = true;
} else {
regen();
@@ -695,7 +695,7 @@ bool WageEngine::handleTakeCommand(const char *target) {
if (t.contains(n)) {
if ((*it)->_type == Obj::IMMOBILE_OBJECT) {
- appendText((char *)"You can't move it.");
+ appendText("You can't move it.");
} else {
takeObj(*it);
}
@@ -747,7 +747,7 @@ bool WageEngine::handleAimCommand(const char *t) {
_aim = Chr::SIDE;
} else {
wasHandled = false;
- appendText((char *)"Please aim for the head, chest, or side.");
+ appendText("Please aim for the head, chest, or side.");
}
_commandWasQuick = true;
@@ -776,7 +776,7 @@ bool WageEngine::handleWearCommand(const char *t) {
} else if ((*it)->_type == Obj::SPIRITUAL_ARMOR) {
wearObj(*it, Chr::MAGIC_ARMOR);
} else {
- appendText((char *)"You cannot wear that object.");
+ appendText("You cannot wear that object.");
}
handled = true;
Commit: c1d548764a749fb804fe46f3dd494c26394535db
https://github.com/scummvm/scummvm/commit/c1d548764a749fb804fe46f3dd494c26394535db
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:04+01:00
Commit Message:
WAGE: Event more const
Changed paths:
engines/wage/combat.cpp
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index c1c184a..7a93636 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -613,7 +613,7 @@ bool WageEngine::handleInventoryCommand() {
return true;
}
-static const char *armorMessages[] = {
+static const char *const armorMessages[] = {
"Head protection:",
"Chest protection:",
"Shield protection:", // TODO: check message
Commit: 7dd3874a4379e0f7a52c392f09e6816a9f9303c8
https://github.com/scummvm/scummvm/commit/7dd3874a4379e0f7a52c392f09e6816a9f9303c8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:04+01:00
Commit Message:
WAGE: Indentation fixes
Changed paths:
engines/wage/design.h
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 43f9ce1..94a620a 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -79,17 +79,17 @@ public:
private:
byte *_data;
- int _len;
+ int _len;
Common::Rect *_bounds;
Graphics::Surface *_surface;
private:
- void drawRect(Graphics::Surface *surface, Common::ReadStream &in,
- Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
+ void drawRect(Graphics::Surface *surface, Common::ReadStream &in,
+ Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
void drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in,
- Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
+ Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
void drawPolygon(Graphics::Surface *surface, Common::ReadStream &in,
- Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
+ Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
void drawOval(Graphics::Surface *surface, Common::ReadStream &in,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
void drawBitmap(Graphics::Surface *surface, Common::ReadStream &in);
Commit: a31cfff9d6da18a219ec6861755219f92bc5427b
https://github.com/scummvm/scummvm/commit/a31cfff9d6da18a219ec6861755219f92bc5427b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:05+01:00
Commit Message:
WAGE: Let compiler optimize %8's
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 2acd8728..63721f6 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -184,8 +184,10 @@ void drawPixel(int x, int y, int color, void *data) {
if (p->thickness == 1) {
if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h) {
- *((byte *)p->surface->getBasePtr(x, y)) =
- (pat[y % 8] & (1 << (7 - x % 8))) ?
+ uint xu = (uint)x; // for letting compiler optimize it
+ uint yu = (uint)y;
+ *((byte *)p->surface->getBasePtr(xu, yu)) =
+ (pat[yu % 8] & (1 << (7 - xu % 8))) ?
color : kColorWhite;
}
} else {
@@ -196,10 +198,13 @@ void drawPixel(int x, int y, int color, void *data) {
for (y = y1; y < y2; y++)
for (x = x1; x < x2; x++)
- if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h)
- *((byte *)p->surface->getBasePtr(x, y)) =
- (pat[y % 8] & (1 << (7 - x % 8))) ?
+ if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h) {
+ uint xu = (uint)x; // for letting compiler optimize it
+ uint yu = (uint)y;
+ *((byte *)p->surface->getBasePtr(xu, yu)) =
+ (pat[yu % 8] & (1 << (7 - xu % 8))) ?
color : kColorWhite;
+ }
}
}
Commit: c0be640d5e118e4607e1aea82fd089c7a6288d9b
https://github.com/scummvm/scummvm/commit/c0be640d5e118e4607e1aea82fd089c7a6288d9b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:05+01:00
Commit Message:
WAGE: More const'ness
Changed paths:
engines/wage/entities.cpp
engines/wage/menu.cpp
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 4852199..27ee745 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -151,7 +151,7 @@ void Scene::paint(Graphics::Surface *surface, int x, int y) {
// Source: Apple IIGS Technical Note #41, "Font Family Numbers"
// http://apple2.boldt.ca/?page=til/tn.iigs.041
-const char *fontNames[] = {
+static const char *const fontNames[] = {
"Chicago", // system font
"Geneva", // application font
"New York",
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 83e610a..414d535 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -85,7 +85,7 @@ struct MenuData {
int action;
byte shortcut;
bool enabled;
-} menuSubItems[] = {
+} static const menuSubItems[] = {
{ kMenuFile, "New", kMenuActionNew, 0, false },
{ kMenuFile, "Open...", kMenuActionOpen, 0, false },
{ kMenuFile, "Close", kMenuActionClose, 0, true },
@@ -121,7 +121,7 @@ Menu::Menu(Gui *gui) : _gui(gui) {
_items.push_back(edit);
for (int i = 0; menuSubItems[i].menunum; i++) {
- MenuData *m = &menuSubItems[i];
+ const MenuData *m = &menuSubItems[i];
_items[m->menunum]->subitems.push_back(new MenuSubItem(m->title, m->action, 0, m->shortcut, m->enabled));
}
Commit: 47e3fec8ea6578de6e3cd34241c0685a31167902
https://github.com/scummvm/scummvm/commit/47e3fec8ea6578de6e3cd34241c0685a31167902
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:05+01:00
Commit Message:
WAGE: Firther work on input improvements
Changed paths:
engines/wage/gui.cpp
engines/wage/wage.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index d7e1233..3ddc508 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -578,9 +578,10 @@ void Gui::drawInput() {
_bordersDirty = true;
}
+ _out.pop_back();
_lines.pop_back();
appendText(_engine->_inputText.c_str());
- _inputTextLineNum = _lines.size() - 1;
+ _inputTextLineNum = _out.size() - 1;
const Graphics::Font *font = getConsoleFont();
@@ -590,7 +591,7 @@ void Gui::drawInput() {
int x = kConWPadding + _consoleTextArea.left;
int y = _cursorY + _consoleTextArea.top;
- Common::Rect r(x, y, x + _consoleTextArea.width(), y + font->getFontHeight());
+ Common::Rect r(x, y, x + _consoleTextArea.width() - kConWPadding, y + font->getFontHeight());
_screen.fillRect(r, kColorWhite);
// undraw cursor
@@ -599,12 +600,12 @@ void Gui::drawInput() {
cursorTimerHandler(this);
_cursorOff = false;
- font->drawString(&_screen, _lines[_inputTextLineNum], x, y, _screen.w, kColorBlack);
+ font->drawString(&_screen, _out[_inputTextLineNum], x, y, _screen.w, kColorBlack);
g_system->copyRectToScreen(_screen.getBasePtr(x, y), _screen.pitch, x, y, _consoleTextArea.width(), font->getFontHeight());
}
- _cursorX = font->getStringWidth(_lines[_inputTextLineNum]) + kConHPadding;
+ _cursorX = font->getStringWidth(_out[_inputTextLineNum]) + kConHPadding;
}
void Gui::loadFonts() {
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 1c9a982..12f4262 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -172,7 +172,6 @@ void WageEngine::processEvents() {
processTurn(&_inputText, NULL);
_inputText = "";
- _gui->drawInput();
break;
default:
Commit: c80bc8cbe0b02c8cd4ced475e395aadc5a06158f
https://github.com/scummvm/scummvm/commit/c80bc8cbe0b02c8cd4ced475e395aadc5a06158f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:05+01:00
Commit Message:
WAGE: Move all console-related stuff to gui-console.cpp
Changed paths:
A engines/wage/gui-console.cpp
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/module.mk
diff --git a/engines/wage/gui-console.cpp b/engines/wage/gui-console.cpp
new file mode 100644
index 0000000..0d9fb39
--- /dev/null
+++ b/engines/wage/gui-console.cpp
@@ -0,0 +1,350 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "common/timer.h"
+#include "common/unzip.h"
+#include "graphics/cursorman.h"
+#include "graphics/fonts/bdf.h"
+#include "graphics/palette.h"
+
+#include "wage/wage.h"
+#include "wage/design.h"
+#include "wage/entities.h"
+#include "wage/menu.h"
+#include "wage/gui.h"
+#include "wage/world.h"
+
+namespace Wage {
+
+const Graphics::Font *Gui::getConsoleFont() {
+ char fontName[128];
+ Scene *scene = _engine->_world->_player->_currentScene;
+
+ snprintf(fontName, 128, "%s-%d", scene->getFontName(), scene->_fontSize);
+
+ return getFont(fontName, Graphics::FontManager::kConsoleFont);
+}
+
+void Gui::clearOutput() {
+ _out.clear();
+ _lines.clear();
+ _consoleFullRedraw = true;
+}
+
+void Gui::appendText(const char *s) {
+ Common::String str(s);
+ _consoleDirty = true;
+
+ if (!str.contains('\n')) {
+ _out.push_back(str);
+ flowText(str);
+ return;
+ }
+
+ // Okay, we got new lines, need to split it
+ // and push substrings individually
+ Common::String tmp = "";
+
+ for (uint i = 0; i < str.size(); i++) {
+ if (str[i] == '\n') {
+ _out.push_back(tmp);
+ flowText(tmp);
+ tmp = "";
+ continue;
+ }
+
+ tmp += str[i];
+ }
+
+ _out.push_back(tmp);
+ flowText(tmp);
+}
+
+enum {
+ kConWOverlap = 20,
+ kConHOverlap = 20,
+ kConWPadding = 3,
+ kConHPadding = 4,
+ kConOverscan = 3
+};
+
+void Gui::flowText(Common::String &str) {
+ Common::StringArray wrappedLines;
+ int textW = _consoleTextArea.width() - kConWPadding * 2;
+ const Graphics::Font *font = getConsoleFont();
+
+ font->wordWrapText(str, textW, wrappedLines);
+
+ if (wrappedLines.size() == 0) // Sometimes we have empty lines
+ _lines.push_back("");
+
+ for (Common::StringArray::const_iterator j = wrappedLines.begin(); j != wrappedLines.end(); ++j)
+ _lines.push_back(*j);
+
+ uint pos = _scrollPos;
+ _scrollPos = MAX<int>(0, (_lines.size() - 1 - _consoleNumLines) * _consoleLineHeight);
+
+ _cursorX = kConWPadding;
+
+ if (_scrollPos)
+ _cursorY = (_consoleNumLines) * _consoleLineHeight + kConHPadding;
+ else
+ _cursorY = (_lines.size() - 1) * _consoleLineHeight + kConHPadding;
+
+ if (pos != _scrollPos)
+ _consoleFullRedraw = true;
+
+ if (!_engine->_temporarilyHidden)
+ draw();
+}
+
+void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) {
+ bool fullRedraw = _consoleFullRedraw;
+ bool textReflow = false;
+ int surfW = r.width() + kConWOverlap * 2;
+ int surfH = r.height() + kConHOverlap * 2;
+
+ Common::Rect boundsR(kConWOverlap - kConOverscan, kConHOverlap - kConOverscan,
+ r.width() + kConWOverlap + kConOverscan, r.height() + kConHOverlap + kConOverscan);
+ Common::Rect fullR(0, 0, surfW, surfH);
+
+ if (_console.w != surfW || _console.h != surfH) {
+ if (_console.w != surfW)
+ textReflow = true;
+
+ _console.free();
+
+ _console.create(surfW, surfH, Graphics::PixelFormat::createFormatCLUT8());
+ fullRedraw = true;
+ }
+
+ if (fullRedraw)
+ _console.fillRect(fullR, kColorWhite);
+
+ const Graphics::Font *font = getConsoleFont();
+
+ _consoleLineHeight = font->getFontHeight();
+ int textW = r.width() - kConWPadding * 2;
+ int textH = r.height() - kConHPadding * 2;
+
+ if (textReflow) {
+ _lines.clear();
+
+ for (uint i = 0; i < _out.size(); i++)
+ flowText(_out[i]);
+ }
+
+ const int firstLine = _scrollPos / _consoleLineHeight;
+ const int lastLine = MIN((_scrollPos + textH) / _consoleLineHeight + 1, _lines.size());
+ const int xOff = kConWOverlap;
+ const int yOff = kConHOverlap;
+ int x1 = xOff + kConWPadding;
+ int y1 = yOff - (_scrollPos % _consoleLineHeight) + kConHPadding;
+
+ if (fullRedraw)
+ _consoleNumLines = (r.height() - 2 * kConWPadding) / _consoleLineHeight - 2;
+
+ for (int line = firstLine; line < lastLine; line++) {
+ const char *str = _lines[line].c_str();
+ int color = kColorBlack;
+
+ if ((line > _selectionStartY && line < _selectionEndY) ||
+ (line > _selectionEndY && line < _selectionStartY)) {
+ color = kColorWhite;
+ Common::Rect trect(0, y1, _console.w, y1 + _consoleLineHeight);
+
+ Design::drawFilledRect(&_console, trect, kColorBlack, _patterns, kPatternSolid);
+ }
+
+ if (line == _selectionStartY || line == _selectionEndY) {
+ if (_selectionStartY != _selectionEndY) {
+ int color1 = kColorBlack;
+ int color2 = kColorWhite;
+ int midpoint = _selectionStartX;
+
+ if (_selectionStartY > _selectionEndY)
+ SWAP(color1, color2);
+
+ if (line == _selectionEndY) {
+ SWAP(color1, color2);
+ midpoint = _selectionEndX;
+ }
+
+ Common::String beg(_lines[line].c_str(), &_lines[line].c_str()[midpoint]);
+ Common::String end(&_lines[line].c_str()[midpoint]);
+
+ int rectW = font->getStringWidth(beg) + kConWPadding + kConWOverlap;
+ Common::Rect trect(0, y1, _console.w, y1 + _consoleLineHeight);
+ if (color1 == kColorWhite)
+ trect.right = rectW;
+ else
+ trect.left = rectW;
+
+ Design::drawFilledRect(&_console, trect, kColorBlack, _patterns, kPatternSolid);
+
+ font->drawString(&_console, beg, x1, y1, textW, color1);
+ font->drawString(&_console, end, x1 + rectW - kConWPadding - kConWOverlap, y1, textW, color2);
+ } else {
+ int startPos = _selectionStartX;
+ int endPos = _selectionEndX;
+
+ if (startPos > endPos)
+ SWAP(startPos, endPos);
+
+ Common::String beg(_lines[line].c_str(), &_lines[line].c_str()[startPos]);
+ Common::String mid(&_lines[line].c_str()[startPos], &_lines[line].c_str()[endPos]);
+ Common::String end(&_lines[line].c_str()[endPos]);
+
+ int rectW1 = font->getStringWidth(beg) + kConWPadding + kConWOverlap;
+ int rectW2 = rectW1 + font->getStringWidth(mid);
+ Common::Rect trect(rectW1, y1, rectW2, y1 + _consoleLineHeight);
+
+ Design::drawFilledRect(&_console, trect, kColorBlack, _patterns, kPatternSolid);
+
+ font->drawString(&_console, beg, x1, y1, textW, kColorBlack);
+ font->drawString(&_console, mid, x1 + rectW1 - kConWPadding - kConWOverlap, y1, textW, kColorWhite);
+ font->drawString(&_console, end, x1 + rectW2 - kConWPadding - kConWOverlap, y1, textW, kColorBlack);
+ }
+ } else {
+ if (*str)
+ font->drawString(&_console, _lines[line], x1, y1, textW, color);
+ }
+
+ y1 += _consoleLineHeight;
+ }
+
+ g->copyRectToSurface(_console, r.left - kConOverscan, r.top - kConOverscan, boundsR);
+ g_system->copyRectToScreen(g->getBasePtr(r.left, r.top), g->pitch, r.left, r.top, r.width(), r.height());
+}
+
+void Gui::drawInput() {
+ if (!_screen.getPixels())
+ return;
+
+ if (_sceneIsActive) {
+ _sceneIsActive = false;
+ _bordersDirty = true;
+ }
+
+ _out.pop_back();
+ _lines.pop_back();
+ appendText(_engine->_inputText.c_str());
+ _inputTextLineNum = _out.size() - 1;
+
+ const Graphics::Font *font = getConsoleFont();
+
+ if (_engine->_inputText.contains('\n')) {
+ _consoleDirty = true;
+ } else {
+ int x = kConWPadding + _consoleTextArea.left;
+ int y = _cursorY + _consoleTextArea.top;
+
+ Common::Rect r(x, y, x + _consoleTextArea.width() - kConWPadding, y + font->getFontHeight());
+ _screen.fillRect(r, kColorWhite);
+
+ undrawCursor();
+
+ font->drawString(&_screen, _out[_inputTextLineNum], x, y, _screen.w, kColorBlack);
+
+ g_system->copyRectToScreen(_screen.getBasePtr(x, y), _screen.pitch, x, y, _consoleTextArea.width(), font->getFontHeight());
+ }
+
+ _cursorX = font->getStringWidth(_out[_inputTextLineNum]) + kConHPadding;
+}
+
+void Gui::actionCopy() {
+ if (_selectionStartX == -1)
+ return;
+
+ int startX = _selectionStartX;
+ int startY = _selectionStartY;
+ int endX = _selectionEndX;
+ int endY = _selectionEndY;
+
+ if (startY > endY) {
+ SWAP(startX, endX);
+ SWAP(endX, endY);
+ }
+
+ _clipboard.clear();
+
+ for (int i = startY; i <= endY; i++) {
+ if (startY == endY) {
+ _clipboard = Common::String(&_lines[i].c_str()[startX], &_lines[i].c_str()[endX]);
+ break;
+ }
+
+ if (i == startY) {
+ _clipboard += &_lines[i].c_str()[startX];
+ _clipboard += '\n';
+ } else if (i == endY) {
+ _clipboard += Common::String(_lines[i].c_str(), &_lines[i].c_str()[endX]);
+ } else {
+ _clipboard += _lines[i];
+ _clipboard += '\n';
+ }
+ }
+
+ _menu->enableCommand(kMenuEdit, kMenuActionPaste, true);
+}
+
+void Gui::actionPaste() {
+ _undobuffer = _engine->_inputText;
+ _engine->_inputText += _clipboard;
+ drawInput();
+
+ _menu->enableCommand(kMenuEdit, kMenuActionUndo, true);
+}
+
+void Gui::actionUndo() {
+ _engine->_inputText = _undobuffer;
+ drawInput();
+
+ _menu->enableCommand(kMenuEdit, kMenuActionUndo, false);
+}
+
+} // End of namespace Wage
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 3ddc508..309617e 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -185,6 +185,13 @@ Gui::~Gui() {
delete _menu;
}
+void Gui::undrawCursor() {
+ _cursorOff = true;
+ _cursorState = false;
+ cursorTimerHandler(this);
+ _cursorOff = false;
+}
+
const Graphics::Font *Gui::getFont(const char *name, Graphics::FontManager::FontUsage fallback) {
const Graphics::Font *font;
@@ -201,54 +208,10 @@ const Graphics::Font *Gui::getFont(const char *name, Graphics::FontManager::Font
return font;
}
-const Graphics::Font *Gui::getConsoleFont() {
- char fontName[128];
- Scene *scene = _engine->_world->_player->_currentScene;
-
- snprintf(fontName, 128, "%s-%d", scene->getFontName(), scene->_fontSize);
-
- return getFont(fontName, Graphics::FontManager::kConsoleFont);
-}
-
const Graphics::Font *Gui::getTitleFont() {
return getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
}
-void Gui::clearOutput() {
- _out.clear();
- _lines.clear();
- _consoleFullRedraw = true;
-}
-
-void Gui::appendText(const char *s) {
- Common::String str(s);
- _consoleDirty = true;
-
- if (!str.contains('\n')) {
- _out.push_back(str);
- flowText(str);
- return;
- }
-
- // Okay, we got new lines, need to split it
- // and push substrings individually
- Common::String tmp = "";
-
- for (uint i = 0; i < str.size(); i++) {
- if (str[i] == '\n') {
- _out.push_back(tmp);
- flowText(tmp);
- tmp = "";
- continue;
- }
-
- tmp += str[i];
- }
-
- _out.push_back(tmp);
- flowText(tmp);
-}
-
void Gui::draw() {
if (_scene != _engine->_world->_player->_currentScene || _sceneDirty) {
_scene = _engine->_world->_player->_currentScene;
@@ -412,202 +375,6 @@ void Gui::paintBorder(Graphics::Surface *g, Common::Rect &r, WindowType windowTy
g_system->copyRectToScreen(g->getBasePtr(x, y), g->pitch, x, y, width, height);
}
-enum {
- kConWOverlap = 20,
- kConHOverlap = 20,
- kConWPadding = 3,
- kConHPadding = 4,
- kConOverscan = 3
-};
-
-void Gui::flowText(Common::String &str) {
- Common::StringArray wrappedLines;
- int textW = _consoleTextArea.width() - kConWPadding * 2;
- const Graphics::Font *font = getConsoleFont();
-
- font->wordWrapText(str, textW, wrappedLines);
-
- if (wrappedLines.size() == 0) // Sometimes we have empty lines
- _lines.push_back("");
-
- for (Common::StringArray::const_iterator j = wrappedLines.begin(); j != wrappedLines.end(); ++j)
- _lines.push_back(*j);
-
- uint pos = _scrollPos;
- _scrollPos = MAX<int>(0, (_lines.size() - 1 - _consoleNumLines) * _consoleLineHeight);
-
- _cursorX = kConWPadding;
-
- if (_scrollPos)
- _cursorY = (_consoleNumLines) * _consoleLineHeight + kConHPadding;
- else
- _cursorY = (_lines.size() - 1) * _consoleLineHeight + kConHPadding;
-
- if (pos != _scrollPos)
- _consoleFullRedraw = true;
-
- if (!_engine->_temporarilyHidden)
- draw();
-}
-
-void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) {
- bool fullRedraw = _consoleFullRedraw;
- bool textReflow = false;
- int surfW = r.width() + kConWOverlap * 2;
- int surfH = r.height() + kConHOverlap * 2;
-
- Common::Rect boundsR(kConWOverlap - kConOverscan, kConHOverlap - kConOverscan,
- r.width() + kConWOverlap + kConOverscan, r.height() + kConHOverlap + kConOverscan);
- Common::Rect fullR(0, 0, surfW, surfH);
-
- if (_console.w != surfW || _console.h != surfH) {
- if (_console.w != surfW)
- textReflow = true;
-
- _console.free();
-
- _console.create(surfW, surfH, Graphics::PixelFormat::createFormatCLUT8());
- fullRedraw = true;
- }
-
- if (fullRedraw)
- _console.fillRect(fullR, kColorWhite);
-
- const Graphics::Font *font = getConsoleFont();
-
- _consoleLineHeight = font->getFontHeight();
- int textW = r.width() - kConWPadding * 2;
- int textH = r.height() - kConHPadding * 2;
-
- if (textReflow) {
- _lines.clear();
-
- for (uint i = 0; i < _out.size(); i++)
- flowText(_out[i]);
- }
-
- const int firstLine = _scrollPos / _consoleLineHeight;
- const int lastLine = MIN((_scrollPos + textH) / _consoleLineHeight + 1, _lines.size());
- const int xOff = kConWOverlap;
- const int yOff = kConHOverlap;
- int x1 = xOff + kConWPadding;
- int y1 = yOff - (_scrollPos % _consoleLineHeight) + kConHPadding;
-
- if (fullRedraw)
- _consoleNumLines = (r.height() - 2 * kConWPadding) / _consoleLineHeight - 2;
-
- for (int line = firstLine; line < lastLine; line++) {
- const char *str = _lines[line].c_str();
- int color = kColorBlack;
-
- if ((line > _selectionStartY && line < _selectionEndY) ||
- (line > _selectionEndY && line < _selectionStartY)) {
- color = kColorWhite;
- Common::Rect trect(0, y1, _console.w, y1 + _consoleLineHeight);
-
- Design::drawFilledRect(&_console, trect, kColorBlack, _patterns, kPatternSolid);
- }
-
- if (line == _selectionStartY || line == _selectionEndY) {
- if (_selectionStartY != _selectionEndY) {
- int color1 = kColorBlack;
- int color2 = kColorWhite;
- int midpoint = _selectionStartX;
-
- if (_selectionStartY > _selectionEndY)
- SWAP(color1, color2);
-
- if (line == _selectionEndY) {
- SWAP(color1, color2);
- midpoint = _selectionEndX;
- }
-
- Common::String beg(_lines[line].c_str(), &_lines[line].c_str()[midpoint]);
- Common::String end(&_lines[line].c_str()[midpoint]);
-
- int rectW = font->getStringWidth(beg) + kConWPadding + kConWOverlap;
- Common::Rect trect(0, y1, _console.w, y1 + _consoleLineHeight);
- if (color1 == kColorWhite)
- trect.right = rectW;
- else
- trect.left = rectW;
-
- Design::drawFilledRect(&_console, trect, kColorBlack, _patterns, kPatternSolid);
-
- font->drawString(&_console, beg, x1, y1, textW, color1);
- font->drawString(&_console, end, x1 + rectW - kConWPadding - kConWOverlap, y1, textW, color2);
- } else {
- int startPos = _selectionStartX;
- int endPos = _selectionEndX;
-
- if (startPos > endPos)
- SWAP(startPos, endPos);
-
- Common::String beg(_lines[line].c_str(), &_lines[line].c_str()[startPos]);
- Common::String mid(&_lines[line].c_str()[startPos], &_lines[line].c_str()[endPos]);
- Common::String end(&_lines[line].c_str()[endPos]);
-
- int rectW1 = font->getStringWidth(beg) + kConWPadding + kConWOverlap;
- int rectW2 = rectW1 + font->getStringWidth(mid);
- Common::Rect trect(rectW1, y1, rectW2, y1 + _consoleLineHeight);
-
- Design::drawFilledRect(&_console, trect, kColorBlack, _patterns, kPatternSolid);
-
- font->drawString(&_console, beg, x1, y1, textW, kColorBlack);
- font->drawString(&_console, mid, x1 + rectW1 - kConWPadding - kConWOverlap, y1, textW, kColorWhite);
- font->drawString(&_console, end, x1 + rectW2 - kConWPadding - kConWOverlap, y1, textW, kColorBlack);
- }
- } else {
- if (*str)
- font->drawString(&_console, _lines[line], x1, y1, textW, color);
- }
-
- y1 += _consoleLineHeight;
- }
-
- g->copyRectToSurface(_console, r.left - kConOverscan, r.top - kConOverscan, boundsR);
- g_system->copyRectToScreen(g->getBasePtr(r.left, r.top), g->pitch, r.left, r.top, r.width(), r.height());
-}
-
-void Gui::drawInput() {
- if (!_screen.getPixels())
- return;
-
- if (_sceneIsActive) {
- _sceneIsActive = false;
- _bordersDirty = true;
- }
-
- _out.pop_back();
- _lines.pop_back();
- appendText(_engine->_inputText.c_str());
- _inputTextLineNum = _out.size() - 1;
-
- const Graphics::Font *font = getConsoleFont();
-
- if (_engine->_inputText.contains('\n')) {
- _consoleDirty = true;
- } else {
- int x = kConWPadding + _consoleTextArea.left;
- int y = _cursorY + _consoleTextArea.top;
-
- Common::Rect r(x, y, x + _consoleTextArea.width() - kConWPadding, y + font->getFontHeight());
- _screen.fillRect(r, kColorWhite);
-
- // undraw cursor
- _cursorOff = true;
- _cursorState = false;
- cursorTimerHandler(this);
- _cursorOff = false;
-
- font->drawString(&_screen, _out[_inputTextLineNum], x, y, _screen.w, kColorBlack);
-
- g_system->copyRectToScreen(_screen.getBasePtr(x, y), _screen.pitch, x, y, _consoleTextArea.width(), font->getFontHeight());
- }
-
- _cursorX = font->getStringWidth(_out[_inputTextLineNum]) + kConHPadding;
-}
-
void Gui::loadFonts() {
Common::Archive *dat;
@@ -803,55 +570,4 @@ void Gui::updateTextSelection(int x, int y) {
_consoleFullRedraw = true;
}
-void Gui::actionCopy() {
- if (_selectionStartX == -1)
- return;
-
- int startX = _selectionStartX;
- int startY = _selectionStartY;
- int endX = _selectionEndX;
- int endY = _selectionEndY;
-
- if (startY > endY) {
- SWAP(startX, endX);
- SWAP(endX, endY);
- }
-
- _clipboard.clear();
-
- for (int i = startY; i <= endY; i++) {
- if (startY == endY) {
- _clipboard = Common::String(&_lines[i].c_str()[startX], &_lines[i].c_str()[endX]);
- break;
- }
-
- if (i == startY) {
- _clipboard += &_lines[i].c_str()[startX];
- _clipboard += '\n';
- } else if (i == endY) {
- _clipboard += Common::String(_lines[i].c_str(), &_lines[i].c_str()[endX]);
- } else {
- _clipboard += _lines[i];
- _clipboard += '\n';
- }
- }
-
- _menu->enableCommand(kMenuEdit, kMenuActionPaste, true);
-}
-
-void Gui::actionPaste() {
- _undobuffer = _engine->_inputText;
- _engine->_inputText += _clipboard;
- drawInput();
-
- _menu->enableCommand(kMenuEdit, kMenuActionUndo, true);
-}
-
-void Gui::actionUndo() {
- _engine->_inputText = _undobuffer;
- drawInput();
-
- _menu->enableCommand(kMenuEdit, kMenuActionUndo, false);
-}
-
} // End of namespace Wage
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 2353a59..ae53f4b 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -109,6 +109,7 @@ public:
void actionUndo();
private:
+ void undrawCursor();
void paintBorder(Graphics::Surface *g, Common::Rect &r, WindowType windowType);
void renderConsole(Graphics::Surface *g, Common::Rect &r);
void drawBox(Graphics::Surface *g, int x, int y, int w, int h);
diff --git a/engines/wage/module.mk b/engines/wage/module.mk
index d2a4be4..f91e841 100644
--- a/engines/wage/module.mk
+++ b/engines/wage/module.mk
@@ -7,6 +7,7 @@ MODULE_OBJS := \
dialog.o \
entities.o \
gui.o \
+ gui-console.o \
menu.o \
randomhat.o \
script.o \
Commit: 1e2d292eb4c9e2dc8a5b209d7d2e726e15f43ce9
https://github.com/scummvm/scummvm/commit/1e2d292eb4c9e2dc8a5b209d7d2e726e15f43ce9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:05+01:00
Commit Message:
WAGE: Finally fix input text behavior
Changed paths:
engines/wage/wage.cpp
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 12f4262..5ea1e3b 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -172,6 +172,7 @@ void WageEngine::processEvents() {
processTurn(&_inputText, NULL);
_inputText = "";
+ _gui->appendText("");
break;
default:
@@ -208,14 +209,10 @@ void WageEngine::setMenu(Common::String menu) {
}
void WageEngine::appendText(const char *str) {
- if (_inputText.size()) {
- _inputText += '\n';
- _gui->drawInput();
+ _gui->appendText(str);
+ if (_inputText.size())
_inputText = "";
- }
-
- _gui->appendText(str);
}
void WageEngine::gameOver() {
Commit: fcebf28fd2501e8cd835fc57588ae3e51b2cb5ca
https://github.com/scummvm/scummvm/commit/fcebf28fd2501e8cd835fc57588ae3e51b2cb5ca
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:06+01:00
Commit Message:
WAGE: Fix behavior of the multiline paste
Changed paths:
engines/wage/gui-console.cpp
diff --git a/engines/wage/gui-console.cpp b/engines/wage/gui-console.cpp
index 0d9fb39..414d13f 100644
--- a/engines/wage/gui-console.cpp
+++ b/engines/wage/gui-console.cpp
@@ -336,6 +336,7 @@ void Gui::actionPaste() {
_undobuffer = _engine->_inputText;
_engine->_inputText += _clipboard;
drawInput();
+ _engine->_inputText = _out.back(); // Set last part of the multiline text
_menu->enableCommand(kMenuEdit, kMenuActionUndo, true);
}
Commit: 1158987a1e4f078ed1ae699409fd26558486722e
https://github.com/scummvm/scummvm/commit/1158987a1e4f078ed1ae699409fd26558486722e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:06+01:00
Commit Message:
WAGE: Disable Undo action after command exectution
Changed paths:
engines/wage/gui-console.cpp
engines/wage/gui.h
engines/wage/wage.cpp
diff --git a/engines/wage/gui-console.cpp b/engines/wage/gui-console.cpp
index 414d13f..9b02608 100644
--- a/engines/wage/gui-console.cpp
+++ b/engines/wage/gui-console.cpp
@@ -348,4 +348,8 @@ void Gui::actionUndo() {
_menu->enableCommand(kMenuEdit, kMenuActionUndo, false);
}
+void Gui::disableUndo() {
+ _menu->enableCommand(kMenuEdit, kMenuActionUndo, false);
+}
+
} // End of namespace Wage
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index ae53f4b..652e0ff 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -107,6 +107,7 @@ public:
void actionCopy();
void actionPaste();
void actionUndo();
+ void disableUndo();
private:
void undrawCursor();
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 5ea1e3b..9260223 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -173,6 +173,7 @@ void WageEngine::processEvents() {
processTurn(&_inputText, NULL);
_inputText = "";
_gui->appendText("");
+ _gui->disableUndo();
break;
default:
Commit: 1b27abafdc17ca4f5855b63cb53712fabd9693cb
https://github.com/scummvm/scummvm/commit/1b27abafdc17ca4f5855b63cb53712fabd9693cb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:06+01:00
Commit Message:
WAGE: Skip disabled command on shortcuts
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 414d535..aeb5792 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -547,7 +547,7 @@ void Menu::processMenuShortCut(byte flags, uint16 ascii) {
if (flags & (Common::KBD_CTRL | Common::KBD_META)) {
for (int i = 0; i < _items.size(); i++)
for (int j = 0; j < _items[i]->subitems.size(); j++)
- if (tolower(_items[i]->subitems[j]->shortcut) == ascii) {
+ if (_items[i]->subitems[j]->enabled && tolower(_items[i]->subitems[j]->shortcut) == ascii) {
executeCommand(_items[i]->subitems[j]);
break;
}
Commit: 5cea5a4d3aa712c21fbdfd9283c8ce9981086a67
https://github.com/scummvm/scummvm/commit/5cea5a4d3aa712c21fbdfd9283c8ce9981086a67
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:06+01:00
Commit Message:
WAGE: Implement Cut and Clear actions
Changed paths:
engines/wage/gui-console.cpp
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/menu.cpp
diff --git a/engines/wage/gui-console.cpp b/engines/wage/gui-console.cpp
index 9b02608..92e61f9 100644
--- a/engines/wage/gui-console.cpp
+++ b/engines/wage/gui-console.cpp
@@ -348,6 +348,49 @@ void Gui::actionUndo() {
_menu->enableCommand(kMenuEdit, kMenuActionUndo, false);
}
+void Gui::actionClear() {
+ int startPos = _selectionStartX;
+ int endPos = _selectionEndX;
+
+ if (startPos > endPos)
+ SWAP(startPos, endPos);
+
+ Common::String beg(_lines[_selectionStartY].c_str(), &_lines[_selectionStartY].c_str()[startPos]);
+ Common::String end(&_lines[_selectionStartY].c_str()[endPos]);
+
+ _undobuffer = _engine->_inputText;
+ _engine->_inputText = beg + end;
+ drawInput();
+
+ _menu->enableCommand(kMenuEdit, kMenuActionUndo, true);
+
+ _selectionStartY = -1;
+ _selectionEndY = -1;
+}
+
+void Gui::actionCut() {
+ int startPos = _selectionStartX;
+ int endPos = _selectionEndX;
+
+ if (startPos > endPos)
+ SWAP(startPos, endPos);
+
+ Common::String beg(_lines[_selectionStartY].c_str(), &_lines[_selectionStartY].c_str()[startPos]);
+ Common::String mid(&_lines[_selectionStartY].c_str()[startPos], &_lines[_selectionStartY].c_str()[endPos]);
+ Common::String end(&_lines[_selectionStartY].c_str()[endPos]);
+
+ _undobuffer = _engine->_inputText;
+ _engine->_inputText = beg + end;
+ _clipboard = mid;
+ drawInput();
+
+ _menu->enableCommand(kMenuEdit, kMenuActionUndo, true);
+ _menu->enableCommand(kMenuEdit, kMenuActionPaste, true);
+
+ _selectionStartY = -1;
+ _selectionEndY = -1;
+}
+
void Gui::disableUndo() {
_menu->enableCommand(kMenuEdit, kMenuActionUndo, false);
}
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 309617e..819f588 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -485,6 +485,14 @@ Designed *Gui::mouseUp(int x, int y) {
_menu->enableCommand(kMenuEdit, kMenuActionCopy, false);
} else {
_menu->enableCommand(kMenuEdit, kMenuActionCopy, true);
+
+ bool cutAllowed = false;
+
+ if (_selectionStartY == _selectionEndY && _selectionStartY == _lines.size() - 1)
+ cutAllowed = true;
+
+ _menu->enableCommand(kMenuEdit, kMenuActionCut, cutAllowed);
+ _menu->enableCommand(kMenuEdit, kMenuActionClear, cutAllowed);
}
}
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 652e0ff..f679faa 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -107,6 +107,8 @@ public:
void actionCopy();
void actionPaste();
void actionUndo();
+ void actionClear();
+ void actionCut();
void disableUndo();
private:
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index aeb5792..a65d4dd 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -519,7 +519,7 @@ void Menu::executeCommand(MenuSubItem *subitem) {
_gui->actionUndo();
break;
case kMenuActionCut:
- warning("STUB: Unhandled shortcut");
+ _gui->actionCut();
break;
case kMenuActionCopy:
_gui->actionCopy();
@@ -528,7 +528,7 @@ void Menu::executeCommand(MenuSubItem *subitem) {
_gui->actionPaste();
break;
case kMenuActionClear:
- warning("STUB: Unhandled shortcut");
+ _gui->actionClear();
break;
case kMenuActionCommand:
Commit: 96cb9a620ab9730eaef49f4f587371a21408df6b
https://github.com/scummvm/scummvm/commit/96cb9a620ab9730eaef49f4f587371a21408df6b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:06+01:00
Commit Message:
WAGE: More const
Changed paths:
engines/wage/script.cpp
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 79a5e4f..f875321 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -929,7 +929,7 @@ enum {
struct Mapping {
const char *cmd;
int type;
-} mapping[] = {
+} static const mapping[] = {
{ "IF{", STATEMENT }, // 0x80
{ "=", OPERATOR },
{ "<", OPERATOR },
Commit: 5e21a82c1eb9b9e46a3be63c0ab2d6768b943159
https://github.com/scummvm/scummvm/commit/5e21a82c1eb9b9e46a3be63c0ab2d6768b943159
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:21+01:00
Commit Message:
WAGE: Simplify code
Changed paths:
engines/wage/util.cpp
diff --git a/engines/wage/util.cpp b/engines/wage/util.cpp
index 2586c28..51fcd2d 100644
--- a/engines/wage/util.cpp
+++ b/engines/wage/util.cpp
@@ -57,10 +57,7 @@ Common::String readPascalString(Common::SeekableReadStream *in) {
int len;
int i;
- len = in->readSByte();
- if (len < 0)
- len += 256;
-
+ len = in->readByte();
buf = (char *)malloc(len + 1);
for (i = 0; i < len; i++) {
buf[i] = in->readByte();
Commit: d91b52052de0b7a5e33529b2bcced1b97488a773
https://github.com/scummvm/scummvm/commit/d91b52052de0b7a5e33529b2bcced1b97488a773
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:21+01:00
Commit Message:
WAGE: Rename to match our naming conventions
Changed paths:
engines/wage/menu.cpp
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index a65d4dd..e6d4655 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -202,14 +202,14 @@ void Menu::createCommandsMenu(MenuItem *menu) {
bool enabled = true;
int style = 0;
char shortcut = 0;
- const char *shortptr = strrchr(item.c_str(), '/');
- if (shortptr != NULL) {
- if (strlen(shortptr) == 2) {
- shortcut = shortptr[1];
+ const char *shortPtr = strrchr(item.c_str(), '/');
+ if (shortPtr != NULL) {
+ if (strlen(shortPtr) == 2) {
+ shortcut = shortPtr[1];
item.deleteLastChar();
item.deleteLastChar();
} else {
- error("Unexpected shortcut: '%s', item '%s' in menu '%s'", shortptr, item.c_str(), string.c_str());
+ error("Unexpected shortcut: '%s', item '%s' in menu '%s'", shortPtr, item.c_str(), string.c_str());
}
}
Commit: 9c8d0352ad5078606c1b854a599e964c1d4d1ad2
https://github.com/scummvm/scummvm/commit/9c8d0352ad5078606c1b854a599e964c1d4d1ad2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:21+01:00
Commit Message:
WAGE: Avoid potential race condition in cursor drawing code
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 819f588..5267e4e 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -131,7 +131,12 @@ static void cursorTimerHandler(void *refCon) {
if (!gui->_cursorOff)
gui->_cursorState = !gui->_cursorState;
- g_system->copyRectToScreen(gui->_screen.getBasePtr(x, y), gui->_screen.pitch, x, y, 1, kCursorHeight);
+ gui->_cursorRect.left = x;
+ gui->_cursorRect.right = x + 1;
+ gui->_cursorRect.top = y;
+ gui->_cursorRect.bottom = y + kCursorHeight;
+
+ gui->_cursorDirty = true;
}
Gui::Gui(WageEngine *engine) {
@@ -141,6 +146,7 @@ Gui::Gui(WageEngine *engine) {
_consoleDirty = true;
_bordersDirty = true;
_menuDirty = true;
+ _cursorDirty = false;
_consoleFullRedraw = true;
_screen.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8());
@@ -252,6 +258,13 @@ void Gui::draw() {
if (_menuDirty)
_menu->render();
+ if (_cursorDirty) {
+ g_system->copyRectToScreen(_screen.getBasePtr(_cursorRect.left, _cursorRect.top), _screen.pitch,
+ _cursorRect.left, _cursorRect.top, _cursorRect.width(), _cursorRect.height());
+
+ _cursorDirty = false;
+ }
+
_sceneDirty = false;
_consoleDirty = false;
_bordersDirty = false;
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index f679faa..8cdc827 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -138,6 +138,9 @@ public:
Patterns _patterns;
+ bool _cursorDirty;
+ Common::Rect _cursorRect;
+
private:
Graphics::Surface _console;
Menu *_menu;
Commit: c5a01f3f38aae04cf114db68c27aaadfbe558a88
https://github.com/scummvm/scummvm/commit/c5a01f3f38aae04cf114db68c27aaadfbe558a88
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:21+01:00
Commit Message:
WAGE: Marked some methods as static, const'ness
Changed paths:
engines/wage/combat.cpp
engines/wage/wage.h
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index 7a93636..9581c90 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -177,7 +177,7 @@ void WageEngine::performCombatAction(Chr *npc, Chr *player) {
delete magics;
}
-const char *targets[] = { "head", "chest", "side" };
+static const char *const targets[] = { "head", "chest", "side" };
void WageEngine::performAttack(Chr *attacker, Chr *victim, Obj *weapon) {
if (_world->_weaponMenuDisabled)
@@ -883,7 +883,7 @@ bool WageEngine::handleAttack(Obj *weapon) {
return true;
}
-const char *WageEngine::getPercentMessage(double percent) {
+const char *const WageEngine::getPercentMessage(double percent) {
if (percent < 0.40) {
return "very bad";
} else if (percent < 0.55) {
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 65bfa91..42749dc 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -176,7 +176,7 @@ public:
bool handleAttack(Obj *weapon);
void printPlayerCondition(Chr *player);
- const char *getPercentMessage(double percent);
+ const char *const getPercentMessage(double percent);
public:
Common::RandomSource *_rnd;
Commit: c0697f7f2b7bea2b6e4dafb6fa5ac03aa0681638
https://github.com/scummvm/scummvm/commit/c0697f7f2b7bea2b6e4dafb6fa5ac03aa0681638
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:21+01:00
Commit Message:
WAGE: const goodness
Changed paths:
engines/wage/combat.cpp
engines/wage/util.cpp
engines/wage/wage.h
engines/wage/world.cpp
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index 9581c90..c8eee68 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -571,7 +571,7 @@ Common::String *WageEngine::getGroundItemsList(Scene *scene) {
return NULL;
}
-void WageEngine::appendObjNames(Common::String &str, ObjArray &objs) {
+void WageEngine::appendObjNames(Common::String &str, const ObjArray &objs) {
for (uint i = 0; i < objs.size(); i++) {
Obj *obj = objs[i];
@@ -849,7 +849,7 @@ bool WageEngine::handleOfferCommand(const char *target) {
return false;
}
-bool WageEngine::tryAttack(Obj *weapon, Common::String &input) {
+bool WageEngine::tryAttack(const Obj *weapon, const Common::String &input) {
Common::String w(weapon->_name);
w.toLowercase();
Common::String i(input);
@@ -883,7 +883,7 @@ bool WageEngine::handleAttack(Obj *weapon) {
return true;
}
-const char *const WageEngine::getPercentMessage(double percent) {
+const char *WageEngine::getPercentMessage(double percent) {
if (percent < 0.40) {
return "very bad";
} else if (percent < 0.55) {
diff --git a/engines/wage/util.cpp b/engines/wage/util.cpp
index 51fcd2d..2a72960 100644
--- a/engines/wage/util.cpp
+++ b/engines/wage/util.cpp
@@ -84,7 +84,7 @@ Common::Rect *readRect(Common::SeekableReadStream *in) {
return new Common::Rect(x1, y1, x2, y2);
}
-const char *getIndefiniteArticle(Common::String &word) {
+const char *getIndefiniteArticle(const Common::String &word) {
switch (word[0]) {
case 'a': case 'A':
case 'e': case 'E':
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 42749dc..9e1795b 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -109,7 +109,7 @@ enum {
Common::String readPascalString(Common::SeekableReadStream *in);
Common::Rect *readRect(Common::SeekableReadStream *in);
-const char *getIndefiniteArticle(Common::String &word);
+const char *getIndefiniteArticle(const Common::String &word);
const char *prependGenderSpecificPronoun(int gender);
const char *getGenderSpecificPronoun(int gender, bool capitalize);
@@ -158,7 +158,7 @@ public:
bool handleMoveCommand(Directions dir, const char *dirName);
bool handleLookCommand();
Common::String *getGroundItemsList(Scene *scene);
- void appendObjNames(Common::String &str, ObjArray &objs);
+ void appendObjNames(Common::String &str, const ObjArray &objs);
bool handleInventoryCommand();
bool handleStatusCommand();
bool handleRestCommand();
@@ -172,11 +172,11 @@ public:
void wearObj(Obj *o, int pos);
- bool tryAttack(Obj *weapon, Common::String &input);
+ bool tryAttack(const Obj *weapon, const Common::String &input);
bool handleAttack(Obj *weapon);
void printPlayerCondition(Chr *player);
- const char *const getPercentMessage(double percent);
+ const char *getPercentMessage(double percent);
public:
Common::RandomSource *_rnd;
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index daa2de9..4a8e5fb 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -385,7 +385,7 @@ Common::String *World::loadStringFromDITL(Common::MacResManager *resMan, int res
return NULL;
}
-bool InvComparator(Obj *l, Obj *r) {
+static bool InvComparator(const Obj *l, const Obj *r) {
return l->_index < r->_index;
}
@@ -402,7 +402,7 @@ void World::move(Obj *obj, Chr *chr) {
_engine->onMove(obj, from, chr);
}
-bool ObjComparator(Obj *o1, Obj *o2) {
+static bool ObjComparator(const Obj *o1, const Obj *o2) {
bool o1Immobile = (o1->_type == Obj::IMMOBILE_OBJECT);
bool o2Immobile = (o2->_type == Obj::IMMOBILE_OBJECT);
if (o1Immobile == o2Immobile) {
Commit: 13da5d5376050186f79860aa32ab4faf291a4a64
https://github.com/scummvm/scummvm/commit/13da5d5376050186f79860aa32ab4faf291a4a64
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:22+01:00
Commit Message:
WAGE: Renames to follow our conventions
Changed paths:
engines/wage/world.cpp
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 4a8e5fb..19af33c 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -385,7 +385,7 @@ Common::String *World::loadStringFromDITL(Common::MacResManager *resMan, int res
return NULL;
}
-static bool InvComparator(const Obj *l, const Obj *r) {
+static bool invComparator(const Obj *l, const Obj *r) {
return l->_index < r->_index;
}
@@ -397,12 +397,12 @@ void World::move(Obj *obj, Chr *chr) {
obj->_currentOwner = chr;
chr->_inventory.push_back(obj);
- Common::sort(chr->_inventory.begin(), chr->_inventory.end(), InvComparator);
+ Common::sort(chr->_inventory.begin(), chr->_inventory.end(), invComparator);
_engine->onMove(obj, from, chr);
}
-static bool ObjComparator(const Obj *o1, const Obj *o2) {
+static bool objComparator(const Obj *o1, const Obj *o2) {
bool o1Immobile = (o1->_type == Obj::IMMOBILE_OBJECT);
bool o2Immobile = (o2->_type == Obj::IMMOBILE_OBJECT);
if (o1Immobile == o2Immobile) {
@@ -420,12 +420,12 @@ void World::move(Obj *obj, Scene *scene, bool skipSort) {
scene->_objs.push_back(obj);
if (!skipSort)
- Common::sort(scene->_objs.begin(), scene->_objs.end(), ObjComparator);
+ Common::sort(scene->_objs.begin(), scene->_objs.end(), objComparator);
_engine->onMove(obj, from, scene);
}
-bool ChrComparator(Chr *l, Chr *r) {
+static bool chrComparator(const Chr *l, const Chr *r) {
return l->_index < r->_index;
}
@@ -440,7 +440,7 @@ void World::move(Chr *chr, Scene *scene, bool skipSort) {
scene->_chrs.push_back(chr);
if (!skipSort)
- Common::sort(scene->_chrs.begin(), scene->_chrs.end(), ChrComparator);
+ Common::sort(scene->_chrs.begin(), scene->_chrs.end(), chrComparator);
if (scene == _storageScene) {
chr->resetState();
Commit: bbcd45500437aa2faee9240faa07bf2d9fe03666
https://github.com/scummvm/scummvm/commit/bbcd45500437aa2faee9240faa07bf2d9fe03666
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:22+01:00
Commit Message:
GRAPHICS: Use our own sort instead of bubble
Changed paths:
graphics/primitives.cpp
diff --git a/graphics/primitives.cpp b/graphics/primitives.cpp
index 0e97065..d2ed4b4 100644
--- a/graphics/primitives.cpp
+++ b/graphics/primitives.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "common/algorithm.h"
#include "common/util.h"
#include "graphics/primitives.h"
@@ -365,17 +366,8 @@ void drawPolygonScan(int *polyX, int *polyY, int npoints, Common::Rect &bbox, in
j = i;
}
- // Sort the nodes, via a simple “Bubble” sort.
- i = 0;
- while (i < nodes - 1) {
- if (nodeX[i] > nodeX[i + 1]) {
- SWAP(nodeX[i], nodeX[i + 1]);
- if (i)
- i--;
- } else {
- i++;
- }
- }
+ // Sort the nodes
+ Common::sort(nodeX, ARRAYEND(nodeX));
// Fill the pixels between node pairs.
for (i = 0; i < nodes; i += 2) {
Commit: 362557935b0dd6b7941ae667cefae79481218e07
https://github.com/scummvm/scummvm/commit/362557935b0dd6b7941ae667cefae79481218e07
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:22+01:00
Commit Message:
WAGE: Use String::clear() for emptying stings
Changed paths:
engines/wage/gui-console.cpp
engines/wage/menu.cpp
engines/wage/wage.cpp
engines/wage/world.cpp
diff --git a/engines/wage/gui-console.cpp b/engines/wage/gui-console.cpp
index 92e61f9..2f4bac2 100644
--- a/engines/wage/gui-console.cpp
+++ b/engines/wage/gui-console.cpp
@@ -87,13 +87,13 @@ void Gui::appendText(const char *s) {
// Okay, we got new lines, need to split it
// and push substrings individually
- Common::String tmp = "";
+ Common::String tmp;
for (uint i = 0; i < str.size(); i++) {
if (str[i] == '\n') {
_out.push_back(tmp);
flowText(tmp);
- tmp = "";
+ tmp.clear();
continue;
}
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index e6d4655..d6dbcfb 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -249,7 +249,7 @@ void Menu::createCommandsMenu(MenuItem *menu) {
menu->subitems.push_back(new MenuSubItem(item.c_str(), kMenuActionCommand, style, shortcut, enabled));
}
- item = "";
+ item.clear();
}
}
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 9260223..f36d7ce 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -171,7 +171,7 @@ void WageEngine::processEvents() {
break;
processTurn(&_inputText, NULL);
- _inputText = "";
+ _inputText.clear();
_gui->appendText("");
_gui->disableUndo();
break;
@@ -212,8 +212,7 @@ void WageEngine::setMenu(Common::String menu) {
void WageEngine::appendText(const char *str) {
_gui->appendText(str);
- if (_inputText.size())
- _inputText = "";
+ _inputText.clear();
}
void WageEngine::gameOver() {
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 19af33c..79dc456 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -265,7 +265,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
res = resMan->getResource(MKTAG('M','E','N','U'), 2001);
if (res != NULL) {
Common::StringArray *menu = readMenu(res);
- _aboutMenuItemName = "";
+ _aboutMenuItemName.clear();
Common::String string = menu->operator[](1);
for (int i = 0; i < string.size() && string[i] != ';'; i++) // Read token
Commit: e105ec8df306bb84a2919806695535eab64f10e9
https://github.com/scummvm/scummvm/commit/e105ec8df306bb84a2919806695535eab64f10e9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:22+01:00
Commit Message:
WAGE: Proper name for include guard
Changed paths:
engines/wage/wage.h
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 9e1795b..6905fdc 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -45,8 +45,8 @@
*
*/
-#ifndef WAGE_H
-#define WAGE_H
+#ifndef WAGE_WAGE_H
+#define WAGE_WAGE_H
#include "engines/engine.h"
#include "common/debug.h"
Commit: e56fa508895b1f9840f76e4a70545047db20e67a
https://github.com/scummvm/scummvm/commit/e56fa508895b1f9840f76e4a70545047db20e67a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:22+01:00
Commit Message:
WAGE: Better names for constants
Changed paths:
engines/wage/util.cpp
diff --git a/engines/wage/util.cpp b/engines/wage/util.cpp
index 2a72960..1b3dfc9 100644
--- a/engines/wage/util.cpp
+++ b/engines/wage/util.cpp
@@ -97,24 +97,24 @@ const char *getIndefiniteArticle(const Common::String &word) {
}
enum {
- GENDER_HE = 0,
- GENDER_SHE = 1,
- GENDER_IT = 2
+ GENDER_MALE = 0,
+ GENDER_FEMALE = 1,
+ GENDER_NEUTRAL = 2
};
const char *prependGenderSpecificPronoun(int gender) {
- if (gender == GENDER_HE)
+ if (gender == GENDER_MALE)
return "his ";
- else if (gender == GENDER_SHE)
+ else if (gender == GENDER_FEMALE)
return "her ";
else
return "its ";
}
const char *getGenderSpecificPronoun(int gender, bool capitalize) {
- if (gender == GENDER_HE)
+ if (gender == GENDER_MALE)
return capitalize ? "He" : "he";
- else if (gender == GENDER_SHE)
+ else if (gender == GENDER_FEMALE)
return capitalize ? "She" : "she";
else
return capitalize ? "It" : "it";
Commit: eacbe42e3a995038150527f3bab0c9a20316da33
https://github.com/scummvm/scummvm/commit/eacbe42e3a995038150527f3bab0c9a20316da33
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:23+01:00
Commit Message:
WAGE: Simplify operand stringification
Changed paths:
engines/wage/script.h
diff --git a/engines/wage/script.h b/engines/wage/script.h
index 39fbbc5..f4ee105 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -77,7 +77,6 @@ private:
Designed *inputClick;
} _value;
OperandType _type;
- Common::String _str;
Operand(Obj *value, OperandType type) {
_value.obj = value;
@@ -115,15 +114,9 @@ private:
}
Common::String toString() {
- char buf[128];
-
- if (_value.obj == NULL)
- _str = "";
-
switch(_type) {
case NUMBER:
- _str = snprintf(buf, 128, "%d", _value.number);
- return _str;
+ return Common::String::format("%d", _value.number);
case STRING:
case TEXT_INPUT:
return *_value.string;
Commit: e83a0ce32e584c1581166bb4c40c04d6ca591670
https://github.com/scummvm/scummvm/commit/e83a0ce32e584c1581166bb4c40c04d6ca591670
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:23+01:00
Commit Message:
WAGE: Moved non-trivial method implementation to .cpp file
Changed paths:
engines/wage/script.cpp
engines/wage/script.h
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index f875321..a08b324 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -54,6 +54,26 @@
namespace Wage {
+Common::String Script::Operand::toString() {
+ switch(_type) {
+ case NUMBER:
+ return Common::String::format("%d", _value.number);
+ case STRING:
+ case TEXT_INPUT:
+ return *_value.string;
+ case OBJ:
+ return _value.obj->toString();
+ case CHR:
+ return _value.chr->toString();
+ case SCENE:
+ return _value.scene->toString();
+ case CLICK_INPUT:
+ return _value.inputClick->toString();
+ default:
+ error("Unhandled operand type: _type");
+ }
+}
+
Script::Script(Common::SeekableReadStream *data) : _data(data) {
convertToText();
}
diff --git a/engines/wage/script.h b/engines/wage/script.h
index f4ee105..1a7d07d 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -113,25 +113,7 @@ private:
delete _value.string;
}
- Common::String toString() {
- switch(_type) {
- case NUMBER:
- return Common::String::format("%d", _value.number);
- case STRING:
- case TEXT_INPUT:
- return *_value.string;
- case OBJ:
- return _value.obj->toString();
- case CHR:
- return _value.chr->toString();
- case SCENE:
- return _value.scene->toString();
- case CLICK_INPUT:
- return _value.inputClick->toString();
- default:
- error("Unhandled operand type: _type");
- }
- }
+ Common::String toString();
};
struct ScriptText {
Commit: 13c979ae8f18f07d91fcd3c3290eee259a70261b
https://github.com/scummvm/scummvm/commit/13c979ae8f18f07d91fcd3c3290eee259a70261b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:23+01:00
Commit Message:
WAGE: Indentation fixes
Changed paths:
engines/wage/combat.cpp
engines/wage/entities.h
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index c8eee68..ce111ff 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -147,30 +147,30 @@ void WageEngine::performCombatAction(Chr *npc, Chr *player) {
int token = hat.drawToken();
switch (token) {
- case kTokWeapons:
- // TODO: I think the monster should choose the "best" weapon.
- performAttack(npc, player, weapons->operator[](_rnd->getRandomNumber(weapons->size() - 1)));
+ case kTokWeapons:
+ // TODO: I think the monster should choose the "best" weapon.
+ performAttack(npc, player, weapons->operator[](_rnd->getRandomNumber(weapons->size() - 1)));
+ break;
+ case kTokMagic:
+ // TODO: I think the monster should choose the "best" magic.
+ performMagic(npc, player, magics->operator[](_rnd->getRandomNumber(magics->size() - 1)));
+ break;
+ case kTokRun:
+ performMove(npc, validMoves);
+ break;
+ case kTokOffer:
+ performOffer(npc, player);
+ break;
+ case kTokNone:
+ break;
+ default:
+ {
+ int cnt = 0;
+ for (ObjList::const_iterator it = objs->begin(); it != objs->end(); ++it, ++cnt)
+ if (cnt == token)
+ performTake(npc, *it);
break;
- case kTokMagic:
- // TODO: I think the monster should choose the "best" magic.
- performMagic(npc, player, magics->operator[](_rnd->getRandomNumber(magics->size() - 1)));
- break;
- case kTokRun:
- performMove(npc, validMoves);
- break;
- case kTokOffer:
- performOffer(npc, player);
- break;
- case kTokNone:
- break;
- default:
- {
- int cnt = 0;
- for (ObjList::const_iterator it = objs->begin(); it != objs->end(); ++it, ++cnt)
- if (cnt == token)
- performTake(npc, *it);
- break;
- }
+ }
}
delete weapons;
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index a9066fe..f72df34 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -333,7 +333,7 @@ public:
class Sound {
public:
- Sound(Common::String name, Common::SeekableReadStream *data) : _name(name), _data(data) {}
+ Sound(Common::String name, Common::SeekableReadStream *data) : _name(name), _data(data) {}
~Sound() { }
Common::String _name;
Commit: b09e70d1ca528f8eecf31ed1957866d888ede190
https://github.com/scummvm/scummvm/commit/b09e70d1ca528f8eecf31ed1957866d888ede190
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:23+01:00
Commit Message:
WAGE: Consistently use .empty() instead of .size() == 0
Changed paths:
engines/wage/combat.cpp
engines/wage/design.cpp
engines/wage/entities.cpp
engines/wage/gui-console.cpp
engines/wage/menu.cpp
engines/wage/script.cpp
engines/wage/wage.cpp
engines/wage/world.cpp
engines/wage/world.h
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index ce111ff..b60c896 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -112,25 +112,25 @@ void WageEngine::performCombatAction(Chr *npc, Chr *player) {
// for the chance (e.g. only when all values were set to 0?).
if (winning) {
if (!_world->_weaponMenuDisabled) {
- if (weapons->size() > 0)
+ if (!weapons->empty())
hat.addTokens(kTokWeapons, npc->_winningWeapons + 1);
- if (magics->size() > 0)
+ if (!magics->empty())
hat.addTokens(kTokMagic, npc->_winningMagic);
}
if (validMoves != 0)
hat.addTokens(kTokRun, npc->_winningRun + 1);
- if (npc->_inventory.size())
+ if (!npc->_inventory.empty())
hat.addTokens(kTokOffer, npc->_winningOffer + 1);
} else {
if (!_world->_weaponMenuDisabled) {
- if (weapons->size() > 0)
+ if (!weapons->empty())
hat.addTokens(kTokWeapons, npc->_losingWeapons + 1);
- if (magics->size() > 0)
+ if (!magics->empty())
hat.addTokens(kTokMagic, npc->_losingMagic);
}
if (validMoves != 0)
hat.addTokens(kTokRun, npc->_losingRun + 1);
- if (npc->_inventory.size())
+ if (!npc->_inventory.empty())
hat.addTokens(kTokOffer, npc->_losingOffer + 1);
}
@@ -563,7 +563,7 @@ Common::String *WageEngine::getGroundItemsList(Scene *scene) {
if ((*it)->_type != Obj::IMMOBILE_OBJECT)
objs.push_back(*it);
- if (objs.size()) {
+ if (!objs.empty()) {
Common::String *res = new Common::String("On the ground you see ");
appendObjNames(*res, objs);
return res;
@@ -602,7 +602,7 @@ bool WageEngine::handleInventoryCommand() {
if (!player->isWearing(*it))
objs.push_back(*it);
- if (!objs.size()) {
+ if (objs.empty()) {
appendText("Your pack is empty.");
} else {
Common::String res("Your pack contains ");
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 63721f6..a85f655 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -497,7 +497,7 @@ FloodFill::FloodFill(Graphics::Surface *surface, byte color1, byte color2) {
}
FloodFill::~FloodFill() {
- while(_queue.size()) {
+ while(!_queue.empty()) {
Common::Point *p = _queue.front();
delete p;
@@ -523,7 +523,7 @@ void FloodFill::addSeed(int x, int y) {
}
void FloodFill::fill() {
- while (_queue.size()) {
+ while (!_queue.empty()) {
Common::Point *p = _queue.front();
_queue.pop_front();
addSeed(p->x , p->y - 1);
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 27ee745..f85a228 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -369,7 +369,7 @@ Chr::Chr(Common::String name, Common::SeekableReadStream *data) {
_weapon2 = NULL;
// Create native weapons
- if (_nativeWeapon1.size() && _operativeVerb1.size()) {
+ if (!_nativeWeapon1.empty() && !_operativeVerb1.empty()) {
_weapon1 = new Obj;
_weapon1->_name = _nativeWeapon1;
@@ -380,7 +380,7 @@ Chr::Chr(Common::String name, Common::SeekableReadStream *data) {
_weapon1->_sound = _weaponSound1;
}
- if (_nativeWeapon2.size() && _operativeVerb2.size()) {
+ if (!_nativeWeapon2.empty() && !_operativeVerb2.empty()) {
_weapon2 = new Obj;
_weapon2->_name = _nativeWeapon2;
diff --git a/engines/wage/gui-console.cpp b/engines/wage/gui-console.cpp
index 2f4bac2..f1095de 100644
--- a/engines/wage/gui-console.cpp
+++ b/engines/wage/gui-console.cpp
@@ -119,7 +119,7 @@ void Gui::flowText(Common::String &str) {
font->wordWrapText(str, textW, wrappedLines);
- if (wrappedLines.size() == 0) // Sometimes we have empty lines
+ if (wrappedLines.empty()) // Sometimes we have empty lines
_lines.push_back("");
for (Common::StringArray::const_iterator j = wrappedLines.begin(); j != wrappedLines.end(); ++j)
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index d6dbcfb..6e2260a 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -284,7 +284,7 @@ void Menu::createWeaponsMenu(MenuItem *menu) {
}
delete weapons;
- if (menu->subitems.size() == 0)
+ if (menu->subitems.empty())
menu->subitems.push_back(new MenuSubItem("You have no weapons", 0, 0, 0, false));
}
@@ -306,10 +306,10 @@ int Menu::calculateMenuWidth(MenuItem *menu) {
int maxWidth = 0;
for (int i = 0; i < menu->subitems.size(); i++) {
MenuSubItem *item = menu->subitems[i];
- if (item->text.size()) {
+ if (!item->text.empty()) {
Common::String text(item->text);
Common::String acceleratorText(getAcceleratorString(item, " "));
- if (acceleratorText.size()) {
+ if (!acceleratorText.empty()) {
text += acceleratorText;
}
@@ -358,7 +358,7 @@ void Menu::render() {
Design::drawFilledRect(&_gui->_screen, hbox, kColorBlack, _gui->_patterns, kPatternSolid);
color = kColorWhite;
- if (it->subitems.size())
+ if (!it->subitems.empty())
renderSubmenu(it);
}
@@ -387,14 +387,14 @@ void Menu::renderSubmenu(MenuItem *menu) {
int accelX = r->right - 25;
int color = kColorBlack;
- if (i == _activeSubItem && text.size() && menu->subitems[i]->enabled) {
+ if (i == _activeSubItem && !text.empty() && menu->subitems[i]->enabled) {
color = kColorWhite;
Common::Rect trect(r->left, y - (_gui->_builtInFonts ? 1 : 0), r->right, y + _font->getFontHeight());
Design::drawFilledRect(&_gui->_screen, trect, kColorBlack, _gui->_patterns, kPatternSolid);
}
- if (text.size()) {
+ if (!text.empty()) {
Graphics::Surface *s = &_gui->_screen;
int tx = x, ty = y;
@@ -409,7 +409,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
_font->drawString(s, text, tx, ty, r->width(), color);
- if (acceleratorText.size())
+ if (!acceleratorText.empty())
_font->drawString(s, acceleratorText, accelX, ty, r->width(), color);
if (!menu->subitems[i]->enabled) {
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index a08b324..523f1e1 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -419,7 +419,7 @@ Script::Operand *Script::readStringOperand() {
}
_data->seek(-1, SEEK_CUR);
- if (allDigits && str->size() > 0) {
+ if (allDigits && !str->empty()) {
int r = atol(str->c_str());
delete str;
@@ -1137,7 +1137,7 @@ void Script::convertToText() {
}
}
- if (scr->line.size())
+ if (!scr->line.empty())
_scriptText.push_back(scr);
else
delete scr;
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index f36d7ce..1c13a31 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -160,7 +160,7 @@ void WageEngine::processEvents() {
case Common::EVENT_KEYDOWN:
switch (event.kbd.keycode) {
case Common::KEYCODE_BACKSPACE:
- if (_inputText.size()) {
+ if (!_inputText.empty()) {
_inputText.deleteLastChar();
_gui->drawInput();
}
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 79dc456..6e79aaa 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -117,7 +117,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
if (resArray.size() > 1)
warning("Too many VERS resources");
- if (resArray.size()) {
+ if (!resArray.empty()) {
debug(3, "Loading version info");
res = resMan->getResource(MKTAG('V','E','R','S'), resArray[0]);
@@ -226,10 +226,10 @@ bool World::loadWorld(Common::MacResManager *resMan) {
addSound(new Sound(resMan->getResName(MKTAG('A','S','N','D'), *iter), res));
}
- if (_soundLibrary1.size() > 0) {
+ if (!_soundLibrary1.empty()) {
loadExternalSounds(_soundLibrary1);
}
- if (_soundLibrary2.size() > 0) {
+ if (!_soundLibrary2.empty()) {
loadExternalSounds(_soundLibrary2);
}
@@ -305,8 +305,8 @@ Common::StringArray *World::readMenu(Common::SeekableReadStream *res) {
Common::String menu;
byte itemData[4];
- while (menuItem.size() > 0) {
- if (menu.size() > 0) {
+ while (!menuItem.empty()) {
+ if (!menu.empty()) {
menu += ';';
}
if ((enableFlags & (1 << menuItemNumber)) == 0) {
@@ -492,7 +492,7 @@ const char *World::getAboutMenuItemName() {
*menu = '\0';
- if (_aboutMenuItemName.size() == 0) {
+ if (_aboutMenuItemName.empty()) {
sprintf(menu, "About %s...", _name.c_str());
} else { // Replace '@' with name
const char *str = _aboutMenuItemName.c_str();
diff --git a/engines/wage/world.h b/engines/wage/world.h
index cb72391..1416fc3 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -101,7 +101,7 @@ public:
Common::String _weaponsMenuName;
void addScene(Scene *room) {
- if (room->_name.size() != 0) {
+ if (!room->_name.empty()) {
Common::String s = room->_name;
s.toLowercase();
_scenes[s] = room;
Commit: 8e8145ef25243d271e4fef6668dc4cff8386ae23
https://github.com/scummvm/scummvm/commit/8e8145ef25243d271e4fef6668dc4cff8386ae23
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:23+01:00
Commit Message:
WAGE: Fix name in accordance with our naming conventions
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index a85f655..86418bc 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -51,13 +51,13 @@
namespace Wage {
-struct plotData {
+struct PlotData {
Graphics::Surface *surface;
Patterns *patterns;
uint fillType;
int thickness;
- plotData(Graphics::Surface *s, Patterns *p, int f, int t) :
+ PlotData(Graphics::Surface *s, Patterns *p, int f, int t) :
surface(s), patterns(p), fillType(f), thickness(t) {}
};
@@ -93,7 +93,7 @@ void Design::paint(Graphics::Surface *surface, Patterns &patterns, int x, int y)
}
#if 0
- plotData pd(_surface, &patterns, 8, 1);
+ PlotData pd(_surface, &patterns, 8, 1);
int x1 = 50, y1 = 50, x2 = 200, y2 = 200, borderThickness = 30;
Common::Rect inn(x1-5, y1-5, x2+5, y2+5);
drawRoundRect(inn, 6, kColorGray, false, drawPixelPlain, &pd);
@@ -175,7 +175,7 @@ bool Design::isPointOpaque(int x, int y) {
}
void drawPixel(int x, int y, int color, void *data) {
- plotData *p = (plotData *)data;
+ PlotData *p = (PlotData *)data;
if (p->fillType > p->patterns->size())
return;
@@ -209,7 +209,7 @@ void drawPixel(int x, int y, int color, void *data) {
}
void drawPixelPlain(int x, int y, int color, void *data) {
- plotData *p = (plotData *)data;
+ PlotData *p = (PlotData *)data;
if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h)
*((byte *)p->surface->getBasePtr(x, y)) = (byte)color;
@@ -228,7 +228,7 @@ void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in,
SWAP(y1, y2);
Common::Rect r(x1, y1, x2, y2);
- plotData pd(surface, &patterns, fillType, 1);
+ PlotData pd(surface, &patterns, fillType, 1);
if (fillType <= patterns.size())
Graphics::drawFilledRect(r, kColorBlack, drawPixel, &pd);
@@ -258,7 +258,7 @@ void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in,
SWAP(y1, y2);
Common::Rect r(x1, y1, x2, y2);
- plotData pd(surface, &patterns, fillType, 1);
+ PlotData pd(surface, &patterns, fillType, 1);
if (fillType <= patterns.size())
Graphics::drawRoundRect(r, arc/2, kColorBlack, true, drawPixel, &pd);
@@ -328,7 +328,7 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in,
ypoints[i] = ycoords[i];
}
- plotData pd(surface, &patterns, fillType, 1);
+ PlotData pd(surface, &patterns, fillType, 1);
if (fillType <= patterns.size()) {
Graphics::drawPolygonScan(xpoints, ypoints, npoints, bbox, kColorBlack, drawPixel, &pd);
@@ -351,7 +351,7 @@ void Design::drawOval(Graphics::Surface *surface, Common::ReadStream &in,
int16 x1 = in.readSint16BE();
int16 y2 = in.readSint16BE();
int16 x2 = in.readSint16BE();
- plotData pd(surface, &patterns, fillType, 1);
+ PlotData pd(surface, &patterns, fillType, 1);
if (fillType <= patterns.size())
Graphics::drawEllipse(x1, y1, x2-1, y2-1, kColorBlack, true, drawPixel, &pd);
@@ -452,7 +452,7 @@ void Design::drawRect(Graphics::Surface *surface, Common::Rect &rect, int thickn
}
void Design::drawRect(Graphics::Surface *surface, int x1, int y1, int x2, int y2, int thickness, int color, Patterns &patterns, byte fillType) {
- plotData pd(surface, &patterns, fillType, thickness);
+ PlotData pd(surface, &patterns, fillType, thickness);
Graphics::drawLine(x1, y1, x2, y1, kColorBlack, drawPixel, &pd);
Graphics::drawLine(x2, y1, x2, y2, kColorBlack, drawPixel, &pd);
@@ -462,26 +462,26 @@ void Design::drawRect(Graphics::Surface *surface, int x1, int y1, int x2, int y2
void Design::drawFilledRect(Graphics::Surface *surface, Common::Rect &rect, int color, Patterns &patterns, byte fillType) {
- plotData pd(surface, &patterns, fillType, 1);
+ PlotData pd(surface, &patterns, fillType, 1);
for (int y = rect.top; y <= rect.bottom; y++)
Graphics::drawHLine(rect.left, rect.right, y, color, drawPixel, &pd);
}
void Design::drawFilledRoundRect(Graphics::Surface *surface, Common::Rect &rect, int arc, int color, Patterns &patterns, byte fillType) {
- plotData pd(surface, &patterns, fillType, 1);
+ PlotData pd(surface, &patterns, fillType, 1);
Graphics::drawRoundRect(rect, arc, color, true, drawPixel, &pd);
}
void Design::drawHLine(Graphics::Surface *surface, int x1, int x2, int y, int thickness, int color, Patterns &patterns, byte fillType) {
- plotData pd(surface, &patterns, fillType, thickness);
+ PlotData pd(surface, &patterns, fillType, thickness);
Graphics::drawHLine(x1, x2, y, color, drawPixel, &pd);
}
void Design::drawVLine(Graphics::Surface *surface, int x, int y1, int y2, int thickness, int color, Patterns &patterns, byte fillType) {
- plotData pd(surface, &patterns, fillType, thickness);
+ PlotData pd(surface, &patterns, fillType, thickness);
Graphics::drawVLine(x, y1, y2, color, drawPixel, &pd);
}
Commit: 33b8a265c556d75d01a9ca24233ca250526270e4
https://github.com/scummvm/scummvm/commit/33b8a265c556d75d01a9ca24233ca250526270e4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:24+01:00
Commit Message:
WAGE: Remove redundant check
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 86418bc..e3cae0f 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -74,7 +74,7 @@ Design::Design(Common::SeekableReadStream *data) {
Design::~Design() {
free(_data);
- if (_surface && _surface->getPixels())
+ if (_surface)
_surface->free();
delete _surface;
}
Commit: 9d9fefb17a24c98681ae4bd660d98aa0e67209f9
https://github.com/scummvm/scummvm/commit/9d9fefb17a24c98681ae4bd660d98aa0e67209f9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:24+01:00
Commit Message:
WAGE: Simplify polygon reading code
Changed paths:
engines/wage/design.cpp
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index e3cae0f..9178482 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -297,7 +297,7 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in,
int y2 = y1;
int x2 = x1;
int b = in.readSByte();
- if ((b & 0xff) == 0x80) {
+ if (b == -128) {
y2 = in.readSint16BE();
numBytes -= 3;
} else {
@@ -305,7 +305,7 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in,
numBytes -= 1;
}
b = in.readSByte();
- if ((b & 0xff) == 0x80) {
+ if (b == -128) {
x2 = in.readSint16BE();
numBytes -= 3;
} else {
Commit: acdddf8ade68a4c899c20499ac4ffcc68e94e79d
https://github.com/scummvm/scummvm/commit/acdddf8ade68a4c899c20499ac4ffcc68e94e79d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:24+01:00
Commit Message:
WAGE: Simplify bitmap reading code
Changed paths:
engines/wage/design.cpp
engines/wage/design.h
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 9178482..44891f1 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -363,7 +363,7 @@ void Design::drawOval(Graphics::Surface *surface, Common::ReadStream &in,
Graphics::drawEllipse(x1, y1, x2-1, y2-1, kColorBlack, false, drawPixel, &pd);
}
-void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in) {
+void Design::drawBitmap(Graphics::Surface *surface, Common::SeekableReadStream &in) {
int numBytes = in.readSint16BE();
int y1 = in.readSint16BE();
int x1 = in.readSint16BE();
@@ -419,8 +419,7 @@ void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in) {
}
}
- while (numBytes--)
- in.readByte();
+ in.skip(numBytes);
FloodFill ff(&tmp, kColorWhite, kColorGreen);
for (int yy = 0; yy < h; yy++) {
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 94a620a..baa9973 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -92,7 +92,7 @@ private:
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
void drawOval(Graphics::Surface *surface, Common::ReadStream &in,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
- void drawBitmap(Graphics::Surface *surface, Common::ReadStream &in);
+ void drawBitmap(Graphics::Surface *surface, Common::SeekableReadStream &in);
};
class FloodFill {
Commit: d2303ac6dda77440a4ce41f83c1f11aa8e497e9f
https://github.com/scummvm/scummvm/commit/d2303ac6dda77440a4ce41f83c1f11aa8e497e9f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:24+01:00
Commit Message:
GRAPHICS: Fix regression in polygon drawing
Changed paths:
graphics/primitives.cpp
diff --git a/graphics/primitives.cpp b/graphics/primitives.cpp
index d2ed4b4..90009b3 100644
--- a/graphics/primitives.cpp
+++ b/graphics/primitives.cpp
@@ -367,7 +367,7 @@ void drawPolygonScan(int *polyX, int *polyY, int npoints, Common::Rect &bbox, in
}
// Sort the nodes
- Common::sort(nodeX, ARRAYEND(nodeX));
+ Common::sort(nodeX, &nodeX[nodes]);
// Fill the pixels between node pairs.
for (i = 0; i < nodes; i += 2) {
Commit: eef56e167e481e413bd4c616e7c915e834c74726
https://github.com/scummvm/scummvm/commit/eef56e167e481e413bd4c616e7c915e834c74726
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:24+01:00
Commit Message:
WAGE: Simplify savename generation code
Changed paths:
engines/wage/detection.cpp
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
index fd79eb6..e03c447 100644
--- a/engines/wage/detection.cpp
+++ b/engines/wage/detection.cpp
@@ -216,9 +216,7 @@ SaveStateList WageMetaEngine::listSaves(const char *target) const {
int WageMetaEngine::getMaximumSaveSlot() const { return 999; }
void WageMetaEngine::removeSaveState(const char *target, int slot) const {
- char fileName[MAXPATHLEN];
- sprintf(fileName, "%s.%03d", target, slot);
- g_system->getSavefileManager()->removeSavefile(fileName);
+ g_system->getSavefileManager()->removeSavefile(Common::String::format("%s.%03d", target, slot));
}
#if PLUGIN_ENABLED_DYNAMIC(WAGE)
Commit: 499519fec3820d5f5ad377953560c321ac3efcab
https://github.com/scummvm/scummvm/commit/499519fec3820d5f5ad377953560c321ac3efcab
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:13:25+01:00
Commit Message:
WAGE: Fix int/uint comparison
Changed paths:
engines/wage/combat.cpp
engines/wage/dialog.cpp
engines/wage/dialog.h
engines/wage/entities.h
engines/wage/gui.cpp
engines/wage/menu.cpp
engines/wage/world.cpp
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index b60c896..aa8ec53 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -366,7 +366,7 @@ void WageEngine::performHealingMagic(Chr *chr, Obj *magicalObject) {
appendText(buf);
}
- int chance = _rnd->getRandomNumber(255);
+ uint chance = _rnd->getRandomNumber(255);
if (chance < magicalObject->_accuracy) {
int type = magicalObject->_attackType;
@@ -486,7 +486,7 @@ void WageEngine::regen() {
}
void WageEngine::takeObj(Obj *obj) {
- if ((int)_world->_player->_inventory.size() >= _world->_player->_maximumCarriedObjects) {
+ if (_world->_player->_inventory.size() >= _world->_player->_maximumCarriedObjects) {
appendText("Your pack is full, you must drop something.");
} else {
char buf[256];
diff --git a/engines/wage/dialog.cpp b/engines/wage/dialog.cpp
index d98af30..263570b 100644
--- a/engines/wage/dialog.cpp
+++ b/engines/wage/dialog.cpp
@@ -59,7 +59,7 @@ enum {
kDialogHeight = 113
};
-Dialog::Dialog(Gui *gui, int width, const char *text, DialogButtonArray *buttons, int defaultButton) :
+Dialog::Dialog(Gui *gui, int width, const char *text, DialogButtonArray *buttons, uint defaultButton) :
_gui(gui), _text(text), _buttons(buttons), _defaultButton(defaultButton) {
assert(_gui->_engine);
assert(_gui->_engine->_world);
@@ -78,7 +78,7 @@ Dialog::Dialog(Gui *gui, int width, const char *text, DialogButtonArray *buttons
_mouseOverPressedButton = false;
// Adjust button positions
- for (int i = 0; i < _buttons->size(); i++)
+ for (uint i = 0; i < _buttons->size(); i++)
_buttons->operator[](i)->bounds.translate(_bbox.left, _bbox.top);
_needsRedraw = true;
@@ -98,7 +98,7 @@ void Dialog::paint() {
static int boxOutline[] = { 1, 0, 0, 1, 1 };
drawOutline(_bbox, boxOutline, ARRAYSIZE(boxOutline));
- for (int i = 0; i < _buttons->size(); i++) {
+ for (uint i = 0; i < _buttons->size(); i++) {
DialogButton *button = _buttons->operator[](i);
static int buttonOutline[] = { 0, 0, 0, 0, 1 };
@@ -110,7 +110,7 @@ void Dialog::paint() {
int color = kColorBlack;
- if (i == _pressedButton && _mouseOverPressedButton) {
+ if ((int)i == _pressedButton && _mouseOverPressedButton) {
Common::Rect bb(button->bounds.left + 5, button->bounds.top + 5,
button->bounds.right - 5, button->bounds.bottom - 5);
@@ -195,7 +195,7 @@ int Dialog::run() {
}
int Dialog::matchButton(int x, int y) {
- for (int i = 0; i < _buttons->size(); i++)
+ for (uint i = 0; i < _buttons->size(); i++)
if (_buttons->operator[](i)->bounds.contains(x, y))
return i;
diff --git a/engines/wage/dialog.h b/engines/wage/dialog.h
index 544b457..c5878ac 100644
--- a/engines/wage/dialog.h
+++ b/engines/wage/dialog.h
@@ -67,7 +67,7 @@ typedef Common::Array<DialogButton *> DialogButtonArray;
class Dialog {
public:
- Dialog(Gui *gui, int width, const char *text, DialogButtonArray *buttons, int defaultButton);
+ Dialog(Gui *gui, int width, const char *text, DialogButtonArray *buttons, uint defaultButton);
~Dialog();
int run();
@@ -81,7 +81,7 @@ private:
const Graphics::Font *_font;
DialogButtonArray *_buttons;
int _pressedButton;
- int _defaultButton;
+ uint _defaultButton;
bool _mouseOverPressedButton;
bool _needsRedraw;
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index f72df34..0f5016e 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -156,7 +156,7 @@ public:
int _gender;
bool _nameProperNoun;
bool _playerCharacter;
- int _maximumCarriedObjects;
+ uint _maximumCarriedObjects;
int _returnTo;
int _physicalStrength;
@@ -168,7 +168,7 @@ public:
int _resistanceToMagic;
int _spiritualAccuracy;
int _runningSpeed;
- int _rejectsOffers;
+ uint _rejectsOffers;
int _followsOpponent;
Common::String _initialSound;
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 5267e4e..f7196ab 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -501,7 +501,7 @@ Designed *Gui::mouseUp(int x, int y) {
bool cutAllowed = false;
- if (_selectionStartY == _selectionEndY && _selectionStartY == _lines.size() - 1)
+ if (_selectionStartY == _selectionEndY && _selectionStartY == (int)_lines.size() - 1)
cutAllowed = true;
_menu->enableCommand(kMenuEdit, kMenuActionCut, cutAllowed);
@@ -545,7 +545,7 @@ void Gui::mouseDown(int x, int y) {
int Gui::calcTextX(int x, int textLine) {
const Graphics::Font *font = getConsoleFont();
- if (textLine >= _lines.size())
+ if ((uint)textLine >= _lines.size())
return 0;
Common::String str = _lines[textLine];
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 6e2260a..b859867 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -141,7 +141,7 @@ Menu::Menu(Gui *gui) : _gui(gui) {
int y = 1;
int x = 18;
- for (int i = 0; i < _items.size(); i++) {
+ for (uint i = 0; i < _items.size(); i++) {
int w = _font->getStringWidth(_items[i]->name);
if (_items[i]->bbox.bottom == 0) {
@@ -170,15 +170,15 @@ Menu::Menu(Gui *gui) : _gui(gui) {
}
Menu::~Menu() {
- for (int i = 0; i < _items.size(); i++) {
- for (int j = 0; j < _items[i]->subitems.size(); j++)
+ for (uint i = 0; i < _items.size(); i++) {
+ for (uint j = 0; j < _items[i]->subitems.size(); j++)
delete _items[i]->subitems[j];
delete _items[i];
}
}
void Menu::regenCommandsMenu() {
- for (int j = 0; j < _commands->subitems.size(); j++)
+ for (uint j = 0; j < _commands->subitems.size(); j++)
delete _commands->subitems[j];
_commands->subitems.clear();
@@ -192,7 +192,7 @@ void Menu::createCommandsMenu(MenuItem *menu) {
Common::String item;
- for (int i = 0; i < string.size(); i++) {
+ for (uint i = 0; i < string.size(); i++) {
while(i < string.size() && string[i] != ';') // Read token
item += string[i++];
@@ -239,7 +239,7 @@ void Menu::createCommandsMenu(MenuItem *menu) {
if (tmpitem[0] == '(') {
enabled = false;
- for (int j = 0; j < item.size(); j++)
+ for (uint j = 0; j < item.size(); j++)
if (item[j] == '(') {
item.deleteChar(j);
break;
@@ -257,7 +257,7 @@ void Menu::regenWeaponsMenu() {
if (_gui->_engine->_world->_weaponMenuDisabled)
return;
- for (int j = 0; j < _weapons->subitems.size(); j++)
+ for (uint j = 0; j < _weapons->subitems.size(); j++)
delete _weapons->subitems[j];
_weapons->subitems.clear();
@@ -270,7 +270,7 @@ void Menu::createWeaponsMenu(MenuItem *menu) {
Chr *player = _gui->_engine->_world->_player;
ObjArray *weapons = player->getWeapons(true);
- for (int i = 0; i < weapons->size(); i++) {
+ for (uint i = 0; i < weapons->size(); i++) {
Obj *obj = (*weapons)[i];
if (obj->_type == Obj::REGULAR_WEAPON ||
obj->_type == Obj::THROW_WEAPON ||
@@ -304,7 +304,7 @@ const char *Menu::getAcceleratorString(MenuSubItem *item, const char *prefix) {
int Menu::calculateMenuWidth(MenuItem *menu) {
int maxWidth = 0;
- for (int i = 0; i < menu->subitems.size(); i++) {
+ for (uint i = 0; i < menu->subitems.size(); i++) {
MenuSubItem *item = menu->subitems[i];
if (!item->text.empty()) {
Common::String text(item->text);
@@ -345,11 +345,11 @@ void Menu::render() {
r.top = kMenuHeight - 1;
Design::drawFilledRect(&_gui->_screen, r, kColorBlack, _gui->_patterns, kPatternSolid);
- for (int i = 0; i < _items.size(); i++) {
+ for (uint i = 0; i < _items.size(); i++) {
int color = kColorBlack;
MenuItem *it = _items[i];
- if (_activeItem == i) {
+ if ((uint)_activeItem == i) {
Common::Rect hbox = it->bbox;
hbox.left -= 1;
@@ -381,13 +381,13 @@ void Menu::renderSubmenu(MenuItem *menu) {
int x = r->left + kMenuDropdownPadding;
int y = r->top + 1;
- for (int i = 0; i < menu->subitems.size(); i++) {
+ for (uint i = 0; i < menu->subitems.size(); i++) {
Common::String text(menu->subitems[i]->text);
Common::String acceleratorText(getAcceleratorString(menu->subitems[i], ""));
int accelX = r->right - 25;
int color = kColorBlack;
- if (i == _activeSubItem && !text.empty() && menu->subitems[i]->enabled) {
+ if (i == (uint)_activeSubItem && !text.empty() && menu->subitems[i]->enabled) {
color = kColorWhite;
Common::Rect trect(r->left, y - (_gui->_builtInFonts ? 1 : 0), r->right, y + _font->getFontHeight());
@@ -442,9 +442,9 @@ bool Menu::mouseClick(int x, int y) {
if (!_menuActivated)
_screenCopy.copyFrom(_gui->_screen);
- for (int i = 0; i < _items.size(); i++)
+ for (uint i = 0; i < _items.size(); i++)
if (_items[i]->bbox.contains(x, y)) {
- if (_activeItem == i)
+ if ((uint)_activeItem == i)
return false;
if (_activeItem != -1) { // Restore background
@@ -545,8 +545,8 @@ void Menu::processMenuShortCut(byte flags, uint16 ascii) {
ascii = tolower(ascii);
if (flags & (Common::KBD_CTRL | Common::KBD_META)) {
- for (int i = 0; i < _items.size(); i++)
- for (int j = 0; j < _items[i]->subitems.size(); j++)
+ for (uint i = 0; i < _items.size(); i++)
+ for (uint j = 0; j < _items[i]->subitems.size(); j++)
if (_items[i]->subitems[j]->enabled && tolower(_items[i]->subitems[j]->shortcut) == ascii) {
executeCommand(_items[i]->subitems[j]);
break;
@@ -555,7 +555,7 @@ void Menu::processMenuShortCut(byte flags, uint16 ascii) {
}
void Menu::enableCommand(int menunum, int action, bool state) {
- for (int i = 0; i < _items[menunum]->subitems.size(); i++)
+ for (uint i = 0; i < _items[menunum]->subitems.size(); i++)
if (_items[menunum]->subitems[i]->action == action)
_items[menunum]->subitems[i]->enabled = state;
}
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 6e79aaa..a387d95 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -268,7 +268,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
_aboutMenuItemName.clear();
Common::String string = menu->operator[](1);
- for (int i = 0; i < string.size() && string[i] != ';'; i++) // Read token
+ for (uint i = 0; i < string.size() && string[i] != ';'; i++) // Read token
_aboutMenuItemName += string[i];
delete res;
Commit: 11e03fbce271d4817225d834349e5f2e276353ef
https://github.com/scummvm/scummvm/commit/11e03fbce271d4817225d834349e5f2e276353ef
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-02-14T17:20:25+01:00
Commit Message:
Merge pull request #658 from sev-/wage
WAGE: New Engine
Changed paths:
A devtools/create_wage/create_wage.sh
A engines/wage/combat.cpp
A engines/wage/configure.engine
A engines/wage/design.cpp
A engines/wage/design.h
A engines/wage/detection.cpp
A engines/wage/dialog.cpp
A engines/wage/dialog.h
A engines/wage/entities.cpp
A engines/wage/entities.h
A engines/wage/gui-console.cpp
A engines/wage/gui.cpp
A engines/wage/gui.h
A engines/wage/menu.cpp
A engines/wage/menu.h
A engines/wage/module.mk
A engines/wage/randomhat.cpp
A engines/wage/randomhat.h
A engines/wage/script.cpp
A engines/wage/script.h
A engines/wage/util.cpp
A engines/wage/wage.cpp
A engines/wage/wage.h
A engines/wage/world.cpp
A engines/wage/world.h
graphics/primitives.cpp
graphics/primitives.h
More information about the Scummvm-git-logs
mailing list