Oolite 1.91.0.7644-241112-7f5034b
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 43 of file PlayerEntityStickProfile.m.

360{
361 switch (current_axis)
362 {
363 case AXIS_ROLL:
364 return DESC(@"stickmapper-roll");
365
366 case AXIS_PITCH:
367 return DESC(@"stickmapper-pitch");
368
369 case AXIS_YAW:
370 return DESC(@"stickmapper-yaw");
371 }
372 return @"";
373}
@ AXIS_PITCH
@ AXIS_YAW
@ AXIS_ROLL
#define DESC(key)
Definition Universe.h:839

◆ currentProfileIsSpline

- (BOOL) currentProfileIsSpline

Extends class StickProfileScreen.

Definition at line 43 of file PlayerEntityStickProfile.m.

442{
443 if ([[stickHandler getProfileForAxis: current_axis] isKindOfClass: [OOJoystickSplineAxisProfile class]])
444 {
445 return YES;
446 }
447 return NO;
448}

◆ decreaseDeadzone

- (void) decreaseDeadzone

Extends class StickProfileScreen.

Definition at line 43 of file PlayerEntityStickProfile.m.

387{
388 OOJoystickAxisProfile *profile = [stickHandler getProfileForAxis: current_axis];
389 if (profile)
390 {
391 [profile setDeadzone: [profile deadzone] - STICK_MAX_DEADZONE / 20];
392 }
393 [self showScreen];
394 return;
395}
void setDeadzone:(double newValue)

◆ DecreaseParam

- (void) DecreaseParam

Extends class StickProfileScreen.

Definition at line 43 of file PlayerEntityStickProfile.m.

496{
497 OOJoystickAxisProfile *profile = [stickHandler getProfileForAxis: current_axis];
498 OOJoystickStandardAxisProfile *standard_profile;
499
500 if (profile && [profile isKindOfClass: [OOJoystickStandardAxisProfile class]])
501 {
502 standard_profile = (OOJoystickStandardAxisProfile *) profile;
503 [standard_profile setParameter: [standard_profile parameter] - 0.05];
504 [stickHandler saveStickSettings];
505 }
506 [self showScreen];
507 return;
508}
void setParameter:(double newValue)

◆ DecreasePower

- (void) DecreasePower

Extends class StickProfileScreen.

Definition at line 43 of file PlayerEntityStickProfile.m.

466{
467 OOJoystickAxisProfile *profile = [stickHandler getProfileForAxis: current_axis];
468 OOJoystickStandardAxisProfile *standard_profile;
469
470 if (profile && [profile isKindOfClass: [OOJoystickStandardAxisProfile class]])
471 {
472 standard_profile = (OOJoystickStandardAxisProfile *) profile;
473 [standard_profile setPower: [standard_profile power] - STICKPROFILE_MAX_POWER / 20];
474 [stickHandler saveStickSettings];
475 }
476 [self showScreen];
477 return;
478}

◆ graphProfile:at:size:

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

Extends class StickProfileScreen.

Definition at line 43 of file PlayerEntityStickProfile.m.

