Skip to content

Commit

Permalink
#194.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich2 committed Oct 5, 2022
1 parent 1b75098 commit e59b881
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Tiling/ExsSrc/gOne/GOneGui.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ case class GOneGui(canv: CanvasPlatform, scenStart: OneScen, viewIn: HGView) ext
}

/** [[TextGraphic]]s to display the [[HCen]] coordinate in the tiles that have no unit counters. */
def hexStrs: Arr[TextGraphic] = players.projNoneHcPtMap{ (hc, pt) => TextGraphic(hc.strComma, 20, pt) }
def hexStrs: Arr[TextGraphic] = players.projNoneHcPtMap{ (hc, pt) => pt.textAt(hc.strComma, 20) }

/** This makes the tiles active. They respond to mouse clicks. It does not paint or draw the tiles. */
val actives: Arr[PolygonActive] = proj.tileActives
Expand Down
2 changes: 1 addition & 1 deletion Tiling/ExsSrc/gTwo/GTwoGui.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ case class GTwoGui(canv: CanvasPlatform, scenStart: TwoScen, viewIn: SqGridView)
Rect(1.2, 0.8, sc.toPt2Reg).fillDrawTextActive(p.colour, SPlayer(p, sc), str, 24, 2.0) }

/** Not sure why this is called css. */
def css = players.projNoneScPtMap(sc => TextGraphic(sc.rcStr, 20, sc.toPt2Reg))
def css: Arr[TextGraphic] = players.projNoneScPtMap((sc, pt) => pt.textAt(sc.rcStr, 20))

/** This is the planned moves or orders for the next turn. Note this is just a record of the planned moves it is not graphical display of
* those moves. This data is state for the Gui. */
Expand Down
16 changes: 8 additions & 8 deletions Tiling/src/prid/psq/SqCenOptLayer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ class SqCenOptLayer[A <: AnyRef](val unsafeArr: Array[A]) extends AnyVal with TC

/** Coordinate map Nones. Map the None values respective [[SqCen]] coordinates of this [[SqCenOptLayer]] to type B, the first type parameter. Returns
* an immutable Array based collection of type ArrT, the second type parameter. */
def projNoneScPtMap[B, ArrB <: SeqImut[B]](f: SqCen => B)(implicit proj: SqSysProjection, build: ArrBuilder[B, ArrB]): ArrB = projNoneScPtMap(proj)(f)
def projNoneScPtMap[B, ArrB <: SeqImut[B]](f: (SqCen, Pt2) => B)(implicit proj: SqSysProjection, build: ArrBuilder[B, ArrB]): ArrB = projNoneScPtMap(proj)(f)

/** Coordinate map Nones. Map the None values respective [[SqCen]] coordinates of this [[SqCenOptLayer]] to type B, the first type parameter. Returns
* an immutable Array based collection of type ArrT, the second type parameter. */
def projNoneScPtMap[B, ArrB <: SeqImut[B]](proj: SqSysProjection)(f: SqCen => B)(implicit build: ArrBuilder[B, ArrB]): ArrB =
def projNoneScPtMap[B, ArrB <: SeqImut[B]](proj: SqSysProjection)(f: (SqCen, Pt2) => B)(implicit build: ArrBuilder[B, ArrB]): ArrB =
{ val buff = build.newBuff()
proj.foreach { r =>
val a: A = unsafeArr(proj.gridSys.arrIndex(r))
proj.foreach { sc =>
val a: A = unsafeArr(proj.gridSys.arrIndex(sc))
if (a == null) {
val newVal = f(r)
val newVal = f(sc, proj.transCoord(sc))
build.buffGrow(buff, newVal)
}
}
Expand All @@ -110,9 +110,9 @@ class SqCenOptLayer[A <: AnyRef](val unsafeArr: Array[A]) extends AnyVal with TC
unsafeArr(gridSys.arrIndex(s1)) = null.asInstanceOf[A]
}

/** coordinate-foreach-Some. Foreach Some element and its associated [[HCen]] coordinate applies the side effecting parameter function. It ignores
/** coordinate-foreach-Some. Foreach Some element and its associated [[SqCen]] coordinate applies the side effecting parameter function. It ignores
* the None values. */
def scSomesForeach(f: (SqCen, A) => Unit)(implicit gridSys: SqGridSys): Unit = gridSys.foreach { sc =>
def someScForeach(f: (SqCen, A) => Unit)(implicit gridSys: SqGridSys): Unit = gridSys.foreach { sc =>
val a = unsafeArr(gridSys.arrIndex(sc))
if (a != null) f(sc, a)
}
Expand All @@ -135,7 +135,7 @@ class SqCenOptLayer[A <: AnyRef](val unsafeArr: Array[A]) extends AnyVal with TC

def keyMap(implicit gridSys: SqGridSys): Map[A, SqCen] =
{ val build = Map.newBuilder[A, SqCen]
scSomesForeach((p, hc) => build.addOne(hc, p))
someScForeach((p, hc) => build.addOne(hc, p))
build.result
}

Expand Down

0 comments on commit e59b881

Please sign in to comment.