Skip to content

Commit

Permalink
#228 Created More VRow operations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich2 committed Mar 23, 2023
1 parent 3cdd90d commit eeeef17
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Dev/srcStrat/dless/DLessGui.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ case class DLessGui(canv: CanvasPlatform, scenIn: DLessScen, viewIn: HGView, isF

override def frame: GraphicElems =
{
def lines2: GraphicElems = proj.ifTileScale(50, lines1)
//def lines2: GraphicElems = proj.ifTileScale(50, lines1)

def hexStrs: RArr[TextGraphic] = terrs.hcOptFlatMap { (hc, terr) =>
proj.transOptCoord(hc).map { pt =>
Expand All @@ -33,15 +33,15 @@ case class DLessGui(canv: CanvasPlatform, scenIn: DLessScen, viewIn: HGView, isF

def units: GraphicElems = armies.projSomeHcPtMap { (army, hc, pt) =>
val str = ptScale.scaledStr(170, army.toString + "\n" + hc.strComma, 150, "A" + "\n" + hc.strComma, 60, army.toString)
pStrat.UnitCounters.infantry(proj.pixelsPerTile * 0.6, HCenPair(hc, army), army.colour).slate(pt) //.fillDrawTextActive(p.colour, p.polity, str, 24, 2.0)
pStrat.UnitCounters.infantry(proj.pixelsPerTile * 0.45, HCenPair(hc, army), army.colour).slate(pt) //.fillDrawTextActive(p.colour, p.polity, str, 24, 2.0)
}

def moveSegPairs: LineSegPairArr[Army] = moves.optMapOnA1(_.projLineSeg)

/** This is the graphical display of the planned move orders. */
def moveGraphics: GraphicElems = moveSegPairs.pairFlatMap { (seg, pl) => seg.draw(pl.colour).arrow }

tileBackFills ++ tileFrontFills ++ tileActives ++ sideFills ++ sideActives ++ lines2 ++ hexStrs2 ++ units ++ moveGraphics
tileBackFills ++ tileFrontFills ++ tileActives ++ sideFills ++ sideActives ++ lines2 ++ lines4 ++ hexStrs2 ++ units ++ moveGraphics
}

/** Creates the turn button and the action to commit on mouse click. */
Expand Down
2 changes: 2 additions & 0 deletions EGrid/src/eg320/Terr320E30.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ object Terr320E30 extends Long320Terrs
TRow(130, Head4Land(2, Hilly), Head4Land(3, Hilly), Head3Land(1, Hilly), Head2Land(3, Hilly), hills * 4),
VRow(129, MouthUR(1536)),
TRow(128, sea * 2, Island(Hilly), sea, Island(Hilly), hills, desert * 2),
VRow(127, VertInUp(1528)),
TRow(126, sea, Head2Land(5, Plains, Desert), Head2Land(0, Plains, Desert), sea * 2, Head1Land(5, Hilly), desert * 2),
VRow(125, MouthDn(1524), MouthDn(1532), MouthDn(1540)),
TRow(124, desert * 4, plain, desert * 4),
)
}
Expand Down
15 changes: 15 additions & 0 deletions EGrid/src/egrid/EGridBaseGui.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,19 @@ abstract class EGridBaseGui(title: String) extends HGridSysGui(title)
case _ => None
}
}

def lines2: GraphicElems = proj.ifTileScale(50, lines1)

def lines3: GraphicElems = terrs.projHCenFlatMap { (hc, tile) =>
tile match {
case cst: Coastal => cst.indentedSideIndexMap { i =>
val p1: HVAndOffset = corners.cornerV1(hc, i)
val p2 = hc.vExact(i)
LineSegHVAndOffset(p1, p2).map(proj.transHVAndOffset).draw(cst.sideTerrs.contrastBW)
}
case _ => RArr()
}
}

