Oolite
Loading...
Searching...
No Matches
StickProfileScreen(StickProfileInternal) Category Reference

Instance Methods

(void) - showScreen
(void) - nextAxis
(NSString *) - currentAxis
(void) - previousAxis
(void) - increaseDeadzone
(void) - decreaseDeadzone
(void) - nextProfileType
(void) - previousProfileType
(void) - IncreasePower
(BOOL) - currentProfileIsSpline
(void) - DecreasePower
(void) - IncreaseParam
(void) - DecreaseParam
(void) - saveSettings
(void) - graphProfile:at:size:
(void) - startEdit
(NSString *) - profileType

Detailed Description

Definition at line 45 of file PlayerEntityStickProfile.m.

Method Documentation

◆ currentAxis

- (NSString *) currentAxis

Extends class StickProfileScreen.

Definition at line 300 of file PlayerEntityStickProfile.m.

301{
302 switch (current_axis) {
303 case AXIS_ROLL:
304 return DESC(@"stickmapper-roll");
305
306 case AXIS_PITCH:
307 return DESC(@"stickmapper-pitch");
308
309 case AXIS_YAW:
310 return DESC(@"stickmapper-yaw");
311 }
312 return @"";
313}
@ AXIS_PITCH
@ AXIS_YAW
@ AXIS_ROLL
#define DESC(key)
Definition Universe.h:832

References AXIS_PITCH, AXIS_ROLL, AXIS_YAW, currentAxis, and DESC.

Referenced by currentAxis.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ currentProfileIsSpline

- (BOOL) currentProfileIsSpline

Extends class StickProfileScreen.

Definition at line 375 of file PlayerEntityStickProfile.m.

376{
377 if ([[stickHandler getProfileForAxis:current_axis] isKindOfClass:[OOJoystickSplineAxisProfile class]]) {
378 return YES;
379 }
380 return NO;
381}

References currentProfileIsSpline.

Referenced by currentProfileIsSpline.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decreaseDeadzone

- (void) decreaseDeadzone

Extends class StickProfileScreen.

Definition at line 325 of file PlayerEntityStickProfile.m.

326{
327 OOJoystickAxisProfile* profile = [stickHandler getProfileForAxis:current_axis];
328 if (profile) {
329 [profile setDeadzone:[profile deadzone] - STICK_MAX_DEADZONE / 20];
330 }
331 [self showScreen];
332 return;
333}
void setDeadzone:(double newValue)

References OOJoystickAxisProfile::deadzone, decreaseDeadzone, OOJoystickAxisProfile::setDeadzone:, and StickProfileScreen::showScreen.

Referenced by decreaseDeadzone.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DecreaseParam

- (void) DecreaseParam

Extends class StickProfileScreen.

Definition at line 425 of file PlayerEntityStickProfile.m.

426{
427 OOJoystickAxisProfile* profile = [stickHandler getProfileForAxis:current_axis];
428 OOJoystickStandardAxisProfile* standard_profile;
429
430 if (profile && [profile isKindOfClass:[OOJoystickStandardAxisProfile class]]) {
431 standard_profile = (OOJoystickStandardAxisProfile*)profile;
432 [standard_profile setParameter:[standard_profile parameter] - 0.05];
433 [stickHandler saveStickSettings];
434 }
435 [self showScreen];
436 return;
437}
void setParameter:(double newValue)

References DecreaseParam, OOJoystickStandardAxisProfile::parameter, OOJoystickStandardAxisProfile::setParameter:, and StickProfileScreen::showScreen.

Referenced by DecreaseParam.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DecreasePower

- (void) DecreasePower

Extends class StickProfileScreen.

Definition at line 397 of file PlayerEntityStickProfile.m.

398{
399 OOJoystickAxisProfile* profile = [stickHandler getProfileForAxis:current_axis];
400 OOJoystickStandardAxisProfile* standard_profile;
401
402 if (profile && [profile isKindOfClass:[OOJoystickStandardAxisProfile class]]) {
403 standard_profile = (OOJoystickStandardAxisProfile*)profile;
404 [standard_profile setPower:[standard_profile power] - STICKPROFILE_MAX_POWER / 20];
405 [stickHandler saveStickSettings];
406 }
407 [self showScreen];
408 return;
409}

References DecreasePower, OOJoystickStandardAxisProfile::power, OOJoystickStandardAxisProfile::setPower:, and StickProfileScreen::showScreen.

