mirror of
https://github.com/Lyxminxx/binarian.git
synced 2026-10-11 12:51:48 +02:00
Finished the translators
This commit is contained in:
1 parent
4d5fa48dc8
commit
69be021863
3 files changed
+56
-46
No files matched your search
@@ -1,12 +1,9 @@
|
|||||||
from functions import binarian
|
from submenus import entoBin, binToEn, translateMenu
|
||||||
from functions import unbinarian
|
|
||||||
from submenus import entoBin
|
|
||||||
from submenus import binToEn
|
|
||||||
from functions import clear
|
from functions import clear
|
||||||
import readchar
|
import readchar
|
||||||
|
|
||||||
def main_menu():
|
def main_menu():
|
||||||
options = ["Translate from English to Binarian", "Translate from Binarian to English", "Exit"]
|
options = ["Translate from English to Binarian","Translate from Binarian to English","Translate","Exit"]
|
||||||
selected = 0
|
selected = 0
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
@@ -30,11 +27,10 @@ def main_menu():
|
|||||||
break
|
break
|
||||||
elif options[selected] == "Translate from English to Binarian":
|
elif options[selected] == "Translate from English to Binarian":
|
||||||
entoBin()
|
entoBin()
|
||||||
elif option[selected == "Translate from Binarian to English"]:
|
elif options[selected] == "Translate from Binarian to English":
|
||||||
binToEn()
|
binToEn()
|
||||||
else:
|
elif options[selected] == "Translate":
|
||||||
print(f"Selected: {options[selected]}")
|
translateMenu()
|
||||||
input("Press Enter to return to menu...")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main_menu()
|
main_menu()
|
||||||
+40
-37
@@ -1,9 +1,10 @@
|
|||||||
import readchar
|
import readchar
|
||||||
from gamemodes import norToBin
|
from gamemodes import norToBin, binToNor
|
||||||
from gamemodes import binToNor
|
|
||||||
from functions import clear
|
from functions import clear
|
||||||
|
from translate import translateEnToBin, translateBinToEn # Ensure these are correctly imported
|
||||||
|
|
||||||
def entoBin():
|
def entoBin():
|
||||||
options = ["Level 1", "Level 2", "Level 3","Level 4", "Level 5" , "Back to main menu"]
|
options = ["Level 1", "Level 2", "Level 3", "Level 4", "Level 5", "Back to main menu"]
|
||||||
selected = 0
|
selected = 0
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
@@ -22,29 +23,15 @@ def entoBin():
|
|||||||
elif key == readchar.key.DOWN and selected < len(options) - 1:
|
elif key == readchar.key.DOWN and selected < len(options) - 1:
|
||||||
selected += 1
|
selected += 1
|
||||||
elif key == readchar.key.ENTER:
|
elif key == readchar.key.ENTER:
|
||||||
if options[selected] == "Level 1":
|
if selected < 5: # If it's a level
|
||||||
clear()
|
clear()
|
||||||
norToBin(1)
|
norToBin(selected + 1)
|
||||||
elif options[selected] == "Level 2":
|
else: # Back to main menu
|
||||||
clear()
|
|
||||||
norToBin(2)
|
|
||||||
elif options[selected] == "Level 3":
|
|
||||||
clear()
|
|
||||||
norToBin(3)
|
|
||||||
elif options[selected] == "Level 4":
|
|
||||||
clear()
|
|
||||||
norToBin(4)
|
|
||||||
elif options[selected] == "Level 5":
|
|
||||||
clear()
|
|
||||||
norToBin(5)
|
|
||||||
elif options[selected] == "Back to main menu":
|
|
||||||
print("Exiting...")
|
print("Exiting...")
|
||||||
break
|
break
|
||||||
else:
|
|
||||||
print(f"Selected: {options[selected]}")
|
|
||||||
|
|
||||||
def binToEn():
|
def binToEn():
|
||||||
options = ["Level 1", "Level 2", "Level 3","Level 4", "Level 5" , "Back to main menu"]
|
options = ["Level 1", "Level 2", "Level 3", "Level 4", "Level 5", "Back to main menu"]
|
||||||
selected = 0
|
selected = 0
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
@@ -63,23 +50,39 @@ def binToEn():
|
|||||||
elif key == readchar.key.DOWN and selected < len(options) - 1:
|
elif key == readchar.key.DOWN and selected < len(options) - 1:
|
||||||
selected += 1
|
selected += 1
|
||||||
elif key == readchar.key.ENTER:
|
elif key == readchar.key.ENTER:
|
||||||
if options[selected] == "Level 1":
|
if selected < 5:
|
||||||
clear()
|
clear()
|
||||||
binToNor(1)
|
binToNor(selected + 1)
|
||||||
elif options[selected] == "Level 2":
|
else:
|
||||||
clear()
|
|
||||||
binToNor(2)
|
|
||||||
elif options[selected] == "Level 3":
|
|
||||||
clear()
|
|
||||||
binToNor(3)
|
|
||||||
elif options[selected] == "Level 4":
|
|
||||||
clear()
|
|
||||||
binToNor(4)
|
|
||||||
elif options[selected] == "Level 5":
|
|
||||||
clear()
|
|
||||||
binToNor(5)
|
|
||||||
elif options[selected] == "Back to main menu":
|
|
||||||
print("Exiting...")
|
print("Exiting...")
|
||||||
break
|
break
|
||||||
|
|
||||||
|
def translateMenu():
|
||||||
|
options = ["Binarian to English", "English to Binarian", "Back to main menu"]
|
||||||
|
selected = 0
|
||||||
|
|
||||||
|
while True:
|
||||||
|
clear()
|
||||||
|
print("Select if you want to translate from or to Binarian!")
|
||||||
|
print("Use arrow keys to navigate and Enter to select:\n")
|
||||||
|
|
||||||
|
for i, option in enumerate(options):
|
||||||
|
prefix = "> " if i == selected else " "
|
||||||
|
print(f"{prefix}{option}")
|
||||||
|
|
||||||
|
key = readchar.readkey()
|
||||||
|
|
||||||
|
if key == readchar.key.UP and selected > 0:
|
||||||
|
selected -= 1
|
||||||
|
elif key == readchar.key.DOWN and selected < len(options) - 1:
|
||||||
|
selected += 1
|
||||||
|
elif key == readchar.key.ENTER:
|
||||||
|
if selected == 0:
|
||||||
|
clear()
|
||||||
|
translateBinToEn()
|
||||||
|
elif selected == 1:
|
||||||
|
clear()
|
||||||
|
translateEnToBin()
|
||||||
else:
|
else:
|
||||||
print(f"Selected: {options[selected]}")
|
print("Exiting...")
|
||||||
|
break
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
from functions import *
|
||||||
|
|
||||||
|
def translateEnToBin():
|
||||||
|
userIn = input("Enter english word/sentence\n>")
|
||||||
|
print(binarian(userIn))
|
||||||
|
input("Hit ENTER to continue")
|
||||||
|
|
||||||
|
def translateBinToEn():
|
||||||
|
userIn = input("Enter binarian word/sentence\n>")
|
||||||
|
print(unbinarian(userIn))
|
||||||
|
input("Hit ENTER to continue")
|
||||||
Reference in new issue
Block a user