Viewport zoom, adjust in redalert.ini(ZoomLevel) F5/F6 to zoom in and out.

This commit is contained in:
Justin Marshall
2020-07-27 10:52:41 -07:00
parent 364659e640
commit c28f4d0cfa
12 changed files with 307 additions and 59 deletions
+45 -12
View File
@@ -255,6 +255,12 @@ void DisplayClass::One_Time(void)
TransIconsetHD[2] = Image_LoadImage("ui/trans/trans2.png");
ShadowShapes = Image_LoadImage("ui/shroud.png");
Image_t* sceneAlbedoTexture = Image_CreateBlankImage("sceneAlbedoTexture", ScreenWidth, ScreenHeight, true);
Image_t* sceneDepthTexture = Image_CreateDepthImage("sceneDepthTexture", ScreenWidth, ScreenHeight);
sceneRenderTexture = new RenderTexture(sceneAlbedoTexture, sceneDepthTexture);
sceneRenderTexture->InitRenderTexture();
// jmarshall end
Set_View_Dimensions(0, 0);
@@ -285,6 +291,7 @@ void DisplayClass::Init_Clear(void)
*/
PendingObjectPtr = 0;
PendingObject = 0;
zoomLevel = 0;
PendingHouse = HOUSE_NONE;
CursorSize = 0;
IsTargettingMode = SPC_NONE;
@@ -1098,7 +1105,6 @@ void DisplayClass::AI(KeyNumType & input, int x, int y)
MapClass::AI(input, x, y);
}
/***********************************************************************************************
* DisplayClass::Submit -- Adds a game object to the map rendering system. *
* *
@@ -1179,11 +1185,10 @@ void DisplayClass::Remove(ObjectClass const * object, LayerType layer)
*=============================================================================================*/
CELL DisplayClass::Click_Cell_Calc(int x, int y) const
{
int tileX, tileY;
int tileX, tileY;
if (!CellClass::ScreenCoordsToIsoTile(x, y, tileX, tileY)) {
return -1;
}
x = tileX * CELL_PIXEL_W;
y = tileY * CELL_PIXEL_H;
@@ -1969,7 +1974,8 @@ void DisplayClass::CacheVisibleCells(void) {
MapClass::Draw_It(forced);
if (IsToRedraw || forced) {
GL_SetRenderTexture(sceneRenderTexture);
{
BStart(BENCH_TACTICAL);
IsToRedraw = false;
@@ -2135,14 +2141,6 @@ void DisplayClass::CacheVisibleCells(void) {
Layer[LAYER_GROUND][index]->IsToDisplay = false;
}
#endif
/*
** Draw the rubber band over the top of it all.
*/
if (IsRubberBand) {
LogicPage->Draw_Rect(BandX+TacPixelX, BandY+TacPixelY, NewX+TacPixelX, NewY+TacPixelY, WHITE);
}
/*
** Clear the redraw flags so that normal redraw flag setting can resume.
*/
@@ -2166,6 +2164,39 @@ void DisplayClass::CacheVisibleCells(void) {
#endif
BEnd(BENCH_TACTICAL);
}
/*
** Draw the rubber band over the top of it all.
*/
if (IsRubberBand) {
LogicPage->Draw_Rect(BandX + TacPixelX, BandY + TacPixelY, NewX + TacPixelX, NewY + TacPixelY, WHITE);
}
GL_SetRenderTexture(NULL);
int renderTargetScale = ZoomLevel;
if(Debug_Map) {
renderTargetScale = 0;
}
double scale = ((((float)ScreenWidth / (float)ScreenHeight) * (float)renderTargetScale) * 0.05) + 1;
GL_RenderImage(sceneRenderTexture->GetColorImage(0), 0, 0, ScreenWidth * scale, ScreenHeight * scale, 0, 0, true, true);
}
void DisplayClass::Pixel_To_Zoom(int& x, int& y) const {
if(Debug_Map) {
return;
}
int renderTargetScale = ZoomLevel;
if (Debug_Map) {
renderTargetScale = 0;
}
double scale = ((((float)ScreenWidth / (float)ScreenHeight) * (float)renderTargetScale) * 0.05) + 1;
x = x / scale;
y = y / scale;
}
/***********************************************************************************************
@@ -2901,6 +2932,8 @@ int DisplayClass::TacticalClass::Action(unsigned flags, KeyNumType & key)
x = Get_Mouse_X();
y = Get_Mouse_Y();
Map.Pixel_To_Zoom(x, y);
int screenX, screenY;
screenX = x;
screenY = y;
+5
View File
@@ -39,6 +39,7 @@
#include "layer.h"
#include "tacticalcoord.h"
class RenderTexture;
struct Image_t;
class BigOverlay;
@@ -102,6 +103,9 @@ class DisplayClass: public MapClass
short const *CursorSize;
short CursorShapeSave[256]; // For save/load
bool ProximityCheck; // Is proximity check ok?
int zoomLevel;
RenderTexture* sceneRenderTexture;
/*
** This holds the building type that is about to be placed upon the map.
@@ -187,6 +191,7 @@ class DisplayClass: public MapClass
void Select_These(COORDINATE coord1, COORDINATE coord2, bool additive = false);
COORDINATE Pixel_To_Coord(int x, int y) const;
bool Coord_To_Pixel(COORDINATE coord, int & x, int & y) const;
void Pixel_To_Zoom(int& x, int& y) const;
bool Push_Onto_TacMap(COORDINATE &source, COORDINATE &dest);
void Remove(ObjectClass const * object, LayerType layer);
void Submit(ObjectClass const * object, LayerType layer);
+1
View File
@@ -134,6 +134,7 @@ extern LPDIRECTSOUND SoundObject;
extern LPDIRECTSOUNDBUFFER PrimaryBufferPtr;
extern int ScreenWidth;
extern int ScreenHeight;
extern int ZoomLevel;
extern GraphicBufferClass ModeXBuff;
#else
+1
View File
@@ -186,6 +186,7 @@ GraphicBufferClass SysMemPage(DEFAULT_SCREEN_WIDTH, 200, (void*)NULL);
WinTimerClass * WindowsTimer=NULL;
int ScreenWidth=6072;
int ScreenHeight=6072;
int ZoomLevel = 6;
GraphicBufferClass ModeXBuff;
bool InMovie = FALSE; //Are we currently playing a VQ movie?
HANDLE hInstance;
+1
View File
@@ -56,6 +56,7 @@ bool Image_Add32BitImage(const char* name, Image_t* image, int HouseId, int Shap
Image_t* Image_CreateBlankImage(const char* name, int width, int height, bool hasAlpha);
void Image_UploadRaw(Image_t* image, uint8_t* data, bool paletteRebuild, uint8_t *palette, bool hasAlpha);
Image_t* Image_CreateDepthImage(const char* name, int width, int height);
void Sys_SetOverlayImage(Image_t* image);
+13
View File
@@ -124,6 +124,18 @@ void UserInputClass::Process_Input(KeyNumType& key, int& flags)
KeyB.Control = true;
}
if(state[SDL_SCANCODE_F5]) {
ZoomLevel--;
ZoomLevel = max(ZoomLevel, 0);
break;
}
if (state[SDL_SCANCODE_F6]) {
ZoomLevel++;
ZoomLevel = min(ZoomLevel, 6);
break;
}
// handle match between SDL and internals (non-text keys)
auto element = sdl_keyMapping.find((SDL_KeyCode)event.key.keysym.sym);
if (element != sdl_keyMapping.end())
@@ -140,6 +152,7 @@ void UserInputClass::Process_Input(KeyNumType& key, int& flags)
{
KeyB.ASCII = (char)event.text.text[0];
}
break;
}
if (Debug_Map || renderConsole)
+40 -34
View File
@@ -37,40 +37,46 @@ void LightManager::Init(void) {
}
void LightManager::RenderLights(void) {
if(Debug_Map) {
for (int i = 0; i < MAX_WORLD_LIGHTS; i++) {
if (!lights[i].active) {
continue;
}
if (!lights[i].isPending) {
int screenx, screeny;
lights[i].GetRenderPosition(screenx, screeny);
GL_RenderImage(lightEditorIcon, screenx, screeny, 30, 30);
}
}
}
GL_SetRenderTexture(hdrRenderTexture);
for (int i = 0; i < MAX_WORLD_LIGHTS; i++) {
if (!lights[i].active) {
continue;
}
if (!lights[i].isPending) {
int screenx, screeny;
lights[i].GetRenderPosition(screenx, screeny);
int halfRadius = lights[i].radius / 2;
GL_RenderImage(pointLightAttenImage0, screenx - halfRadius, ScreenHeight - (screeny + halfRadius), lights[i].radius, lights[i].radius);
}
}
GL_SetRenderTexture(NULL);
GL_EnableBlend(GL_BLEND_ADD);
GL_RenderImage(hdrLightBufferTexture, 0, 0, ScreenWidth, ScreenHeight);
GL_EnableBlend(GL_BLEND_NONE);
//if(Debug_Map) {
// for (int i = 0; i < MAX_WORLD_LIGHTS; i++) {
// if (!lights[i].active) {
// continue;
// }
//
// if (!lights[i].isPending) {
// int screenx, screeny;
// lights[i].GetRenderPosition(screenx, screeny);
// GL_RenderImage(lightEditorIcon, screenx, screeny, 30, 30);
// }
// }
//}
//
//GL_SetRenderTexture(hdrRenderTexture);
//
//for (int i = 0; i < MAX_WORLD_LIGHTS; i++) {
// if (!lights[i].active) {
// continue;
// }
//
// if (!lights[i].isPending) {
// int screenx, screeny;
// lights[i].GetRenderPosition(screenx, screeny);
// int halfRadius = lights[i].radius / 2;
// GL_RenderImage(pointLightAttenImage0, screenx - halfRadius, ScreenHeight - (screeny + halfRadius), lights[i].radius, lights[i].radius);
// }
//}
//
//GL_SetRenderTexture(NULL);
//
//GL_EnableBlend(GL_BLEND_ADD);
// int renderTargetScale = ZoomLevel;
// if (Debug_Map) {
// renderTargetScale = 0;
// }
// double scale = ((((float)ScreenWidth / (float)ScreenHeight) * (float)renderTargetScale) * 0.05) + 1;
//
// GL_RenderImage(hdrLightBufferTexture, 0, 0, ScreenWidth * scale, ScreenHeight * scale, 0, 0, true, true);
//GL_EnableBlend(GL_BLEND_NONE);
}
void LightManager::FreeAllLights(void) {
+20 -10
View File
@@ -19,7 +19,7 @@ static void GL_SetRenderTextureCallback(const ImDrawList* parent_list, const ImD
}
else {
renderTexture->MakeCurrent();
glClearColor(0.45, 0.45, 0.45, 1.0);
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
}
}
@@ -67,17 +67,27 @@ void GL_ResetClipRect(void) {
ImGui::GetBackgroundDrawList()->PopClipRect();
}
void GL_RenderImage(Image_t* image, int x, int y, int width, int height, int colorRemap, int shapeId) {
if(x < 0 || y < 0) {
return;
}
void GL_RenderImage(Image_t* image, int x, int y, int width, int height, int colorRemap, int shapeId, bool ignoreOutOfScreenPixels, bool flipUV) {
if (!ignoreOutOfScreenPixels)
{
if (x < 0 || y < 0) {
return;
}
if(x >= ScreenWidth || y >= ScreenHeight) {
return;
if (x >= ScreenWidth || y >= ScreenHeight) {
return;
}
}
ImVec2 mi(x, y);
ImVec2 ma(x + width, y + height);
ImVec2 uv(0, 0);
ImVec2 uv2(1, 1);
if(flipUV) {
uv.y = 1;
uv2.y = 0;
}
if (forceForgegroundRender) {
GL_RenderForeGroundImage(image, x, y, width, height, colorRemap, shapeId);
@@ -86,12 +96,12 @@ void GL_RenderImage(Image_t* image, int x, int y, int width, int height, int col
if (image->numFrames > 0) {
if(image->HouseImages[colorRemap].image[shapeId][((int)animFrameNum) % image->numFrames] == 0)
ImGui::GetBackgroundDrawList()->AddImage((ImTextureID)image->HouseImages[colorRemap].image[shapeId][0], mi, ma, ImVec2(0, 0), ImVec2(1, 1), g_currentColor);
ImGui::GetBackgroundDrawList()->AddImage((ImTextureID)image->HouseImages[colorRemap].image[shapeId][0], mi, ma, uv, uv2, g_currentColor);
else
ImGui::GetBackgroundDrawList()->AddImage((ImTextureID)image->HouseImages[colorRemap].image[shapeId][((int)animFrameNum) % image->numFrames], mi, ma, ImVec2(0, 0), ImVec2(1, 1), g_currentColor);
ImGui::GetBackgroundDrawList()->AddImage((ImTextureID)image->HouseImages[colorRemap].image[shapeId][((int)animFrameNum) % image->numFrames], mi, ma, uv, uv2, g_currentColor);
}
else {
ImGui::GetBackgroundDrawList()->AddImage((ImTextureID)image->HouseImages[colorRemap].image[shapeId][0], mi, ma, ImVec2(0, 0), ImVec2(1, 1), g_currentColor);
ImGui::GetBackgroundDrawList()->AddImage((ImTextureID)image->HouseImages[colorRemap].image[shapeId][0], mi, ma, uv, uv2, g_currentColor);
}
}
+1 -1
View File
@@ -10,7 +10,7 @@ enum GLBlendType {
GL_BLEND_ADD
};
void GL_RenderImage(Image_t* image, int x, int y, int width, int height, int colorRemap = 0, int shapeId = 0);
void GL_RenderImage(Image_t* image, int x, int y, int width, int height, int colorRemap = 0, int shapeId = 0, bool ignoreOutOfScreenPixels = false, bool flipUV = false);
void GL_RenderForeGroundImage(Image_t* image, int x, int y, int width, int height, int colorRemap = 0, int shapeId = 0);
void GL_DrawText(int color, int x, int y, char* text);
void GL_FillRect(int color, int x, int y, int width, int height);
+1
View File
@@ -932,6 +932,7 @@ void Read_Setup_Options( RawFileClass *config_file )
ScreenWidth = ini.Get_Int("Options", "Width", 1280);
ScreenHeight = ini.Get_Int("Options", "Height", 720);
ZoomLevel = ini.Get_Int("Options", "ZoomLevel", 0);
/*
** See if an alternative socket number has been specified
+42 -2
View File
@@ -315,8 +315,8 @@ Image_t* Image_CreateBlankImage(const char* name, int width, int height, bool ha
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
strcpy(image->name, name);
@@ -330,6 +330,46 @@ Image_t* Image_CreateBlankImage(const char* name, int width, int height, bool ha
return image;
}
Image_t* Image_CreateDepthImage(const char* name, int width, int height) {
int64_t hash = generateHashValue(name, strlen(name));
int image_table_size = loaded_images.size();
if (image_table_size > 0)
{
Image_t** image_table = &loaded_images[0];
// Check to see if the image is already loaded.
for (int i = 0; i < image_table_size; i++) {
if (image_table[i]->namehash == hash) {
return image_table[i];
}
}
}
Image_t* image = new Image_t();
GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
strcpy(image->name, name);
image->HouseImages[0].image[0][0] = texture;
image->namehash = hash;
image->renderwidth[0] = image->width = width;
image->renderheight[0] = image->height = height;
loaded_images.push_back(image);
return image;
}
void Image_UploadRaw(Image_t* image, uint8_t* data, bool paletteRebuild, uint8_t* palette, bool hasAlpha) {
if (image->ScratchBuffer == NULL && paletteRebuild) {
image->ScratchBuffer = new uint8_t[image->width * image->height * 4];
+137
View File
@@ -0,0 +1,137 @@
[Options]
ScrollFix=Yes
LimitCpuUsage=Yes
SlowerScrollrate=No
HardwareFills=No
VideoBackBuffer=Yes
Resolution=400
Width=1280
Height=720
ZoomLevel=6
ShowAllMusic=Yes
PlayEnglishIntro=Yes
VideoInterlaceMode=2
SkipScoreScreen=No
RandomStartingSong=No
GameLanguage=1
Show640x480BlackBars=false
MouseWheelScrolling=Yes
DisplayOriginalMultiplayerMaps=Yes
DisplayCounterstrikeMultiplayerMaps=Yes
DisplayAftermathMultiplayerMaps=Yes
UseSmallInfantry=No
NoCD=Yes
CounterstrikeEnabled=Yes
AftermathEnabled=Yes
ScoreVolume=0.5
GameSpeed=2
ScrollRate=5
Brightness=0.5
Volume=0.375
MultiplayerScoreVolume=0.5
Contrast=0.5
Color=0.5
Tint=0.5
AutoScroll=yes
IsScoreRepeat=no
IsScoreShuffle=no
PaletteScroll=yes
[MultiplayerDefaults]
Money=10000
ShroudRegrows=No
CaptureTheFlag=No
Crates=No
Bases=Yes
OreRegenerates=Yes
UnitCount=0
TechLevel=10
AIDifficulty=1
AIPlayers=1
[Intro]
PlayIntro=no
[WinHotkeys]
KeySellOf=0
KeySidebarToggle=36
KeyQuickSave=80
KeyQuickLoad=76
KeyDebug=73
KeyForceMove1=18
KeyForceMove2=18
KeyForceAttack1=17
KeyForceAttack2=17
KeySelect1=16
KeySelect2=16
KeyScatter=88
KeyStop=83
KeyGuard=71
KeyNext=78
KeyPrevious=77
KeyFormation=67
KeyHome1=36
KeyHome2=103
KeyBase=72
KeyResign=35
KeyAlliance=65
KeyBookmark1=86
KeyBookmark2=32
KeyBookmark3=82
KeyBookmark4=87
KeySelectView=69
KeyRepairToggle=84
KeyRepairOn=0
KeyRepairOff=0
KeySellToggle=90
KeySellOn=0
KeySellOff=0
KeyMapToggle=66
KeySidebarUp=68
KeySidebarDown=70
KeyOption1=27
KeyOption2=0
KeyScrollLeft=37
KeyScrollRight=39
KeyScrollUp=38
KeyScrollDown=40
KeyQueueMove1=81
KeyQueueMove2=81
KeyTeam1=49
KeyTeam2=50
KeyTeam3=51
KeyTeam4=52
KeyTeam5=53
KeyTeam6=54
KeyTeam7=55
KeyTeam8=56
KeyTeam9=57
KeyTeam10=48
[MultiPlayer]
PhoneIndex=-1
Color=0
Side=2
Handle=Red-Alert
[ConfigTool]
UseRAAspectRatio=No
ConfigToolTab=0
[Launcher]
ShowThreadingIssuesWarning=Yes
[SerialDefaults]
CallWaitStringIndex=3
InitStringIndex=0
DialMethod=T
Baud=-1
IRQ=-1
Port=0h
Compression=0
ErrorCorrection=0
HardwareFlowControl=1
[InitStrings]
000=ATZ