| 143 | } |
| 144 | |
| 145 | void |
| 146 | mswin_map_layout(HWND hWnd, LPSIZE map_size) |
| 147 | { |
| 148 | /* check arguments */ |
| 149 | if (!IsWindow(hWnd) || !map_size || map_size->cx <= 0 |
| 150 | || map_size->cy <= 0) |
| 151 | return; |
| 152 | |
| 153 | PNHMapWindow data = (PNHMapWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA); |
| 154 | |
| 155 | /* calculate window size */ |
| 156 | RECT client_rt; |
| 157 | GetClientRect(hWnd, &client_rt); |
| 158 | |
| 159 | SIZE wnd_size; |
| 160 | wnd_size.cx = client_rt.right - client_rt.left; |
| 161 | wnd_size.cy = client_rt.bottom - client_rt.top; |
| 162 | |
| 163 | // calculate back buffer scale |
| 164 | data->monitorScale = win10_monitor_scale(hWnd); |
| 165 | |
| 166 | boolean bText = data->bAsciiMode || |
| 167 | (u.uz.dlevel != 0 && Is_rogue_level(&u.uz)); |
| 168 | |
| 169 | if (bText && !data->bFitToScreenMode) |
| 170 | data->backScale = data->monitorScale; |
| 171 | else |
| 172 | data->backScale = 1.0; |
| 173 | |
| 174 | /* set back buffer tile size */ |
| 175 | if (bText && data->bFitToScreenMode) { |
| 176 | data->xBackTile = wnd_size.cx / COLNO; |
| 177 | data->yBackTile = wnd_size.cy / ROWNO; |
| 178 | data->yBackTile = max(data->yBackTile, 12); |
| 179 | } else { |
| 180 | data->xBackTile = (int)(data->tileWidth * data->backScale); |
| 181 | data->yBackTile = (int)(data->tileHeight * data->backScale); |
| 182 | } |
| 183 | |
| 184 | if (bText) { |
| 185 | LOGFONT lgfnt; |
| 186 | |
| 187 | ZeroMemory(&lgfnt, sizeof(lgfnt)); |
| 188 | if (data->bFitToScreenMode) { |
| 189 | lgfnt.lfHeight = -data->yBackTile; // height of font |
| 190 | lgfnt.lfWidth = 0; // average character width |
| 191 | } else { |
| 192 | lgfnt.lfHeight = -data->yBackTile; // height of font |
| 193 | lgfnt.lfWidth = -data->xBackTile; // average character width |
| 194 | } |
| 195 | lgfnt.lfEscapement = 0; // angle of escapement |
| 196 | lgfnt.lfOrientation = 0; // base-line orientation angle |
| 197 | lgfnt.lfWeight = FW_NORMAL; // font weight |
| 198 | lgfnt.lfItalic = FALSE; // italic attribute option |
| 199 | lgfnt.lfUnderline = FALSE; // underline attribute option |
| 200 | lgfnt.lfStrikeOut = FALSE; // strikeout attribute option |
| 201 | lgfnt.lfCharSet = mswin_charset(); // character set identifier |
| 202 | lgfnt.lfOutPrecision = OUT_DEFAULT_PRECIS; // output precision |
no test coverage detected