Skip to content

Commit c6bf4d1

Browse files
committedApr 9, 2015
Added memory to manual (well, made it remember where you were when closing it with escape).
More documentation fixes.

File tree

17 files changed

+48
-29
lines changed

17 files changed

+48
-29
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Acid
22

3-
![Reflux?](oredict:oc:acid)
3+
![Reflux?](oredict:oc:materialAcid)
44

55
You'll probabl only see this item when playing with the hardmod recipe set, in which case you'll need it to etch [circuit boards](circuitBoard.md) to craft [printed circuit boards](printedCircuitBoard.md).
Has conversations. Original line has conversations.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Arithmetic Logic Unit
22

3-
![I can into logic!](oredict:oc:alu)
3+
![I can into logic!](oredict:oc:materialALU)
44

55
Used for crafting most things pushing numbers, such as [CPUs](cpu1.md) and [graphics cards](gpu1.md).
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Arrow Keys
22

3-
![Just be grateful it's not made from arrows.](oredict:oc:arrowKeys)
3+
![Just be grateful it's not made from arrows.](oredict:oc:materialArrowKey)
44

55
At the risk of repeating myself: it's a button sink. Because the button economy has seen some serious inflation in recent years.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Button Group
22

3-
![Needs more buttons.](oredict:oc:buttonGroup)
3+
![Needs more buttons.](oredict:oc:materialButtonGroup)
44

55
Because you *always* have too many buttons lying around somewhere. Don't lie. We all shift-click that button recipe time and again.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Card
22

3-
![Can't be read.](oredict:oc:card)
3+
![Can't be read.](oredict:oc:materialCard)
44

55
Common crafting material for most, if not all card components in OpenComputers.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Microchips
22

3-
![Not the edible ones.](oredict:oc:chip1)
3+
![Not the edible ones.](oredict:oc:circuitChip1)
44

55
Microchips are the bread and butter of electronic component crafting. They come in different tiers, for the different tier of devices they're used to craft with.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Circuit Board
22

3-
![Needs more gold.](oredict:oc:circuitBoard)
3+
![Needs more gold.](oredict:oc:materialCircuitBoard)
44

55
Intermediary crafting item made from [raw circuit boards](rawCircuitBoard.md) and used to make [printed circuit boards](printedCircuitBoard.md).
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Control Unit
22

3-
![With built-in cruise control.](oredict:oc:controlUnit)
3+
![With built-in cruise control.](oredict:oc:materialCU)
44

55
Higher tier crafting material used in more advanced circuitry, such as [CPUs](cpu1.md).
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Cutting Wire
22

3-
![Not a garrote. Honest.](oredict:oc:cuttingWire)
3+
![Not a garrote. Honest.](oredict:oc:materialCuttingWire)
44

55
You'll usually only encounter this when playing with the hard mode recipe set. In that case, this is used for crafting [raw circuit boards](rawCircuitBoard.md). Very inefficiently.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Disc
22

3-
![World. RIP Terry Pratchett.](oredict:oc:disk)
3+
![World. RIP Terry Pratchett.](oredict:oc:materialDisk)
44

55
Basic crafting component used in crafting storage media such as [floppies](floppy.md) and [hard drives](hdd1.md).
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Interweb
22

3-
![A website is a place where there's cobweb.](oredict:oc:interweb)
3+
![A website is a place where there's cobweb.](oredict:oc:materialInterweb)
44

55
The interweb is a basic component for all things related to long distance communication. It uses the strange mechanics of all things End to allow something along the lines of quantum communication. Used most notably in [internet cards](internetCard.md) and [linked cards](linkedCard.md).
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Numeric Keypad
22

3-
![Check for fingerprints.](oredict:oc:numPad)
3+
![Check for fingerprints.](oredict:oc:materialNumPad)
44

55
The numpad is part of every [keyboard](../block/keyboard.md). I allows you to enter numbers. I'm seriously running out of ideas of what to write here...
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Printed Circuit Board
22

3-
![AKA PCB](oredict:oc:printedCircuitBoard)
3+
![AKA PCB](oredict:oc:materialCircuitBoardPrinted)
44

55
The printed circuit board is, next to the [transistor](transistor.md), one of the most basic crafting materials in OpenComputers. It is used as a basis for many components, such as [cards](card.md) and a large number of [blocks](../block/index.md).
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Raw Circuit Board
22

3-
![Not sushi.](oredict:oc:rawCircuitBoard)
3+
![Not sushi.](oredict:oc:materialCircuitBoardRaw)
44

55
Intermediary crafting material, used for crafting [circuit boards](circuitBoard.md) (or [printed circuit boards](printedCircuitBoard.md), depending on the recipe set you use).
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Transistor
22

3-
![I think I've used up all my references.](oredict:oc:transistor)
3+
![I think I've used up all my references.](oredict:oc:materialTransistor)
44

55
The transistor is one of the most basic crafting ingredients in OpenComputers. It is mainly used to craft [microchips](chip1.md) and other electronic goodies.

‎src/main/scala/li/cil/oc/client/gui/Manual.scala

+29-14
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,46 @@ import scala.collection.convert.WrapAsJava._
2222
import scala.collection.mutable
2323
import scala.io.Source
2424

25+
object Manual {
26+
final val LanguageKey = "%LANGUAGE%"
27+
28+
val history = new mutable.Stack[History]
29+
30+
reset()
31+
32+
def reset(): Unit = {
33+
history.clear()
34+
history.push(new History(s"doc/$LanguageKey/index.md"))
35+
}
36+
37+
class History(val path: String) {
38+
var offset = 0
39+
}
40+
41+
}
42+
2543
class Manual extends GuiScreen {
2644
final val documentMaxWidth = 230
2745
final val documentMaxHeight = 176
2846
final val scrollPosX = 244
2947
final val scrollPosY = 6
3048
final val scrollWidth = 6
3149
final val scrollHeight = 180
32-
final val languageKey = "%LANGUAGE%"
3350

3451
var guiLeft = 0
3552
var guiTop = 0
3653
var xSize = 0
3754
var ySize = 0
38-
var offset = 0
3955
var isDragging = false
4056
var document = Iterable.empty[PseudoMarkdown.Segment]
4157
var documentHeight = 0
42-
var history = mutable.Stack(s"doc/$languageKey/index.md")
4358
var hoveredLink = None: Option[String]
4459
protected var scrollButton: ImageButton = _
4560

4661
private def canScroll = maxOffset > 0
4762

63+
def offset = Manual.history.top.offset
64+
4865
def maxOffset = documentHeight - documentMaxHeight
4966

5067
def add[T](list: util.List[T], value: Any) = list.add(value.asInstanceOf[T])
@@ -59,7 +76,7 @@ class Manual extends GuiScreen {
5976

6077
def loadPage(path: String, localized: Boolean = false, seen: List[String] = List.empty): Iterator[String] = {
6178
val language = FMLCommonHandler.instance.getCurrentLanguage
62-
val resolvedPath = path.replaceAll(languageKey, language)
79+
val resolvedPath = path.replaceAll(Manual.LanguageKey, language)
6380
if (seen.contains(resolvedPath)) return Iterator("Redirection loop: ") ++ seen.iterator ++ Iterator(path)
6481
val location = new ResourceLocation(Settings.resourceDomain, resolvedPath)
6582
var is: InputStream = null
@@ -77,7 +94,7 @@ class Manual extends GuiScreen {
7794
}
7895
catch {
7996
case e: FileNotFoundException if !localized && language != "en_US" =>
80-
loadPage(path.replaceAll(languageKey, "en_US"), localized = true, seen)
97+
loadPage(path.replaceAll(Manual.LanguageKey, "en_US"), localized = true, seen)
8198
case t: Throwable =>
8299
Iterator(s"Failed loading page '$path':") ++ t.toString.lines
83100
}
@@ -87,24 +104,22 @@ class Manual extends GuiScreen {
87104
}
88105

89106
def refreshPage(): Unit = {
90-
document = PseudoMarkdown.parse(loadPage(history.top))
107+
document = PseudoMarkdown.parse(loadPage(Manual.history.top.path))
91108
documentHeight = PseudoMarkdown.height(document, documentMaxWidth, fontRendererObj)
92109
scrollTo(offset)
93110
}
94111

95112
def pushPage(path: String): Unit = {
96-
val resolvedPath = resolveLink(path, history.top)
97-
if (resolvedPath != history.top) {
98-
history.push(resolvedPath)
99-
scrollTo(0)
113+
val resolvedPath = resolveLink(path, Manual.history.top.path)
114+
if (resolvedPath != Manual.history.top.path) {
115+
Manual.history.push(new Manual.History(resolvedPath))
100116
refreshPage()
101117
}
102118
}
103119

104120
def popPage(): Unit = {
105-
if (history.size > 1) {
106-
history.pop()
107-
scrollTo(0)
121+
if (Manual.history.size > 1) {
122+
Manual.history.pop()
108123
refreshPage()
109124
}
110125
else {
@@ -215,7 +230,7 @@ class Manual extends GuiScreen {
215230
private def scrollDown() = scrollTo(offset + PseudoMarkdown.lineHeight(fontRendererObj) * 3)
216231

217232
private def scrollTo(row: Int): Unit = {
218-
offset = math.max(0, math.min(maxOffset, row))
233+
Manual.history.top.offset = math.max(0, math.min(maxOffset, row))
219234
val yMin = guiTop + scrollPosY
220235
if (maxOffset > 0) {
221236
scrollButton.yPosition = yMin + (scrollHeight - 13) * offset / maxOffset

‎src/main/scala/li/cil/oc/common/item/Manual.scala

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import net.minecraft.world.World
1515
class Manual(val parent: Delegator) extends Delegate {
1616
override def onItemRightClick(stack: ItemStack, world: World, player: EntityPlayer): ItemStack = {
1717
if (world.isRemote) {
18+
if (player.isSneaking) {
19+
gui.Manual.reset()
20+
}
1821
player.openGui(OpenComputers, GuiType.Manual.id, world, 0, 0, 0)
1922
}
2023
super.onItemRightClick(stack, world, player)
@@ -28,6 +31,7 @@ class Manual(val parent: Delegator) extends Delegate {
2831
player.openGui(OpenComputers, GuiType.Manual.id, world, 0, 0, 0)
2932
Minecraft.getMinecraft.currentScreen match {
3033
case manual: gui.Manual =>
34+
gui.Manual.reset()
3135
val descriptor = api.Items.get(new ItemStack(block))
3236
manual.pushPage("block/" + descriptor.name + ".md")
3337
case _ =>

0 commit comments

Comments
 (0)
Please sign in to comment.