Referenced by DecreasePower.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ graphProfile:at:size:

- (void) graphProfile: (GLfloat) alpha
at: (Vector) at
size: (NSSize) size 

Extends class StickProfileScreen.

Definition at line 439 of file PlayerEntityStickProfile.m.

439 :(GLfloat)alpha at:(Vector)at size:(NSSize)size
440{
441 OOJoystickAxisProfile* profile = [stickHandler getProfileForAxis:current_axis];
442 OOJoystickSplineAxisProfile* spline_profile;
443 NSInteger i;
444 NSPoint point;
445 NSArray* control_points;
446
447 if (!profile)
448 return;
449 graphRect = NSMakeRect(at.x, at.y, size.width, size.height);
451 OOGL(glColor4f(0.2, 0.2, 0.5, alpha));
452 OOGLBEGIN(GL_QUADS);
453 glVertex3f(at.x, at.y, at.z);
454 glVertex3f(at.x + size.width, at.y, at.z);
455 glVertex3f(at.x + size.width, at.y + size.height, at.z);
456 glVertex3f(at.x, at.y + size.height, at.z);
457 OOGLEND();
458 OOGL(glColor4f(0.9, 0.9, 0.9, alpha));
459 OOGL(GLScaledLineWidth(2.0f));
460 OOGLBEGIN(GL_LINE_STRIP);
461 for (i = 0; i <= size.width - 20; i++) {
462 glVertex3f(at.x + i + 10, at.y + 10 + (size.height - 20) * [profile rawValue:((float)i) / (size.width - 20)], at.z);
463 }
464 OOGLEND();
465 OOGL(glColor4f(0.5, 0.0, 0.5, alpha));
466 GLDrawFilledOval(at.x + 10, at.y + 10, at.z, NSMakeSize(4, 4), 20);
467 GLDrawFilledOval(at.x + size.width - 10, at.y + size.height - 10, at.z, NSMakeSize(4, 4), 20);
468 if ([profile isKindOfClass:[OOJoystickSplineAxisProfile class]]) {
469 spline_profile = (OOJoystickSplineAxisProfile*)profile;
470 control_points = [spline_profile controlPoints];
471 for (i = 0; i < (NSInteger)[control_points count]; i++) {
472 if (i == selected_control_point) {
473 OOGL(glColor4f(1.0, 0.0, 0.0, alpha));
474 } else {
475 OOGL(glColor4f(0.0, 1.0, 0.0, alpha));
476 }
477 point = [[control_points objectAtIndex:i] pointValue];
478 GLDrawFilledOval(at.x + 10 + point.x * (size.width - 20), at.y + 10 + point.y * (size.height - 20), at.z, NSMakeSize(4, 4), 20);
479 }
480 }
481 OOGL(glColor4f(0.9, 0.9, 0.0, alpha));
482 OODrawStringAligned(DESC(@"oolite-stickprofile-movement"), at.x + size.width - 5, at.y, at.z, NSMakeSize(8, 10), YES);
483 OODrawString(DESC(@"oolite-stickprofile-response"), at.x, at.y + size.height - 10, at.z, NSMakeSize(8, 10));
484 return;
485}
void OODrawStringAligned(NSString *text, GLfloat x, GLfloat y, GLfloat z, NSSize siz, BOOL rightAlign)
void OODrawString(NSString *text, GLfloat x, GLfloat y, GLfloat z, NSSize siz)
#define OO_ENTER_OPENGL()
#define OOGLBEGIN
Definition OOOpenGL.h:269
void GLDrawFilledOval(GLfloat x, GLfloat y, GLfloat z, NSSize siz, GLfloat step)
Definition OOOpenGL.m:158
void GLScaledLineWidth(GLfloat width)
Definition OOOpenGL.m:206
#define OOGL(statement)
Definition OOOpenGL.h:262
#define OOGLEND
Definition OOOpenGL.h:270
struct Vector Vector
voidpf void uLong size
Definition ioapi.h:126
OOScalar x
Definition OOVector.h:32
OOScalar y
Definition OOVector.h:33
OOScalar z
Definition OOVector.h:34

References OOJoystickSplineAxisProfile::controlPoints, DESC, GLDrawFilledOval(), GLScaledLineWidth(), OO_ENTER_OPENGL, OODrawString(), OODrawStringAligned(), OOGL, OOGLBEGIN, OOGLEND, Vector::x, Vector::y, and Vector::z.

Here is the call graph for this function:

