branch | ui-scaling |
changeset 15664 | 0b99e220568a |
parent 15283 | c4fd2813b127 |
child 15665 | 63e2b7b2ec47 |
child 15672 | b3c9f5463cee |
15663:d92eeb468dad | 15664:0b99e220568a |
---|---|
92 (ChatCmd: '/history'; ProcedureCallChatCmd: 'history'), |
92 (ChatCmd: '/history'; ProcedureCallChatCmd: 'history'), |
93 (ChatCmd: '/fullscreen'; ProcedureCallChatCmd: 'fullscr') |
93 (ChatCmd: '/fullscreen'; ProcedureCallChatCmd: 'fullscr') |
94 ); |
94 ); |
95 |
95 |
96 |
96 |
97 const PaddingFactor = (1/6); // relative to font size |
97 const PaddingFactor = 0.125; // relative to font size in pixels |
98 |
98 |
99 var Padding, ClHeight: integer; |
99 var Padding, ClHeight: integer; |
100 LastChatScaleValue, LastUIScaleValue: real; |
100 LastChatScaleValue, LastUIScaleValue: real; |
101 SkipNextInput: boolean; |
101 SkipNextInput: boolean; |
102 |
102 |
119 begin |
119 begin |
120 selectedPos:= -1; |
120 selectedPos:= -1; |
121 end; |
121 end; |
122 |
122 |
123 procedure AdjustToUIScale(); |
123 procedure AdjustToUIScale(); |
124 var fntSize: integer; |
124 var fntSize, fntSizePx: integer; |
125 begin |
125 begin |
126 // don't do anything if no change |
126 // don't do anything if no change |
127 if (ChatScaleValue = LastChatScaleValue) and (UIScaleValue = LastUIScaleValue) then |
127 if (ChatScaleValue = LastChatScaleValue) and (UIScaleValue = LastUIScaleValue) then |
128 exit; |
128 exit; |
129 |
129 |
130 LastChatScaleValue:= ChatScaleValue; |
130 LastChatScaleValue:= ChatScaleValue; |
131 LastUIScaleValue:= UIScaleValue; |
131 LastUIScaleValue:= UIScaleValue; |
132 |
132 |
133 // determine font size - note: +0.001 to because I don't trust float inaccuracy combined with trunc |
133 fntSize:= max(1, round(UIScaleValue * ChatScaleValue * cBaseChatFontHeight)); |
134 fntSize:= max(1, trunc(UIScaleValue * ChatScaleValue * cBaseChatFontHeight + 0.001)); |
|
135 |
134 |
136 if Fontz[fntChat].Height <> fntSize then |
135 if Fontz[fntChat].Height <> fntSize then |
137 begin |
136 begin |
138 // adjust associated heights |
137 // adjust associated heights |
139 Fontz[fntChat].Height:= fntSize; |
138 Fontz[fntChat].Height:= fntSize; |
144 if Fontz[CJKfntChat].Handle <> nil then |
143 if Fontz[CJKfntChat].Handle <> nil then |
145 LoadFont(CJKfntChat); |
144 LoadFont(CJKfntChat); |
146 end; |
145 end; |
147 |
146 |
148 // adjust line height etc. |
147 // adjust line height etc. |
149 Padding:= max(1, trunc(PaddingFactor * fntSize + 0.1)); |
148 fntSizePx:= round(cFontPxToPtRatio * fntSize); |
150 ClHeight:= 2 * Padding + fntSize; |
149 Padding:= max(1, round(PaddingFactor * fntSizePx)); |
150 |
|
151 ClHeight:= 2 * Padding + fntSizePx; |
|
151 |
152 |
152 // clear cache of already rendered lines |
153 // clear cache of already rendered lines |
153 ReloadLines(); |
154 ReloadLines(); |
154 UpdateInputLinePrefix(); |
155 UpdateInputLinePrefix(); |
155 UpdateCursorCoords(); |
156 UpdateCursorCoords(); |
283 strSurface:= TTF_RenderUTF8_Blended(Fontz[font].Handle, Str2PChar(str), cl.color); |
284 strSurface:= TTF_RenderUTF8_Blended(Fontz[font].Handle, Str2PChar(str), cl.color); |
284 // fix format |
285 // fix format |
285 if strSurface <> nil then tmpSurface:= SDL_ConvertSurface(strSurface, resSurface^.format, 0); |
286 if strSurface <> nil then tmpSurface:= SDL_ConvertSurface(strSurface, resSurface^.format, 0); |
286 SDL_FreeSurface(strSurface); |
287 SDL_FreeSurface(strSurface); |
287 //SDL_UpperBlit(strSurface, nil, resSurface, @dstrect); |
288 //SDL_UpperBlit(strSurface, nil, resSurface, @dstrect); |
288 if tmpSurface <> nil then copyToXY(tmpSurface, resSurface, Padding, 2); |
289 if tmpSurface <> nil then copyToXY(tmpSurface, resSurface, Padding, Padding); |
289 SDL_FreeSurface(tmpSurface); |
290 SDL_FreeSurface(tmpSurface); |
290 |
291 |
291 cl.Tex:= Surface2Tex(resSurface, false); |
292 cl.Tex:= Surface2Tex(resSurface, false); |
292 |
293 |
293 SDL_FreeSurface(resSurface) |
294 SDL_FreeSurface(resSurface) |
415 |
416 |
416 if selectedPos < 0 then |
417 if selectedPos < 0 then |
417 begin |
418 begin |
418 // draw cursor |
419 // draw cursor |
419 if ((RealTicks - LastKeyPressTick) and 512) < 256 then |
420 if ((RealTicks - LastKeyPressTick) and 512) < 256 then |
420 DrawLineOnScreen(left + cursorX, top + Padding, left + cursorX, top + ClHeight - Padding, 2.0, $00, $FF, $FF, $FF); |
421 DrawLineOnScreen(left + cursorX, top + Padding, left + cursorX, top + ClHeight - Padding, max(2, round(UIScaleValue * ChatScaleValue * 2.0)), $00, $FF, $FF, $FF); |
421 end |
422 end |
422 else // draw selection |
423 else // draw selection |
423 begin |
424 begin |
424 selRect.y:= top + Padding; |
425 selRect.y:= top + Padding; |
425 selRect.h:= clHeight - 2 * Padding; |
426 selRect.h:= clHeight - 2 * Padding; |