@@ -40,13 +40,26 @@ CastSpell::CastSpell() : PartyView("CastSpell") {
40
40
}
41
41
42
42
bool CastSpell::msgFocus (const FocusMessage &msg) {
43
- (void )PartyView::msgFocus (msg);
43
+ if (!isInCombat ())
44
+ (void )PartyView::msgFocus (msg);
45
+
44
46
updateSelectedSpell ();
45
47
return true ;
46
48
}
47
49
50
+ bool CastSpell::msgUnfocus (const UnfocusMessage &msg) {
51
+ if (!isInCombat ())
52
+ (void )PartyView::msgUnfocus (msg);
53
+
54
+ return true ;
55
+ }
56
+
48
57
void CastSpell::draw () {
49
- PartyView::draw ();
58
+ if (!isInCombat ()) {
59
+ PartyView::draw ();
60
+ } else {
61
+ ScrollView::draw ();
62
+ }
50
63
_fontReduced = false ;
51
64
52
65
const Character &c = *g_globals->_currCharacter ;
@@ -56,11 +69,12 @@ void CastSpell::draw() {
56
69
57
70
setTextColor (37 );
58
71
72
+ int spellNum = c.spellNumber ();
59
73
Common::String spellName = STRING[" enhdialogs.cast_spell.none" ];
60
- if (c. _nonCombatSpell >= 0 && c. _nonCombatSpell < 47 ) {
61
- spellName = STRING[Common::String::format (" spells.cleric.%d" , c. _nonCombatSpell )];
62
- } else if (c. _nonCombatSpell >= 47 ) {
63
- spellName = STRING[Common::String::format (" spells.wizard.%d" , c. _nonCombatSpell - 47 )];
74
+ if (spellNum >= 0 && spellNum < 47 ) {
75
+ spellName = STRING[Common::String::format (" spells.cleric.%d" , spellNum )];
76
+ } else if (spellNum >= 47 ) {
77
+ spellName = STRING[Common::String::format (" spells.wizard.%d" , spellNum - 47 )];
64
78
}
65
79
writeString (0 , 60 , spellName, ALIGN_MIDDLE);
66
80
@@ -82,8 +96,7 @@ void CastSpell::draw() {
82
96
bool CastSpell::msgKeypress (const KeypressMessage &msg) {
83
97
if (msg.keycode == Common::KEYCODE_c) {
84
98
// Cast a spell
85
- const Character &c = *g_globals->_currCharacter ;
86
- if (c._nonCombatSpell != -1 ) {
99
+ if (_spellIndex != -1 ) {
87
100
if (!canCast ()) {
88
101
close ();
89
102
spellError ();
@@ -101,8 +114,10 @@ bool CastSpell::msgKeypress(const KeypressMessage &msg) {
101
114
// Select a new spell
102
115
addView (" Spellbook" );
103
116
return true ;
104
- } else {
117
+ } else if (! isInCombat ()) {
105
118
return PartyView::msgKeypress (msg);
119
+ } else {
120
+ return false ;
106
121
}
107
122
}
108
123
@@ -111,8 +126,10 @@ bool CastSpell::msgAction(const ActionMessage &msg) {
111
126
close ();
112
127
return true ;
113
128
114
- } else {
129
+ } else if (! isInCombat ()) {
115
130
return PartyView::msgAction (msg);
131
+ } else {
132
+ return false ;
116
133
}
117
134
}
118
135
@@ -132,13 +149,15 @@ bool CastSpell::msgGame(const GameMessage &msg) {
132
149
void CastSpell::updateSelectedSpell () {
133
150
const Character &c = *g_globals->_currCharacter ;
134
151
135
- if (c._nonCombatSpell == -1 ) {
152
+ int spellNum = c.spellNumber ();
153
+ if (spellNum == -1 ) {
136
154
_requiredSp = _requiredGems = 0 ;
155
+ _spellIndex = -1 ;
137
156
138
157
} else {
139
158
int lvl, num;
140
- getSpellLevelNum (c. _nonCombatSpell , lvl, num);
141
- assert (getSpellIndex (&c, lvl, num) == c. _nonCombatSpell );
159
+ getSpellLevelNum (spellNum , lvl, num);
160
+ assert (getSpellIndex (&c, lvl, num) == spellNum );
142
161
143
162
setSpell (&c, lvl, num);
144
163
}
@@ -150,6 +169,9 @@ void CastSpell::charSwitched(Character *priorChar) {
150
169
}
151
170
152
171
void CastSpell::castSpell (Character *target) {
172
+ if (_spellIndex == -1 )
173
+ return ;
174
+
153
175
if (!isMagicAllowed ()) {
154
176
g_events->send (InfoMessage (STRING[" spells.magic_doesnt_work" ]));
155
177
0 commit comments