# HG changeset patch # User sheepluva # Date 1526458260 -7200 # Node ID 32a1696ca93aa38d4d95cd81c754e92e086b1505 # Parent 706b34d0ce602180e917df3db90601e4c680f18c WIP: make chat resizing faster hold shift for pixel-precise size changes diff -r 706b34d0ce60 -r 32a1696ca93a hedgewars/uChat.pas --- a/hedgewars/uChat.pas Tue May 15 23:47:07 2018 +0200 +++ b/hedgewars/uChat.pas Wed May 16 10:11:00 2018 +0200 @@ -129,8 +129,8 @@ LastChatScaleValue:= ChatScaleValue; LastUIScaleValue:= UIScaleValue; - // determine font size - note: +0.1 to because I don't trust float inaccuracy combined with floor - fntSize:= max(1, floor(UIScaleValue * ChatScaleValue * Fontz[fnt16].Height + 0.1)); + // determine font size - note: +0.001 to because I don't trust float inaccuracy combined with floor + fntSize:= max(1, floor(UIScaleValue * ChatScaleValue * cBaseChatFontHeight + 0.001)); if Fontz[fntChat].Height <> fntSize then begin @@ -154,26 +154,36 @@ UpdateCursorCoords(); end; -procedure ChatSizeInc(); +procedure ChatSizeInc(pxprecise: boolean); +var fntSize: integer; begin -// TODO cChatMinScaleLevel, cChatSizeDelta (probably half of cZoomDelta) -// TODO always - effectively -- increase font by 1px? -if ChatScaleValue < cMinZoomLevel then +if pxprecise then begin - ChatScaleValue:= ChatScaleValue + cZoomDelta; - AdjustToUIScale(); - end; + fntSize:= Fontz[fntChat].Height; + inc(fntSize); + ChatScaleValue:= 1.0 * fntSize / cBaseChatFontHeight; + end +else + ChatScaleValue:= ChatScaleValue * (1.0 + cChatScaleRelDelta); +if ChatScaleValue > cMaxChatScaleValue then + ChatScaleValue:= cMaxChatScaleValue; +AdjustToUIScale(); end; -procedure ChatSizeDec(); +procedure ChatSizeDec(pxprecise: boolean); +var fntSize: integer; begin -// TODO cChatMaxScaleLevel, cChatSizeDelta (probably half of cZoomDelta) -// TODO always - effectively -- increase font by 1px? -if ChatScaleValue > cMaxZoomLevel then +if pxprecise then begin - ChatScaleValue:= ChatScaleValue - cZoomDelta; - AdjustToUIScale(); - end; + fntSize:= Fontz[fntChat].Height; + dec(fntSize); + ChatScaleValue:= 1.0 * fntSize / cBaseChatFontHeight; + end +else + ChatScaleValue:= ChatScaleValue / (1.0 + cChatScaleRelDelta); +if ChatScaleValue < cMinChatScaleValue then + ChatScaleValue:= cMinChatScaleValue; +AdjustToUIScale(); end; procedure chatSizeReset(); @@ -1091,7 +1101,7 @@ begin if ctrl then begin - ChatSizeInc(); + ChatSizeInc(selMode); SkipNextInput:= true; end; end; @@ -1100,7 +1110,7 @@ begin if ctrl then begin - ChatSizeDec(); + ChatSizeDec(selMode); SkipNextInput:= true; end; end; diff -r 706b34d0ce60 -r 32a1696ca93a hedgewars/uConsts.pas --- a/hedgewars/uConsts.pas Tue May 15 23:47:07 2018 +0200 +++ b/hedgewars/uConsts.pas Wed May 16 10:11:00 2018 +0200 @@ -194,7 +194,13 @@ // do not change this value cDefaultZoomLevel = 2.0; + + cBaseChatFontHeight = 12; cDefaultChatScaleLevel = 1.0; + cChatScaleRelDelta = 0.1; + cMinChatScaleValue = 0.8; + cMaxChatScaleValue = 20; + cDefaultUIScaleLevel = 1.0; // game flags