510 : (GLfloat) alpha at: (Vector) at size: (NSSize) size
511{
512 OOJoystickAxisProfile *profile = [stickHandler getProfileForAxis: current_axis];
513 OOJoystickSplineAxisProfile *spline_profile;
514 NSInteger i;
515 NSPoint point;
516 NSArray *control_points;
517
518 if (!profile) return;
519 graphRect = NSMakeRect(at.x, at.y, size.width, size.height);
521 OOGL(glColor4f(0.2,0.2,0.5,alpha));
522 OOGLBEGIN(GL_QUADS);
523 glVertex3f(at.x,at.y,at.z);
524 glVertex3f(at.x + size.width,at.y,at.z);
525 glVertex3f(at.x + size.width,at.y + size.height,at.z);
526 glVertex3f(at.x,at.y + size.height,at.z);
527 OOGLEND();
528 OOGL(glColor4f(0.9,0.9,0.9,alpha));
529 OOGL(GLScaledLineWidth(2.0f));
530 OOGLBEGIN(GL_LINE_STRIP);
531 for (i = 0; i <= size.width - 20; i++)
532 {
533 glVertex3f(at.x+i+10,at.y+10+(size.height-20)*[profile rawValue:((float)i)/(size.width-20)],at.z);
534 }
535 OOGLEND();
536 OOGL(glColor4f(0.5,0.0,0.5,alpha));
537 GLDrawFilledOval(at.x+10,at.y+10,at.z,NSMakeSize(4,4),20);
538 GLDrawFilledOval(at.x+size.width-10,at.y+size.height-10,at.z,NSMakeSize(4,4),20);
539 if ([profile isKindOfClass: [OOJoystickSplineAxisProfile class]])
540 {
541 spline_profile = (OOJoystickSplineAxisProfile *)profile;
542 control_points = [spline_profile controlPoints];
543 for (i = 0; i < (NSInteger)[control_points count]; i++)
544 {
545 if (i == selected_control_point)
546 {
547 OOGL(glColor4f(1.0,0.0,0.0,alpha));
548 }
549 else
550 {
551 OOGL(glColor4f(0.0,1.0,0.0,alpha));
552 }
553 point = [[control_points objectAtIndex: i] pointValue];
554 GLDrawFilledOval(at.x+10+point.x*(size.width - 20),at.y+10+point.y*(size.height-20),at.z,NSMakeSize(4,4),20);
555 }
556 }
557 OOGL(glColor4f(0.9,0.9,0.0,alpha));
558 OODrawStringAligned(DESC(@"oolite-stickprofile-movement"), at.x + size.width - 5, at.y, at.z, NSMakeSize(8,10), YES);
559 OODrawString(DESC(@"oolite-stickprofile-response"), at.x, at.y + size.height - 10, at.z, NSMakeSize(8,10));
560 return;
561}
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:253
void GLDrawFilledOval(GLfloat x, GLfloat y, GLfloat z, NSSize siz, GLfloat step)
Definition OOOpenGL.m:165
void GLScaledLineWidth(GLfloat width)
Definition OOOpenGL.m:218
#define OOGL(statement)
Definition OOOpenGL.h:251
#define OOGLEND
Definition OOOpenGL.h:254
voidpf void uLong size
Definition ioapi.h:134

◆ increaseDeadzone

- (void) increaseDeadzone

Extends class StickProfileScreen.

Definition at line 43 of file PlayerEntityStickProfile.m.

376{
377 OOJoystickAxisProfile *profile = [stickHandler getProfileForAxis: current_axis];
378 if (profile)
379 {
380 [profile setDeadzone: [profile deadzone] + STICK_MAX_DEADZONE / 20];
381 }
382 [self showScreen];
383 return;
384}

◆ IncreaseParam

- (void) IncreaseParam

Extends class StickProfileScreen.

Definition at line 43 of file PlayerEntityStickProfile.m.

481{
482 OOJoystickAxisProfile *profile = [stickHandler getProfileForAxis: current_axis];
483 OOJoystickStandardAxisProfile *standard_profile;
484
485 if (profile && [profile isKindOfClass: [OOJoystickStandardAxisProfile class]])
486 {
487 standard_profile = (OOJoystickStandardAxisProfile *) profile;
488 [standard_profile setParameter: [standard_profile parameter] + 0.05];
489 [stickHandler saveStickSettings];
490 }
491 [self showScreen];
492 return;
493}

◆ IncreasePower

- (void) IncreasePower

Extends class StickProfileScreen.

Definition at line 43 of file PlayerEntityStickProfile.m.

451{
452 OOJoystickAxisProfile *profile = [stickHandler getProfileForAxis: current_axis];
453 OOJoystickStandardAxisProfile *standard_profile;
454
455 if (profile && [profile isKindOfClass: [OOJoystickStandardAxisProfile class]])
456 {
457 standard_profile = (OOJoystickStandardAxisProfile *) profile;
458 [standard_profile setPower: [standard_profile power] + STICKPROFILE_MAX_POWER / 20];
459 [stickHandler saveStickSettings];
460 }
461 [self showScreen];
462 return;
463}

◆ nextAxis

- (void) nextAxis

Extends class StickProfileScreen.

Definition at line 43 of file PlayerEntityStickProfile.m.

340{
341 if (current_axis == AXIS_ROLL)
342 current_axis = AXIS_PITCH;
343 else if (current_axis == AXIS_PITCH)
344 current_axis = AXIS_YAW;
345 [self showScreen];
346 return;
347}

◆ nextProfileType

- (void) nextProfileType

Extends class StickProfileScreen.

Definition at line 43 of file PlayerEntityStickProfile.m.

