Skip to content

Commit 494dcb1

Browse files
committed
start OSDManager cleanup
1 parent dc582a4 commit 494dcb1

File tree

1 file changed

+13
-32
lines changed

1 file changed

+13
-32
lines changed

src/BizHawk.Client.Common/DisplayManager/OSDManager.cs

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -172,29 +172,13 @@ public void DrawMessages(IBlitter g)
172172
}
173173

174174
public string InputStrMovie()
175-
=> MakeStringFor(_movieSession.MovieController);
176-
177-
public string InputStrImmediate()
178-
=> MakeStringFor(_inputManager.AutofireStickyXorAdapter);
179-
180-
public string InputPrevious()
181175
{
182-
if (_movieSession.Movie.IsPlayingOrRecording())
183-
{
184-
var state = _movieSession.Movie.GetInputState(_emulator.Frame - 1);
185-
if (state != null)
186-
{
187-
return MakeStringFor(state);
188-
}
189-
}
190-
191-
return "";
176+
var state = _movieSession.Movie?.GetInputState(_emulator.Frame - 1);
177+
return state is not null ? MakeStringFor(state) : "";
192178
}
193179

194-
public string InputStrOrAll()
195-
=> _movieSession.Movie.IsPlayingOrRecording() && _emulator.Frame > 0
196-
? MakeStringFor(_inputManager.AutofireStickyXorAdapter.Or(_movieSession.Movie.GetInputState(_emulator.Frame - 1)))
197-
: InputStrImmediate();
180+
public string InputStrImmediate()
181+
=> MakeStringFor(_inputManager.AutofireStickyXorAdapter);
198182

199183
private static string MakeStringFor(IController controller)
200184
{
@@ -244,34 +228,31 @@ public void DrawScreenInfo(IBlitter g)
244228

245229
if (_config.DisplayInput)
246230
{
247-
var moviePlaying = _movieSession.Movie.IsPlaying();
248-
// After the last frame of the movie, we want both the last movie input and the current inputs.
249-
var atMovieEnd = _movieSession.Movie.IsFinished() && _movieSession.Movie.IsAtEnd();
250-
if (moviePlaying || atMovieEnd)
231+
if (_movieSession.Movie.IsPlaying())
251232
{
252233
var input = InputStrMovie();
253234
var point = GetCoordinates(g, _config.InputDisplay, input);
254235
var c = Color.FromArgb(_config.MovieInput);
255236
g.DrawString(input, c, point.X, point.Y);
256237
}
257-
258-
if (!moviePlaying) // TODO: message config -- allow setting of "mixed", and "auto"
238+
else // TODO: message config -- allow setting of "mixed", and "auto"
259239
{
260240
var previousColor = Color.FromArgb(_config.LastInputColor);
261241
var immediateColor = Color.FromArgb(_config.MessagesColor);
262242
var autoColor = Color.Pink;
263243
var changedColor = Color.PeachPuff;
264244

265-
//we need some kind of string for calculating position when right-anchoring, of something like that
266-
var bgStr = InputStrOrAll();
267-
var point = GetCoordinates(g, _config.InputDisplay, bgStr);
268-
269245
// now, we're going to render these repeatedly, with higher-priority things overriding
270246

271247
// first display previous frame's input.
272248
// note: that's only available in case we're working on a movie
273-
var previousStr = InputPrevious();
274-
g.DrawString(previousStr, previousColor, point.X, point.Y);
249+
var previousStr = InputStrMovie();
250+
251+
//we need some kind of string for calculating position when right-anchoring, of something like that
252+
var point = GetCoordinates(g, _config.InputDisplay, previousStr);
253+
254+
bool atMovieEnd = _movieSession.Movie.IsFinished() && _movieSession.Movie.IsAtEnd();
255+
g.DrawString(previousStr, atMovieEnd ? Color.FromArgb(_config.MovieInput) : previousColor, point.X, point.Y);
275256

276257
// next, draw the immediate input.
277258
// that is, whatever is being held down interactively right this moment even if the game is paused

0 commit comments

Comments
 (0)