1745 :(GLfloat)
x :(GLfloat)
y :(GLfloat)z :(GLfloat) alpha :(BOOL)compact
1746{
1748
1749 if (!player)
1750 return;
1751
1753
1758 NSPoint info_system_coordinates = [[UNIVERSE systemManager] getCoordinatesForSystem: [player
infoSystemID] inGalaxy: [player
galaxyNumber]];
1761 GLfloat r = 1.0, g = 1.0, b = 1.0;
1762 BOOL noNova;
1763 NSPoint cu;
1764 NSUInteger systemParameter;
1765
1766 double fuel = 35.0 * [player
dialFuel];
1767
1768 double hcenter = size_in_pixels.width/2.0;
1772 double hoffset = hcenter - chart_centre_coordinates.
x*hscale;
1773 double voffset = size_in_pixels.height - vcenter - chart_centre_coordinates.
y*vscale;
1774
1775 if (compact)
1776 {
1777 hscale = size_in_pixels.width / 256.0;
1778 vscale = -1.0 * size_in_pixels.height / 512.0;
1779 hoffset = 0.0f;
1780 voffset = size_in_pixels.height - pixel_title_size.height - 5;
1782 chart_centre_coordinates.x = 128.0;
1783 chart_centre_coordinates.y = 128.0;
1785 }
1786
1787 int i;
1788 double d, distance = 0.0, time = 0.0;
1789 int jumps = 0;
1790 NSPoint star;
1792 NSRect clipRect;
1793
1795 BOOL routeExists = NO;
1796
1797 NSInteger concealment[256];
1798 for (i=0;i<256;i++) {
1799 NSDictionary *systemInfo = [systemManager getPropertiesForSystem:i inGalaxy:galaxy_id];
1800 concealment[i] = [systemInfo oo_intForKey:@"concealment" defaultValue:OO_SYSTEMCONCEALMENT_NONE];
1801 }
1802
1803 BOOL *systemsFound = [UNIVERSE systemsFound];
1804 NSSize viewSize = [[UNIVERSE gameView] backingViewSize];
1805 double aspect_ratio = viewSize.width / viewSize.height;
1806
1807
1808 GLfloat govcol[] = { 0.5, 0.0, 0.7,
1809 0.7, 0.5, 0.3,
1810 0.0, 1.0, 0.3,
1811 1.0, 0.8, 0.1,
1812 1.0, 0.0, 0.0,
1813 0.1, 0.5, 1.0,
1814 0.7, 0.7, 0.7,
1815 0.7, 1.0, 1.0};
1816
1817 if (aspect_ratio > 4.0/3.0)
1818 {
1819 pixelRatio = viewSize.height / 480.0;
1820 }
1821 else
1822 {
1823 pixelRatio = viewSize.width / 640.0;
1824 }
1825
1827
1828 clipRect = NSMakeRect((viewSize.width - size_in_pixels.width*pixelRatio)/2.0,
1829 (viewSize.height + size_in_pixels.height*pixelRatio)/2.0 - (pixel_title_size.height + 15 + (textRow-2)*
MAIN_GUI_ROW_HEIGHT) * pixelRatio,
1830 size_in_pixels.width * pixelRatio,
1832
1834 double dx, dy;
1835
1836
1838
1839
1840 cu = NSMakePoint((float)(hscale*galaxy_coordinates.x+hoffset),(float)(vscale*galaxy_coordinates.y+voffset));
1841
1842
1843 OOGL(glEnable(GL_SCISSOR_TEST));
1844 OOGL(glScissor(clipRect.origin.x, clipRect.origin.y, clipRect.size.width, clipRect.size.height));
1845
1846
1847
1848
1850 static struct saved_system
1851 {
1853 int tec, eco, gov;
1854 NSString* p_name;
1855 BOOL nova;
1856 } nearby_systems[ 256 ];
1857 static int num_nearby_systems = 0;
1858
1860 {
1861
1863 for (i = 0; i < num_nearby_systems; i++)
1864 [nearby_systems[ i ].p_name release];
1865
1866 num_nearby_systems = 0;
1867 for (i = 0; i < 256; i++)
1868 {
1869
1870 NSDictionary* sys_info = [UNIVERSE generateSystemData:i];
1871 if (
EXPECT_NOT([sys_info oo_boolForKey:
@"sun_gone_nova"]))
1872 {
1873 nearby_systems[ num_nearby_systems ].gov = -1;
1874 }
1875 else
1876 {
1877 nearby_systems[ num_nearby_systems ].tec = [sys_info oo_intForKey:KEY_TECHLEVEL];
1878 nearby_systems[ num_nearby_systems ].eco = [sys_info oo_intForKey:KEY_ECONOMY];
1879 nearby_systems[ num_nearby_systems ].gov = [sys_info oo_intForKey:KEY_GOVERNMENT];
1880 }
1881 nearby_systems[ num_nearby_systems ].sysid = i;
1882 nearby_systems[ num_nearby_systems ].p_name = [[sys_info oo_stringForKey:KEY_NAME] retain];
1883 nearby_systems[ num_nearby_systems ].nova = [[UNIVERSE generateSystemData:i] oo_boolForKey:@"sun_gone_nova"];
1884 num_nearby_systems++;
1885 }
1887 }
1888
1892 static NSDictionary *routeInfo =
nil;
1893
1894
1898 {
1900 }
1904 {
1906 }
1907
1908 if (advancedNavArrayMode !=
OPTIMIZED_BY_NONE && [player hasEquipmentItemProviding:
@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
1909 {
1911 OOSystemID destNumber = [PLAYER targetSystemID];
1912 if (routeInfo ==
nil || planetNumber != savedPlanetNumber || destNumber != savedDestNumber || advancedNavArrayMode != savedArrayMode)
1913 {
1914 [routeInfo release];
1915 routeInfo = [[UNIVERSE routeFromSystem:planetNumber toSystem:destNumber optimizedBy:advancedNavArrayMode] retain];
1916 savedPlanetNumber = planetNumber;
1917 savedDestNumber = destNumber;
1918 savedArrayMode = advancedNavArrayMode;
1919 }
1920 target = destNumber;
1921
1922
1923
1924
1925
1926 if (routeInfo) routeExists = YES;
1927
1928 [self drawAdvancedNavArrayAtX:x+hoffset y:y+voffset z:z alpha:alpha usingRoute: (planetNumber != destNumber ? (id)routeInfo : nil) optimizedBy:advancedNavArrayMode zoom: zoom];
1929
1930 if (routeExists)
1931 {
1932 distance = [routeInfo oo_doubleForKey:@"distance"];
1933 time = [routeInfo oo_doubleForKey:@"time"];
1934 jumps = [routeInfo oo_intForKey:@"jumps"];
1935
1936 if (distance == 0.0 && planetNumber != destNumber)
1937 {
1938
1939 distance = 0.1;
1940 time = 0.01;
1941 }
1942 }
1943 }
1944 else
1945 {
1946 [self drawAdvancedNavArrayAtX:x+hoffset y:y+voffset z:z alpha:alpha usingRoute:nil optimizedBy:OPTIMIZED_BY_NONE zoom: zoom];
1947 }
1948 if (!routeExists)
1949 {
1950 NSPoint targetCoordinates = [systemManager getCoordinatesForSystem:target inGalaxy:galaxy_id];
1951
1953 if (distance == 0.0)
1954 {
1955 if (target != [
PLAYER systemID])
1956 {
1957
1958
1959 distance = 0.1;
1960 }
1961 }
1962 if ([player hasHyperspaceMotor] && distance <= [player fuel]/10.0)
1963 {
1964 time = distance * distance;
1965 }
1966 else
1967 {
1968 time = 0.0;
1969 }
1970 }
1971
1972 if ([player hasHyperspaceMotor])
1973 {
1974
1976 [
self setGLColorFromSetting:kGuiChartRangeColor defaultValue:[
OOColor greenColor] alpha:alpha];
1977
1978 GLDrawOval(
x + cu.x,
y + cu.y, z, NSMakeSize((
float)(fuel*hscale), 2*(
float)(fuel*vscale)), 5);
1979 }
1980
1981
1982
1983
1984 [
self setGLColorFromSetting:kGuiChartCrosshairColor defaultValue:[
OOColor greenColor] alpha:alpha];
1985
1986 [self drawCrossHairsWithSize:12/zoom+2 x:x + cu.x y:y + cu.y z:z];
1987
1988
1989
1990
1991 [
self setGLColorFromSetting:kGuiChartCursorColor defaultValue:[
OOColor redColor] alpha:alpha];
1992 cu = NSMakePoint((float)(hscale*cursor_coordinates.x+hoffset),(float)(vscale*cursor_coordinates.y+voffset));
1993 [self drawCrossHairsWithSize:7/zoom+2 x:x + cu.x y:y + cu.y z:z];
1994
1995
1996
1998 OOGL(glColor4f(1.0f, 1.0f, 0.75f, alpha));
1999
2000 for (i = 0; i < num_nearby_systems; i++)
2001 {
2002 NSPoint sys_coordinates = [systemManager getCoordinatesForSystem:i inGalaxy:galaxy_id];
2003
2004 dx = fabs(chart_centre_coordinates.x - sys_coordinates.x);
2005 dy = fabs(chart_centre_coordinates.y - sys_coordinates.y);
2006
2008 continue;
2009
2010
2012
2013 continue;
2014 }
2015
2016 NSDictionary *systemInfo = [systemManager getPropertiesForSystem:i inGalaxy:galaxy_id];
2017 float blob_factor = [guiUserSettings oo_floatForKey:kGuiChartCircleScale defaultValue:0.0017];
2018 float blob_size = (1.0f + blob_factor * [systemInfo oo_floatForKey:@"radius"])/zoom;
2019 if (blob_size < 0.5) blob_size = 0.5;
2020
2021 star.x = (float)(sys_coordinates.x * hscale + hoffset);
2022 star.y = (float)(sys_coordinates.y * vscale + voffset);
2023
2024 noNova = !nearby_systems[i].nova;
2025 NSAssert1(chart_mode <= OOLRC_MODE_TECHLEVEL, @"Long range chart mode %i out of range", (int)chart_mode);
2026
2027 NSArray *markers = [markedDestinations objectForKey:[NSNumber numberWithInt:i]];
2029 {
2030 GLfloat base_size = 0.5f * blob_size + 2.5f;
2031 [self drawSystemMarkers:markers atX:x+star.x andY:y+star.y andZ:z withAlpha:alpha andScale:base_size];
2032 }
2033
2035
2036 r = g = b = 0.7;
2037 OOGL(glColor4f(r, g, b, alpha));
2038 } else {
2039 switch (chart_mode)
2040 {
2041 case OOLRC_MODE_ECONOMY:
2043 {
2044 systemParameter = nearby_systems[i].eco;
2045 GLfloat ce1 = 1.0f - 0.125f * systemParameter;
2046 [self setGLColorFromSetting:[NSString stringWithFormat:kGuiChartEconomyUColor, (unsigned long)systemParameter]
2048 alpha:1.0];
2049 }
2050 else
2051 {
2052 r = g = b = 0.3;
2053 OOGL(glColor4f(r, g, b, alpha));
2054 }
2055 break;
2056 case OOLRC_MODE_GOVERNMENT:
2058 {
2059 systemParameter = nearby_systems[i].gov;
2060 [self setGLColorFromSetting:[NSString stringWithFormat:kGuiChartGovernmentUColor, (unsigned long)systemParameter]
2062 alpha:1.0];
2063 }
2064 else
2065 {
2066 r = g = b = 0.3;
2067 OOGL(glColor4f(r, g, b, alpha));
2068 }
2069 break;
2070 case OOLRC_MODE_TECHLEVEL:
2072 {
2073 systemParameter = nearby_systems[i].tec;
2074 r = 0.6;
2075 g = b = 0.20 + (0.05 * (GLfloat)systemParameter);
2076 }
2077 else
2078 {
2079 r = g = b = 0.3;
2080 }
2081 OOGL(glColor4f(r, g, b, alpha));
2082 break;
2083 case OOLRC_MODE_UNKNOWN:
2084 case OOLRC_MODE_SUNCOLOR:
2086 {
2087 r = g = b = 1.0;
2089 if (sunColor !=
nil) {
2091 alpha = 1.0;
2092 }
2093 }
2094 else
2095 {
2096 r = 1.0;
2097 g = 0.2;
2098 b = 0.0;
2099 }
2100 OOGL(glColor4f(r, g, b, alpha));
2101 break;
2102 }
2103 }
2104
2106 }
2107
2108
2109
2110 GLfloat systemNameScale = [guiUserSettings oo_floatForKey:kGuiChartLabelScale defaultValue:1.0];
2111
2113 [
self setGLColorFromSetting:kGuiChartMatchBoxColor defaultValue:[
OOColor greenColor] alpha:alpha];
2114
2115 int n_matches = 0, foundIndex = -1;
2116
2117 for (i = 0; i < 256; i++) if (systemsFound[i])
2118 {
2119 if(foundSystem == n_matches) foundIndex = i;
2120 n_matches++;
2121 }
2122
2123 if (n_matches == 0)
2124 {
2125 foundSystem = 0;
2126 }
2128 {
2129
2130 }
2131 else
2132 {
2133 for (i = 0; i < 256; i++)
2134 {
2136 {
2137 continue;
2138 }
2139
2140 BOOL mark = systemsFound[i];
2141 float marker_size = 8.0/zoom;
2142 NSPoint sys_coordinates = [systemManager getCoordinatesForSystem:i inGalaxy:galaxy_id];
2143
2144 dx = fabs(chart_centre_coordinates.x - sys_coordinates.x);
2145 dy = fabs(chart_centre_coordinates.y - sys_coordinates.y);
2146
2148 {
2149 star.x = (float)(sys_coordinates.x * hscale + hoffset);
2150 star.y = (float)(sys_coordinates.y * vscale + voffset);
2152 glVertex3f(
x + star.x - marker_size,
y + star.y - marker_size, z);
2153 glVertex3f(
x + star.x + marker_size,
y + star.y - marker_size, z);
2154 glVertex3f(
x + star.x + marker_size,
y + star.y + marker_size, z);
2155 glVertex3f(
x + star.x - marker_size,
y + star.y + marker_size, z);
2157 if (i == foundIndex || n_matches == 1)
2158 {
2159 if (n_matches == 1) foundSystem = 0;
2161 {
2162 [
self setGLColorFromSetting:kGuiChartMatchLabelColor defaultValue:[
OOColor cyanColor] alpha:alpha];
2163 OODrawString([
UNIVERSE systemNameIndex:i] ,
x + star.x + 2.0,
y + star.y - 10.0f, z, NSMakeSize(10*systemNameScale,10*systemNameScale));
2164 [
self setGLColorFromSetting:kGuiChartMatchBoxColor defaultValue:[
OOColor greenColor] alpha:alpha];
2165 }
2166 }
2168 {
2169 OODrawString([
UNIVERSE systemNameIndex:i] ,
x + star.x + 2.0,
y + star.y - 10.0f, z, NSMakeSize(10*systemNameScale,10*systemNameScale));
2170 }
2171 }
2172 }
2173 }
2174
2175
2176
2177
2178
2179 int targetIdx = -1;
2180 struct saved_system *sys;
2181 NSSize chSize = NSMakeSize(pixel_row_height*systemNameScale/zoom,pixel_row_height*systemNameScale/zoom);
2182
2184 for (i = 0; i < num_nearby_systems; i++)
2185 {
2187 {
2188 continue;
2189 }
2190
2191 sys = nearby_systems + i;
2192 NSPoint sys_coordinates = [systemManager getCoordinatesForSystem:sys->sysid inGalaxy:galaxy_id];
2193
2194 dx = fabs(chart_centre_coordinates.x - sys_coordinates.x);
2195 dy = fabs(chart_centre_coordinates.y - sys_coordinates.y);
2196
2198 continue;
2199 star.x = (float)(sys_coordinates.x * hscale + hoffset);
2200 star.y = (float)(sys_coordinates.y * vscale + voffset);
2201 if (sys->sysid == target)
2202 {
2203 targetIdx = i;
2204 }
2205
2206
2207
2209 {
2210 if (![player showInfoFlag])
2211 {
2212
2214 if (d <= jumpRange)
2215 {
2216 [
self setGLColorFromSetting:kGuiChartLabelReachableColor defaultValue:[
OOColor yellowColor] alpha:alpha];
2217 }
2218 else
2219 {
2220 [
self setGLColorFromSetting:kGuiChartLabelColor defaultValue:[
OOColor yellowColor] alpha:alpha];
2221
2222 }
2223
2224 OODrawString(sys->p_name,
x + star.x + 2.0,
y + star.y, z, chSize);
2225 }
2226 else if (
EXPECT(sys->gov >= 0))
2227 {
2229 {
2230 [
self setGLColorFromSetting:kGuiChartLabelColor defaultValue:[
OOColor yellowColor] alpha:alpha];
2232 }
2233 else
2234 {
2235 OODrawPlanetInfo(sys->gov, sys->eco, sys->tec,
x + star.x + 2.0,
y + star.y + 2.0, z, chSize);
2236 }
2237 }
2238 }
2239 }
2240
2241
2242
2244 {
2246 {
2247 sys = nearby_systems + targetIdx;
2248 NSPoint sys_coordinates = [systemManager getCoordinatesForSystem:sys->sysid inGalaxy:galaxy_id];
2249
2250 star.x = (float)(sys_coordinates.x * hscale + hoffset);
2251 star.y = (float)(sys_coordinates.y * vscale + voffset);
2252
2253 if (![player showInfoFlag])
2254 {
2256 if (d <= jumpRange)
2257 {
2258 [
self setGLColorFromSetting:kGuiChartLabelReachableColor defaultValue:[
OOColor yellowColor] alpha:alpha];
2259 }
2260 else
2261 {
2262 [
self setGLColorFromSetting:kGuiChartLabelColor defaultValue:[
OOColor yellowColor] alpha:alpha];
2263
2264 }
2265
2267 }
2268 else if (sys->gov >= 0)
2269 {
2271 {
2272 [
self setGLColorFromSetting:kGuiChartLabelColor defaultValue:[
OOColor yellowColor] alpha:alpha];
2274 }
2275 else
2276 {
2278 }
2279 }
2280 }
2281 }
2282
2284 tab_stops[0] = 0;
2285 tab_stops[1] = 96;
2286 tab_stops[2] = 288;
2287 [self overrideTabs:tab_stops from:kGuiChartTraveltimeTabs length:3];
2288 [self setTabStops:tab_stops];
2289 NSString *targetName = [[UNIVERSE getSystemName:target] retain];
2290
2291
2292 NSString *travelDistLine = @"";
2293 if (distance > 0)
2294 {
2295 travelDistLine =
OOExpandKey(
@"long-range-chart-distance", distance);
2296 }
2297 NSString *travelTimeLine = @"";
2298 if (time > 0)
2299 {
2300 travelTimeLine =
OOExpandKey(
@"long-range-chart-est-travel-time", time);
2301 }
2302
2304 {
2305 [self setArray:[NSArray arrayWithObjects:targetName, travelDistLine,travelTimeLine,nil] forRow:textRow];
2306 }
2307 else
2308 {
2309 [self setArray:[NSArray arrayWithObjects:@"", travelDistLine,travelTimeLine,nil] forRow:textRow];
2310 }
2311 if ([
PLAYER guiScreen] == GUI_SCREEN_SHORT_RANGE_CHART)
2312 {
2313 if (jumps > 0)
2314 {
2315 [self setArray:[NSArray arrayWithObjects: @"", OOExpandKey(@"short-range-chart-jumps", jumps), nil] forRow: textRow + 1];
2316 }
2317 else
2318 {
2319 [self setArray:[NSArray array] forRow: textRow + 1];
2320 }
2321 }
2322 [targetName release];
2323
2324
2326 [
self setGLColorFromSetting: kGuiChartInfoMarkerColor defaultValue:[
OOColor blueColor] alpha:alpha];
2327 cu = NSMakePoint((float)(hscale*info_system_coordinates.x+hoffset),(float)(vscale*info_system_coordinates.y+voffset));
2328 GLDrawOval(
x + cu.x,
y + cu.y, z, NSMakeSize(6.0f/zoom+2.0f, 6.0f/zoom+2.0f), 5);
2329
2330
2331 OOGL(glDisable(GL_SCISSOR_TEST));
2332
2333
2336 glVertex3f(
x + 0, (
float)(
y + size_in_pixels.height - (textRow-1)*
MAIN_GUI_ROW_HEIGHT - pixel_title_size.height), z);
2337 glVertex3f(
x + size_in_pixels.width, (GLfloat)(
y + size_in_pixels.height - (textRow-1)*
MAIN_GUI_ROW_HEIGHT - pixel_title_size.height), z);
2338 glVertex3f(
x + size_in_pixels.width, (GLfloat)(
y + size_in_pixels.height - (textRow-1)*
MAIN_GUI_ROW_HEIGHT - pixel_title_size.height - 2), z);
2339 glVertex3f(
x + 0, (GLfloat)(
y + size_in_pixels.height - (textRow-1)*
MAIN_GUI_ROW_HEIGHT - pixel_title_size.height - 2), z);
2341}
@ GUI_BACKGROUND_SPECIAL_CUSTOM_ANA_QUICKEST
@ GUI_BACKGROUND_SPECIAL_SHORT_ANA_SHORTEST
@ GUI_BACKGROUND_SPECIAL_LONG
@ GUI_BACKGROUND_SPECIAL_LONG_ANA_SHORTEST
@ GUI_BACKGROUND_SPECIAL_SHORT_ANA_QUICKEST
@ GUI_BACKGROUND_SPECIAL_LONG_ANA_QUICKEST
@ GUI_BACKGROUND_SPECIAL_CUSTOM_ANA_SHORTEST
OOGUITabStop OOGUITabSettings[GUI_MAX_COLUMNS]
#define MAIN_GUI_ROW_HEIGHT
static BOOL _refreshStarChart
void OODrawHilightedString(NSString *text, GLfloat x, GLfloat y, GLfloat z, NSSize siz)
void OODrawHilightedPlanetInfo(int gov, int eco, int tec, GLfloat x, GLfloat y, GLfloat z, NSSize siz)
void OODrawPlanetInfo(int gov, int eco, int tec, GLfloat x, GLfloat y, GLfloat z, NSSize siz)
void GLDrawFilledOval(GLfloat x, GLfloat y, GLfloat z, NSSize siz, GLfloat step)
void GLScaledLineWidth(GLfloat width)
void GLDrawOval(GLfloat x, GLfloat y, GLfloat z, NSSize siz, GLfloat step)
#define OOExpandKey(key,...)
@ OO_SYSTEMCONCEALMENT_NODATA
#define CHART_SCREEN_VERTICAL_CENTRE
@ GUI_ROW_CHART_SYSTEM_COMPACT
#define CHART_SCREEN_VERTICAL_CENTRE_COMPACT
#define CHART_CLIP_BORDER
OOColor * colorWithRed:green:blue:alpha:(float red,[green] float green,[blue] float blue,[alpha] float alpha)
OOLongRangeChartMode longRangeChartMode
OOGalaxyID galaxyNumber()
NSPoint galaxy_coordinates
NSPoint cursor_coordinates
OOSystemID infoSystemID()
NSPoint adjusted_chart_centre()
NSDictionary * markedDestinations()