398{
399 OOJoystickAxisProfile *profile = [stickHandler getProfileForAxis: current_axis];
400 double deadzone;
401
402 if ([profile isKindOfClass: [OOJoystickStandardAxisProfile class]])
403 {
404 deadzone = [profile deadzone];
405 [profiles[current_axis][0] release];
406 profiles[current_axis][0] = [profile retain];
407 if (!profiles[current_axis][1])
408 {
409 profiles[current_axis][1] = [[OOJoystickSplineAxisProfile alloc] init];
410 }
411 [profiles[current_axis][1] setDeadzone: deadzone];
412 [stickHandler setProfile: profiles[current_axis][1] forAxis: current_axis];
413 [stickHandler saveStickSettings];
414 }
415 [self showScreen];
416 return;
417}

◆ previousAxis

- (void) previousAxis

Extends class StickProfileScreen.

Definition at line 43 of file PlayerEntityStickProfile.m.

350{
351 if (current_axis == AXIS_PITCH)
352 current_axis = AXIS_ROLL;
353 else if (current_axis == AXIS_YAW)
354 current_axis = AXIS_PITCH;
355 [self showScreen];
356 return;
357}

◆ previousProfileType

- (void) previousProfileType

Extends class StickProfileScreen.

Definition at line 43 of file PlayerEntityStickProfile.m.

420{
421 OOJoystickAxisProfile *profile = [stickHandler getProfileForAxis: current_axis];
422 double deadzone;
423
424 if ([profile isKindOfClass: [OOJoystickSplineAxisProfile class]])
425 {
426 deadzone = [profile deadzone];
427 [profiles[current_axis][1] release];
428 profiles[current_axis][1] = [profile retain];
429 if (!profiles[current_axis][0])
430 {
431 profiles[current_axis][0] = [[OOJoystickStandardAxisProfile alloc] init];
432 }
433 [profiles[current_axis][0] setDeadzone: deadzone];
434 [stickHandler setProfile: profiles[current_axis][0] forAxis: current_axis];
435 [stickHandler saveStickSettings];
436 }
437 [self showScreen];
438 return;
439}

◆ profileType

- (NSString *) profileType

Extends class StickProfileScreen.

Definition at line 43 of file PlayerEntityStickProfile.m.

657{
658 OOJoystickAxisProfile *profile = [stickHandler getProfileForAxis: current_axis];
659
660 if ([profile isKindOfClass: [OOJoystickStandardAxisProfile class]])
661 {
662 return DESC(@"oolite-stickprofile-type-standard");
663 }
664 if ([profile isKindOfClass: [OOJoystickSplineAxisProfile class]])
665 {
666 return DESC(@"oolite-stickprofile-type-spline");
667 }
668 return DESC(@"oolite-stickprofile-type-standard");
669}

◆ saveSettings

- (void) saveSettings

Extends class StickProfileScreen.

Definition at line 43 of file PlayerEntityStickProfile.m.

583{
584 [stickHandler saveStickSettings];
585 return;
586}

◆ showScreen

- (void) showScreen

Extends class StickProfileScreen.

Definition at line 43 of file PlayerEntityStickProfile.m.

589{
590 OOJoystickAxisProfile *profile = [stickHandler getProfileForAxis: current_axis];
591 OOJoystickStandardAxisProfile *standard_profile;
592 NSString *v1 = @"||||||||||||||||||||";
593 NSString *v2 = @"....................";
594 int bars;
595 double value;
596 double power;
597
598 OOGUITabStop tabStop[GUI_MAX_COLUMNS];
599 tabStop[0] = 50;
600 tabStop[1] = 140;
601 [gui setTabStops:tabStop];
602 [gui setArray: [NSArray arrayWithObjects: DESC(@"oolite-stickprofile-axis"), [self currentAxis], nil ] forRow: GUI_ROW_STICKPROFILE_AXIS];
603 [gui setKey: GUI_KEY_OK forRow: GUI_ROW_STICKPROFILE_AXIS];
604 value = [profile deadzone];
605 bars = (int)(20 * value / STICK_MAX_DEADZONE + 0.5);
606 if (bars < 0) bars = 0;
607 if (bars > 20) bars = 20;
608 [gui setArray: [NSArray arrayWithObjects: DESC(@"oolite-stickprofile-deadzone"),
609 [NSString stringWithFormat:
610 @"%@%@ (%0.4f)",
611 [v1 substringToIndex: bars],
612 [v2 substringToIndex: 20 - bars],
613 value],
614 nil] forRow: GUI_ROW_STICKPROFILE_DEADZONE];
615 [gui setKey: GUI_KEY_OK forRow: GUI_ROW_STICKPROFILE_DEADZONE];
616 [gui setArray: [NSArray arrayWithObjects: DESC(@"oolite-stickprofile-profile-type"), [self profileType], nil ] forRow: GUI_ROW_STICKPROFILE_PROFILE_TYPE];
617 [gui setKey: GUI_KEY_OK forRow: GUI_ROW_STICKPROFILE_PROFILE_TYPE];
618 if ([profile isKindOfClass:[OOJoystickStandardAxisProfile class]])
619 {
620 standard_profile = (OOJoystickStandardAxisProfile*) profile;
621 power = [standard_profile power];
622 bars = (int)(20*power / STICKPROFILE_MAX_POWER + 0.5);
623 if (bars < 0) bars = 0;
624 if (bars > 20) bars = 20;
625 [gui setArray: [NSArray arrayWithObjects: DESC(@"oolite-stickprofile-range"),
626 [NSString stringWithFormat: @"%@%@ (%.1f) ", [v1 substringToIndex: bars], [v2 substringToIndex: 20 - bars], power],
627 nil] forRow: GUI_ROW_STICKPROFILE_POWER];
628 [gui setKey: GUI_KEY_OK forRow: GUI_ROW_STICKPROFILE_POWER];
629 value = [standard_profile parameter];
630 bars = 20*value;
631 if (bars < 0) bars = 0;
632 if (bars > 20) bars = 20;
633 [gui setArray: [NSArray arrayWithObjects: DESC(@"oolite-stickprofile-sensitivity"),
634 [NSString stringWithFormat: @"%@%@ (%0.2f) ", [v1 substringToIndex: bars], [v2 substringToIndex: 20 - bars], value],
635 nil] forRow: GUI_ROW_STICKPROFILE_PARAM];
636 [gui setKey: GUI_KEY_OK forRow: GUI_ROW_STICKPROFILE_PARAM];
637 [gui setColor:[OOColor yellowColor] forRow: GUI_ROW_STICKPROFILE_PARAM];
638 }
639 else
640 {
641 [gui setText: @"" forRow: GUI_ROW_STICKPROFILE_POWER];
642 [gui setKey: GUI_KEY_SKIP forRow: GUI_ROW_STICKPROFILE_POWER];
643 [gui setText: DESC(@"oolite-stickprofile-spline-instructions") forRow: GUI_ROW_STICKPROFILE_PARAM];
644 [gui setKey: GUI_KEY_SKIP forRow: GUI_ROW_STICKPROFILE_PARAM];
645 [gui setColor:[OOColor magentaColor] forRow: GUI_ROW_STICKPROFILE_PARAM];
646 }
647 [gui setText: DESC(@"gui-back") forRow: GUI_ROW_STICKPROFILE_BACK];
648 [gui setKey: GUI_KEY_OK forRow: GUI_ROW_STICKPROFILE_BACK];
649 [gui setSelectableRange: NSMakeRange(1, GUI_ROW_STICKPROFILE_BACK)];
650 [[UNIVERSE gameView] suppressKeysUntilKeyUp];
651 [gui setForegroundTextureKey:[PLAYER status] == STATUS_DOCKED ? @"docked_overlay" : @"paused_overlay"];
652 [gui setBackgroundTextureKey: @"settings"];
653 return;
654}
NSInteger OOGUITabStop
#define STICK_MAX_DEADZONE
#define STICKPROFILE_MAX_POWER
OOColor * yellowColor()
Definition OOColor.m:292
OOColor * magentaColor()
Definition OOColor.m:298
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque

◆ startEdit

- (void) startEdit

Extends class StickProfileScreen.

Definition at line 43 of file PlayerEntityStickProfile.m.

564{
565 int i, j;
566
567 for (i = 0; i < 3; i++)
568 {
569 for (j = 0; j < 2; j++)
570 {
571 [profiles[i][j] release];
572 profiles[i][j] = nil;
573 }
574 }
575 current_axis = AXIS_ROLL;
576 selected_control_point = -1;
577 dragged_control_point = -1;
578 double_click_control_point = -1;
579 return;
580}
return nil

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