MCPcopy Create free account
hub / github.com/SimHacker/micropolis / ForceOnScreen

Method ForceOnScreen

MicropolisCore/src/CellEngine/src/cellengine.cpp:508–542  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

506
507
508void CellEngine::ForceOnScreen()
509{
510 int hangout;
511 int xx = x;
512 int yy = y;
513 int ww = idealWidth;
514 int hh = idealHeight;
515 int ww2 = width;
516 int hh2 = height;
517
518 hangout = (xx + ww2) - screenWidth;
519 if (hangout > 0) {
520 xx -= hangout;
521 }
522 hangout = (yy + hh2) - screenHeight;
523 if (hangout > 0) {
524 yy -= hangout;
525 }
526 hangout = -xx;
527 if (hangout > 0) {
528 xx += hangout;
529 }
530 hangout = -yy;
531 if (hangout > 0) {
532 yy -= hangout;
533 }
534 if ((xx + ww2) > screenWidth) {
535 ww = screenWidth - xx;
536 }
537 if ((yy + hh2) > screenHeight) {
538 hh = screenHeight - yy;
539 }
540
541 SetRect(xx, yy, ww, hh);
542}
543
544
545long CellEngine::OnScreen()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected