42#define EXTRADATA_TYPE mapExtraData_t
43#define EXTRADATA(node) UI_EXTRADATA(node, EXTRADATA_TYPE)
44#define EXTRADATACONST(node) UI_EXTRADATACONST(node, EXTRADATA_TYPE)
108 const float epsilon = 0.1f;
109 if (diffAngle > epsilon) {
113 rotationSpeed = sin(3.05f * diffAngle /
UI_MAPEXTRADATACONST(node).smoothDeltaLength) * diffAngle;
115 rotationSpeed = std::min(diffAngle,
UI_MAPEXTRADATACONST(node).curRotationSpeed + rotationSpeed * 0.5f);
124 const float epsilonZoom = 0.01f;
126 if (fabsf(diffZoom) > epsilonZoom) {
133 speed = std::min(maxSpeed, newSpeed);
158 const float length = sqrt(dist1 * dist1 + dist2 * dist2);
182 const float sin_q = sin(q);
183 const float cos_q = cos(q);
188 const float phi = x * dphi - q;
189 sin_phi[x] = sin(phi);
190 cos_phi[x] = cos(phi);
197 const float root = sqrt(1 - a * a);
199 const float pos = sin_phi[x] * root * sin_q - (a *
SIN_ALPHA + cos_phi[x] * root *
COS_ALPHA) * cos_q;
203 else if (pos <= -
DAWN)
206 *px++ = (
byte) (128.0 * (pos /
DAWN + 1));
246 data.geoscapeNode = node;
251 const char* map =
data.map;
256 static float lastQ = 0.0f;
270 bool disableSolarRender =
false;
272 disableSolarRender =
true;
300 for (
int i = 0;
i < 2;
i++) {
379 while (pos[0] > 180.0)
381 while (pos[0] < -180.0)
404 dist = sqrt((x - mid[0]) * (x - mid[0]) + (y - mid[1]) * (y - mid[1]));
416 v[0] = - (y - mid[1]);
417 v[1] = - (x - mid[0]);
418 v[2] = - sqrt(radius * radius - (x - mid[0]) * (x - mid[0]) - (y - mid[1]) * (y - mid[1]));
512 bool down = deltaY > 0;
548 m->zoom(node,
false);
564 const float zoomAmount = 50.0f;
584 Com_Printf(
"UI_GeoscapeNodeZoom_f: Invalid parameter: %s\n", cmd);
614 float scrollX = 0.0f, scrollY = 0.0f;
615 const float scrollAmount = 80.0f;
630 scrollX = scrollAmount;
633 scrollX = -scrollAmount;
636 scrollY = scrollAmount;
639 scrollY = -scrollAmount;
642 Com_Printf(
"UI_GeoscapeNodeScroll_f: Invalid parameter\n");
681 for (
int i = 0;
i < 2;
i++) {
696 behaviour->
name =
"geoscape";
DateTime class definition.
void GAME_DrawMap(geoscapeData_t *data)
void GAME_DrawMapMarkers(uiNode_t *node)
geoscapeData_t geoscapeData
void GAME_MapClick(uiNode_t *node, int x, int y, const vec2_t pos)
Shared game type headers.
Header file for keyboard handler.
Share stuff between the different cgame implementations.
static const int SECONDS_PER_DAY
static const short SECONDS_PER_HOUR
static const int DAYS_PER_YEAR
void onLoading(uiNode_t *node) override
Called before loading. Used to set default attribute values.
void screenToMap(const uiNode_t *node, int x, int y, vec2_t pos)
Return longitude and latitude of a point of the screen for 2D geoscape.
void screenTo3DMap(const uiNode_t *node, int x, int y, vec2_t pos)
Return longitude and latitude of a point of the screen for 3D geoscape (globe).
void smoothTranslate(uiNode_t *node)
smooth translation of the 2D geoscape
void startMouseShifting(uiNode_t *node, int x, int y)
void onMouseUp(uiNode_t *node, int x, int y, int button) override
bool onStartDragging(uiNode_t *node, int startX, int startY, int currentX, int currentY, int button) override
Send mouse event when a pressed mouse button is dragged.
void calcAndUploadDayAndNightTexture(uiNode_t *node, float q)
Applies alpha values to the night overlay image for 2d geoscape.
void onCapturedMouseLost(uiNode_t *node) override
Called when the node have lost the captured node We clean cached data.
void draw(uiNode_t *node) override
void smoothRotate(uiNode_t *node)
smooth rotation of the 3D geoscape
bool onScroll(uiNode_t *node, int deltaX, int deltaY) override
void zoom(uiNode_t *node, bool out)
void onCapturedMouseMove(uiNode_t *node, int x, int y) override
void onLeftClick(uiNode_t *node, int x, int y) override
const char * Cmd_Argv(int arg)
Returns a given argument.
int Cmd_Argc(void)
Return the number of arguments of the current command. "command parameter" will result in a argc of 2...
void Cmd_AddCommand(const char *cmdName, xcommand_t function, const char *desc)
Add a new command to the script interface.
void Com_Printf(const char *const fmt,...)
static uiNode_t * geoscapeNode
float Cvar_GetValue(const char *varName)
Returns the float value of a cvar.
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
vec_t VectorNormalize(vec3_t v)
Calculate unit vector for a given vec3_t.
vec_t VectorLength(const vec3_t v)
Calculate the length of a vector.
void RotatePointAroundVector(vec3_t dst, const vec3_t dir, const vec3_t point, float degrees)
Rotate a point around a given vector.
void VecToPolar(const vec3_t v, vec2_t a)
Converts vector coordinates into polar coordinates.
#define Mem_AllocTypeN(type, n)
bool R_EnableRenderbuffer(bool enable)
Enable the render to the framebuffer.
void R_DrawFlatGeoscape(const vec2_t nodePos, const vec2_t nodeSize, float p, float cx, float cy, float iz, const char *map, bool overlayNation, bool overlayXVI, bool overlayRadar, image_t *r_dayandnightTexture, image_t *r_xviTexture, image_t *r_radarTexture)
Draw the day and night images of a flat geoscape multitexture feature is used to blend the images.
void R_DrawBloom(void)
handle post-processing bloom
void R_Draw3DGlobe(const vec2_t pos, const vec2_t size, int day, int second, const vec3_t rotate, float zoom, const char *map, bool disableSolarRender, float ambient, bool overlayNation, bool overlayXVI, bool overlayRadar, image_t *r_xviTexture, image_t *r_radarTexture, bool renderNationGlow)
responsible for drawing the 3d globe on geoscape param[in] rotate the rotate angle of the globe param...
QGL_EXTERN int GLboolean GLfloat * v
QGL_EXTERN GLsizei const GLvoid * data
QGL_EXTERN GLuint GLsizei GLsizei * length
image_t * R_LoadImageData(const char *name, const byte *pic, int width, int height, imagetype_t type)
Creates a new image from RGBA data. Stores it in the gltextures array and also uploads it.
void R_UploadAlpha(const image_t *image, const byte *alphaData)
Header for lua script functions.
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
node behaviour, how a node work
Contain the context of the calling of a function.
Atomic structure used to define most of the UI.
uiBehaviour_t * behaviour
const struct value_s * UI_RegisterNodeMethod(uiBehaviour_t *behaviour, const char *name, uiNodeMethod_t function)
Register a node method to a behaviour.
#define UI_RegisterExtradataNodeProperty(BEHAVIOUR, NAME, TYPE, EXTRADATATYPE, ATTRIBUTE)
Initialize a property from extradata of node.
void * UI_SWIG_TypeQuery(const char *name)
This function queries the SWIG type table for a type information structure. It is used in combination...
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
void UI_GetNodeScreenPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node in the screen. Screen position is not used for the node rende...
SharedPtr< uiNode > UINodePtr
image_t * r_dayandnightTexture
static void UI_GeoscapeNodeZoomOut(uiNode_t *node, const uiCallContext_t *context)
static cvar_t * cl_mapzoommax
static void UI_GeoscapeNodeZoom_f(void)
Command binding for map zooming.
static void UI_GeoscapeNodeScroll_f(void)
Command binding for map scrolling.
mapDragMode_t
Status of the node.
void UI_RegisterGeoscapeNode(uiBehaviour_t *behaviour)
static const float SMOOTHING_STEP_2D
static const float SMOOTHACCELERATION
static cvar_t * cl_mapzoommin
static cvar_t * cl_3dmapAmbient
static void UI_GeoscapeNodeZoomIn(uiNode_t *node, const uiCallContext_t *context)
#define UI_MAPEXTRADATACONST(node)
#define GLOBE_RADIUS
radius of the globe in screen coordinates
#define UI_MAPEXTRADATA(node)
void UI_PushClipRect(int x, int y, int width, int height)
void UI_PopClipRect(void)
#define Vector4Set(v, r, g, b, a)
#define VectorSubtract(a, b, dest)
#define VectorCopy(src, dest)
#define Vector2Set(v, x, y)
#define VectorAdd(a, b, dest)
#define VectorSet(v, x, y, z)
#define VectorScale(in, scale, out)
#define Vector2Copy(src, dest)