def lines4: GraphicElems = proj.ifTileScale(50, lines3)
}
15 changes: 14 additions & 1 deletion EGrid/src/egrid/ExpWorldGui.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ class ExpWorldGui(val canv: CanvasPlatform, scenIn: EScenBasic, viewIn: HGView,

def lines2: GraphicElems = proj.ifTileScale(50, lines1)

def lines3: GraphicElems = terrs.projHCenFlatMap { (hc, tile) =>
tile match {
case cst: Coastal => cst.indentedSideIndexMap { i =>
val p1: HVAndOffset = corners.cornerV1(hc, i)
val p2 = hc.vExact(i)
LineSegHVAndOffset(p1, p2).map(proj.transHVAndOffset).draw(cst.sideTerrs.contrastBW)
}
case _ => RArr()
}
}

def lines4: GraphicElems = proj.ifTileScale(50, lines3)

def outerLines = proj.outerSidesDraw(3, Gold)

def rcTexts1 = terrs.hcOptFlatMap { (hc, terr) =>
Expand All @@ -90,7 +103,7 @@ class ExpWorldGui(val canv: CanvasPlatform, scenIn: EScenBasic, viewIn: HGView,
def irrLines: GraphicElems = ifGlobe{ ep => ep.irrLines2 }
def irrNames: GraphicElems = ifGlobe{ ep => ep.irrNames2 }

seas ++ irrFills ++ irrNames ++ tileBackFills ++ tileFrontFills ++ tileActives ++ sideFills ++ sideActives ++ lines2/* +% outerLines&*/ ++ rcTexts2 ++ irrLines
seas ++ irrFills ++ irrNames ++ tileBackFills ++ tileFrontFills ++ tileActives ++ sideFills ++ sideActives ++ lines2 ++ lines4/* +% outerLines&*/ ++ rcTexts2 ++ irrLines
}

mainMouseUp = (b, cl, _) => (b, selected, cl) match {
Expand Down
17 changes: 17 additions & 0 deletions EGrid/src/egrid/WTerrSetter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ abstract class WTerrSetter(gridIn: HGrid, val terrs: HCenLayer[WTile], val sTerr
/** Creates the head of a strait / river with the head down right and the straits going up left. */
case class MouthDR(c: Int, st: WSTerr = Sea) extends VRowElem

/** Creates the head of a strait / river / etc with the head down and the straits going up. */
case class MouthDn(c: Int, st: WSTerr = Sea) extends VRowElem

/** Creates the head of a strait / river with the head down left and the straits going up right. */
case class MouthDL(c: Int, st: WSTerr = Sea) extends VRowElem

/** Creates the head of a strait / river with the head up left and the straits going down right. */
case class MouthUL(c: Int, st: WSTerr = Sea) extends VRowElem

Expand Down Expand Up @@ -59,6 +65,7 @@ abstract class WTerrSetter(gridIn: HGrid, val terrs: HCenLayer[WTile], val sTerr
}
}
}

case data: VRow =>
{ val row = data.row
data.edits.foreach{
Expand All @@ -78,6 +85,16 @@ abstract class WTerrSetter(gridIn: HGrid, val terrs: HCenLayer[WTile], val sTerr
sTerrs.set(row, c - 1, WSideMid(st))
}

case MouthDn(c, st) =>
{ corners.setMouth0(row - 1, c)
sTerrs.set(row + 1, c, WSideMid(st))
}

case MouthDL(c, st) =>
{ corners.setMouth1(row - 1, c - 2)
sTerrs.set(row, c + 1, WSideMid(st))
}

case MouthUL(c, st) => {
corners.setMouth2(row + 1, c - 2)
sTerrs.set(row, c + 2, WSideMid(st))
Expand Down
3 changes: 3 additions & 0 deletions Tiling/srcHex/HCenLayer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class HCenLayer[A <: AnyRef](val unsafeArray: Array[A]) extends AnyVal with TCen
build.buffToSeqLike(buff)
}

def projHCenFlatMap[BB <: Arr[_]](f: (HCen, A) => BB)(implicit proj: HSysProjection, build: ArrFlatBuilder[BB]): BB =
proj.hCensFlatMap{hc => f(hc, apply(hc)(proj.parent)) }

/** Completes the given row from the given starting c column value to the end of the row. An exception is
* thrown if the tile values don't match with the end of the row. */
final def setRowEnd(row: Int, cStart: Int, tileMultis: Multiple[A]*)(implicit grid: HGrid): HCen =
Expand Down
6 changes: 6 additions & 0 deletions Tiling/srcHex/HIndentN.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ trait HIndentN
def indentStartIndex: Int

def indentedSideIndexForeach(f: Int => Unit): Unit

def indentedSideIndexMap[B, ArrB <: Arr[B]](f: Int => B)(implicit build: ArrMapBuilder[B, ArrB]): ArrB =
{ val buff = build.newBuff()
indentedSideIndexForeach{ i => buff.grow(f(i)) }
build.buffToSeqLike(buff)
}
}

/** Hex tile indented on 6 of its sides, representing an island and its surrounding waters or similarly geometrically structured terrain where the
Expand Down
1 change: 1 addition & 0 deletions Tiling/srcHex/HSysProjection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ trait HSysProjection extends TSysProjection
var gChild: HGridSys
def hCensMap[B, ArrB <: Arr[B]](f: HCen => B)(implicit build: ArrMapBuilder[B, ArrB]): ArrB = gChild.map(f)
def hCensOptMap[B, ArrB <: Arr[B]](f: HCen => Option[B])(implicit build: ArrMapBuilder[B, ArrB]): ArrB = gChild.optMap(f)
def hCensFlatMap[ArrB <: Arr[_]](f: HCen => ArrB)(implicit build: ArrFlatBuilder[ArrB]): ArrB = gChild.flatMap(f)
def hCenPtMap(f: (HCen, Pt2) => GraphicElem): GraphicElems
def hCenSizedMap(hexScale: Double = 20)(f: (HCen, Pt2) => GraphicElem): GraphicElems

Expand Down

0 comments on commit eeeef17

Please sign in to comment.