Added extra chart configuration options for mission screens (#284)
This commit is contained in:
parent
e486175777
commit
433d8d7583
@ -487,12 +487,14 @@ typedef enum
|
||||
NSPoint cursor_coordinates;
|
||||
NSPoint chart_focus_coordinates;
|
||||
NSPoint chart_centre_coordinates;
|
||||
NSPoint custom_chart_centre_coordinates;
|
||||
// where we want the chart centre to be - used for smooth transitions
|
||||
NSPoint target_chart_centre;
|
||||
NSPoint target_chart_focus;
|
||||
// Chart zoom is 1.0 when fully zoomed in and increases as we zoom out. The reason I've done it that way round
|
||||
// is because we might want to implement bigger galaxies one day, and thus may need to zoom out indefinitely.
|
||||
OOScalar chart_zoom;
|
||||
OOScalar custom_chart_zoom;
|
||||
OOScalar target_chart_zoom;
|
||||
OOScalar saved_chart_zoom;
|
||||
OORouteType ANA_mode;
|
||||
@ -772,9 +774,13 @@ typedef enum
|
||||
- (OOGalaxyID) galaxyNumber;
|
||||
- (NSPoint) galaxy_coordinates;
|
||||
- (void) setGalaxyCoordinates:(NSPoint)newPosition;
|
||||
- (void) setCustomChartCentre:(NSPoint)coords;
|
||||
- (NSPoint) cursor_coordinates;
|
||||
- (NSPoint) chart_centre_coordinates;
|
||||
- (NSPoint) custom_chart_centre_coordinates;
|
||||
- (OOScalar) chart_zoom;
|
||||
- (OOScalar) custom_chart_zoom;
|
||||
- (void) setCustomChartZoom:(OOScalar)zoom;
|
||||
- (NSPoint) adjusted_chart_centre;
|
||||
- (OORouteType) ANAMode;
|
||||
|
||||
|
@ -537,17 +537,50 @@ NSComparisonResult marketSorterByMassUnit(id a, id b, void *market);
|
||||
|
||||
- (OOScalar) chart_zoom
|
||||
{
|
||||
if(_missionBackgroundSpecial == GUI_BACKGROUND_SPECIAL_SHORT)
|
||||
if(_missionBackgroundSpecial == GUI_BACKGROUND_SPECIAL_SHORT ||
|
||||
_missionBackgroundSpecial == GUI_BACKGROUND_SPECIAL_SHORT_ANA_QUICKEST ||
|
||||
_missionBackgroundSpecial == GUI_BACKGROUND_SPECIAL_SHORT_ANA_SHORTEST)
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
else if(_missionBackgroundSpecial == GUI_BACKGROUND_SPECIAL_LONG)
|
||||
else if(_missionBackgroundSpecial == GUI_BACKGROUND_SPECIAL_LONG ||
|
||||
_missionBackgroundSpecial == GUI_BACKGROUND_SPECIAL_LONG_ANA_SHORTEST ||
|
||||
_missionBackgroundSpecial == GUI_BACKGROUND_SPECIAL_LONG_ANA_QUICKEST)
|
||||
{
|
||||
return CHART_MAX_ZOOM;
|
||||
}
|
||||
else if(_missionBackgroundSpecial == GUI_BACKGROUND_SPECIAL_CUSTOM ||
|
||||
_missionBackgroundSpecial == GUI_BACKGROUND_SPECIAL_CUSTOM_ANA_QUICKEST ||
|
||||
_missionBackgroundSpecial == GUI_BACKGROUND_SPECIAL_CUSTOM_ANA_SHORTEST)
|
||||
{
|
||||
return custom_chart_zoom;
|
||||
}
|
||||
return chart_zoom;
|
||||
}
|
||||
|
||||
- (OOScalar) custom_chart_zoom
|
||||
{
|
||||
return custom_chart_zoom;
|
||||
}
|
||||
|
||||
- (void) setCustomChartZoom:(OOScalar)zoom
|
||||
{
|
||||
custom_chart_zoom = zoom;
|
||||
}
|
||||
|
||||
|
||||
- (NSPoint) custom_chart_centre_coordinates
|
||||
{
|
||||
return custom_chart_centre_coordinates;
|
||||
}
|
||||
|
||||
|
||||
- (void) setCustomChartCentre:(NSPoint)coords
|
||||
{
|
||||
custom_chart_centre_coordinates.x = coords.x;
|
||||
custom_chart_centre_coordinates.y = coords.y;
|
||||
}
|
||||
|
||||
|
||||
- (NSPoint) adjusted_chart_centre
|
||||
{
|
||||
@ -555,15 +588,24 @@ NSComparisonResult marketSorterByMassUnit(id a, id b, void *market);
|
||||
double scroll_pos; // cursor coordinate at which we'd want to scoll chart in the direction we're currently considering
|
||||
double ecc; // chart centre coordinate we'd want if the cursor was on the edge of the galaxy in the current direction
|
||||
|
||||
if(_missionBackgroundSpecial == GUI_BACKGROUND_SPECIAL_SHORT)
|
||||
if(_missionBackgroundSpecial == GUI_BACKGROUND_SPECIAL_SHORT ||
|
||||
_missionBackgroundSpecial == GUI_BACKGROUND_SPECIAL_SHORT_ANA_QUICKEST ||
|
||||
_missionBackgroundSpecial == GUI_BACKGROUND_SPECIAL_SHORT_ANA_SHORTEST)
|
||||
{
|
||||
return galaxy_coordinates;
|
||||
}
|
||||
else if(_missionBackgroundSpecial == GUI_BACKGROUND_SPECIAL_LONG)
|
||||
else if(_missionBackgroundSpecial == GUI_BACKGROUND_SPECIAL_LONG ||
|
||||
_missionBackgroundSpecial == GUI_BACKGROUND_SPECIAL_LONG_ANA_QUICKEST ||
|
||||
_missionBackgroundSpecial == GUI_BACKGROUND_SPECIAL_LONG_ANA_SHORTEST)
|
||||
{
|
||||
return NSMakePoint(128.0, 128.0);
|
||||
}
|
||||
|
||||
else if (_missionBackgroundSpecial == GUI_BACKGROUND_SPECIAL_CUSTOM ||
|
||||
_missionBackgroundSpecial == GUI_BACKGROUND_SPECIAL_CUSTOM_ANA_QUICKEST ||
|
||||
_missionBackgroundSpecial == GUI_BACKGROUND_SPECIAL_CUSTOM_ANA_SHORTEST)
|
||||
{
|
||||
return custom_chart_centre_coordinates;
|
||||
}
|
||||
// When fully zoomed in we want to centre chart on chart_centre_coordinates. When zoomed out we want the chart centred on
|
||||
// (128.0, 128.0) so the galaxy fits the screen width. For intermediate zoom we interpolate.
|
||||
acc.x = chart_centre_coordinates.x + (128.0 - chart_centre_coordinates.x) * (chart_zoom - 1.0) / (CHART_MAX_ZOOM - 1.0);
|
||||
@ -1319,6 +1361,9 @@ NSComparisonResult marketSorterByMassUnit(id a, id b, void *market);
|
||||
}
|
||||
}
|
||||
|
||||
custom_chart_zoom = 1.0;
|
||||
custom_chart_centre_coordinates = NSMakePoint(galaxy_coordinates.y, galaxy_coordinates.y);
|
||||
|
||||
/* Energy bombs are no longer supported without OXPs. As compensation,
|
||||
we'll award either a Q-mine or some cash. We can't determine what to
|
||||
award until we've handled missiles later on, though.
|
||||
@ -12389,6 +12434,54 @@ static NSString *last_outfitting_key=nil;
|
||||
{
|
||||
_missionBackgroundSpecial = GUI_BACKGROUND_SPECIAL_SHORT;
|
||||
}
|
||||
else if ([special isEqualToString:@"SHORT_RANGE_CHART_SHORTEST"])
|
||||
{
|
||||
if ([self hasEquipmentItemProviding:@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
|
||||
{
|
||||
_missionBackgroundSpecial = GUI_BACKGROUND_SPECIAL_SHORT_ANA_SHORTEST;
|
||||
}
|
||||
else
|
||||
{
|
||||
_missionBackgroundSpecial = GUI_BACKGROUND_SPECIAL_SHORT;
|
||||
}
|
||||
}
|
||||
else if ([special isEqualToString:@"SHORT_RANGE_CHART_QUICKEST"])
|
||||
{
|
||||
if ([self hasEquipmentItemProviding:@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
|
||||
{
|
||||
_missionBackgroundSpecial = GUI_BACKGROUND_SPECIAL_SHORT_ANA_QUICKEST;
|
||||
}
|
||||
else
|
||||
{
|
||||
_missionBackgroundSpecial = GUI_BACKGROUND_SPECIAL_SHORT;
|
||||
}
|
||||
}
|
||||
else if ([special isEqualToString:@"CUSTOM_CHART"])
|
||||
{
|
||||
_missionBackgroundSpecial = GUI_BACKGROUND_SPECIAL_CUSTOM;
|
||||
}
|
||||
else if ([special isEqualToString:@"CUSTOM_CHART_SHORTEST"])
|
||||
{
|
||||
if ([self hasEquipmentItemProviding:@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
|
||||
{
|
||||
_missionBackgroundSpecial = GUI_BACKGROUND_SPECIAL_CUSTOM_ANA_SHORTEST;
|
||||
}
|
||||
else
|
||||
{
|
||||
_missionBackgroundSpecial = GUI_BACKGROUND_SPECIAL_CUSTOM;
|
||||
}
|
||||
}
|
||||
else if ([special isEqualToString:@"CUSTOM_CHART_QUICKEST"])
|
||||
{
|
||||
if ([self hasEquipmentItemProviding:@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
|
||||
{
|
||||
_missionBackgroundSpecial = GUI_BACKGROUND_SPECIAL_CUSTOM_ANA_QUICKEST;
|
||||
}
|
||||
else
|
||||
{
|
||||
_missionBackgroundSpecial = GUI_BACKGROUND_SPECIAL_CUSTOM;
|
||||
}
|
||||
}
|
||||
else if ([special isEqualToString:@"LONG_RANGE_CHART"])
|
||||
{
|
||||
_missionBackgroundSpecial = GUI_BACKGROUND_SPECIAL_LONG;
|
||||
|
@ -53,7 +53,12 @@ typedef enum
|
||||
typedef enum
|
||||
{
|
||||
GUI_BACKGROUND_SPECIAL_NONE,
|
||||
GUI_BACKGROUND_SPECIAL_CUSTOM,
|
||||
GUI_BACKGROUND_SPECIAL_CUSTOM_ANA_SHORTEST,
|
||||
GUI_BACKGROUND_SPECIAL_CUSTOM_ANA_QUICKEST,
|
||||
GUI_BACKGROUND_SPECIAL_SHORT,
|
||||
GUI_BACKGROUND_SPECIAL_SHORT_ANA_SHORTEST,
|
||||
GUI_BACKGROUND_SPECIAL_SHORT_ANA_QUICKEST,
|
||||
GUI_BACKGROUND_SPECIAL_LONG,
|
||||
GUI_BACKGROUND_SPECIAL_LONG_ANA_SHORTEST,
|
||||
GUI_BACKGROUND_SPECIAL_LONG_ANA_QUICKEST
|
||||
|
@ -1039,7 +1039,18 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
|
||||
|
||||
switch (spec)
|
||||
{
|
||||
case GUI_BACKGROUND_SPECIAL_CUSTOM:
|
||||
case GUI_BACKGROUND_SPECIAL_CUSTOM_ANA_SHORTEST:
|
||||
case GUI_BACKGROUND_SPECIAL_CUSTOM_ANA_QUICKEST:
|
||||
bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"custom_chart_mission"];
|
||||
if (bgDescriptor == nil)
|
||||
{
|
||||
bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"short_range_chart"];
|
||||
}
|
||||
break;
|
||||
case GUI_BACKGROUND_SPECIAL_SHORT:
|
||||
case GUI_BACKGROUND_SPECIAL_SHORT_ANA_SHORTEST:
|
||||
case GUI_BACKGROUND_SPECIAL_SHORT_ANA_QUICKEST:
|
||||
bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"short_range_chart_mission"];
|
||||
if (bgDescriptor == nil)
|
||||
{
|
||||
@ -1346,7 +1357,13 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
|
||||
|
||||
if (self == [UNIVERSE gui])
|
||||
{
|
||||
if ([player guiScreen] == GUI_SCREEN_SHORT_RANGE_CHART || [player guiScreen] == GUI_SCREEN_LONG_RANGE_CHART || backgroundSpecial == GUI_BACKGROUND_SPECIAL_SHORT)
|
||||
if ([player guiScreen] == GUI_SCREEN_SHORT_RANGE_CHART || [player guiScreen] == GUI_SCREEN_LONG_RANGE_CHART ||
|
||||
backgroundSpecial == GUI_BACKGROUND_SPECIAL_SHORT ||
|
||||
backgroundSpecial == GUI_BACKGROUND_SPECIAL_SHORT_ANA_QUICKEST ||
|
||||
backgroundSpecial == GUI_BACKGROUND_SPECIAL_SHORT_ANA_SHORTEST ||
|
||||
backgroundSpecial == GUI_BACKGROUND_SPECIAL_CUSTOM ||
|
||||
backgroundSpecial == GUI_BACKGROUND_SPECIAL_CUSTOM_ANA_QUICKEST ||
|
||||
backgroundSpecial == GUI_BACKGROUND_SPECIAL_CUSTOM_ANA_SHORTEST)
|
||||
{
|
||||
[self drawStarChart:x - 0.5f * size_in_pixels.width :y - 0.5f * size_in_pixels.height :z :alpha :NO];
|
||||
}
|
||||
@ -1843,11 +1860,15 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
|
||||
static NSDictionary *routeInfo = nil;
|
||||
|
||||
/* May override current mode for mission screens */
|
||||
if (backgroundSpecial == GUI_BACKGROUND_SPECIAL_LONG_ANA_SHORTEST)
|
||||
if (backgroundSpecial == GUI_BACKGROUND_SPECIAL_LONG_ANA_SHORTEST ||
|
||||
backgroundSpecial == GUI_BACKGROUND_SPECIAL_SHORT_ANA_SHORTEST ||
|
||||
backgroundSpecial == GUI_BACKGROUND_SPECIAL_CUSTOM_ANA_SHORTEST)
|
||||
{
|
||||
advancedNavArrayMode = OPTIMIZED_BY_JUMPS;
|
||||
}
|
||||
else if (backgroundSpecial == GUI_BACKGROUND_SPECIAL_LONG_ANA_QUICKEST)
|
||||
else if (backgroundSpecial == GUI_BACKGROUND_SPECIAL_LONG_ANA_QUICKEST ||
|
||||
backgroundSpecial == GUI_BACKGROUND_SPECIAL_SHORT_ANA_QUICKEST ||
|
||||
backgroundSpecial == GUI_BACKGROUND_SPECIAL_CUSTOM_ANA_QUICKEST)
|
||||
{
|
||||
advancedNavArrayMode = OPTIMIZED_BY_TIME;
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ MA 02110-1301, USA.
|
||||
#import "OOJavaScriptEngine.h"
|
||||
#import "OOJSScript.h"
|
||||
#import "OOConstToJSString.h"
|
||||
#import "OOJSVector.h"
|
||||
|
||||
#import "OOJSPlayer.h"
|
||||
#import "PlayerEntityScriptMethods.h"
|
||||
@ -572,6 +573,51 @@ static JSBool MissionRunScreen(JSContext *context, uintN argc, jsval *vp)
|
||||
[player setMissionBackgroundDescriptor:GetParameterImageDescriptor(context, params, "background")];
|
||||
[player setMissionBackgroundSpecial:GetParameterString(context, params, "backgroundSpecial")];
|
||||
|
||||
if (JS_GetProperty(context, params, "customChartZoom", &value) && !JSVAL_IS_VOID(value))
|
||||
{
|
||||
jsdouble zoom;
|
||||
if (JS_ValueToNumber(context, value, &zoom))
|
||||
{
|
||||
if (zoom >= 1 && zoom <= CHART_MAX_ZOOM)
|
||||
{
|
||||
[player setCustomChartZoom:zoom];
|
||||
}
|
||||
else
|
||||
{
|
||||
OOJSReportWarning(context, @"Mission.runScreen: invalid customChartZoom value specified.");
|
||||
[player setCustomChartZoom:1];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (JS_GetProperty(context, params, "customChartCentre", &value) && !JSVAL_IS_VOID(value))
|
||||
{
|
||||
Vector vValue;
|
||||
if (JSValueToVector(context, value, &vValue))
|
||||
{
|
||||
NSPoint coords = { vValue.x, vValue.y };
|
||||
[player setCustomChartCentre:coords];
|
||||
}
|
||||
else
|
||||
{
|
||||
[player setCustomChartCentre:[player galaxy_coordinates]];
|
||||
OOJSReportWarning(context, @"Mission.runScreen: invalid value for customChartCentre. Must be valid vector. Defaulting to current location.");
|
||||
}
|
||||
}
|
||||
if (JS_GetProperty(context, params, "customChartCentreInLY", &value) && !JSVAL_IS_VOID(value))
|
||||
{
|
||||
Vector vValue;
|
||||
if (JSValueToVector(context, value, &vValue))
|
||||
{
|
||||
NSPoint coords = OOInternalCoordinatesFromGalactic(vValue);
|
||||
[player setCustomChartCentre:coords];
|
||||
}
|
||||
else
|
||||
{
|
||||
[player setCustomChartCentre:[player galaxy_coordinates]];
|
||||
OOJSReportWarning(context, @"Mission.runScreen: invalid value for customChartCentreInLY. Must be valid vector. Defaulting to current location.");
|
||||
}
|
||||
}
|
||||
|
||||
[UNIVERSE removeDemoShips]; // remove any demoship or miniature planet that may be remaining from previous screens
|
||||
|
||||
if ([player status] == STATUS_IN_FLIGHT)
|
||||
|
Loading…
x
Reference in New Issue
Block a user