◆ increaseDeadzone

- (void) increaseDeadzone

Extends class StickProfileScreen.

Definition at line 315 of file PlayerEntityStickProfile.m.

316{
317 OOJoystickAxisProfile* profile = [stickHandler getProfileForAxis:current_axis];
318 if (profile) {
319 [profile setDeadzone:[profile deadzone] + STICK_MAX_DEADZONE / 20];
320 }
321 [self showScreen];
322 return;
323}

References OOJoystickAxisProfile::deadzone, increaseDeadzone, OOJoystickAxisProfile::setDeadzone:, and StickProfileScreen::showScreen.

Referenced by increaseDeadzone.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IncreaseParam

- (void) IncreaseParam

Extends class StickProfileScreen.

Definition at line 411 of file PlayerEntityStickProfile.m.

412{
413 OOJoystickAxisProfile* profile = [stickHandler getProfileForAxis:current_axis];
414 OOJoystickStandardAxisProfile* standard_profile;
415
416 if (profile && [profile isKindOfClass:[OOJoystickStandardAxisProfile class]]) {
417 standard_profile = (OOJoystickStandardAxisProfile*)profile;
418 [standard_profile setParameter:[standard_profile parameter] + 0.05];
419 [stickHandler saveStickSettings];
420 }
421 [self showScreen];
422 return;
423}

References IncreaseParam, OOJoystickStandardAxisProfile::parameter, OOJoystickStandardAxisProfile::setParameter:, and StickProfileScreen::showScreen.

Referenced by IncreaseParam.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IncreasePower

- (void) IncreasePower

Extends class StickProfileScreen.

Definition at line 383 of file PlayerEntityStickProfile.m.

384{
385 OOJoystickAxisProfile* profile = [stickHandler getProfileForAxis:current_axis];
386 OOJoystickStandardAxisProfile* standard_profile;
387
388 if (profile && [profile isKindOfClass:[OOJoystickStandardAxisProfile class]]) {
389 standard_profile = (OOJoystickStandardAxisProfile*)profile;
390 [standard_profile setPower:[standard_profile power] + STICKPROFILE_MAX_POWER / 20];
391 [stickHandler saveStickSettings];
392 }
393 [self showScreen];
394 return;
395}

References IncreasePower, OOJoystickStandardAxisProfile::power, OOJoystickStandardAxisProfile::setPower:, and StickProfileScreen::showScreen.

Referenced by IncreasePower.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nextAxis

- (void) nextAxis

Extends class StickProfileScreen.

Definition at line 280 of file PlayerEntityStickProfile.m.

281{
282 if (current_axis == AXIS_ROLL)
283 current_axis = AXIS_PITCH;
284 else if (current_axis == AXIS_PITCH)
285 current_axis = AXIS_YAW;
286 [self showScreen];
287 return;
288}

References AXIS_PITCH, AXIS_ROLL, AXIS_YAW, nextAxis, and StickProfileScreen::showScreen.

Referenced by nextAxis.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nextProfileType

- (void) nextProfileType

Extends class StickProfileScreen.

Definition at line 335 of file PlayerEntityStickProfile.m.

336{
337 OOJoystickAxisProfile* profile = [stickHandler getProfileForAxis:current_axis];
338 double deadzone;
339
340 if ([profile isKindOfClass:[OOJoystickStandardAxisProfile class]]) {
341 deadzone = [profile deadzone];
342 [profiles[current_axis][0] release];
343 profiles[current_axis][0] = [profile retain];
344 if (!profiles[current_axis][1]) {
345 profiles[current_axis][1] = [[OOJoystickSplineAxisProfile alloc] init];
346 }
347 [profiles[current_axis][1] setDeadzone:deadzone];
348 [stickHandler setProfile:profiles[current_axis][1] forAxis:current_axis];
349 [stickHandler saveStickSettings];
350 }
351 [self showScreen];
352 return;
353}

References OOJoystickAxisProfile::deadzone, nextProfileType, and StickProfileScreen::showScreen.

Referenced by nextProfileType.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ previousAxis

- (void) previousAxis

Extends class StickProfileScreen.

Definition at line 290 of file PlayerEntityStickProfile.m.

291{
292 if (current_axis == AXIS_PITCH)
293 current_axis = AXIS_ROLL;
294 else if (current_axis == AXIS_YAW)
295 current_axis = AXIS_PITCH;
296 [self showScreen];
297 return;
298}

References AXIS_PITCH, AXIS_ROLL, AXIS_YAW, previousAxis, and StickProfileScreen::showScreen.

Referenced by previousAxis.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ previousProfileType

- (void) previousProfileType

Extends class StickProfileScreen.

Definition at line 355 of file PlayerEntityStickProfile.m.

356{
357 OOJoystickAxisProfile* profile = [stickHandler getProfileForAxis:current_axis];
358 double deadzone;
359
360 if ([profile isKindOfClass:[OOJoystickSplineAxisProfile class]]) {
361 deadzone = [profile deadzone];
362 [profiles[current_axis][1] release];
363 profiles[current_axis][1] = [profile retain];
364 if (!profiles[current_axis][0]) {
365 profiles[current_axis][0] = [[OOJoystickStandardAxisProfile alloc] init];
366 }
367 [profiles[current_axis][0] setDeadzone:deadzone];
368 [stickHandler setProfile:profiles[current_axis][0] forAxis:current_axis];
369 [stickHandler saveStickSettings];
370 }
371 [self showScreen];
372 return;
373}

References OOJoystickAxisProfile::deadzone, previousProfileType, and StickProfileScreen::showScreen.

Referenced by previousProfileType.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ profileType

- (NSString *) profileType

Extends class StickProfileScreen.

Definition at line 584 of file PlayerEntityStickProfile.m.

585{
586 OOJoystickAxisProfile* profile = [stickHandler getProfileForAxis:current_axis];
587
588 if ([profile isKindOfClass:[OOJoystickStandardAxisProfile class]]) {
589 return DESC(@"oolite-stickprofile-type-standard");
590 }
591 if ([profile isKindOfClass:[OOJoystickSplineAxisProfile class]]) {
592 return DESC(@"oolite-stickprofile-type-spline");
593 }
594 return DESC(@"oolite-stickprofile-type-standard");
595}

References DESC, and profileType.

Referenced by profileType.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveSettings

- (void) saveSettings

Extends class StickProfileScreen.

Definition at line 504 of file PlayerEntityStickProfile.m.

505{
506 [stickHandler saveStickSettings];
507 return;
508}

References saveSettings.

Referenced by saveSettings.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ showScreen

- (void) showScreen

Extends class StickProfileScreen.

Definition at line 510 of file PlayerEntityStickProfile.m.

511{
512 OOJoystickAxisProfile* profile = [stickHandler getProfileForAxis:current_axis];
513 OOJoystickStandardAxisProfile* standard_profile;
514 NSString* v1 = @"||||||||||||||||||||";
515 NSString* v2 = @"....................";
516 int bars;
517 double value;
518 double power;
519
520 OOGUITabStop tabStop[GUI_MAX_COLUMNS];
521 tabStop[0] = 50;
522 tabStop[1] = 140;
523 [gui setTabStops:tabStop];
524 [gui setArray:[NSArray arrayWithObjects:DESC(@"oolite-stickprofile-axis"), [self currentAxis], nil] forRow:GUI_ROW_STICKPROFILE_AXIS];
525 [gui setKey:GUI_KEY_OK forRow:GUI_ROW_STICKPROFILE_AXIS];
526 value = [profile deadzone];
527 bars = (int)(20 * value / STICK_MAX_DEADZONE + 0.5);
528 if (bars < 0)
529 bars = 0;
530 if (bars > 20)
531 bars = 20;
532 [gui setArray:[NSArray arrayWithObjects:DESC(@"oolite-stickprofile-deadzone"),
533 [NSString stringWithFormat:
534 @"%@%@ (%0.4f)",
535 [v1 substringToIndex:bars],
536 [v2 substringToIndex:20 - bars],
537 value],
538 nil]
539 forRow:GUI_ROW_STICKPROFILE_DEADZONE];
540 [gui setKey:GUI_KEY_OK forRow:GUI_ROW_STICKPROFILE_DEADZONE];
541 [gui setArray:[NSArray arrayWithObjects:DESC(@"oolite-stickprofile-profile-type"), [self profileType], nil] forRow:GUI_ROW_STICKPROFILE_PROFILE_TYPE];
542 [gui setKey:GUI_KEY_OK forRow:GUI_ROW_STICKPROFILE_PROFILE_TYPE];
543 if ([profile isKindOfClass:[OOJoystickStandardAxisProfile class]]) {
544 standard_profile = (OOJoystickStandardAxisProfile*)profile;
545 power = [standard_profile power];
546 bars = (int)(20 * power / STICKPROFILE_MAX_POWER + 0.5);
547 if (bars < 0)
548 bars = 0;
549 if (bars > 20)
550 bars = 20;
551 [gui setArray:[NSArray arrayWithObjects:DESC(@"oolite-stickprofile-range"),
552 [NSString stringWithFormat:@"%@%@ (%.1f) ", [v1 substringToIndex:bars], [v2 substringToIndex:20 - bars], power],
553 nil]
554 forRow:GUI_ROW_STICKPROFILE_POWER];
555 [gui setKey:GUI_KEY_OK forRow:GUI_ROW_STICKPROFILE_POWER];
556 value = [standard_profile parameter];
557 bars = 20 * value;
558 if (bars < 0)
559 bars = 0;
560 if (bars > 20)
561 bars = 20;
562 [gui setArray:[NSArray arrayWithObjects:DESC(@"oolite-stickprofile-sensitivity"),
563 [NSString stringWithFormat:@"%@%@ (%0.2f) ", [v1 substringToIndex:bars], [v2 substringToIndex:20 - bars], value],
564 nil]
565 forRow:GUI_ROW_STICKPROFILE_PARAM];
566 [gui setKey:GUI_KEY_OK forRow:GUI_ROW_STICKPROFILE_PARAM];
567 [gui setColor:[OOColor yellowColor] forRow:GUI_ROW_STICKPROFILE_PARAM];
568 } else {
569 [gui setText:@"" forRow:GUI_ROW_STICKPROFILE_POWER];
570 [gui setKey:GUI_KEY_SKIP forRow:GUI_ROW_STICKPROFILE_POWER];
571 [gui setText:DESC(@"oolite-stickprofile-spline-instructions") forRow:GUI_ROW_STICKPROFILE_PARAM];
572 [gui setKey:GUI_KEY_SKIP forRow:GUI_ROW_STICKPROFILE_PARAM];
573 [gui setColor:[OOColor magentaColor] forRow:GUI_ROW_STICKPROFILE_PARAM];
574 }
575 [gui setText:DESC(@"gui-back") forRow:GUI_ROW_STICKPROFILE_BACK];
576 [gui setKey:GUI_KEY_OK forRow:GUI_ROW_STICKPROFILE_BACK];
577 [gui setSelectableRange:NSMakeRange(1, GUI_ROW_STICKPROFILE_BACK)];
578 [[UNIVERSE gameView] suppressKeysUntilKeyUp];
579 [gui setForegroundTextureKey:[PLAYER status] == STATUS_DOCKED ? @"docked_overlay" : @"paused_overlay"];
580 [gui setBackgroundTextureKey:@"settings"];
581 return;
582}
NSInteger OOGUITabStop
#define STICK_MAX_DEADZONE
#define STICKPROFILE_MAX_POWER
OOColor * yellowColor()
Definition OOColor.m:279
OOColor * magentaColor()
Definition OOColor.m:284
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque

References StickProfileScreen::currentAxis, OOJoystickAxisProfile::deadzone, int(), OOColor::magentaColor, OOJoystickStandardAxisProfile::parameter, OOJoystickStandardAxisProfile::power, StickProfileScreen::profileType, GuiDisplayGen::setArray:forRow:, GuiDisplayGen::setBackgroundTextureKey:, GuiDisplayGen::setColor:forRow:, GuiDisplayGen::setForegroundTextureKey:, GuiDisplayGen::setKey:forRow:, GuiDisplayGen::setSelectableRange:, GuiDisplayGen::setTabStops:, GuiDisplayGen::setText:forRow:, showScreen, STICK_MAX_DEADZONE, STICKPROFILE_MAX_POWER, and OOColor::yellowColor.

Referenced by showScreen.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ startEdit

- (void) startEdit

Extends class StickProfileScreen.

Definition at line 487 of file PlayerEntityStickProfile.m.

488{
489 int i, j;
490
491 for (i = 0; i < 3; i++) {
492 for (j = 0; j < 2; j++) {
493 [profiles[i][j] release];
494 profiles[i][j] = nil;
495 }
496 }
497 current_axis = AXIS_ROLL;
498 selected_control_point = -1;
499 dragged_control_point = -1;
500 double_click_control_point = -1;
501 return;
502}
return nil

References AXIS_ROLL, nil, and startEdit.

Referenced by startEdit.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this category was generated from the following file: